Example usage for javafx.animation Interpolator EASE_IN

List of usage examples for javafx.animation Interpolator EASE_IN

Introduction

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

Prototype

Interpolator EASE_IN

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

Click Source Link

Document

Built-in interpolator instance that provides ease in 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 a2s . 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 addSite(ActionEvent event) {
    addSitePane.setVisible(true);//w w w . j ava 2s.  c  o m
    RotateTransition rt = new RotateTransition(Duration.millis(200), addSitePane);
    rt.setFromAngle(180);
    rt.setToAngle(0);
    rt.setCycleCount(1);
    rt.setInterpolator(Interpolator.EASE_IN);
    fadeout(true);
    rt.play();
}