Example usage for javafx.scene.effect GaussianBlur radiusProperty

List of usage examples for javafx.scene.effect GaussianBlur radiusProperty

Introduction

In this page you can find the example usage for javafx.scene.effect GaussianBlur radiusProperty.

Prototype

public final DoubleProperty radiusProperty() 

Source Link

Usage

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

private void blurNode(Node node, double toValue, @SuppressWarnings("SameParameterValue") Runnable onFinish) {
    guiAnimationQueue.submit(() -> {/*w  w  w.j a  v a  2 s .com*/
        GaussianBlur blur = (GaussianBlur) node.getEffect();
        if (blur == null) {
            blur = new GaussianBlur(0);
            node.setEffect(blur);
        }
        node.setEffect(blur);
        Timeline timeline = new Timeline();
        KeyValue keyValue = new KeyValue(blur.radiusProperty(), toValue);
        KeyFrame keyFrame = new KeyFrame(Duration.seconds(animationSpeed), keyValue);
        timeline.getKeyFrames().add(keyFrame);

        timeline.setOnFinished((event) -> {
            if (toValue == 0) {
                node.setEffect(null);
            }
            if (onFinish != null) {
                onFinish.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);
                    }//from ww  w  .j  a va  2 s.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);
}