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

The following examples show how to use javafx.animation.FadeTransition#play() . 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 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 2
Source File: PopOver.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Hides the pop over by quickly changing its opacity to 0.
 *
 * @param fadeOutDuration
 *            the duration of the fade transition that is being used to
 *            change the opacity of the pop over
 * @since 1.0
 */
public final void hide(Duration fadeOutDuration) {
    if (fadeOutDuration == null) {
        fadeOutDuration = DEFAULT_FADE_DURATION;
    }

    if (isShowing()) {
        // Fade Out
        Node skinNode = getSkin().getNode();
        skinNode.setOpacity(0);

        FadeTransition fadeOut = new FadeTransition(fadeOutDuration,
                skinNode);
        fadeOut.setFromValue(1);
        fadeOut.setToValue(0);
        fadeOut.setOnFinished(evt -> super.hide());
        fadeOut.play();
    }
}
 
Example 3
Source File: Resumen.java    From uip-pc2 with MIT License 6 votes vote down vote up
public void transferir(ActionEvent actionEvent) {
    Stage stage = (Stage) movimientos.getScene().getWindow();
    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("Transferencia.fxml"));
    Parent root = null;
    try {
        root = fxmlLoader.load();
    } catch (Exception e) {
        Alert alerta = new Alert(Alert.AlertType.ERROR);
        alerta.setTitle("Error de Aplicación");
        alerta.setContentText("Llama al lapecillo de sistemas.");
        alerta.showAndWait();
        Platform.exit();
    }
    FadeTransition ft = new FadeTransition(Duration.millis(1500), root);
    ft.setFromValue(0.0);
    ft.setToValue(1.0);
    ft.play();
    Transferencia controller = fxmlLoader.<Transferencia>getController();
    controller.cargar_datos(cuenta.getText()); // ¯\_(ツ)_/¯ cuenta viene de la linea 27
    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.show();
}
 
Example 4
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 5
Source File: VolumeChart.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void seriesAdded(XYChart.Series<Number, Number> series, int seriesIndex) {
    for (int j = 0; j < series.getData().size(); j++) {
        XYChart.Data<Number, Number> item = series.getData().get(j);
        Node volumeBar = createCandle(seriesIndex, item, j);
        if (shouldAnimate()) {
            volumeBar.setOpacity(0);
            getPlotChildren().add(volumeBar);
            FadeTransition ft = new FadeTransition(Duration.millis(500), volumeBar);
            ft.setToValue(1);
            ft.play();
        } else {
            getPlotChildren().add(volumeBar);
        }
    }
}
 
Example 6
Source File: CardPlayedToken.java    From metastone with GNU General Public License v2.0 6 votes vote down vote up
public CardPlayedToken(GameBoardView boardView, Card card) {
	Window parent = boardView.getScene().getWindow();
	this.cardToken = new CardTooltip();

	popup = new Popup();
	popup.getContent().setAll(cardToken);
	popup.setX(parent.getX() + 40);
	popup.show(parent);
	popup.setY(parent.getY() + parent.getHeight() * 0.5 - cardToken.getHeight() * 0.5);

	cardToken.setCard(card);

	NotificationProxy.sendNotification(GameNotification.ANIMATION_STARTED);
	FadeTransition animation = new FadeTransition(Duration.seconds(1.2), cardToken);
	animation.setDelay(Duration.seconds(0.6f));
	animation.setOnFinished(this::onComplete);
	animation.setFromValue(1);
	animation.setToValue(0);
	animation.play();
}
 
Example 7
Source File: CandleStickChart.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void dataItemAdded(XYChart.Series<Number, Number> series, int itemIndex, XYChart.Data<Number, Number> item) {
    Node candle = createCandle(getData().indexOf(series), item, itemIndex);
    getPlotChildren().remove(candle);

    if (shouldAnimate()) {
        candle.setOpacity(0);
        getPlotChildren().add(candle);
        // fade in new candle
        FadeTransition ft = new FadeTransition(Duration.millis(500), candle);
        ft.setToValue(1);
        ft.play();
    } else {
        getPlotChildren().add(candle);
    }
    // always draw average line on top

    if (series.getNode() instanceof Path) {
        Path seriesPath = (Path) series.getNode();
        seriesPath.toFront();
    }
}
 
