]> gerrit.simantics Code Review - simantics/district.git/blobdiff - org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkVertexNode.java
Connection lines for control inputs.
[simantics/district.git] / org.simantics.district.network.ui / src / org / simantics / district / network / ui / nodes / DistrictNetworkVertexNode.java
index 377c7f7e8d11840ff6c706b0798a52e9e61fe43f..221ed714ac562cfcf0aa38f2915f65c760db66ef 100644 (file)
@@ -23,13 +23,13 @@ public class DistrictNetworkVertexNode extends G2DParentNode implements ISelecti
 
     private static final long serialVersionUID = -2641639101400236719L;
 
-    private static final BasicStroke STROKE           = new BasicStroke(4, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
-    private static final Color       SELECTION_COLOR  = new Color(255, 0, 255, 96);
+    private static final double left = -0.00005;
+    private static final double top = left;
+    public static final double width = 0.0001;
+    private static final double height = width;
 
-    private static final double left = -0.25;
-    private static final double top = -0.25;
-    private static final double width = 0.5;
-    private static final double height = 0.5;
+    private static final BasicStroke STROKE           = new BasicStroke((float)width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
+    private static final Color       SELECTION_COLOR  = new Color(255, 0, 255, 96);
 
     private static final Rectangle2D NORMAL = new Rectangle2D.Double(left, top, width, height);
     private static final Rectangle2D HOVERED = new Rectangle2D.Double(left * 3, top * 3, width * 3, height * 3);
@@ -63,7 +63,7 @@ public class DistrictNetworkVertexNode extends G2DParentNode implements ISelecti
         AffineTransform t = getTransform();
         if (t != null && !t.isIdentity()) {
             ot = g2d.getTransform();
-            g2d.transform(getTransform());
+            g2d.transform(t);
         }
 
         Object oaaHint = null;
@@ -77,11 +77,9 @@ public class DistrictNetworkVertexNode extends G2DParentNode implements ISelecti
         Color newColor = dynamicColor != null ? dynamicColor : color;
         boolean changeColor = !oldColor.equals(newColor);
 
-        double viewScaleRecip = 10;
+        double viewScaleRecip = 1;
         if (scaleStroke) {
-            double scale = GeometryUtils.getScale(g2d.getTransform());
-            scale = Math.max(10000, Math.min(scale, 50000));
-            viewScaleRecip /= scale;
+            viewScaleRecip *= DistrictNetworkNodeUtils.calculateScaleRecip(g2d.getTransform());
         }
         double scaleRecip = viewScaleRecip * nodeSize;
 
@@ -111,8 +109,10 @@ public class DistrictNetworkVertexNode extends G2DParentNode implements ISelecti
         // Render SVG symbol
         for (INode nn : getNodes()) {
             G2DNode g2dNode = (G2DNode)nn;
-            symbolTransform = DistrictNetworkNodeUtils.getTransformToRectangle(toDraw, symbolTransform);
-            g2dNode.setTransform(symbolTransform);
+            if (nn instanceof SVGNode) {
+                symbolTransform = DistrictNetworkNodeUtils.getTransformToRectangle(toDraw, symbolTransform);
+                g2dNode.setTransform(symbolTransform);
+            }
             g2dNode.render(g2d);
         }
         
@@ -152,7 +152,11 @@ public class DistrictNetworkVertexNode extends G2DParentNode implements ISelecti
     private Rectangle2D calculateBounds(Rectangle2D rect) {
         Point2D calcPoint = DistrictNetworkNodeUtils.calculatePoint2D(vertex.getPoint(), point);
         AffineTransform at = getTransform();
-        return new Rectangle2D.Double(calcPoint.getX(), calcPoint.getY(), width / at.getScaleX(), height / at.getScaleY()).getBounds2D();
+        double x = calcPoint.getX();
+        double y = calcPoint.getY();
+        double widthh = width / at.getScaleX();
+        double heighth = height / at.getScaleY();
+        return new Rectangle2D.Double(x - widthh, y - heighth, widthh * 2, heighth * 2).getBounds2D();
     }
 
     public void setVertex(DistrictNetworkVertex vertex) {