List of usage examples for javafx.animation FadeTransition setOnFinished
public final void setOnFinished(EventHandler<ActionEvent> value)
From source file:Main.java
public static void startValueSetAnimation(final Pane parent) { final javafx.scene.shape.Rectangle rectangle = new javafx.scene.shape.Rectangle(); Insets margin = BorderPane.getMargin(parent); if (margin == null) { margin = new Insets(0); }/* w w w . jav a 2s . c om*/ rectangle.widthProperty().bind(parent.widthProperty().subtract(margin.getLeft() + margin.getRight())); rectangle.heightProperty().bind(parent.heightProperty().subtract(margin.getTop() + margin.getBottom())); rectangle.setFill(Color.rgb(0, 150, 201)); parent.getChildren().add(rectangle); BoxBlur bb = new BoxBlur(); bb.setWidth(5); bb.setHeight(5); bb.setIterations(3); rectangle.setEffect(bb); FadeTransition ft = new FadeTransition(Duration.millis(250), rectangle); ft.setFromValue(0.2); ft.setToValue(0.8); ft.setCycleCount(2); ft.setAutoReverse(true); ft.play(); ft.setOnFinished(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { parent.getChildren().remove(rectangle); } }); }
From source file:mesclasses.view.RootLayoutController.java
private void displayNotification(int type, String texte) { notificationMessageLabel.setText(texte); notificationPane.getStyleClass().clear(); CssUtil.removeClass(deleteNotifBtn, "notif-warning"); CssUtil.removeClass(deleteNotifBtn, "notif-error"); Double timeDisplayed = 3.0D;// w w w. ja v a2s .co m switch (type) { case MessageEvent.SUCCESS: CssUtil.addClass(notificationPane, "notif-success"); deleteNotifBtn.setManaged(false); deleteNotifBtn.setVisible(false); notificationTitleLabel.setText("SUCCES"); break; case MessageEvent.WARNING: CssUtil.addClass(notificationPane, "notif-warning"); CssUtil.addClass(deleteNotifBtn, "notif-warning"); notificationTitleLabel.setText("ATTENTION"); break; case MessageEvent.ERROR: CssUtil.addClass(notificationPane, "notif-error"); CssUtil.addClass(deleteNotifBtn, "notif-error"); notificationTitleLabel.setText("ERREUR"); timeDisplayed = 0.0; break; } notificationPane.setManaged(true); notificationPane.setVisible(true); if (timeDisplayed > 0.0) { FadeTransition ft = new FadeTransition(Duration.millis(150), notificationPane); ft.setFromValue(0.0); ft.setToValue(1.0); ft.setCycleCount(1); ft.play(); Timeline timeline = new Timeline(); timeline.getKeyFrames().add(new KeyFrame(Duration.seconds(timeDisplayed), (ActionEvent event) -> { FadeTransition ft2 = new FadeTransition(Duration.millis(150), notificationPane); ft2.setFromValue(1.0); ft2.setToValue(0.0); ft2.setCycleCount(1); ft2.play(); ft2.setOnFinished((ActionEvent event1) -> { notificationPane.setManaged(false); notificationPane.setVisible(false); }); })); timeline.play(); } }
From source file:com.github.vatbub.tictactoe.view.Main.java
private void fadeNode(Node node, double toValue, boolean block, Runnable onFinish) { guiAnimationQueue.submit(() -> {//w w w . j av a2 s .c om if (block) { guiAnimationQueue.setBlocked(true); } if (!node.isVisible()) { node.setOpacity(0); node.setVisible(true); } FadeTransition fadeTransition = new FadeTransition(); fadeTransition.setNode(node); fadeTransition.setFromValue(node.getOpacity()); fadeTransition.setToValue(toValue); fadeTransition.setDuration(Duration.seconds(animationSpeed)); fadeTransition.setAutoReverse(false); fadeTransition.setOnFinished((event) -> { if (toValue == 0) { node.setEffect(null); node.setVisible(false); } if (block) { guiAnimationQueue.setBlocked(false); } if (onFinish != null) { onFinish.run(); } }); fadeTransition.play(); }); }
From source file:com.bekwam.resignator.ResignatorAppMainViewController.java
@FXML public void showConsole(ActionEvent evt) { CheckMenuItem mi = (CheckMenuItem) evt.getSource(); if (logger.isDebugEnabled()) { logger.debug("[SHOW] show={}", mi.isSelected()); }/*from w ww . j ava 2 s. c o m*/ if (mi.isSelected() && !sp.getItems().contains(console)) { if (logger.isDebugEnabled()) { logger.debug("[SHOW] adding console region"); } console.setOpacity(0.0d); sp.getItems().add(console); FadeTransition ft = new FadeTransition(Duration.millis(400), console); ft.setFromValue(0.0); ft.setToValue(1.0); ft.setCycleCount(1); ft.setAutoReverse(false); ft.play(); return; } if (!mi.isSelected() && sp.getItems().contains(console)) { if (logger.isDebugEnabled()) { logger.debug("[SHOW] removing console region"); } FadeTransition ft = new FadeTransition(Duration.millis(300), console); ft.setFromValue(1.0); ft.setToValue(0.1); ft.setCycleCount(1); ft.setAutoReverse(false); ft.play(); ft.setOnFinished((e) -> sp.getItems().remove(console)); } }
From source file:com.bekwam.resignator.ResignatorAppMainViewController.java
@FXML public void showProfileBrowser(ActionEvent evt) { CheckMenuItem mi = (CheckMenuItem) evt.getSource(); if (logger.isDebugEnabled()) { logger.debug("[SHOW] show={}", mi.isSelected()); }/*from w w w . j a v a 2 s .co m*/ if (mi.isSelected() && !outerSp.getItems().contains(profileBrowser)) { if (logger.isDebugEnabled()) { logger.debug("[SHOW] adding profileBrowser region"); } profileBrowser.setOpacity(0.0d); outerSp.getItems().add(0, profileBrowser); outerSp.setDividerPositions(0.3); FadeTransition ft = new FadeTransition(Duration.millis(400), profileBrowser); ft.setFromValue(0.0); ft.setToValue(1.0); ft.setCycleCount(1); ft.setAutoReverse(false); ft.play(); return; } if (!mi.isSelected() && outerSp.getItems().contains(profileBrowser)) { if (logger.isDebugEnabled()) { logger.debug("[SHOW] removing profileBrowser region"); } FadeTransition ft = new FadeTransition(Duration.millis(300), profileBrowser); ft.setFromValue(1.0); ft.setToValue(0.1); ft.setCycleCount(1); ft.setAutoReverse(false); ft.play(); ft.setOnFinished((e) -> outerSp.getItems().remove(profileBrowser)); } }