]> gerrit.simantics Code Review - simantics/district.git/blobdiff - org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DynamicVisualisationContributionsNode.java
DynamicVisualisations enhancements & deprecate old profiles & settings
[simantics/district.git] / org.simantics.district.network.ui / src / org / simantics / district / network / ui / nodes / DynamicVisualisationContributionsNode.java
index 7705a201e12e2bc1e97980975acf47245232387d..b3149324eb42fb342262a88f1831d194c0c5cdb6 100644 (file)
@@ -5,7 +5,6 @@ import java.awt.Color;
 import java.awt.Font;
 import java.awt.Graphics2D;
 import java.awt.geom.AffineTransform;
-import java.awt.geom.Ellipse2D;
 import java.awt.geom.Rectangle2D;
 import java.util.List;
 import java.util.Map;
@@ -217,64 +216,69 @@ public class DynamicVisualisationContributionsNode extends G2DNode {
         
         int i = 0;
         
-        for (Entry<String, DynamicSizeContribution> object : dynamicSizingContributions.entrySet()) {
-            DynamicSizeContribution cc = object.getValue();
-            
-            double min = cc.getDefaultMin();
-            double max = cc.getDefaultMax();
-            String unit = cc.getUnit();
-            String label = cc.getLabel();
-            
-            DynamicSizeMap map = cc.getDefaultSizeMap();
-            
-            List<Double> sizes = map.getSizes();
-            
-            double sizeBarBoxTop = (sizeBarBoxTopInitial + (colorBarBoxHeight * i));
-            i++;
-
-            g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.8f));
-            g2d.setColor(new Color(0.9f, 0.9f, 0.9f, 0.95f));
-            
-            Rectangle2D vertical = new Rectangle2D.Double(sizeBarBoxLeft, sizeBarBoxTop, colorBarBoxWidth, colorBarBoxHeight);
-            g2d.fill(vertical);
-            
-            double sizeVerticalLeft = sizeBarBoxLeft + 5;
-            double sizeVerticalTop = sizeBarBoxTop + 15;
-            double sizeVerticalHeigth = colorBarBoxHeight - 30;
-
-            double sizeVerticalWidth = (sizeBarBoxWidth - 10) / sizes.size();
-            
-            Font rulerFont = new Font("Tahoma", Font.PLAIN, DPIUtil.upscale(9));
-            g2d.setFont(rulerFont);
-
-            double interval = (max - min) / sizes.size();
-            
-            for (int j = 0; j < sizes.size(); j++) {
+        if (dynamicSizingContributions != null) {
+            for (Entry<String, DynamicSizeContribution> object : dynamicSizingContributions.entrySet()) {
+                DynamicSizeContribution cc = object.getValue();
+                
+                if (!cc.isUsed())
+                    continue;
+                
+                double min = cc.getDefaultMin();
+                double max = cc.getDefaultMax();
+                String unit = cc.getUnit();
+                String label = cc.getLabel();
+                
+                DynamicSizeMap map = cc.getDefaultSizeMap();
+                
+                List<Double> sizes = map.getSizes();
+                
+                double sizeBarBoxTop = (sizeBarBoxTopInitial + (colorBarBoxHeight * i));
+                i++;
+    
+                g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.8f));
+                g2d.setColor(new Color(0.9f, 0.9f, 0.9f, 0.95f));
+                
+                Rectangle2D vertical = new Rectangle2D.Double(sizeBarBoxLeft, sizeBarBoxTop, colorBarBoxWidth, colorBarBoxHeight);
+                g2d.fill(vertical);
                 
-                Double size = sizes.get(j);
+                double sizeVerticalLeft = sizeBarBoxLeft + 5;
+                double sizeVerticalTop = sizeBarBoxTop + 15;
+                double sizeVerticalHeigth = colorBarBoxHeight - 30;
+    
+                double sizeVerticalWidth = (sizeBarBoxWidth - 10) / sizes.size();
                 
-                g2d.setColor(new Color((float)0, (float)0, (float)0.8, 0.8f));
-                double sizedWidth = (size / 5) * sizeVerticalHeigth;
-                Rectangle2D rect = new Rectangle2D.Double(sizeVerticalLeft, (sizeVerticalTop), sizedWidth, sizeVerticalHeigth);
-                g2d.fill(rect);
+                Font rulerFont = new Font("Tahoma", Font.PLAIN, DPIUtil.upscale(9));
+                g2d.setFont(rulerFont);
+    
+                double interval = (max - min) / sizes.size();
                 
-                double value = min + j * interval;
-                String str = Double.toString(value);
-                if (str.length() > 4) {
-                    str = str.substring(0, 3);
+                for (int j = 0; j < sizes.size(); j++) {
+                    
+                    Double size = sizes.get(j);
+                    
+                    g2d.setColor(new Color((float)0, (float)0, (float)0.8, 0.8f));
+                    double sizedWidth = (size / 5) * sizeVerticalHeigth;
+                    Rectangle2D rect = new Rectangle2D.Double(sizeVerticalLeft, (sizeVerticalTop), sizedWidth, sizeVerticalHeigth);
+                    g2d.fill(rect);
+                    
+                    double value = min + j * interval;
+                    String str = Double.toString(value);
+                    if (str.length() > 4) {
+                        str = str.substring(0, 3);
+                    }
+                    g2d.setColor(Color.BLACK);
+                    g2d.drawString(str, (float)(sizeVerticalLeft - 8), (float)(sizeBarBoxTop + sizeBarBoxHeight));
+                    
+                    sizeVerticalLeft = sizeVerticalLeft + sizeVerticalWidth;
                 }
                 g2d.setColor(Color.BLACK);
-                g2d.drawString(str, (float)(sizeVerticalLeft - 8), (float)(sizeBarBoxTop + sizeBarBoxHeight));
                 
-                sizeVerticalLeft = sizeVerticalLeft + sizeVerticalWidth;
+                String str = Double.toString(max);
+                g2d.drawString(str, (int)(sizeBarBoxLeft + sizeBarBoxWidth - 30), (int)(sizeBarBoxTop + sizeBarBoxHeight));
+                
+                str = object.getKey() + " - " + label + " [" + unit + "]";
+                g2d.drawString(str, (int)sizeBarBoxLeft + 5, (int)sizeBarBoxTop + 10);
             }
-            g2d.setColor(Color.BLACK);
-            
-            String str = Double.toString(max);
-            g2d.drawString(str, (int)(sizeBarBoxLeft + sizeBarBoxWidth - 30), (int)(sizeBarBoxTop + sizeBarBoxHeight));
-            
-            str = object.getKey() + " - " + label + " [" + unit + "]";
-            g2d.drawString(str, (int)sizeBarBoxLeft + 5, (int)sizeBarBoxTop + 10);
         }
     }