Java Code Examples for javafx.animation.FadeTransition#setOnFinished()

The following examples show how to use javafx.animation.FadeTransition#setOnFinished() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TimelineChart.java    From constellation with Apache License 2.0 6 votes vote down vote up
@Override
protected void seriesRemoved(final Series<Number, Number> series) {

    final Node child = series.getNode();
    if (shouldAnimate()) {
        // fade out old item:
        final FadeTransition ft = new FadeTransition(Duration.millis(500), child);
        ft.setToValue(0);
        ft.setOnFinished(new EventHandler<ActionEvent>() {
            @Override
            public void handle(final ActionEvent actionEvent) {
                getPlotChildren().clear();
            }
        });
        ft.play();
    } else {
        getPlotChildren().clear();
    }
}
 
Example 2
Source File: VolumeChart.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void dataItemRemoved(XYChart.Data<Number, Number> item, XYChart.Series<Number, Number> series) {
    final Node node = item.getNode();
    if (shouldAnimate()) {
        FadeTransition ft = new FadeTransition(Duration.millis(500), node);
        ft.setToValue(0);
        ft.setOnFinished((ActionEvent actionEvent) -> {
            getPlotChildren().remove(node);
            removeDataItemFromDisplay(series, item);
        });
        ft.play();
    } else {
        getPlotChildren().remove(node);
        removeDataItemFromDisplay(series, item);
    }
}
 
Example 3
Source File: ContentPane.java    From pdfsam with GNU Affero General Public License v3.0 6 votes vote down vote up
@Inject
public ContentPane(WorkArea modules, Dashboard dashboard, NewsPanel news,
        @Named("defaultDashboardItemId") String defaultDasboardItem) {
    this.modules = modules;
    this.dashboard = dashboard;
    this.newsContainer = new VBox(news);
    this.newsContainer.getStyleClass().add("news-container");
    StackPane stack = new StackPane(modules, dashboard);
    setHgrow(stack, Priority.ALWAYS);
    newsContainer.managedProperty().bind(newsContainer.visibleProperty());
    newsContainer.setVisible(false);
    fadeIn = new FadeTransition(new Duration(300), newsContainer);
    fadeIn.setFromValue(0);
    fadeIn.setToValue(1);
    fadeOut = new FadeTransition(new Duration(300), newsContainer);
    fadeOut.setFromValue(1);
    fadeOut.setToValue(0);
    fadeOut.setOnFinished(e -> {
        newsContainer.setVisible(false);
    });
    getChildren().addAll(stack, newsContainer);
    eventStudio().addAnnotatedListeners(this);
    eventStudio().broadcast(new SetActiveDashboardItemRequest(defaultDasboardItem));
}
 
Example 4
Source File: Sprite.java    From examples-javafx-repos1 with Apache License 2.0 6 votes vote down vote up
public void flagAsError() {
	
	this.normal.setVisible(true);  // hidden behind error
	this.highlight.setVisible(false);
	this.drag.setVisible(false);
	this.error.setVisible(true);
	
	FadeTransition ft = new FadeTransition(Duration.seconds(4), this.error);
    ft.setFromValue(1.0);
    ft.setToValue(0.0);
    ft.setOnFinished( (evt) -> {
    	
		this.normal.setVisible(true);  // show normal
		this.highlight.setVisible(false);
		this.drag.setVisible(false);
		this.error.setVisible(false);

    	this.error.setOpacity( 1.0d );  // restore opacity
    	
    });
    ft.play();
}
 
Example 5
Source File: CandleStickChart.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void dataItemRemoved(XYChart.Data<Number, Number> item, XYChart.Series<Number, Number> series) {
    if (series.getNode() instanceof Path) {
        Path seriesPath = (Path) series.getNode();
        seriesPath.getElements().clear();
    }

    final Node node = item.getNode();
    if (shouldAnimate()) {
        // fade out old candle
        FadeTransition ft = new FadeTransition(Duration.millis(500), node);
        ft.setToValue(0);
        ft.setOnFinished((ActionEvent actionEvent) -> {
            getPlotChildren().remove(node);
            removeDataItemFromDisplay(series, item);
        });
        ft.play();
    } else {
        getPlotChildren().remove(node);
        removeDataItemFromDisplay(series, item);
    }
}
 
Example 6
Source File: ParetoInfoPopup.java    From charts with Apache License 2.0 6 votes vote down vote up
private void init() {
    setAutoFix(true);
    rowCount = 2;

    fadeIn = new FadeTransition(Duration.millis(200), hBox);
    fadeIn.setFromValue(0);
    fadeIn.setToValue(0.75);

    fadeOut = new FadeTransition(Duration.millis(200), hBox);
    fadeOut.setFromValue(0.75);
    fadeOut.setToValue(0.0);
    fadeOut.setOnFinished(e -> hide());

    delay = new PauseTransition(Duration.millis(_timeout));
    delay.setOnFinished(e -> animatedHide());
}
 
