Example usage for javafx.animation Interpolator EASE_OUT

List of usage examples for javafx.animation Interpolator EASE_OUT

Introduction

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

Prototype

Interpolator EASE_OUT

To view the source code for javafx.animation Interpolator EASE_OUT.

Click Source Link

Document

Built-in interpolator instance that provides ease out behavior.

Usage

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

private void setLowerRightAnchorPaneDimensions(Labeled nodeToShow, Labeled nodeToHide, boolean noAnimation,
        double widthOffset) {
    final double secondAnimationOffset = 0.1;
    if (widthOffset > 0) {
        nodeToShow.setPrefWidth(nodeToShow.getWidth() + widthOffset);
    }//  ww  w. j a v a2  s  .c o  m

    if (noAnimation) {
        nodeToShow.setOpacity(1);
        nodeToShow.setVisible(true);
        nodeToHide.setVisible(false);
        playOnlineAnchorPane.setPrefHeight(nodeToShow.getHeight());
        playOnlineAnchorPane.setPrefWidth(nodeToShow.getWidth());
    } else {
        nodeToShow.setOpacity(0);
        nodeToShow.setVisible(true);
        nodeToShow.setPrefWidth(nodeToShow.getWidth());
        nodeToShow.setPrefHeight(nodeToShow.getHeight());

        DoubleProperty firstProperty;
        DoubleProperty secondProperty;
        double firstPropertyValue;
        double secondPropertyValue;
        double secondPropertyInitialValue;

        if (nodeToShow.getHeight() > nodeToShow.getWidth()) {
            firstProperty = playOnlineAnchorPane.prefHeightProperty();
            firstPropertyValue = nodeToShow.getHeight() + AnchorPane.getBottomAnchor(nodeToShow);
            secondProperty = playOnlineAnchorPane.prefWidthProperty();
            secondPropertyValue = nodeToShow.getWidth() + AnchorPane.getRightAnchor(nodeToShow);
            secondPropertyInitialValue = nodeToHide.getWidth();
        } else {
            firstProperty = playOnlineAnchorPane.prefWidthProperty();
            firstPropertyValue = nodeToShow.getWidth() + AnchorPane.getRightAnchor(nodeToShow);
            secondProperty = playOnlineAnchorPane.prefHeightProperty();
            secondPropertyValue = nodeToShow.getHeight() + AnchorPane.getBottomAnchor(nodeToShow);
            secondPropertyInitialValue = nodeToHide.getHeight();
        }

        KeyValue keyValueFirstProperty = new KeyValue(firstProperty, firstPropertyValue,
                Interpolator.EASE_BOTH);
        KeyValue keyValueNodeToHideOpacity1 = new KeyValue(nodeToHide.opacityProperty(), 0,
                Interpolator.EASE_IN);
        KeyFrame keyFrame1 = new KeyFrame(Duration.seconds(animationSpeed), keyValueFirstProperty,
                keyValueNodeToHideOpacity1);

        KeyValue keyValueSecondProperty1 = new KeyValue(secondProperty, secondPropertyInitialValue);
        KeyValue keyValueNodeToShowOpacity1 = new KeyValue(nodeToShow.opacityProperty(),
                nodeToShow.getOpacity());
        KeyFrame keyFrame2 = new KeyFrame(Duration.seconds(secondAnimationOffset * animationSpeed),
                keyValueSecondProperty1, keyValueNodeToShowOpacity1);

        KeyValue keyValueSecondProperty2 = new KeyValue(secondProperty, secondPropertyValue,
                Interpolator.EASE_BOTH);
        KeyValue keyValueNodeToShowOpacity2 = new KeyValue(nodeToShow.opacityProperty(), 1,
                Interpolator.EASE_OUT);
        KeyFrame keyFrame3 = new KeyFrame(Duration.seconds((1 + secondAnimationOffset) * animationSpeed),
                keyValueSecondProperty2, keyValueNodeToShowOpacity2);

        Timeline timeline = new Timeline(keyFrame1, keyFrame2, keyFrame3);
        timeline.setOnFinished((event) -> nodeToHide.setVisible(false));
        timeline.play();
    }
}

From source file:Watcher.FXMLDocumentController.java

@FXML
protected void cancelSiteAdd(MouseEvent event) {
    RotateTransition rt = new RotateTransition(Duration.millis(200), addSitePane);
    rt.setFromAngle(0);// w  w w  . jav  a2  s .  c  om
    rt.setToAngle(180);
    rt.setCycleCount(1);
    rt.setInterpolator(Interpolator.EASE_OUT);
    rt.setOnFinished(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent t) {
            addSitePane.setVisible(false);
            fadeout(false);
        }
    });

    rt.play();
}