Search in sources :

Example 11 with FadeTransition

use of javafx.animation.FadeTransition in project bitsquare by bitsquare.

the class CandleStickChart method seriesAdded.

@Override
protected void seriesAdded(XYChart.Series<Number, Number> series, int seriesIndex) {
    // handle any data already in series
    for (int j = 0; j < series.getData().size(); j++) {
        XYChart.Data item = series.getData().get(j);
        Node candle = createCandle(seriesIndex, item, j);
        if (!getPlotChildren().contains(candle)) {
            getPlotChildren().add(candle);
            if (shouldAnimate()) {
                candle.setOpacity(0);
                FadeTransition ft = new FadeTransition(Duration.millis(500), candle);
                ft.setToValue(1);
                ft.play();
            }
        }
    }
    Path seriesPath = new Path();
    seriesPath.getStyleClass().setAll("candlestick-average-line", "series" + seriesIndex);
    series.setNode(seriesPath);
    if (!getPlotChildren().contains(seriesPath)) {
        getPlotChildren().add(seriesPath);
        if (shouldAnimate()) {
            seriesPath.setOpacity(0);
            FadeTransition ft = new FadeTransition(Duration.millis(500), seriesPath);
            ft.setToValue(1);
            ft.play();
        }
    }
}
Also used : Path(javafx.scene.shape.Path) FadeTransition(javafx.animation.FadeTransition) Node(javafx.scene.Node) XYChart(javafx.scene.chart.XYChart)

Example 12 with FadeTransition

use of javafx.animation.FadeTransition in project bitsquare by bitsquare.

the class VolumeChart method dataItemRemoved.

@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));
        ft.play();
    } else {
        getPlotChildren().remove(node);
    }
}
Also used : FadeTransition(javafx.animation.FadeTransition) ActionEvent(javafx.event.ActionEvent) Node(javafx.scene.Node)

Aggregations

FadeTransition (javafx.animation.FadeTransition)12 Node (javafx.scene.Node)8 ActionEvent (javafx.event.ActionEvent)4 XYChart (javafx.scene.chart.XYChart)4 Path (javafx.scene.shape.Path)4 Rectangle2D (javafx.geometry.Rectangle2D)1 Scene (javafx.scene.Scene)1 Label (javafx.scene.control.Label)1 StackPane (javafx.scene.layout.StackPane)1 Duration (javafx.util.Duration)1