List of usage examples for javafx.scene.effect GaussianBlur GaussianBlur
public GaussianBlur(double radius)
From source file:net.rptools.tokentool.controller.TokenTool_Controller.java
@FXML void initialize() { // Note: A Pane is added to the compositeTokenPane so the ScrollPane doesn't consume the mouse events assert fileManageOverlaysMenu != null : "fx:id=\"fileManageOverlaysMenu\" was not injected: check your FXML file 'TokenTool.fxml'."; assert fileSaveAsMenu != null : "fx:id=\"fileSaveAsMenu\" was not injected: check your FXML file 'TokenTool.fxml'."; assert fileExitMenu != null : "fx:id=\"fileExitMenu\" was not injected: check your FXML file 'TokenTool.fxml'."; assert editCaptureScreenMenu != null : "fx:id=\"editCaptureScreenMenu\" was not injected: check your FXML file 'TokenTool.fxml'."; assert editCopyImageMenu != null : "fx:id=\"editCopyImageMenu\" was not injected: check your FXML file 'TokenTool.fxml'."; assert editPasteImageMenu != null : "fx:id=\"editPasteImageMenu\" was not injected: check your FXML file 'TokenTool.fxml'."; assert helpAboutMenu != null : "fx:id=\"helpAboutMenu\" was not injected: check your FXML file 'TokenTool.fxml'."; assert saveOptionsPane != null : "fx:id=\"saveOptionsPane\" was not injected: check your FXML file 'TokenTool.fxml'."; assert overlayOptionsPane != null : "fx:id=\"overlayOptionsPane\" was not injected: check your FXML file 'TokenTool.fxml'."; assert backgroundOptionsPane != null : "fx:id=\"backgroundOptionsPane\" was not injected: check your FXML file 'TokenTool.fxml'."; assert zoomOptionsPane != null : "fx:id=\"zoomOptionsPane\" was not injected: check your FXML file 'TokenTool.fxml'."; assert compositeTokenPane != null : "fx:id=\"compositeTokenPane\" was not injected: check your FXML file 'TokenTool.fxml'."; assert tokenPreviewPane != null : "fx:id=\"tokenPreviewPane\" was not injected: check your FXML file 'TokenTool.fxml'."; assert portraitScrollPane != null : "fx:id=\"portraitScrollPane\" was not injected: check your FXML file 'TokenTool.fxml'."; assert compositeGroup != null : "fx:id=\"compositeGroup\" was not injected: check your FXML file 'TokenTool.fxml'."; assert overlayTreeView != null : "fx:id=\"overlayTreeview\" was not injected: check your FXML file 'TokenTool.fxml'."; assert portraitImageView != null : "fx:id=\"portraitImageView\" was not injected: check your FXML file 'TokenTool.fxml'."; assert maskImageView != null : "fx:id=\"maskImageView\" was not injected: check your FXML file 'TokenTool.fxml'."; assert overlayImageView != null : "fx:id=\"overlayImageView\" was not injected: check your FXML file 'TokenTool.fxml'."; assert tokenImageView != null : "fx:id=\"tokenImageView\" was not injected: check your FXML file 'TokenTool.fxml'."; assert useFileNumberingCheckbox != null : "fx:id=\"useFileNumberingCheckbox\" was not injected: check your FXML file 'TokenTool.fxml'."; assert overlayUseAsBaseCheckbox != null : "fx:id=\"overlayUseAsBaseCheckbox\" was not injected: check your FXML file 'TokenTool.fxml'."; assert clipPortraitCheckbox != null : "fx:id=\"clipPortraitCheckbox\" was not injected: check your FXML file 'TokenTool.fxml'."; assert fileNameTextField != null : "fx:id=\"fileNameTextField\" was not injected: check your FXML file 'TokenTool.fxml'."; assert fileNameSuffixLabel != null : "fx:id=\"fileNameSuffixLabel\" was not injected: check your FXML file 'TokenTool.fxml'."; assert fileNameSuffixTextField != null : "fx:id=\"fileNameSuffixTextField\" was not injected: check your FXML file 'TokenTool.fxml'."; assert overlayNameLabel != null : "fx:id=\"overlayNameLabel\" was not injected: check your FXML file 'TokenTool.fxml'."; assert backgroundColorPicker != null : "fx:id=\"backgroundColorPicker\" was not injected: check your FXML file 'TokenTool.fxml'."; assert overlayAspectToggleButton != null : "fx:id=\"overlayAspectToggleButton\" was not injected: check your FXML file 'TokenTool.fxml'."; assert portraitTransparencySlider != null : "fx:id=\"portraitTransparencySlider\" was not injected: check your FXML file 'TokenTool.fxml'."; assert portraitBlurSlider != null : "fx:id=\"portraitBlurSlider\" was not injected: check your FXML file 'TokenTool.fxml'."; assert portraitGlowSlider != null : "fx:id=\"portraitGlowSlider\" was not injected: check your FXML file 'TokenTool.fxml'."; assert overlayTransparencySlider != null : "fx:id=\"overlayTransparencySlider\" was not injected: check your FXML file 'TokenTool.fxml'."; assert overlayWidthSpinner != null : "fx:id=\"overlayWidthSpinner\" was not injected: check your FXML file 'TokenTool.fxml'."; assert overlayHeightSpinner != null : "fx:id=\"overlayHeightSpinner\" was not injected: check your FXML file 'TokenTool.fxml'."; assert overlayTreeProgressBar != null : "fx:id=\"overlayTreeProgressIndicator\" was not injected: check your FXML file 'ManageOverlays.fxml'."; executorService = Executors.newCachedThreadPool(runable -> { loadOverlaysThread = Executors.defaultThreadFactory().newThread(runable); loadOverlaysThread.setDaemon(true); return loadOverlaysThread; });/* w w w. j a va2 s.com*/ overlayTreeView.setShowRoot(false); overlayTreeView.getSelectionModel().selectedItemProperty().addListener( (observable, oldValue, newValue) -> updateCompositImageView((TreeItem<Path>) newValue)); addPseudoClassToLeafs(overlayTreeView); // Bind color picker to compositeTokenPane background fill backgroundColorPicker.setValue(Color.TRANSPARENT); ObjectProperty<Background> background = compositeTokenPane.backgroundProperty(); background.bind(Bindings.createObjectBinding(() -> { BackgroundFill fill = new BackgroundFill(backgroundColorPicker.getValue(), CornerRadii.EMPTY, Insets.EMPTY); return new Background(fill); }, backgroundColorPicker.valueProperty())); // Bind transparency slider to portraitImageView opacity portraitTransparencySlider.valueProperty().addListener(new ChangeListener<Number>() { public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) { portraitImageView.setOpacity(new_val.doubleValue()); updateTokenPreviewImageView(); } }); // // Restrict text field to valid filename characters // Pattern validDoubleText = Pattern.compile("[^a-zA-Z0-9\\\\._ \\\\/`~!@#$%\\\\^&\\\\(\\\\)\\\\-\\\\=\\\\+\\\\[\\\\]\\\\{\\\\}',\\\\\\\\:]"); // Pattern validText = Pattern.compile("[^a-zA-Z0-9 ]"); // TextFormatter<> textFormatter = new TextFormatter<>( // change -> { // String newText = change.getControlNewText(); // if (validText.matcher(newText).matches()) { // return change; // } else // return null; // }); // UnaryOperator<TextFormatter.Change> filter = new UnaryOperator<TextFormatter.Change>() { // @Override // public TextFormatter.Change apply(TextFormatter.Change t) { // String validText = "[^a-zA-Z0-9]"; // // if (t.isReplaced()) // if (t.getText().matches(validText)) // t.setText(t.getControlText().substring(t.getRangeStart(), t.getRangeEnd())); // // if (t.isAdded()) { // if (t.getText().matches(validText)) { // return null; // } // } // // return t; // } // }; UnaryOperator<Change> filter = change -> { String text = change.getText(); if (text.matches(AppConstants.VALID_FILE_NAME_PATTERN)) { return change; } else { change.setText(FileSaveUtil.cleanFileName(text)); ; return change; } // // return null; }; TextFormatter<String> textFormatter = new TextFormatter<>(filter); fileNameTextField.setTextFormatter(textFormatter); // Effects GaussianBlur gaussianBlur = new GaussianBlur(0); Glow glow = new Glow(0); gaussianBlur.setInput(glow); // Bind blur slider to portraitImageView opacity portraitBlurSlider.valueProperty().addListener(new ChangeListener<Number>() { public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) { gaussianBlur.setRadius(new_val.doubleValue()); portraitImageView.setEffect(gaussianBlur); updateTokenPreviewImageView(); } }); // Bind glow slider to portraitImageView opacity portraitGlowSlider.valueProperty().addListener(new ChangeListener<Number>() { public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) { glow.setLevel(new_val.doubleValue()); portraitImageView.setEffect(gaussianBlur); updateTokenPreviewImageView(); } }); // Bind transparency slider to overlayImageView opacity overlayTransparencySlider.valueProperty().addListener(new ChangeListener<Number>() { public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) { overlayImageView.setOpacity(new_val.doubleValue()); updateTokenPreviewImageView(); } }); // Bind width/height spinners to overlay width/height overlayWidthSpinner.getValueFactory().valueProperty() .bindBidirectional(overlayHeightSpinner.getValueFactory().valueProperty()); overlayWidthSpinner.valueProperty().addListener( (observable, oldValue, newValue) -> overlayWidthSpinner_onTextChanged(oldValue, newValue)); overlayHeightSpinner.valueProperty().addListener( (observable, oldValue, newValue) -> overlayHeightSpinner_onTextChanged(oldValue, newValue)); }
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 v a 2 s . c om 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); }
From source file:com.github.vatbub.tictactoe.view.Main.java
private void addWinLineOnWin(Board.WinnerInfo winnerInfo, Paint color, Runnable onFinished) { Line originLine = new Line(0, 0, 0, 0); winLineGroup.getChildren().add(originLine); WinLine winLine = new WinLine(winnerInfo); double winLineEndX = winLine.endArc.getCenterX(); double winLineEndY = winLine.endArc.getCenterY(); winLine.startArc.setFill(color);/*from w w w. j a va 2s . co m*/ winLine.startArc.setStrokeWidth(0); winLine.endArc.setFill(color); winLine.endArc.setStrokeWidth(0); winLine.rightLine.setStrokeWidth(0); winLine.leftLine.setStrokeWidth(0); winLine.centerLine.setStroke(color); winLine.centerLine.strokeWidthProperty().bind(winLine.startArc.radiusXProperty().multiply(2)); winLineGroup.getChildren().addAll(winLine.getAll()); blurNode(gamePane, 4); winLineGroup.setOpacity(0); GaussianBlur blur = new GaussianBlur(100); winLineGroup.setEffect(blur); winLineGroup.setBlendMode(BlendMode.DARKEN); winLineGroup.setVisible(true); double winLineAnimationX1 = 0.2; double winLineAnimationX2 = 0.5; KeyValue stretchKeyValue1x = new KeyValue(winLine.endArc.centerXProperty(), winLine.startArc.getCenterX()); KeyValue stretchKeyValue1y = new KeyValue(winLine.endArc.centerYProperty(), winLine.startArc.getCenterY()); KeyFrame stretchKeyFrame1 = new KeyFrame(Duration.millis(0), stretchKeyValue1x, stretchKeyValue1y); KeyValue stretchKeyValue2x = new KeyValue(winLine.endArc.centerXProperty(), winLine.startArc.getCenterX(), new CustomEaseBothInterpolator(winLineAnimationX1, winLineAnimationX2)); KeyValue stretchKeyValue2y = new KeyValue(winLine.endArc.centerYProperty(), winLine.startArc.getCenterY(), new CustomEaseBothInterpolator(winLineAnimationX1, winLineAnimationX2)); KeyFrame stretchKeyFrame2 = new KeyFrame(Duration.millis(100), stretchKeyValue2x, stretchKeyValue2y); KeyValue stretchKeyValue3x = new KeyValue(winLine.endArc.centerXProperty(), winLineEndX, new CustomEaseBothInterpolator(winLineAnimationX1, winLineAnimationX2)); KeyValue stretchKeyValue3y = new KeyValue(winLine.endArc.centerYProperty(), winLineEndY, new CustomEaseBothInterpolator(winLineAnimationX1, winLineAnimationX2)); KeyFrame stretchKeyFrame3 = new KeyFrame(Duration.millis(800), stretchKeyValue3x, stretchKeyValue3y); KeyValue opacityKeyValue1 = new KeyValue(winLineGroup.opacityProperty(), 0.8); KeyFrame opacityKeyFrame1 = new KeyFrame(Duration.millis(400), opacityKeyValue1); Timeline timeline = new Timeline(); timeline.getKeyFrames().addAll(stretchKeyFrame1, stretchKeyFrame2, stretchKeyFrame3, opacityKeyFrame1); timeline.play(); timeline.setOnFinished((event) -> onFinished.run()); }
From source file:com.github.vatbub.tictactoe.view.Main.java
private void showLooser(Board.WinnerInfo winnerInfo) { String looserName = board.getOpponent(winnerInfo.winningPlayer).getName(); guiAnimationQueue.submitWaitForUnlock(() -> { ShakeTransition anim = new ShakeTransition(gamePane, null); anim.playFromStart();//from w w w. j av a2 s . c o m Timeline timeline = new Timeline(); Circle c1 = new Circle((452 / 600.0) * looserPane.getWidth(), (323 / 640.0) * looserPane.getHeight(), 0); GaussianBlur circleBlur = new GaussianBlur(30); c1.setEffect(circleBlur); looseImage.setClip(c1); addWinLineOnLoose(winnerInfo); KeyValue keyValue1 = new KeyValue(c1.radiusProperty(), 0); KeyFrame keyFrame1 = new KeyFrame(Duration.millis(800), keyValue1); KeyValue keyValue2 = new KeyValue(c1.radiusProperty(), (500 / 640.0) * looserPane.getHeight()); KeyFrame keyFrame2 = new KeyFrame(Duration.millis(900), keyValue2); timeline.getKeyFrames().addAll(keyFrame1, keyFrame2); looseMessage.setOpacity(0); looserText.setText(looserName + " lost :("); looserPane.setVisible(true); looserPane.setOpacity(1); timeline.setOnFinished((event) -> { looseImage.setClip(null); winLineGroup.setClip(null); blurGamePane(); PauseTransition wait = new PauseTransition(); wait.setDuration(Duration.seconds(1)); wait.setOnFinished((event2) -> { FadeTransition looseMessageTransition = new FadeTransition(); looseMessageTransition.setNode(looseMessage); looseMessageTransition.setFromValue(0); looseMessageTransition.setToValue(1); looseMessageTransition.setDuration(Duration.millis(500)); looseMessageTransition.setAutoReverse(false); looseMessageTransition.play(); }); wait.play(); }); timeline.play(); }); }
From source file:com.github.vatbub.tictactoe.view.Main.java
private void addWinLineOnLoose(Board.WinnerInfo winnerInfo) { final double strokeWidth = 2; Line originLine = new Line(0, 0, 0, 0); winLineGroup.getChildren().add(originLine); WinLine winLine = new WinLine(winnerInfo); winLine.startArc.setFill(Color.TRANSPARENT); winLine.startArc.setStroke(Color.BLACK); winLine.startArc.setStrokeWidth(strokeWidth); winLine.endArc.setFill(Color.TRANSPARENT); winLine.endArc.setStroke(Color.BLACK); winLine.endArc.setStrokeWidth(strokeWidth); winLine.rightLine.setStrokeWidth(strokeWidth); winLine.leftLine.setStrokeWidth(strokeWidth); winLine.centerLine.setStrokeWidth(0); winLineGroup.getChildren().addAll(winLine.getAll()); winLineGroup.setOpacity(0);//w w w.j a v a 2s . co m GaussianBlur blur = new GaussianBlur(7); winLineGroup.setEffect(blur); winLineGroup.setVisible(true); KeyValue keyValue1 = new KeyValue(winLineGroup.opacityProperty(), 0); KeyFrame keyFrame1 = new KeyFrame(Duration.millis(900), keyValue1); KeyValue keyValue2 = new KeyValue(winLineGroup.opacityProperty(), 1); KeyFrame keyFrame2 = new KeyFrame(Duration.millis(950), keyValue2); Timeline timeline = new Timeline(); timeline.getKeyFrames().addAll(keyFrame1, keyFrame2); timeline.play(); }
From source file:com.github.vatbub.tictactoe.view.Main.java
private void blurNode(Node node, double toValue, @SuppressWarnings("SameParameterValue") Runnable onFinish) { guiAnimationQueue.submit(() -> {//from w w w .j a v a 2 s .c om 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(); }); }