Example 7
Source File: InfoPopup.java    From charts with Apache License 2.0 6 votes vote down vote up
private void init() {
    setAutoFix(true);
    rowCount = 2;

    fadeIn = new FadeTransition(Duration.millis(200), hBox);
    fadeIn.setFromValue(0);
    fadeIn.setToValue(0.75);

    fadeOut = new FadeTransition(Duration.millis(200), hBox);
    fadeOut.setFromValue(0.75);
    fadeOut.setToValue(0.0);
    fadeOut.setOnFinished(e -> hide());

    delay = new PauseTransition(Duration.millis(_timeout));
    delay.setOnFinished(e -> animatedHide());
}
 
Example 8
Source File: AdvCandleStickChartSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Override protected void dataItemRemoved(Data<Number, Number> item, Series<Number, Number> series) {
    final Node candle = item.getNode();
    if (shouldAnimate()) {
        // fade out old candle
        FadeTransition ft = new FadeTransition(Duration.millis(500), candle);
        ft.setToValue(0);
        ft.setOnFinished(new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent actionEvent) {
                getPlotChildren().remove(candle);
            }
        });
        ft.play();
    } else {
        getPlotChildren().remove(candle);
    }
}
 
Example 9
Source File: AdvCandleStickChartSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Override protected void seriesRemoved(Series<Number, Number> series) {
    // remove all candle nodes
    for (XYChart.Data<Number, Number> d : series.getData()) {
        final Node candle = d.getNode();
        if (shouldAnimate()) {
            // fade out old candle
            FadeTransition ft = new FadeTransition(Duration.millis(500), candle);
            ft.setToValue(0);
            ft.setOnFinished(new EventHandler<ActionEvent>() {

                @Override
                public void handle(ActionEvent actionEvent) {
                    getPlotChildren().remove(candle);
                }
            });
            ft.play();
        } else {
            getPlotChildren().remove(candle);
        }
    }
}
 
Example 10
Source File: AdvCandleStickChartSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Override protected void dataItemRemoved(Data<Number, Number> item, Series<Number, Number> series) {
    final Node candle = item.getNode();
    if (shouldAnimate()) {
        // fade out old candle
        FadeTransition ft = new FadeTransition(Duration.millis(500), candle);
        ft.setToValue(0);
        ft.setOnFinished(new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent actionEvent) {
                getPlotChildren().remove(candle);
            }
        });
        ft.play();
    } else {
        getPlotChildren().remove(candle);
    }
}
 
Example 11
Source File: Toast.java    From DevToolBox with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void hide() {
    LOGGER.info("hide toast: {}", this);
    if (hideTimer != null) {
        // cancel the timer if the toast is hidden before the timer fires
        hideTimer.stop();
        hideTimer = null;
    }
    if (!isShowing()) {
        return;
    }
    FadeTransition transition = new FadeTransition(fadeOutDuration, content);
    transition.setToValue(0.0);
    transition.setOnFinished((ActionEvent event) -> {
        doHide();
    });
    transition.play();
}
 
Example 12
Source File: TimelineChart.java    From constellation with Apache License 2.0 6 votes vote down vote up
@Override
protected void dataItemRemoved(final Data<Number, Number> item,
        final Series<Number, Number> series) {
    final Node child = item.getNode();

    if (shouldAnimate()) {
        // fade out old item:
        final FadeTransition ft = new FadeTransition(Duration.millis(500), child);
        ft.setToValue(0);
        ft.setOnFinished(new EventHandler<ActionEvent>() {
            @Override
            public void handle(final ActionEvent actionEvent) {
                getPlotChildren().remove(child);
            }
        });
        ft.play();
    } else {
        getPlotChildren().remove(child);
    }
}
 
Example 13
Source File: Transitions.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
public void fadeOutAndRemove(Node node, int duration, EventHandler<ActionEvent> handler) {
    FadeTransition fade = fadeOut(node, getDuration(duration));
    fade.setInterpolator(Interpolator.EASE_IN);
    fade.setOnFinished(actionEvent -> {
        ((Pane) (node.getParent())).getChildren().remove(node);
        //Profiler.printMsgWithTime("fadeOutAndRemove");
        if (handler != null)
            handler.handle(actionEvent);
    });
}
 
Example 14
Source File: InfoPopup.java    From charts with Apache License 2.0 5 votes vote down vote up
private void init() {
    setAutoFix(true);

    fadeIn = new FadeTransition(Duration.millis(200), hBox);
    fadeIn.setFromValue(0);
    fadeIn.setToValue(0.75);

    fadeOut = new FadeTransition(Duration.millis(200), hBox);
    fadeOut.setFromValue(0.75);
    fadeOut.setToValue(0.0);
    fadeOut.setOnFinished(e -> hide());

    delay = new PauseTransition(Duration.millis(_timeout));
    delay.setOnFinished(e -> animatedHide());
}
 
