changeset 1116:535fa5b98147

fix RT-21532 resizing areachart to a too small size can block the whole application & RT-20989 UI is freezed after changing tick unit to negative value
author Paru Somashekar <paru.somashekar@oracle.com>
date Tue, 22 May 2012 11:28:15 -0700
parents afd4133eb2f6
children 3c607527d01a
files javafx-ui-charts/src/javafx/scene/chart/XYChart.java javafx-ui-controls/src/com/sun/javafx/charts/Legend.java javafx-ui-controls/src/javafx/scene/chart/NumberAxis.java
diffstat 3 files changed, 18 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-charts/src/javafx/scene/chart/XYChart.java	Tue May 22 11:32:39 2012 -0400
+++ b/javafx-ui-charts/src/javafx/scene/chart/XYChart.java	Tue May 22 11:28:15 2012 -0700
@@ -613,7 +613,7 @@
 
     /** @inheritDoc */
     @Override protected final void layoutChartChildren(double top, double left, double width, double height) {
-        if(getData() == null) return;
+        if(getData() == null || height <= 0 || width <= 0 ) return;
         if (!rangeValid) {
             rangeValid = true;
             if(getData() != null) updateAxisRange();
--- a/javafx-ui-controls/src/com/sun/javafx/charts/Legend.java	Tue May 22 11:32:39 2012 -0400
+++ b/javafx-ui-controls/src/com/sun/javafx/charts/Legend.java	Tue May 22 11:28:15 2012 -0700
@@ -138,7 +138,8 @@
             if(columns <= 1) return tileSize.getWidth() + getInsets().getLeft() + getInsets().getRight();
         } else {
             rows = (int) Math.floor( contentHeight / (tileSize.getHeight() + GAP) );
-            columns = (int)Math.ceil(getItems().size() / (double)rows);
+            columns = (rows == 0) ? (int)Math.ceil(getItems().size()) : 
+                            (int)Math.ceil(getItems().size() / (double)rows);
         }
         if(columns == 1) rows = Math.min(rows, getItems().size());
         return (columns*(tileSize.getWidth()+GAP)) - GAP + getInsets().getLeft() + getInsets().getRight();
@@ -151,7 +152,8 @@
             if(rows <= 1) return tileSize.getHeight() + getInsets().getTop() + getInsets().getBottom();
         } else {
             columns = (int) Math.floor( contentWidth / (tileSize.getWidth() + GAP) );
-            rows = (int)Math.ceil(getItems().size() / (double)columns);
+            rows = (columns == 0) ? (int)Math.ceil(getItems().size()) : 
+                            (int)Math.ceil(getItems().size() / (double)columns);
         }
         if(rows == 1) columns = Math.min(columns, getItems().size());
         return (rows*(tileSize.getHeight()+GAP)) - GAP + getInsets().getTop() + getInsets().getBottom();
--- a/javafx-ui-controls/src/javafx/scene/chart/NumberAxis.java	Tue May 22 11:32:39 2012 -0400
+++ b/javafx-ui-controls/src/javafx/scene/chart/NumberAxis.java	Tue May 22 11:28:15 2012 -0700
@@ -243,9 +243,9 @@
         final double upperBound = rangeProps[1];
         final double tickUnit = rangeProps[2];
         List<Number> tickValues =  new ArrayList<Number>();
-        if (lowerBound == upperBound) {
+        if (tickUnit <= 0 || lowerBound == upperBound) {
             tickValues.add(lowerBound);
-        } else if (getTickUnit() != 0) {
+        } else if (getTickUnit() > 0) {
             for (double major = lowerBound; major <= upperBound; major += tickUnit)  {
                 tickValues.add(major);
                 if(tickValues.size()>2000) {
@@ -255,7 +255,7 @@
                     break;
                 }
             }
-        }
+        } 
         return tickValues;
     }
 
@@ -270,14 +270,16 @@
         final double upperBound = getUpperBound();
         final double tickUnit = getTickUnit();
         final double minorUnit = tickUnit/getMinorTickCount();
-        for (double major = lowerBound; major < upperBound; major += tickUnit)  {
-            for (double minor=major+minorUnit; minor < (major+tickUnit); minor += minorUnit) {
-                minorTickMarks.add(minor);
-                if(minorTickMarks.size()>10000) {
-                    // This is a ridiculous amount of major tick marks, something has probably gone wrong
-                    System.err.println("Warning we tried to create more than 10000 minor tick marks on a NumberAxis. " +
-                            "Lower Bound=" + getLowerBound() + ", Upper Bound=" + getUpperBound() + ", Tick Unit=" + tickUnit);
-                    break;
+        if (getTickUnit() > 0) {
+            for (double major = lowerBound; major < upperBound; major += tickUnit)  {
+                for (double minor=major+minorUnit; minor < (major+tickUnit); minor += minorUnit) {
+                    minorTickMarks.add(minor);
+                    if(minorTickMarks.size()>10000) {
+                        // This is a ridiculous amount of major tick marks, something has probably gone wrong
+                        System.err.println("Warning we tried to create more than 10000 minor tick marks on a NumberAxis. " +
+                                "Lower Bound=" + getLowerBound() + ", Upper Bound=" + getUpperBound() + ", Tick Unit=" + tickUnit);
+                        break;
+                    }
                 }
             }
         }