]> gerrit.simantics Code Review - simantics/district.git/blobdiff - org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkVertexNode.java
Avoid duplicate validity checks when injecting layer listener
[simantics/district.git] / org.simantics.district.network.ui / src / org / simantics / district / network / ui / nodes / DistrictNetworkVertexNode.java
index 011d682eb2a419f9dc7e02e4706e39c16850d24c..99eb3cc117b7fb91cbb8352016a62da7e9836249 100644 (file)
@@ -11,6 +11,7 @@ import java.awt.geom.Rectangle2D;
 
 import org.simantics.district.network.ModelledCRS;
 import org.simantics.district.network.ui.adapters.DistrictNetworkVertex;
+import org.simantics.scenegraph.ParentNode;
 import org.simantics.scenegraph.g2d.G2DNode;
 import org.simantics.scenegraph.utils.GeometryUtils;
 import org.slf4j.Logger;
@@ -23,10 +24,10 @@ public class DistrictNetworkVertexNode extends G2DNode {
     private static final long serialVersionUID = -2641639101400236719L;
     private DistrictNetworkVertex vertex;
 
-    private static final double left = -0.5;
-    private static final double top = -0.5;
-    private static final double width = 1;
-    private static final double height = 1;
+    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 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);
@@ -39,6 +40,8 @@ public class DistrictNetworkVertexNode extends G2DNode {
 
     private Rectangle2D bounds;
 
+    private Double strokee;
+
     @Override
     public void init() {
         setZIndex(2);
@@ -64,7 +67,11 @@ public class DistrictNetworkVertexNode extends G2DNode {
         double scaleRecip = 1;
         if (scaleStroke) {
             double scale = GeometryUtils.getScale(g2d.getTransform());
-            
+            double str;
+            if (strokee != null)
+                str = strokee;
+            else
+                str = 1.0;
             //System.out.println("scale: " + scale);
             scaleRecip = 1.0 / scale;
         }
@@ -116,6 +123,11 @@ public class DistrictNetworkVertexNode extends G2DNode {
         updateBounds();
     }
     
+    @Override
+    public AffineTransform getTransform() {
+        return super.getTransform();
+    }
+    
     private Rectangle2D calculateBounds(Rectangle2D rect) {
         Point2D calcPoint = calculatePoint2D(vertex);
         AffineTransform at = getTransform();
@@ -125,7 +137,7 @@ public class DistrictNetworkVertexNode extends G2DNode {
     private static Point2D calculatePoint2D(DistrictNetworkVertex vertex) {
         Point2D point= vertex.getPoint();
         double x = ModelledCRS.longitudeToX(point.getX());
-        double y = ModelledCRS.latitudeToY(point.getY());
+        double y = ModelledCRS.latitudeToY(-point.getY()); // Inverse because Simantics Diagram is inverted
 
         // Apply the scaling
         Point2D res = new Point2D.Double(x, y);
@@ -156,4 +168,8 @@ public class DistrictNetworkVertexNode extends G2DNode {
         return color;
     }
 
+    @PropertySetter(value = "stroke")
+    public void setStroke(Double stroke) {
+        this.strokee = stroke / 10;
+    }
 }