changeset 1442:231378f0f928

fix RT-19903 Call ObservableList#clear() for LineChart result on IndexOutOfBoundsException.
author Paru Somashekar <paru.somashekar@oracle.com>
date Thu, 12 Jul 2012 15:58:06 -0700
parents 6c543a637228
children 374f5352788f
files javafx-ui-charts/src/javafx/scene/chart/LineChart.java
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-charts/src/javafx/scene/chart/LineChart.java	Thu Jul 12 15:56:15 2012 -0700
+++ b/javafx-ui-charts/src/javafx/scene/chart/LineChart.java	Thu Jul 12 15:58:06 2012 -0700
@@ -57,7 +57,7 @@
 import com.sun.javafx.css.StyleableBooleanProperty;
 import com.sun.javafx.css.StyleableProperty;
 import com.sun.javafx.css.converters.BooleanConverter;
-import java.util.Collections;
+import java.util.*;
 
 /**
  * Line Chart plots a line connecting the data points in a series. The data points
@@ -259,8 +259,12 @@
                 }
             } else if (itemIndex == 0 && series.getDataSize() > 1) {
                 animate = true;
-                item.setXValue(series.getData().get(0).getXValue());
-                item.setYValue(series.getData().get(0).getYValue());
+                Iterator<Data<X,Y>> iter = getDisplayedDataIterator(series);
+                if (iter.hasNext()) { // get first data value
+                    Data<X,Y> d = iter.next();
+                    item.setXValue(d.getXValue());
+                    item.setYValue(d.getYValue());
+                }
             } else if (itemIndex == (series.getDataSize() - 1) && series.getDataSize() > 1) {
                 animate = true;
                 int last = series.getData().size() - 1;