Example usage for javafx.scene.control Labeled getHeight

List of usage examples for javafx.scene.control Labeled getHeight

Introduction

In this page you can find the example usage for javafx.scene.control Labeled getHeight.

Prototype

public final double getHeight() 

Source Link

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);
    }/*from w w  w  .j  av  a 2  s  . c  om*/

    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();
    }
}