Example 8
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 9
Source File: Secundario.java    From uip-pc2 with MIT License 6 votes vote down vote up
public void volver(ActionEvent actionEvent) {
    Stage stage = (Stage) btnvolver.getScene().getWindow();
    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("Principal.fxml"));
    Parent root = null;
    try {
        root = fxmlLoader.load();
    } catch (Exception e) {
        Alert alerta = new Alert(Alert.AlertType.ERROR);
        alerta.setTitle("Error de Aplicación");
        alerta.setContentText("Llama al lapecillo de sistemas.");
        alerta.showAndWait();
        Platform.exit();
    }
    FadeTransition ft = new FadeTransition(Duration.millis(1500), root);
    ft.setFromValue(0.0);
    ft.setToValue(1.0);
    ft.play();
    Principal controller = fxmlLoader.<Principal>getController();
    controller.setConteo(conteo);
    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.show();
}
 
Example 10
Source File: VolumeChart.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void seriesRemoved(XYChart.Series<Number, Number> series) {
    for (XYChart.Data<Number, Number> d : series.getData()) {
        final Node volumeBar = d.getNode();
        if (shouldAnimate()) {
            FadeTransition ft = new FadeTransition(Duration.millis(500), volumeBar);
            ft.setToValue(0);
            ft.setOnFinished((ActionEvent actionEvent) -> getPlotChildren().remove(volumeBar));
            ft.play();
        } else {
            getPlotChildren().remove(volumeBar);
        }
    }
    if (shouldAnimate()) {
        new Timeline(new KeyFrame(Duration.millis(500), event -> removeSeriesFromDisplay(series))).play();
    } else {
        removeSeriesFromDisplay(series);
    }
}
 
Example 11
Source File: Movimientos.java    From uip-pc2 with MIT License 6 votes vote down vote up
public void salir(MouseEvent mouseEvent) {
    Stage stage = (Stage) salir.getScene().getWindow();
    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("Login.fxml"));
    Parent root = null;
    try {
        root = fxmlLoader.load();
    } catch (Exception e) {
        Alert alerta = new Alert(Alert.AlertType.ERROR);
        alerta.setTitle("Error de Aplicación");
        alerta.setContentText("Llama al lapecillo de sistemas.");
        alerta.showAndWait();
        Platform.exit();
    }
    FadeTransition ft = new FadeTransition(Duration.millis(1500), root);
    ft.setFromValue(0.0);
    ft.setToValue(1.0);
    ft.play();
    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.show();
}
 
Example 12
Source File: Undecorator.java    From DevToolBox with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Activate dock feedback on screen's bounds
 *
 * @param x
 * @param y
 * @param width
 * @param height
 */
public void setDockFeedbackVisible(double x, double y, double width, double height) {
    dockFeedbackPopup.setX(x);
    dockFeedbackPopup.setY(y);

    dockFeedback.setX(SHADOW_WIDTH);
    dockFeedback.setY(SHADOW_WIDTH);
    dockFeedback.setHeight(height - SHADOW_WIDTH * 2);
    dockFeedback.setWidth(width - SHADOW_WIDTH * 2);

    dockFeedbackPopup.setWidth(width);
    dockFeedbackPopup.setHeight(height);

    dockFeedback.setOpacity(1);
    dockFeedbackPopup.show();

    dockFadeTransition = new FadeTransition();
    dockFadeTransition.setDuration(Duration.millis(200));
    dockFadeTransition.setNode(dockFeedback);
    dockFadeTransition.setFromValue(0);
    dockFadeTransition.setToValue(1);
    dockFadeTransition.setAutoReverse(true);
    dockFadeTransition.setCycleCount(3);

    dockFadeTransition.play();

}
 