Example 15
Source File: AnimationHelper.java    From ApkToolPlus with Apache License 2.0 5 votes vote down vote up
/**
 * 淡入
 *
 * @param onFinish
 * @return
 */
public static FadeTransition fadeIn(EventHandler<ActionEvent> onFinish){
    FadeTransition ft = new FadeTransition(Duration.millis(500));
    ft.setFromValue(0.0);
    ft.setToValue(1.1);
    ft.setCycleCount(0);
    ft.setAutoReverse(false);
    if(onFinish != null){
        ft.setOnFinished(onFinish);
    }
    return ft;
}
 
Example 16
Source File: SplashScreenUIController.java    From RentLio with Apache License 2.0 5 votes vote down vote up
private void loadSplashScreen(){
    
    StartRentLio.isSplashLoaded = true;
    AnchorPane splashPane = null;
    try {
        splashPane = FXMLLoader.load(getClass()
                .getResource("/fxml/SplashScreenUI.fxml"));
    } catch (IOException e) {
        e.printStackTrace();
    }
    root.getChildren().setAll(splashPane);

    FadeTransition fadeIn = new FadeTransition(Duration.seconds(3), splashPane);
    fadeIn.setFromValue(0);
    fadeIn.setToValue(1);

    fadeIn.setCycleCount(1);

    FadeTransition fadeOut = new FadeTransition(Duration.seconds(3), splashPane);
    fadeOut.setFromValue(1);
    fadeOut.setToValue(0);
    fadeOut.setCycleCount(1);

    fadeIn.play();

    fadeIn.setOnFinished((e) -> fadeOut.play());

    fadeOut.setOnFinished((e) -> {
        AnchorPane parentContent = CustomStage.getDefaultSceneManager().getScene("LoginUI");
        root.getChildren().setAll(parentContent);
    });
}
 
Example 17
Source File: CardRevealedToken.java    From metastone with GNU General Public License v2.0 5 votes vote down vote up
private void nextTransition(ActionEvent event) {
	FadeTransition animation = new FadeTransition(Duration.seconds(.6), cardToken);
	animation.setOnFinished(this::onComplete);
	animation.setFromValue(1);
	animation.setToValue(0);
	animation.play();
}
 
Example 18
Source File: Undecorator.java    From DevToolBox with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Launch the fade out transition. Must be invoked when the
 * application/window is supposed to be closed
 */
public void setFadeOutTransition() {
    FadeTransition fadeTransition = new FadeTransition(Duration.seconds(1), Undecorator.this);
    fadeTransition.setToValue(0);
    fadeTransition.play();
    fadeTransition.setOnFinished((ActionEvent t) -> {
        stage.hide();
        if (dockFeedbackPopup != null && dockFeedbackPopup.isShowing()) {
            dockFeedbackPopup.hide();
        }
    });
}
 
Example 19
Source File: JoustToken.java    From metastone with GNU General Public License v2.0 5 votes vote down vote up
public JoustToken(GameBoardView boardView, Card card, boolean up, boolean won) {
	Window parent = boardView.getScene().getWindow();
	this.cardToken = new CardTooltip();

	popup = new Popup();
	popup.getContent().setAll(cardToken);
	popup.setX(parent.getX() + 600);
	popup.show(parent);
	int offsetY = up ? -200 : 100;
	popup.setY(parent.getY() + parent.getHeight() * 0.5 - cardToken.getHeight() * 0.5 + offsetY);

	cardToken.setCard(card);

	NotificationProxy.sendNotification(GameNotification.ANIMATION_STARTED);
	FadeTransition animation = new FadeTransition(Duration.seconds(1.0), cardToken);
	animation.setDelay(Duration.seconds(1f));
	animation.setOnFinished(this::onComplete);
	animation.setFromValue(1);
	animation.setToValue(0);
	animation.play();
	
	if (won) {
		ScaleTransition scaleAnimation = new ScaleTransition(Duration.seconds(0.5f), cardToken);
		scaleAnimation.setByX(0.1);
		scaleAnimation.setByY(0.1);
		scaleAnimation.setCycleCount(2);
		scaleAnimation.setAutoReverse(true);
		scaleAnimation.play();	
	}
}
 
Example 20
Source File: CardRevealedToken.java    From metastone with GNU General Public License v2.0 5 votes vote down vote up
private void secondTransition(ActionEvent event) {
	FadeTransition animation = new FadeTransition(Duration.seconds(.6), cardToken);
	animation.setOnFinished(this::nextTransition);
	animation.setFromValue(0);
	animation.setToValue(1);
	animation.play();
}