Example usage for javafx.scene.layout AnchorPane clearConstraints

List of usage examples for javafx.scene.layout AnchorPane clearConstraints

Introduction

In this page you can find the example usage for javafx.scene.layout AnchorPane clearConstraints.

Prototype

public static void clearConstraints(Node child) 

Source Link

Document

Removes all anchor pane constraints from the child node.

Usage

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  w  w  w.  j  av a2s.  c o m*/
                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();
            }));
}

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

private void showWinnerWithTwoHumanPlayers(Board.WinnerInfo winnerInfo) {
    guiAnimationQueue.submitWaitForUnlock(() -> addWinLineOnWin(winnerInfo, Color.YELLOW, () -> {
        twoHumansWinnerText.setText(winnerInfo.winningPlayer.getName() + " won :)");
        double endX = twoHumansWinnerImage.getX();
        double endY = twoHumansWinnerImage.getY();

        AnchorPane.clearConstraints(twoHumansWinnerImage);
        twoHumansWinnerImage.setX(endX);
        twoHumansWinnerImage.setY(twoHumansWinnerImage.getY() + 300);

        // blurGamePane();
        blurGamePane(10.0);//  w w  w  .j a v a  2s.co  m
        twoHumansWinMessage.setOpacity(0);
        twoHumansWinnerImage.setOpacity(0);
        twoHumansWinnerPane.setOpacity(1);
        twoHumansWinnerPane.setVisible(true);
        twoHumansWinnerImage.setVisible(true);

        Timeline timeline = new Timeline();
        double S4 = 1.45;
        double x0 = 0.33;

        KeyValue twoHumansWinnerImageKeyValue1x = new KeyValue(twoHumansWinnerImage.xProperty(), endX,
                new CustomEaseOutInterpolator(S4, x0));
        KeyValue twoHumansWinnerImageKeyValue1y = new KeyValue(twoHumansWinnerImage.yProperty(), endY,
                new CustomEaseOutInterpolator(S4, x0));
        KeyValue twoHumansWinnerImageKeyValue1Opacity = new KeyValue(twoHumansWinnerImage.opacityProperty(), 1);
        KeyFrame twoHumansWinnerImageKeyFrame1 = new KeyFrame(Duration.millis(600),
                twoHumansWinnerImageKeyValue1x, twoHumansWinnerImageKeyValue1y,
                twoHumansWinnerImageKeyValue1Opacity);
        timeline.getKeyFrames().addAll(twoHumansWinnerImageKeyFrame1);

        timeline.setOnFinished((event) -> fadeNode(twoHumansWinMessage, 1, () -> {
            AnchorPane.setLeftAnchor(twoHumansWinnerImage, 0.0);
            AnchorPane.setBottomAnchor(twoHumansWinnerImage, 0.0);
        }));

        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 .  ja v  a2  s.c  o  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();
    });
}