Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8096830

Regression: Misbehavior of TranslateTransition within SequentialTransition

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 8
    • 8
    • javafx
    • None
    • JavaFX 8 b103

      This bug is hard to describe.

      In JavaFX 2.2 the red rectangle animates from its current translateY position to the new one.

      Whereas in JavaFX 8 it always starts from y position = 0 and then translates from there to its new y position.
      If I explicitly set the fromY to the current y value it is better, but it flickers a lot.


      Better you just have a look at this code and running it with JavaFX 2.2 and then JavaFX 8.0.

      import javafx.animation.SequentialTransition;
      import javafx.animation.TranslateTransition;
      import javafx.application.Application;
      import javafx.event.ActionEvent;
      import javafx.event.EventHandler;
      import javafx.scene.Group;
      import javafx.scene.Scene;
      import javafx.scene.paint.Color;
      import javafx.scene.shape.Rectangle;
      import javafx.stage.Stage;
      import javafx.util.Duration;

      public class TestApp5 extends Application {
          public static void main(String[] args) {
              Application.launch();
          }

          private int y = 1;

          @Override
          public void start(Stage stage) throws Exception {
              Rectangle rectangle = new Rectangle(50, 50, Color.RED);

              final SequentialTransition sequentialTransition = new SequentialTransition();
              final TranslateTransition translateTransition = new TranslateTransition(Duration.seconds(1), rectangle);
              translateTransition.setToY(y * 10);

              sequentialTransition.getChildren().addAll(translateTransition);

              Group group = new Group();
              group.getChildren().add(rectangle);

              sequentialTransition.setOnFinished(new EventHandler<ActionEvent>() {
                  @Override
                  public void handle(ActionEvent actionEvent) {
                      // This line helps a little bit, but there's still a lot of flickering.
                      // And it wasn't needed in JavaFX 2.2.
                      //translateTransition.setFromY(y * 10);
                      translateTransition.setToY(++y * 10);
                      sequentialTransition.playFromStart();
                  }
              });
              sequentialTransition.playFromStart();

              Scene scene = new Scene(group, 500, 500);
              stage.setScene(scene);
              stage.show();
          }
      }

            msladecek Martin Sládeček
            cschudtjfx Christian Schudt (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: