Example usage for javafx.animation Timeline Timeline

List of usage examples for javafx.animation Timeline Timeline

Introduction

In this page you can find the example usage for javafx.animation Timeline Timeline.

Prototype

public Timeline() 

Source Link

Document

The constructor of Timeline .

Usage

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 va 2 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: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 .  j a va 2s .  c om*/
    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:spacetrader.controller.EncounterScreenController.java

/**
 * Initializes the controller class./*from  ww  w.jav a2 s.  c o m*/
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    minuteMatrix = new Array2DRowRealMatrix(MINUTE_ARROW);
    hourMatrix = new Array2DRowRealMatrix(HOUR_ARROW);
    context = canvas.getGraphicsContext2D();
    context.translate(375, 275);
    context.setFill(Color.CORNFLOWERBLUE);
    context.fillPolygon(minuteMatrix.getColumn(0), minuteMatrix.getColumn(1), 10);
    context.setFill(Color.MEDIUMAQUAMARINE);
    context.fillPolygon(hourMatrix.getColumn(0), hourMatrix.getColumn(1), 8);
    timeline = new Timeline();
    timeline.setCycleCount(Timeline.INDEFINITE);
    inCount = 0;
    upDown = true;
    KeyFrame frame = new KeyFrame(Duration.seconds(1.0 / 24), new EventHandler<ActionEvent>() {
        public void handle(ActionEvent event) {
            System.out.println(inCount);
            context.clearRect(-375, -275, 750, 550);
            context.setStroke(Color.rgb(0, outCount, 127 + outCount));
            context.setLineWidth(61);
            context.strokeOval(-230, -230, 460, 460);
            context.setStroke(Color.rgb(0, (outCount + 30) % 128, 127 + (outCount + 30) % 128));
            context.strokeOval(-290, -290, 580, 580);
            context.setStroke(Color.rgb(0, (outCount + 60) % 128, 127 + (outCount + 60) % 128));
            context.strokeOval(-350, -350, 700, 700);
            context.setStroke(Color.rgb(0, (outCount + 90) % 128, 127 + (outCount + 90) % 128));
            context.setLineWidth(100);
            context.strokeOval(-430, -430, 860, 860);

            context.setFill(new LinearGradient(-200, -200, 200, 200, false, CycleMethod.NO_CYCLE,
                    new Stop(0, Color.rgb(255, 255 - inCount, inCount)),
                    new Stop(1, Color.rgb(255 - inCount, 0, 255))));
            context.fillOval(-200, -200, 400, 400);
            minuteMatrix = minuteMatrix.multiply(minuteRotateMatrix);
            hourMatrix = hourMatrix.multiply(hourRotateMatrix);
            context.setFill(Color.CORNFLOWERBLUE);
            context.fillPolygon(minuteMatrix.getColumn(0), minuteMatrix.getColumn(1), 10);
            context.setFill(Color.MEDIUMAQUAMARINE);
            context.fillPolygon(hourMatrix.getColumn(0), hourMatrix.getColumn(1), 8);
            if (inCount % 20 < 10) {
                context.drawImage(
                        new Image(Paths.get("image/star.png").toUri().toString(), 360, 360, false, false), -180,
                        -180);
            } else {
                context.drawImage(
                        new Image(Paths.get("image/star.png").toUri().toString(), 300, 300, false, false), -150,
                        -150);
            }
            if (upDown) {
                inCount += 3;
                if (inCount >= 255) {
                    upDown = false;
                }
            } else {
                inCount -= 3;
                if (inCount <= 0) {
                    upDown = true;
                }
            }
            if (outCount >= 128) {
                outCount = 0;
            } else {
                outCount += 8;
            }
        }
    });
    timeline.getKeyFrames().add(frame);
    timeline.play();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Group p = new Group();
    Scene scene = new Scene(p);
    stage.setScene(scene);/*from w  w  w.j a  v  a2s.  c o m*/
    stage.setWidth(500);
    stage.setHeight(500);
    p.setTranslateX(80);
    p.setTranslateY(80);

    //create a circle with effect
    final Circle circle = new Circle(20, Color.rgb(156, 216, 255));
    circle.setEffect(new Lighting());
    //create a text inside a circle
    final Text text = new Text(i.toString());
    text.setStroke(Color.BLACK);
    //create a layout for circle with text inside
    final StackPane stack = new StackPane();
    stack.getChildren().addAll(circle, text);
    stack.setLayoutX(30);
    stack.setLayoutY(30);

    p.getChildren().add(stack);
    stage.show();

    //create a timeline for moving the circle
    timeline = new Timeline();
    timeline.setCycleCount(Timeline.INDEFINITE);
    timeline.setAutoReverse(true);

    //You can add a specific action when each frame is started.
    timer = new AnimationTimer() {
        @Override
        public void handle(long l) {
            text.setText(i.toString());
            i++;
        }
    };

    //create a keyValue with factory: scaling the circle 2times
    KeyValue keyValueX = new KeyValue(stack.scaleXProperty(), 2);
    KeyValue keyValueY = new KeyValue(stack.scaleYProperty(), 2);

    //create a keyFrame, the keyValue is reached at time 2s
    Duration duration = Duration.millis(2000);
    //one can add a specific action when the keyframe is reached
    EventHandler onFinished = new EventHandler<ActionEvent>() {
        public void handle(ActionEvent t) {
            stack.setTranslateX(java.lang.Math.random() * 200 - 100);
            //reset counter
            i = 0;
        }
    };

    KeyFrame keyFrame = new KeyFrame(duration, onFinished, keyValueX, keyValueY);

    //add the keyframe to the timeline
    timeline.getKeyFrames().add(keyFrame);

    timeline.play();
    timer.start();
}

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);//  w  w w .ja  v a 2  s  .c  o  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 . ja  v  a  2  s. co  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 animateDisplay() {
    gridPane.setOpacity(0);/*from   www. ja  va  2  s  . c om*/
    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: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//  w  ww .  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:com.github.vatbub.tictactoe.view.Main.java

