changeset 6518:9940be2f94f3

RT-36283: override Legend computePrefWidth/Height to return zero if there are no legend items
author David Grieve<david.grieve@oracle.com>
date Wed, 19 Mar 2014 16:19:50 -0400
parents 96ca9d80b159
children 7ecb97f4d8ff
files modules/controls/src/main/java/com/sun/javafx/charts/Legend.java
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/modules/controls/src/main/java/com/sun/javafx/charts/Legend.java	Wed Mar 19 16:19:50 2014 -0400
+++ b/modules/controls/src/main/java/com/sun/javafx/charts/Legend.java	Wed Mar 19 16:19:50 2014 -0400
@@ -125,6 +125,18 @@
 
     // -------------- METHODS ---------------------------------------------------
 
+    @Override
+    protected double computePrefWidth(double forHeight) {
+        // Legend prefWidth is zero if there are no legend items
+        return (getItems().size() > 0) ? super.computePrefWidth(forHeight) : 0;
+    }
+
+    @Override
+    protected double computePrefHeight(double forWidth) {
+        // Legend prefHeight is zero if there are no legend items
+        return (getItems().size() > 0) ? super.computePrefHeight(forWidth) : 0;
+    }
+
     /** A item to be displayed on a Legend */
     public static class LegendItem {