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

JavaFX rendering artifacts when using a PathTransition

XMLWordPrintable

    • generic
    • generic

      FULL PRODUCT VERSION :


      A DESCRIPTION OF THE PROBLEM :
      I'm working on a small game in JavaFX where I move polygons using a PathTransition. I encountered an issue that I just could not find a fix for: when moving the polygons they sometimes leave a trace of artifacts behind.

      It does not always occur and seems to be related to the Duration of the animation (see source code)



      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Use source code and as text.fxml the following:

      <?xml version="1.0" encoding="UTF-8"?>

      <?import javafx.scene.layout.AnchorPane?>

      <AnchorPane xmlns:fx="http://javafx.com/fxml/1">
      </AnchorPane>


      REPRODUCIBILITY :
      This bug can be reproduced often.

      ---------- BEGIN SOURCE ----------
      import java.io.IOException;
      import javafx.animation.Interpolator;
      import javafx.animation.TranslateTransition;
      import javafx.application.Application;
      import javafx.fxml.FXMLLoader;
      import javafx.scene.Scene;
      import javafx.scene.layout.Pane;
      import javafx.scene.paint.Color;
      import javafx.scene.shape.Polygon;
      import javafx.stage.Stage;
      import javafx.util.Duration;

      public class Main extends Application{

      private Scene testScene;
      private FXMLLoader testLoader;
      private Pane testPane;
      private Polygon polygon;

      @Override
      public void start(Stage primaryStage) throws Exception {
          testLoader = new FXMLLoader(getClass().getResource("test.fxml"));
          try {
              testPane = (Pane) testLoader.load();
          } catch (IOException e) {
              e.printStackTrace();
          }
          testScene = new Scene(testPane, 500, 500);
          primaryStage.setScene(testScene);

          polygon = new Polygon();
          polygon.setFill(Color.DARKSLATEBLUE);
          polygon.getPoints().setAll(new Double[]{ 50.0, 50.0, 70.0, 50.0, 70.0, 70.0, 50.0, 70.0 });

          TranslateTransition transition = new TranslateTransition();
          transition.setCycleCount(1);
          transition.setDuration(Duration.seconds(3));
          transition.setNode(polygon);
          transition.setFromX(0);
          transition.setToX(0);
          transition.setFromY(0);
          transition.setToY(400);
          transition.play();

          testPane.getChildren().add(polygon);

          primaryStage.show();
      }

      public static void main(String[] args) {
          launch(args);
       }

      }
      ---------- END SOURCE ----------

        1. Main.java
          2 kB
        2. test.fxml
          0.2 kB

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: