]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/NotInSimulationNode.java
Move remaining profiles to visualisations for perf
[simantics/district.git] / org.simantics.district.network.ui / src / org / simantics / district / network / ui / nodes / NotInSimulationNode.java
1 package org.simantics.district.network.ui.nodes;
2
3 import java.awt.BasicStroke;
4 import java.awt.Color;
5 import java.awt.geom.Rectangle2D;
6
7 import org.simantics.scenegraph.ParentNode;
8 import org.simantics.scenegraph.g2d.G2DNode;
9 import org.simantics.scenegraph.utils.GeometryUtils;
10
11 public class NotInSimulationNode extends G2DNode {
12
13     private static final BasicStroke STROKE = new BasicStroke(1.5f);
14     public static final String NODE_NAME = "notInSimulation";
15
16     private static final long serialVersionUID = 1503248449618244809L;
17     private boolean isInSimulation;
18
19     @Override
20     public Rectangle2D getBoundsInLocal() {
21         return null;
22     }
23
24     @Override
25     public Rectangle2D getBoundsInLocal(boolean b) {
26         return null;
27     }
28
29     @Override
30     public Rectangle2D getBounds() {
31         return null;
32     }
33     
34     public void render(java.awt.Graphics2D g) {
35         if (!isInSimulation) {
36             ParentNode<?> parent = getParent();
37             if (!(parent instanceof DistrictNetworkVertexNode))
38                 return;
39             
40             Rectangle2D bounds = ((DistrictNetworkVertexNode)parent).getBoundsInLocal();
41             Rectangle2D expandedBounds = GeometryUtils.expandRectangle( bounds, bounds.getWidth() / 2 );
42             
43             g.setColor(Color.RED);
44             g.setStroke(GeometryUtils.scaleStroke(STROKE, 1.f / (float)g.getTransform().getScaleX()));
45             g.draw(expandedBounds);
46         }
47     }
48
49     public void setIsInSimulation(boolean isInSimulation) {
50         this.isInSimulation = isInSimulation;
51     }
52
53 }