Example 13
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 14
Source File: Toast.java    From DevToolBox with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void doShow() {
    LOGGER.info("show toast: {}", this);
    if (window != null) {
        if (autoCenter) {
            connectAutoCenterHandler();
        }
        if (Double.isNaN(screenX) || Double.isNaN(screenY)) {
            super.show(window);
        } else {
            super.show(window, screenX, screenY);
        }
    } else { // anchor
        if (autoCenter) {
            Scene scene = anchor.getScene();
            if (scene != null) {
                window = scene.getWindow();
            }
            if (window == null) {
                throw new IllegalStateException("anchor node is not attached to a window");
            }
            connectAutoCenterHandler();
        }
        super.show(anchor, Double.isNaN(screenX) ? 0.0 : screenX, Double.isNaN(screenY) ? 0.0 : screenY);
    }
    if (isAutoHide() && !duration.isIndefinite()) {
        hideTimer = new Timeline(new KeyFrame(duration));
        hideTimer.setOnFinished((ActionEvent event) -> {
            hideTimer = null;
            Toast.this.hide();
        });
        hideTimer.playFromStart();
    }
    FadeTransition transition = new FadeTransition(fadeInDuration, content);
    transition.setFromValue(0.0);
    transition.setToValue(contentOpacity);
    transition.play();
}
 
Example 15
Source File: JaceUIController.java    From jace with GNU General Public License v2.0 5 votes vote down vote up
private void showControlOverlay(MouseEvent evt) {
    if (!evt.isPrimaryButtonDown() && !evt.isSecondaryButtonDown()) {
        delayTimer.stop();
        menuButtonPane.setVisible(false);
        controlOverlay.setVisible(true);
        FadeTransition ft = new FadeTransition(Duration.millis(500), controlOverlay);
        ft.setFromValue(0.0);
        ft.setToValue(1.0);
        ft.play();
        rootPane.requestFocus();
    }
}
 
Example 16
Source File: DashboardController.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
private void loadNode(Node node) {
	//System.out.println("loadNode()");
    insertPane.getChildren().clear();
    insertPane.getChildren().add((Node) node);

    FadeTransition ft = new FadeTransition(Duration.millis(1500));
    ft.setNode(node);
    ft.setFromValue(0.1);
    ft.setToValue(1);
    ft.setCycleCount(1);
    ft.setAutoReverse(false);
    ft.play();
}
 
Example 17
Source File: GitFxDialog.java    From GitFx with Apache License 2.0 5 votes vote down vote up
public void applyFadeTransition(Dialog node) {
    FadeTransition fadeTransition = new FadeTransition();
    fadeTransition.setDuration(Duration.seconds(.5));
    fadeTransition.setNode(node.getDialogPane());
    fadeTransition.setFromValue(0);
    fadeTransition.setToValue(1);
    fadeTransition.play();
}
 
Example 18
Source File: SettingsActivity.java    From ApkToolPlus with Apache License 2.0 5 votes vote down vote up
public void close() {
    FadeTransition fadeTransition = AnimationHelper.fadeOut(event -> {
        ActivityManager.getRootView().getChildren().remove(getRootView());
    });
    fadeTransition.setNode(getRootView());
    fadeTransition.play();
    // 保存配置
    Config.save();
}
 
Example 19
Source File: MainUIController.java    From FXGLGames with MIT License 4 votes vote down vote up
private void animateLabel(Label label) {
    FadeTransition ft = new FadeTransition(Duration.seconds(0.33), label);
    ft.setFromValue(0);
    ft.setToValue(1);
    ft.play();
}
 
Example 20
Source File: ProfileController.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
private void animateMessage() {
    FadeTransition ft = new FadeTransition(Duration.millis(1000), success);
    ft.setFromValue(0.0);
    ft.setToValue(1);
    ft.play();
}