]> gerrit.simantics Code Review - simantics/district.git/blobdiff - org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkEdgeNode.java
Amendment to 165a995bf446be802c4623b46706a257a5367c69
[simantics/district.git] / org.simantics.district.network.ui / src / org / simantics / district / network / ui / nodes / DistrictNetworkEdgeNode.java
index 195472fcd2474b0b060de1df3b032c350c672c5e..0e5f30222a6f72682640dd0e70b0ae769ff727de 100644 (file)
@@ -5,10 +5,10 @@ import java.awt.Color;
 import java.awt.Graphics2D;
 import java.awt.RenderingHints;
 import java.awt.geom.AffineTransform;
-import java.awt.geom.Line2D;
 import java.awt.geom.Path2D;
 import java.awt.geom.Point2D;
 import java.awt.geom.Rectangle2D;
+import java.util.Optional;
 
 import org.simantics.district.network.ModelledCRS;
 import org.simantics.district.network.ui.DistrictNetworkEdge;
@@ -40,6 +40,7 @@ public class DistrictNetworkEdgeNode extends G2DParentNode implements ISelection
     private Color color;
     private Double stroke;
     private transient Color dynamicColor = null;
+    private transient Color eventColor = null;
 
     // Dimensions for shut-off valve symbol
     private static final double left = -0.25;
@@ -112,6 +113,7 @@ public class DistrictNetworkEdgeNode extends G2DParentNode implements ISelection
             }
     
             g2d.setColor(dynamicColor != null ? dynamicColor : color);
+            g2d.setColor(eventColor != null ? eventColor : g2d.getColor());
             g2d.setStroke(bs);
             g2d.draw(path);
     
@@ -269,6 +271,11 @@ public class DistrictNetworkEdgeNode extends G2DParentNode implements ISelection
         this.dynamicColor = color;
     }
 
+    @PropertySetter(value = "eventColor")
+    public void setEventColor(Color color) {
+        this.eventColor = color;
+    }
+
     @PropertySetter(value = "arrowLength")
     public void setArrowLength(Double length) {
         // find if there is a child deferred arrow node
@@ -290,4 +297,24 @@ public class DistrictNetworkEdgeNode extends G2DParentNode implements ISelection
         this.hidden = value;
     }
 
+    public void setStaticInformation(Optional<String> staticInformation) {
+        DistrictNetworkStaticInfoNode child = getOrCreateNode(DistrictNetworkStaticInfoNode.NODE_KEY, DistrictNetworkStaticInfoNode.class);
+        child.setEdgeNode(this);
+        if (staticInformation.isPresent()) {
+            child.setInfo(staticInformation.get());
+        } else {
+            child.setInfo(null);
+        }
+    }
+
+    public void setInSimulation(Optional<Boolean> isInSimulation) {
+        if (!isInSimulation.isPresent()) {
+            removeNode(NotInSimulationNode.NODE_NAME);
+        } else {
+            NotInSimulationNode child = getOrCreateNode(NotInSimulationNode.NODE_NAME, NotInSimulationNode.class);
+            child.setZIndex(1000);
+            child.setIsInSimulation(isInSimulation.get());
+        }
+    }
+
 }