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

[Animation] Regression: Misbehavior of *Transition within ParallelTransition

    XMLWordPrintable

Details

    Description

      When a Transition is put into a ParallelTransition, it does not behave as expected and as it did in JavaFX 2.2.

      See this example: The transition always starts at y = 0, although it should have another value.

      This is a regression and nearly the same bug as in RT-32811.

      (The only difference is, that this bug is with ParallelTransition, where as the other one was with SequentialTransition).

      Tested with Java 8 b120.


      import javafx.animation.ParallelTransition;
      import javafx.animation.RotateTransition;
      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 ParallelTransition parallelTransition = new ParallelTransition();
              final RotateTransition rotateTransition = new RotateTransition(Duration.seconds(1), rectangle);
              rotateTransition.setToAngle(0);
              final TranslateTransition translateTransition = new TranslateTransition(Duration.seconds(1), rectangle);
              translateTransition.setToY(y * 10);

              parallelTransition.getChildren().addAll(translateTransition);

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

              parallelTransition.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);
                      //rotateTransition.setToAngle(rotateTransition.getToAngle()+90);
                      parallelTransition.playFromStart();
                  }
              });
              parallelTransition.playFromStart();

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

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:
                Imported: