javafx.animation.PathTransition Java Examples
The following examples show how to use
javafx.animation.PathTransition.
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: GameElimniationController.java From MyBox with Apache License 2.0 | 6 votes |
protected void shake(int i1, int j1) { try { VBox vbox = chessBoard.get(i1 + "-" + j1); double x = vbox.getLayoutX(); double y = vbox.getLayoutY(); Path path = new Path(); path.getElements().add(new LineTo(x - 20, y + 18)); path.getElements().add(new LineTo(x + 20, y + 18)); path.getElements().add(new LineTo(x - 20, y + 18)); path.getElements().add(new LineTo(x + 20, y + 18)); path.getElements().add(new LineTo(x, y)); PathTransition pathTransition = new PathTransition(Duration.millis(200), path, vbox); pathTransition.setCycleCount(3); pathTransition.setAutoReverse(true); pathTransition.play(); } catch (Exception e) { logger.debug(e.toString()); } }
Example #2
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 #3
Source File: Exercise_15_27.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 a pane Pane pane = new Pane(); // Create a text Text text = new Text("Programing is fun"); pane.getChildren().add(text); // Create a path transition PathTransition pt = new PathTransition(Duration.millis(10000), new Line(-50, 50, 250, 50), text); pt.setCycleCount(Timeline.INDEFINITE); 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_27"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage }
Example #4
Source File: RaceTrack.java From marathonv5 with Apache License 2.0 | 4 votes |
public RaceTrack() { ImageView carImageView = new ImageView(new Image( DataAppPreloader.class.getResourceAsStream("images/car.png"))); road = SVGPathBuilder.create() .content(trackPath).fill(null).stroke(Color.gray(0.4)) .strokeWidth(50) .effect(DropShadowBuilder.create().radius(20).blurType(BlurType.ONE_PASS_BOX).build()) .build(); SVGPath trackLine = SVGPathBuilder.create() .content(trackPath).fill(null).stroke(Color.WHITE) .strokeDashArray(8d,6d).build(); Line startLine = LineBuilder.create() .startX(610.312).startY(401.055).endX(610.312).endY(450.838) .stroke(Color.WHITE).strokeDashArray(2d,2d).build(); Text startFinish = TextBuilder.create().text("START/FINISH").fill(Color.WHITE) .x(570).y(475).build(); percentage = TextBuilder.create().text("0%") .x(390).y(170).font(Font.font("System", 60)) .fill(Color.web("#ddf3ff")) .stroke(Color.web("#73c0f7")) .effect(DropShadowBuilder.create().radius(15).color(Color.web("#3382ba")).blurType(BlurType.ONE_PASS_BOX).build()) .build(); ImageView raceCarImg = new ImageView(new Image( DataAppPreloader.class.getResourceAsStream("images/Mini-red-and-white.png"))); raceCarImg.setX(raceCarImg.getImage().getWidth()/2); raceCarImg.setY(raceCarImg.getImage().getHeight()/2); raceCarImg.setRotate(90); raceCar = new Group(raceCarImg); track = new Group(road, trackLine, startLine, startFinish); track.setCache(true); // add children getChildren().addAll(track, raceCar, percentage); // Create path animation that we will use to drive the car along the track race = new PathTransition(Duration.seconds(1), road, raceCar); race.setOrientation(PathTransition.OrientationType.ORTHOGONAL_TO_TANGENT); race.play(); race.pause(); // center our content and set our size setTranslateX(-road.getBoundsInLocal().getMinX()); setTranslateY(-road.getBoundsInLocal().getMinY()); setPrefSize(road.getBoundsInLocal().getWidth(), road.getBoundsInLocal().getHeight()); setMaxSize(USE_PREF_SIZE, USE_PREF_SIZE); }
Example #5
Source File: RaceTrack.java From marathonv5 with Apache License 2.0 | 4 votes |
public RaceTrack() { ImageView carImageView = new ImageView(new Image( DataAppPreloader.class.getResourceAsStream("images/car.png"))); road = SVGPathBuilder.create() .content(trackPath).fill(null).stroke(Color.gray(0.4)) .strokeWidth(50) .effect(DropShadowBuilder.create().radius(20).blurType(BlurType.ONE_PASS_BOX).build()) .build(); SVGPath trackLine = SVGPathBuilder.create() .content(trackPath).fill(null).stroke(Color.WHITE) .strokeDashArray(8d,6d).build(); Line startLine = LineBuilder.create() .startX(610.312).startY(401.055).endX(610.312).endY(450.838) .stroke(Color.WHITE).strokeDashArray(2d,2d).build(); Text startFinish = TextBuilder.create().text("START/FINISH").fill(Color.WHITE) .x(570).y(475).build(); percentage = TextBuilder.create().text("0%") .x(390).y(170).font(Font.font("System", 60)) .fill(Color.web("#ddf3ff")) .stroke(Color.web("#73c0f7")) .effect(DropShadowBuilder.create().radius(15).color(Color.web("#3382ba")).blurType(BlurType.ONE_PASS_BOX).build()) .build(); ImageView raceCarImg = new ImageView(new Image( DataAppPreloader.class.getResourceAsStream("images/Mini-red-and-white.png"))); raceCarImg.setX(raceCarImg.getImage().getWidth()/2); raceCarImg.setY(raceCarImg.getImage().getHeight()/2); raceCarImg.setRotate(90); raceCar = new Group(raceCarImg); track = new Group(road, trackLine, startLine, startFinish); track.setCache(true); // add children getChildren().addAll(track, raceCar, percentage); // Create path animation that we will use to drive the car along the track race = new PathTransition(Duration.seconds(1), road, raceCar); race.setOrientation(PathTransition.OrientationType.ORTHOGONAL_TO_TANGENT); race.play(); race.pause(); // center our content and set our size setTranslateX(-road.getBoundsInLocal().getMinX()); setTranslateY(-road.getBoundsInLocal().getMinY()); setPrefSize(road.getBoundsInLocal().getWidth(), road.getBoundsInLocal().getHeight()); setMaxSize(USE_PREF_SIZE, USE_PREF_SIZE); }
Example #6
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 #7
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 }