public void updateCurrentPlayerLabel(boolean noAnimation, boolean setBlockedValueAfterAnimation) {
    Platform.runLater(() -> stage.setTitle(getWindowTitle()));
    if (board.getCurrentPlayer() != null) {
        if (!board.getCurrentPlayer().getLetter().equals(currentPlayerLabel.getText())) {
            if (noAnimation) {
                setCurrentPlayerValue();
            } else {
                guiAnimationQueue.submitWaitForUnlock(() -> {
                    guiAnimationQueue.setBlocked(true);

                    GaussianBlur blur = (GaussianBlur) currentPlayerLabel.getEffect();
                    if (blur == null) {
                        blur = new GaussianBlur(0);
                    }//w w w .j a  v  a 2s  .  c o  m

                    Calendar changeLabelTextDate = Calendar.getInstance();
                    changeLabelTextDate.add(Calendar.MILLISECOND, (int) (animationSpeed * 1000));
                    runLaterTimer.schedule(new TimerTask() {
                        @Override
                        public void run() {
                            Platform.runLater(() -> setCurrentPlayerValue());
                        }
                    }, changeLabelTextDate.getTime());

                    currentPlayerLabel.setEffect(blur);
                    Timeline timeline = new Timeline();
                    KeyValue keyValue1 = new KeyValue(blur.radiusProperty(), 20);
                    KeyFrame keyFrame1 = new KeyFrame(Duration.seconds(animationSpeed), keyValue1);

                    KeyValue keyValue2 = new KeyValue(blur.radiusProperty(), 0);
                    KeyFrame keyFrame2 = new KeyFrame(Duration.seconds(2 * animationSpeed), keyValue2);

                    timeline.getKeyFrames().addAll(keyFrame1, keyFrame2);

                    timeline.setOnFinished((event) -> {
                        currentPlayerLabel.setEffect(null);
                        guiAnimationQueue.setBlocked(false);
                        setBlockedForInput(setBlockedValueAfterAnimation);
                    });

                    timeline.play();
                });
                return;
            }
        }
    }

    guiAnimationQueue.setBlocked(false);
    setBlockedForInput(setBlockedValueAfterAnimation);
}

From source file:com.github.vatbub.tictactoe.view.Main.java

private void showWinner(Board.WinnerInfo winnerInfo) {
    guiAnimationQueue.submitWaitForUnlock(
            () -> addWinLineOnWin(winnerInfo, new Color(1.0, 145.0 / 255.0, 30.0 / 255.0, 1.0), () -> {
                winnerText.setText(winnerInfo.winningPlayer.getName() + " won :)");
                double endX = winningGirl.getX();
                double endY = winningGirl.getY();

                double confettiOffset = 30;

                double confettiX = confetti.getX();
                double confettiY = confetti.getY();

                AnchorPane.clearConstraints(winningGirl);
                winningGirl.setX(endX);//from   www .  j a v a 2 s  .  com
                winningGirl.setY(root.getHeight() + 140);

                blurGamePane();
                winMessage.setOpacity(0);
                confetti.setOpacity(0);
                winPane.setOpacity(1);
                winPane.setVisible(true);
                winningGirl.setVisible(true);

                Timeline timeline = new Timeline();
                double S4 = 1.45;
                double x0 = 0.33;
                KeyValue confettiKeyValue1x = new KeyValue(confetti.xProperty(), confettiX);
                KeyValue confettiKeyValue1y = new KeyValue(confetti.yProperty(), confettiY - confettiOffset);
                KeyValue confettiKeyValue1opacity = new KeyValue(confetti.opacityProperty(), 0);
                KeyFrame confettiKeyFrame1 = new KeyFrame(Duration.seconds(0), confettiKeyValue1x,
                        confettiKeyValue1y, confettiKeyValue1opacity);

                KeyValue confettiKeyValue2x = new KeyValue(confetti.xProperty(), confettiX);
                KeyValue confettiKeyValue2y = new KeyValue(confetti.yProperty(), confettiY - confettiOffset);
                KeyValue confettiKeyValue2opacity = new KeyValue(confetti.opacityProperty(), 0);
                KeyFrame confettiKeyFrame2 = new KeyFrame(Duration.millis(500), confettiKeyValue2x,
                        confettiKeyValue2y, confettiKeyValue2opacity);

                KeyValue confettiKeyValue3x = new KeyValue(confetti.xProperty(), confettiX,
                        new CustomEaseOutInterpolator(S4, x0));
                KeyValue confettiKeyValue3y = new KeyValue(confetti.yProperty(), confettiY,
                        new CustomEaseOutInterpolator(S4, x0));
                KeyValue confettiKeyValue3opacity = new KeyValue(confetti.opacityProperty(), 1);
                KeyFrame confettiKeyFrame3 = new KeyFrame(Duration.millis(1100), confettiKeyValue3x,
                        confettiKeyValue3y, confettiKeyValue3opacity);

                KeyValue winningGirlKeyValue1x = new KeyValue(winningGirl.xProperty(), endX,
                        new CustomEaseOutInterpolator(S4, x0));
                KeyValue winningGirlKeyValue1y = new KeyValue(winningGirl.yProperty(), endY,
                        new CustomEaseOutInterpolator(S4, x0));
                KeyFrame winningGirlKeyFrame1 = new KeyFrame(Duration.seconds(1), winningGirlKeyValue1x,
                        winningGirlKeyValue1y);
                timeline.getKeyFrames().addAll(winningGirlKeyFrame1, confettiKeyFrame1, confettiKeyFrame2,
                        confettiKeyFrame3);

                timeline.setOnFinished((event) -> fadeNode(winMessage, 1, () -> {
                    AnchorPane.setRightAnchor(winningGirl, 0.0);
                    AnchorPane.setBottomAnchor(winningGirl, 0.0);
                }));

                timeline.play();
            }));
}