changeset 6938:4b558607b25b

RT-33688 [PieChart] label line length equal to 0 results in label disappearing. Reviewed by: jgiles
author Martin Sladecek <martin.sladecek@oracle.com>
date Wed, 30 Apr 2014 08:19:53 +0200
parents 5c12dcee4f69
children 3c4fb09288b6
files modules/controls/src/main/java/javafx/scene/chart/NumberAxis.java modules/controls/src/main/java/javafx/scene/chart/PieChart.java
diffstat 2 files changed, 11 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/modules/controls/src/main/java/javafx/scene/chart/NumberAxis.java	Wed Apr 30 12:13:49 2014 +1200
+++ b/modules/controls/src/main/java/javafx/scene/chart/NumberAxis.java	Wed Apr 30 08:19:53 2014 +0200
@@ -218,14 +218,16 @@
             animator.stop(currentAnimationID);
             currentAnimationID = animator.animate(
                 new KeyFrame(Duration.ZERO,
-                        new KeyValue(currentLowerBound, oldLowerBound),
-                        new KeyValue(scalePropertyImpl(), getScale())
+                        new KeyValue(currentLowerBound, oldLowerBound)
+//                        new KeyValue(scalePropertyImpl(), getScale())
                 ),
                 new KeyFrame(Duration.millis(700),
-                        new KeyValue(currentLowerBound, lowerBound),
-                        new KeyValue(scalePropertyImpl(), scale)
+                        new KeyValue(currentLowerBound, lowerBound)
+//                        new KeyValue(scalePropertyImpl(), scale)
                 )
             );
+            setScale(scale);
+//            currentLowerBound.set(lowerBound);
         } else {
             currentLowerBound.set(lowerBound);
             setScale(scale);
--- a/modules/controls/src/main/java/javafx/scene/chart/PieChart.java	Wed Apr 30 12:13:49 2014 +1200
+++ b/modules/controls/src/main/java/javafx/scene/chart/PieChart.java	Wed Apr 30 08:19:53 2014 +0200
@@ -512,10 +512,8 @@
         boolean shouldShowLabels = getLabelsVisible();
         if(getLabelsVisible()) {
 
-            double minX = begin != null ? Double.MAX_VALUE : 0d;
-            double minY = begin != null ? Double.MAX_VALUE : 0d;
-            double maxX = begin != null ? Double.MIN_VALUE : 0d;
-            double maxY = begin != null ? Double.MIN_VALUE : 0d;
+            double xPad = 0d;
+            double yPad = 0d;
 
             labelsX = new double[getDataSize()];
             labelsY = new double[getDataSize()];
@@ -533,22 +531,15 @@
                 final double sproutY = calcY(labelAngles[index], getLabelLineLength(), 0);
                 labelsX[index] = sproutX;
                 labelsY[index] = sproutY;
-                if (sproutX < 0) { // on left
-                    minX = Math.min(minX, sproutX-item.textNode.getLayoutBounds().getWidth()-LABEL_TICK_GAP);
-                } else { // on right
-                    maxX = Math.max(maxX, sproutX+item.textNode.getLayoutBounds().getWidth()+LABEL_TICK_GAP);
-
-                }
+                xPad = Math.max(xPad, 2 * (item.textNode.getLayoutBounds().getWidth() + LABEL_TICK_GAP + Math.abs(sproutX)));
                 if (sproutY > 0) { // on bottom
-                    maxY = Math.max(maxY, sproutY+item.textNode.getLayoutBounds().getMaxY());
+                    yPad = Math.max(yPad, 2 * Math.abs(sproutY+item.textNode.getLayoutBounds().getMaxY()));
                 } else { // on top
-                    minY = Math.min(minY, sproutY + item.textNode.getLayoutBounds().getMinY());
+                    yPad = Math.max(yPad, 2 * Math.abs(sproutY + item.textNode.getLayoutBounds().getMinY()));
                 }
                 start+= size;
                 index++;
             }
-            double xPad = (Math.max(Math.abs(minX), Math.abs(maxX))) * 2;
-            double yPad = (Math.max(Math.abs(minY), Math.abs(maxY))) * 2;
             pieRadius = Math.min(contentWidth - xPad, contentHeight - yPad) / 2;
             // check if this makes the pie too small
             if (pieRadius < MIN_PIE_RADIUS ) {