X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.district.network.ui%2Fsrc%2Forg%2Fsimantics%2Fdistrict%2Fnetwork%2Fui%2Fnodes%2FDynamicVisualisationContributionsNode.java;h=b3149324eb42fb342262a88f1831d194c0c5cdb6;hb=607611b465ee7737db9489d21d261ff793692b89;hp=7705a201e12e2bc1e97980975acf47245232387d;hpb=26ace6ab51bc85e8c7429b84a0402e70b49fc062;p=simantics%2Fdistrict.git diff --git a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DynamicVisualisationContributionsNode.java b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DynamicVisualisationContributionsNode.java index 7705a201..b3149324 100644 --- a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DynamicVisualisationContributionsNode.java +++ b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DynamicVisualisationContributionsNode.java @@ -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 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 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 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 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); } }