< prev index next >

modules/controls/src/main/java/javafx/scene/chart/XYChart.java

Print this page
rev 8907 : RT-46086: StackedAreaChart doesn't fade out removed series


 908      * @param series The series to remove
 909      */
 910     protected final void removeSeriesFromDisplay(Series<X, Y> series) {
 911         if (series != null) series.setToRemove = false;
 912         series.setChart(null);
 913         displayedSeries.remove(series);
 914     }
 915 
 916     /**
 917      * XYChart maintains a list of all series currently displayed this includes all current series + any series that
 918      * have recently been deleted that are in the process of being faded(animated) out. This creates and returns a
 919      * iterator over that list. This is what implementations of XYChart should use when plotting data.
 920      *
 921      * @return iterator over currently displayed series
 922      */
 923     protected final Iterator<Series<X,Y>> getDisplayedSeriesIterator() {
 924         return Collections.unmodifiableList(displayedSeries).iterator();
 925     }
 926 
 927     /**






























 928      * The current displayed data value plotted on the X axis. This may be the same as xValue or different. It is
 929      * used by XYChart to animate the xValue from the old value to the new value. This is what you should plot
 930      * in any custom XYChart implementations. Some XYChart chart implementations such as LineChart also use this
 931      * to animate when data is added or removed.
 932      */
 933     protected final X getCurrentDisplayedXValue(Data<X,Y> item) { return item.getCurrentX(); }
 934 
 935     /** Set the current displayed data value plotted on X axis.
 936      *
 937      * @param item The XYChart.Data item from which the current X axis data value is obtained.
 938      * @see #getCurrentDisplayedXValue
 939      */
 940     protected final void setCurrentDisplayedXValue(Data<X,Y> item, X value) { item.setCurrentX(value); }
 941 
 942     /** The current displayed data value property that is plotted on X axis.
 943      *
 944      * @param item The XYChart.Data item from which the current X axis data value property object is obtained.
 945      * @return The current displayed X data value ObjectProperty.
 946      * @see #getCurrentDisplayedXValue
 947      */




 908      * @param series The series to remove
 909      */
 910     protected final void removeSeriesFromDisplay(Series<X, Y> series) {
 911         if (series != null) series.setToRemove = false;
 912         series.setChart(null);
 913         displayedSeries.remove(series);
 914     }
 915 
 916     /**
 917      * XYChart maintains a list of all series currently displayed this includes all current series + any series that
 918      * have recently been deleted that are in the process of being faded(animated) out. This creates and returns a
 919      * iterator over that list. This is what implementations of XYChart should use when plotting data.
 920      *
 921      * @return iterator over currently displayed series
 922      */
 923     protected final Iterator<Series<X,Y>> getDisplayedSeriesIterator() {
 924         return Collections.unmodifiableList(displayedSeries).iterator();
 925     }
 926 
 927     /**
 928      * Creates an array of KeyFrames for fading out nodes representing a series
 929      *
 930      * @param series The series to remove
 931      * @param fadeOutTime Time to fade out, in milliseconds
 932      * @return array of two KeyFrames from zero to fadeOutTime
 933      */
 934     protected final KeyFrame[] createSeriesRemoveTimeLine(Series<X, Y> series, long fadeOutTime) {
 935         final List<Node> nodes = new ArrayList<>();
 936         nodes.add(series.getNode());
 937         for (Data<X, Y> d : series.getData()) {
 938             if (d.getNode() != null) {
 939                 nodes.add(d.getNode());
 940             }
 941         }
 942         // fade out series node and symbols
 943         KeyValue[] startValues = new KeyValue[nodes.size()];
 944         KeyValue[] endValues = new KeyValue[nodes.size()];
 945         for (int j = 0; j < nodes.size(); j++) {
 946             startValues[j] = new KeyValue(nodes.get(j).opacityProperty(), 1);
 947             endValues[j] = new KeyValue(nodes.get(j).opacityProperty(), 0);
 948         }
 949         return new KeyFrame[] {
 950             new KeyFrame(Duration.ZERO, startValues),
 951             new KeyFrame(Duration.millis(fadeOutTime), actionEvent -> {
 952                 getPlotChildren().removeAll(nodes);
 953                 removeSeriesFromDisplay(series);
 954             }, endValues)
 955         };
 956     }
 957     /**
 958      * The current displayed data value plotted on the X axis. This may be the same as xValue or different. It is
 959      * used by XYChart to animate the xValue from the old value to the new value. This is what you should plot
 960      * in any custom XYChart implementations. Some XYChart chart implementations such as LineChart also use this
 961      * to animate when data is added or removed.
 962      */
 963     protected final X getCurrentDisplayedXValue(Data<X,Y> item) { return item.getCurrentX(); }
 964 
 965     /** Set the current displayed data value plotted on X axis.
 966      *
 967      * @param item The XYChart.Data item from which the current X axis data value is obtained.
 968      * @see #getCurrentDisplayedXValue
 969      */
 970     protected final void setCurrentDisplayedXValue(Data<X,Y> item, X value) { item.setCurrentX(value); }
 971 
 972     /** The current displayed data value property that is plotted on X axis.
 973      *
 974      * @param item The XYChart.Data item from which the current X axis data value property object is obtained.
 975      * @return The current displayed X data value ObjectProperty.
 976      * @see #getCurrentDisplayedXValue
 977      */


< prev index next >