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%2FDistrictNetworkEdgeNode.java;h=0e5f30222a6f72682640dd0e70b0ae769ff727de;hb=e18075e5fda3ef81c260e4dd9f1211f468344a3c;hp=195472fcd2474b0b060de1df3b032c350c672c5e;hpb=47a6ef4077aacf0ac5753ee568183bbed5d27411;p=simantics%2Fdistrict.git diff --git a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkEdgeNode.java b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkEdgeNode.java index 195472fc..0e5f3022 100644 --- a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkEdgeNode.java +++ b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkEdgeNode.java @@ -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 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 isInSimulation) { + if (!isInSimulation.isPresent()) { + removeNode(NotInSimulationNode.NODE_NAME); + } else { + NotInSimulationNode child = getOrCreateNode(NotInSimulationNode.NODE_NAME, NotInSimulationNode.class); + child.setZIndex(1000); + child.setIsInSimulation(isInSimulation.get()); + } + } + }