List of usage examples for javafx.animation Timeline getKeyFrames
public final ObservableList<KeyFrame> getKeyFrames()
From source file:Main.java
@Override public void start(Stage stage) { final NumberAxis xAxis = new NumberAxis(); final CategoryAxis yAxis = new CategoryAxis(); final BarChart<Number, String> bc = new BarChart<Number, String>(xAxis, yAxis); bc.setTitle("Summary"); xAxis.setLabel("Value"); xAxis.setTickLabelRotation(90);//from w w w.ja va 2 s .co m yAxis.setLabel("Item"); XYChart.Series series1 = new XYChart.Series(); series1.setName("2003"); series1.getData().add(new XYChart.Data(2, itemA)); series1.getData().add(new XYChart.Data(20, itemB)); series1.getData().add(new XYChart.Data(10, itemC)); XYChart.Series series2 = new XYChart.Series(); series2.setName("2004"); series2.getData().add(new XYChart.Data(50, itemA)); series2.getData().add(new XYChart.Data(41, itemB)); series2.getData().add(new XYChart.Data(45, itemC)); XYChart.Series series3 = new XYChart.Series(); series3.setName("2005"); series3.getData().add(new XYChart.Data(45, itemA)); series3.getData().add(new XYChart.Data(44, itemB)); series3.getData().add(new XYChart.Data(18, itemC)); Timeline tl = new Timeline(); tl.getKeyFrames().add(new KeyFrame(Duration.millis(500), new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { for (XYChart.Series<Number, String> series : bc.getData()) { for (XYChart.Data<Number, String> data : series.getData()) { data.setXValue(Math.random() * 100); } } } })); tl.setCycleCount(Animation.INDEFINITE); tl.play(); Scene scene = new Scene(bc, 800, 600); bc.getData().addAll(series1, series2, series3); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { Group root = new Group(); Scene scene = new Scene(root, 800, 600, Color.BLACK); primaryStage.setScene(scene);//from ww w .j a v a2 s . co m Group circles = new Group(); for (int i = 0; i < 30; i++) { Circle circle = new Circle(150, Color.web("white", 0.05)); circle.setStrokeType(StrokeType.OUTSIDE); circle.setStroke(Color.web("white", 0.16)); circle.setStrokeWidth(4); circles.getChildren().add(circle); } Rectangle colors = new Rectangle(scene.getWidth(), scene.getHeight(), new LinearGradient(0f, 1f, 1f, 0f, true, CycleMethod.NO_CYCLE, new Stop[] { new Stop(0, Color.web("#f8bd55")), new Stop(0.14, Color.web("#c0fe56")), new Stop(0.28, Color.web("#5dfbc1")), new Stop(0.43, Color.web("#64c2f8")), new Stop(0.57, Color.web("#be4af7")), new Stop(0.71, Color.web("#ed5fc2")), new Stop(0.85, Color.web("#ef504c")), new Stop(1, Color.web("#f2660f")), })); Group blendModeGroup = new Group( new Group(new Rectangle(scene.getWidth(), scene.getHeight(), Color.BLACK), circles), colors); colors.setBlendMode(BlendMode.OVERLAY); root.getChildren().add(blendModeGroup); circles.setEffect(new BoxBlur(10, 10, 3)); Timeline timeline = new Timeline(); for (Node circle : circles.getChildren()) { timeline.getKeyFrames().addAll(new KeyFrame(Duration.ZERO, // set start position at 0 new KeyValue(circle.translateXProperty(), random() * 800), new KeyValue(circle.translateYProperty(), random() * 600)), new KeyFrame(new Duration(40000), // set end position at 40s new KeyValue(circle.translateXProperty(), random() * 800), new KeyValue(circle.translateYProperty(), random() * 600))); } // play 40s of animation timeline.play(); primaryStage.show(); }
From source file:mesclasses.view.RootLayoutController.java
private void displayNotification(int type, String texte) { notificationMessageLabel.setText(texte); notificationPane.getStyleClass().clear(); CssUtil.removeClass(deleteNotifBtn, "notif-warning"); CssUtil.removeClass(deleteNotifBtn, "notif-error"); Double timeDisplayed = 3.0D;//ww w. j a v a2 s .c o m switch (type) { case MessageEvent.SUCCESS: CssUtil.addClass(notificationPane, "notif-success"); deleteNotifBtn.setManaged(false); deleteNotifBtn.setVisible(false); notificationTitleLabel.setText("SUCCES"); break; case MessageEvent.WARNING: CssUtil.addClass(notificationPane, "notif-warning"); CssUtil.addClass(deleteNotifBtn, "notif-warning"); notificationTitleLabel.setText("ATTENTION"); break; case MessageEvent.ERROR: CssUtil.addClass(notificationPane, "notif-error"); CssUtil.addClass(deleteNotifBtn, "notif-error"); notificationTitleLabel.setText("ERREUR"); timeDisplayed = 0.0; break; } notificationPane.setManaged(true); notificationPane.setVisible(true); if (timeDisplayed > 0.0) { FadeTransition ft = new FadeTransition(Duration.millis(150), notificationPane); ft.setFromValue(0.0); ft.setToValue(1.0); ft.setCycleCount(1); ft.play(); Timeline timeline = new Timeline(); timeline.getKeyFrames().add(new KeyFrame(Duration.seconds(timeDisplayed), (ActionEvent event) -> { FadeTransition ft2 = new FadeTransition(Duration.millis(150), notificationPane); ft2.setFromValue(1.0); ft2.setToValue(0.0); ft2.setCycleCount(1); ft2.play(); ft2.setOnFinished((ActionEvent event1) -> { notificationPane.setManaged(false); notificationPane.setVisible(false); }); })); timeline.play(); } }
From source file:io.bitsquare.gui.main.overlays.Overlay.java
protected void animateHide(Runnable onFinishedHandler) { Interpolator interpolator = Interpolator.SPLINE(0.25, 0.1, 0.25, 1); double duration = getDuration(200); Timeline timeline = new Timeline(); ObservableList<KeyFrame> keyFrames = timeline.getKeyFrames(); if (type.animationType == AnimationType.SlideDownFromCenterTop) { double endY = -gridPane.getHeight(); keyFrames/* ww w. j a va 2 s .c o m*/ .add(new KeyFrame(Duration.millis(0), new KeyValue(gridPane.opacityProperty(), 1, interpolator), new KeyValue(gridPane.translateYProperty(), -10, interpolator))); keyFrames.add(new KeyFrame(Duration.millis(duration), new KeyValue(gridPane.opacityProperty(), 0, interpolator), new KeyValue(gridPane.translateYProperty(), endY, interpolator))); timeline.setOnFinished(e -> onFinishedHandler.run()); timeline.play(); } else if (type.animationType == AnimationType.ScaleFromCenter) { double endScale = 0.25; keyFrames .add(new KeyFrame(Duration.millis(0), new KeyValue(gridPane.opacityProperty(), 1, interpolator), new KeyValue(gridPane.scaleXProperty(), 1, interpolator), new KeyValue(gridPane.scaleYProperty(), 1, interpolator))); keyFrames.add(new KeyFrame(Duration.millis(duration), new KeyValue(gridPane.opacityProperty(), 0, interpolator), new KeyValue(gridPane.scaleXProperty(), endScale, interpolator), new KeyValue(gridPane.scaleYProperty(), endScale, interpolator))); } else if (type.animationType == AnimationType.ScaleYFromCenter) { gridPane.setRotationAxis(Rotate.X_AXIS); gridPane.getScene().setCamera(new PerspectiveCamera()); keyFrames.add(new KeyFrame(Duration.millis(0), new KeyValue(gridPane.rotateProperty(), 0, interpolator), new KeyValue(gridPane.opacityProperty(), 1, interpolator))); keyFrames.add(new KeyFrame(Duration.millis(duration), new KeyValue(gridPane.rotateProperty(), -90, interpolator), new KeyValue(gridPane.opacityProperty(), 0, interpolator))); } else if (type.animationType == AnimationType.ScaleDownToCenter) { double endScale = 0.1; keyFrames .add(new KeyFrame(Duration.millis(0), new KeyValue(gridPane.opacityProperty(), 1, interpolator), new KeyValue(gridPane.scaleXProperty(), 1, interpolator), new KeyValue(gridPane.scaleYProperty(), 1, interpolator))); keyFrames.add(new KeyFrame(Duration.millis(duration), new KeyValue(gridPane.opacityProperty(), 0, interpolator), new KeyValue(gridPane.scaleXProperty(), endScale, interpolator), new KeyValue(gridPane.scaleYProperty(), endScale, interpolator))); } else if (type.animationType == AnimationType.FadeInAtCenter) { keyFrames.add( new KeyFrame(Duration.millis(0), new KeyValue(gridPane.opacityProperty(), 1, interpolator))); keyFrames.add(new KeyFrame(Duration.millis(duration), new KeyValue(gridPane.opacityProperty(), 0, interpolator))); } timeline.setOnFinished(e -> onFinishedHandler.run()); timeline.play(); }
From source file:io.bitsquare.gui.main.overlays.Overlay.java
protected void animateDisplay() { gridPane.setOpacity(0);//from w w w .j av a 2 s .c o m Interpolator interpolator = Interpolator.SPLINE(0.25, 0.1, 0.25, 1); double duration = getDuration(400); Timeline timeline = new Timeline(); ObservableList<KeyFrame> keyFrames = timeline.getKeyFrames(); if (type.animationType == AnimationType.SlideDownFromCenterTop) { double startY = -gridPane.getHeight(); keyFrames .add(new KeyFrame(Duration.millis(0), new KeyValue(gridPane.opacityProperty(), 0, interpolator), new KeyValue(gridPane.translateYProperty(), startY, interpolator))); keyFrames.add(new KeyFrame(Duration.millis(duration), new KeyValue(gridPane.opacityProperty(), 1, interpolator), new KeyValue(gridPane.translateYProperty(), -10, interpolator))); } else if (type.animationType == AnimationType.ScaleFromCenter) { double startScale = 0.25; keyFrames .add(new KeyFrame(Duration.millis(0), new KeyValue(gridPane.opacityProperty(), 0, interpolator), new KeyValue(gridPane.scaleXProperty(), startScale, interpolator), new KeyValue(gridPane.scaleYProperty(), startScale, interpolator) )); keyFrames.add(new KeyFrame(Duration.millis(duration), new KeyValue(gridPane.opacityProperty(), 1, interpolator), new KeyValue(gridPane.scaleXProperty(), 1, interpolator), new KeyValue(gridPane.scaleYProperty(), 1, interpolator))); } else if (type.animationType == AnimationType.ScaleYFromCenter) { double startYScale = 0.25; keyFrames .add(new KeyFrame(Duration.millis(0), new KeyValue(gridPane.opacityProperty(), 0, interpolator), new KeyValue(gridPane.scaleYProperty(), startYScale, interpolator) )); keyFrames.add(new KeyFrame(Duration.millis(duration), new KeyValue(gridPane.opacityProperty(), 1, interpolator), new KeyValue(gridPane.scaleYProperty(), 1, interpolator))); } else if (type.animationType == AnimationType.ScaleDownToCenter) { double startScale = 1.1; keyFrames .add(new KeyFrame(Duration.millis(0), new KeyValue(gridPane.opacityProperty(), 0, interpolator), new KeyValue(gridPane.scaleXProperty(), startScale, interpolator), new KeyValue(gridPane.scaleYProperty(), startScale, interpolator) )); keyFrames.add(new KeyFrame(Duration.millis(duration), new KeyValue(gridPane.opacityProperty(), 1, interpolator), new KeyValue(gridPane.scaleXProperty(), 1, interpolator), new KeyValue(gridPane.scaleYProperty(), 1, interpolator))); } else if (type.animationType == AnimationType.FadeInAtCenter) { keyFrames.add(new KeyFrame(Duration.millis(0), new KeyValue(gridPane.opacityProperty(), 0, interpolator) )); keyFrames.add(new KeyFrame(Duration.millis(duration), new KeyValue(gridPane.opacityProperty(), 1, interpolator))); } timeline.play(); }
From source file:Main.java
private void addBouncyBall(final Scene scene) { final Circle ball = new Circle(100, 100, 20); final Group root = (Group) scene.getRoot(); root.getChildren().add(ball);/*from w w w .ja va2 s.c o m*/ Timeline tl = new Timeline(); tl.setCycleCount(Animation.INDEFINITE); KeyFrame moveBall = new KeyFrame(Duration.seconds(.0200), new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { double xMin = ball.getBoundsInParent().getMinX(); double yMin = ball.getBoundsInParent().getMinY(); double xMax = ball.getBoundsInParent().getMaxX(); double yMax = ball.getBoundsInParent().getMaxY(); if (xMin < 0 || xMax > scene.getWidth()) { dx = dx * -1; } if (yMin < 0 || yMax > scene.getHeight()) { dy = dy * -1; } ball.setTranslateX(ball.getTranslateX() + dx); ball.setTranslateY(ball.getTranslateY() + dy); } }); tl.getKeyFrames().add(moveBall); tl.play(); }
From source file:com.github.vatbub.tictactoe.view.Main.java
private void addWinLineOnLoose(Board.WinnerInfo winnerInfo) { final double strokeWidth = 2; Line originLine = new Line(0, 0, 0, 0); winLineGroup.getChildren().add(originLine); WinLine winLine = new WinLine(winnerInfo); winLine.startArc.setFill(Color.TRANSPARENT); winLine.startArc.setStroke(Color.BLACK); winLine.startArc.setStrokeWidth(strokeWidth); winLine.endArc.setFill(Color.TRANSPARENT); winLine.endArc.setStroke(Color.BLACK); winLine.endArc.setStrokeWidth(strokeWidth); winLine.rightLine.setStrokeWidth(strokeWidth); winLine.leftLine.setStrokeWidth(strokeWidth); winLine.centerLine.setStrokeWidth(0); winLineGroup.getChildren().addAll(winLine.getAll()); winLineGroup.setOpacity(0);//from w ww. ja v a 2 s .c o m GaussianBlur blur = new GaussianBlur(7); winLineGroup.setEffect(blur); winLineGroup.setVisible(true); KeyValue keyValue1 = new KeyValue(winLineGroup.opacityProperty(), 0); KeyFrame keyFrame1 = new KeyFrame(Duration.millis(900), keyValue1); KeyValue keyValue2 = new KeyValue(winLineGroup.opacityProperty(), 1); KeyFrame keyFrame2 = new KeyFrame(Duration.millis(950), keyValue2); Timeline timeline = new Timeline(); timeline.getKeyFrames().addAll(keyFrame1, keyFrame2); timeline.play(); }
From source file:com.github.vatbub.tictactoe.view.Main.java
private void addWinLineOnWin(Board.WinnerInfo winnerInfo, Paint color, Runnable onFinished) { Line originLine = new Line(0, 0, 0, 0); winLineGroup.getChildren().add(originLine); WinLine winLine = new WinLine(winnerInfo); double winLineEndX = winLine.endArc.getCenterX(); double winLineEndY = winLine.endArc.getCenterY(); winLine.startArc.setFill(color);/*w w w. j av a 2 s. c o m*/ winLine.startArc.setStrokeWidth(0); winLine.endArc.setFill(color); winLine.endArc.setStrokeWidth(0); winLine.rightLine.setStrokeWidth(0); winLine.leftLine.setStrokeWidth(0); winLine.centerLine.setStroke(color); winLine.centerLine.strokeWidthProperty().bind(winLine.startArc.radiusXProperty().multiply(2)); winLineGroup.getChildren().addAll(winLine.getAll()); blurNode(gamePane, 4); winLineGroup.setOpacity(0); GaussianBlur blur = new GaussianBlur(100); winLineGroup.setEffect(blur); winLineGroup.setBlendMode(BlendMode.DARKEN); winLineGroup.setVisible(true); double winLineAnimationX1 = 0.2; double winLineAnimationX2 = 0.5; KeyValue stretchKeyValue1x = new KeyValue(winLine.endArc.centerXProperty(), winLine.startArc.getCenterX()); KeyValue stretchKeyValue1y = new KeyValue(winLine.endArc.centerYProperty(), winLine.startArc.getCenterY()); KeyFrame stretchKeyFrame1 = new KeyFrame(Duration.millis(0), stretchKeyValue1x, stretchKeyValue1y); KeyValue stretchKeyValue2x = new KeyValue(winLine.endArc.centerXProperty(), winLine.startArc.getCenterX(), new CustomEaseBothInterpolator(winLineAnimationX1, winLineAnimationX2)); KeyValue stretchKeyValue2y = new KeyValue(winLine.endArc.centerYProperty(), winLine.startArc.getCenterY(), new CustomEaseBothInterpolator(winLineAnimationX1, winLineAnimationX2)); KeyFrame stretchKeyFrame2 = new KeyFrame(Duration.millis(100), stretchKeyValue2x, stretchKeyValue2y); KeyValue stretchKeyValue3x = new KeyValue(winLine.endArc.centerXProperty(), winLineEndX, new CustomEaseBothInterpolator(winLineAnimationX1, winLineAnimationX2)); KeyValue stretchKeyValue3y = new KeyValue(winLine.endArc.centerYProperty(), winLineEndY, new CustomEaseBothInterpolator(winLineAnimationX1, winLineAnimationX2)); KeyFrame stretchKeyFrame3 = new KeyFrame(Duration.millis(800), stretchKeyValue3x, stretchKeyValue3y); KeyValue opacityKeyValue1 = new KeyValue(winLineGroup.opacityProperty(), 0.8); KeyFrame opacityKeyFrame1 = new KeyFrame(Duration.millis(400), opacityKeyValue1); Timeline timeline = new Timeline(); timeline.getKeyFrames().addAll(stretchKeyFrame1, stretchKeyFrame2, stretchKeyFrame3, opacityKeyFrame1); timeline.play(); timeline.setOnFinished((event) -> onFinished.run()); }
From source file:com.github.vatbub.tictactoe.view.Main.java
private void blurNode(Node node, double toValue, @SuppressWarnings("SameParameterValue") Runnable onFinish) { guiAnimationQueue.submit(() -> {//from w ww .java 2s . c om GaussianBlur blur = (GaussianBlur) node.getEffect(); if (blur == null) { blur = new GaussianBlur(0); node.setEffect(blur); } node.setEffect(blur); Timeline timeline = new Timeline(); KeyValue keyValue = new KeyValue(blur.radiusProperty(), toValue); KeyFrame keyFrame = new KeyFrame(Duration.seconds(animationSpeed), keyValue); timeline.getKeyFrames().add(keyFrame); timeline.setOnFinished((event) -> { if (toValue == 0) { node.setEffect(null); } if (onFinish != null) { onFinish.run(); } }); timeline.play(); }); }
From source file:com.github.vatbub.tictactoe.view.Main.java
private void showTie() { guiAnimationQueue.submitWaitForUnlock(() -> { double endX = tiePane.getWidth() - 230; double endY = 90; AnchorPane.clearConstraints(bowTie); bowTie.setX(endX);// w w w. j a v a2s . co m bowTie.setY(-150); blurGamePane(); tieMessage.setOpacity(0); tiePane.setOpacity(1); tiePane.setVisible(true); bowTie.setVisible(true); Timeline timeline = new Timeline(); double S4 = 1.45; double x0 = 0.33; KeyValue keyValue1x = new KeyValue(bowTie.xProperty(), endX, new CustomEaseOutInterpolator(S4, x0)); KeyValue keyValue1y = new KeyValue(bowTie.yProperty(), endY, new CustomEaseOutInterpolator(S4, x0)); KeyFrame keyFrame1 = new KeyFrame(Duration.seconds(1), keyValue1x, keyValue1y); timeline.getKeyFrames().add(keyFrame1); timeline.setOnFinished((event) -> fadeNode(tieMessage, 1, () -> { AnchorPane.setRightAnchor(bowTie, tiePane.getWidth() - bowTie.getFitWidth() - endX); AnchorPane.setTopAnchor(bowTie, endY); })); timeline.play(); }); }