Java Code Examples for javafx.animation.PathTransition#setNode()
The following examples show how to use
javafx.animation.PathTransition#setNode() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Exercise_16_26.java From Intro-to-Java-Programming with MIT License | 5 votes |
@Override // Override the start method in the Application class public void start(Stage primaryStage) { // Create an image ImageView image = new ImageView(new Image( "http://cs.armstrong.edu/liang/common/image/flag6.gif")); // Create a media player MediaPlayer audio = new MediaPlayer(new Media( "http://cs.armstrong.edu/liang/common/audio/anthem/anthem6.mp3")); audio.play(); // Create a line Line line = new Line(250, 600, 250, -70); // Create a pane Pane pane = new Pane(image); // Create a path transition PathTransition pt = new PathTransition(); pt.setDuration(Duration.millis(70000)); pt.setPath(line); pt.setNode(image); pt.setCycleCount(Timeline.INDEFINITE); pt.play(); // Create a scene and place it in the stage Scene scene = new Scene(pane, 500, 500); primaryStage.setTitle("Exercise_16_26"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage }
Example 2
Source File: Exercise_15_24.java From Intro-to-Java-Programming with MIT License | 4 votes |
@Override // Override the start method in the Application class public void start(Stage primaryStage) { // Create a pane Pane pane = new Pane(); // Create a arc Arc arc = new Arc(100, 50, 75, 25, 0, -180); arc.setFill(Color.WHITE); arc.setStroke(Color.BLACK); // Create a circle Circle circle = new Circle(100, 75, 5); // Place nodes in pane pane.getChildren().addAll(arc, circle); // Create a path transition PathTransition pt = new PathTransition(); pt.setDuration(Duration.millis(4000)); pt.setPath(arc); pt.setNode(circle); pt.setOrientation( PathTransition.OrientationType.ORTHOGONAL_TO_TANGENT); pt.setCycleCount(Timeline.INDEFINITE); pt.setAutoReverse(true); pt.play(); // Start animation // Create and register the handle pane.setOnMousePressed(e -> { pt.pause(); }); pane.setOnMouseReleased(e -> { pt.play(); }); // Create a scene and place it in the stage Scene scene = new Scene(pane, 200, 100); primaryStage.setTitle("Exercise_15_24"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage }
Example 3
Source File: Exercise_15_26.java From Intro-to-Java-Programming with MIT License | 4 votes |
@Override // Override the start method in the Application class public void start(Stage primaryStage) { // Create a pane Pane pane = new Pane(); // Create a arc Arc arc = new Arc(100, 50, 75, 25, 0, -180); arc.setFill(Color.WHITE); arc.setStroke(Color.BLACK); // Create a circle Circle ball = new Circle(100, 75, 10); // Place nodes in pane pane.getChildren().addAll(arc, ball); // Create a path transition PathTransition pt = new PathTransition(); pt.setDuration(Duration.millis(4000)); pt.setPath(arc); pt.setNode(ball); pt.setOrientation( PathTransition.OrientationType.ORTHOGONAL_TO_TANGENT); pt.setCycleCount(Timeline.INDEFINITE); pt.setAutoReverse(true); pt.play(); // Start animation // Create a fade transition to ball FadeTransition ft = new FadeTransition(Duration.millis(4000), ball); ft.setFromValue(1.0); ft.setToValue(0.1); ft.setCycleCount(Timeline.INDEFINITE); ft.setAutoReverse(true); ft.play(); // Start animation // Create and register the handle pane.setOnMousePressed(e -> { pt.pause(); ft.pause(); }); pane.setOnMouseReleased(e -> { pt.play(); ft.play(); }); // Create a scene and place it in the stage Scene scene = new Scene(pane, 200, 100); primaryStage.setTitle("Exercise_15_26"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage }