]> gerrit.simantics Code Review - simantics/district.git/blob
7365060b0254bc8c6f62d5c4cb4aeef8e1dcd6d5
[simantics/district.git] /
1 package org.simantics.district.network.ui.nodes;\r
2 \r
3 import java.awt.Color;\r
4 import java.awt.Graphics2D;\r
5 import java.awt.RenderingHints;\r
6 import java.awt.geom.AffineTransform;\r
7 import java.awt.geom.Rectangle2D;\r
8 \r
9 import org.simantics.district.network.ui.adapters.DistrictNetworkVertex;\r
10 import org.simantics.scenegraph.g2d.G2DNode;\r
11 \r
12 public class DistrictNetworkVertexNode extends G2DNode {\r
13 \r
14     private static final long serialVersionUID = -2641639101400236719L;\r
15     private DistrictNetworkVertex vertex;\r
16 \r
17     @Override\r
18     public void render(Graphics2D g2d) {\r
19         AffineTransform ot = null;\r
20         AffineTransform t = getTransform();\r
21         if (t != null && !t.isIdentity()) {\r
22             ot = g2d.getTransform();\r
23             g2d.transform(getTransform());\r
24         }\r
25         \r
26         Object aaHint = g2d.getRenderingHint(RenderingHints.KEY_ANTIALIASING);\r
27         g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);\r
28         \r
29         Color oldColor = g2d.getColor();\r
30         g2d.setColor(Color.RED);\r
31         // render\r
32         \r
33         Rectangle2D.Double rect = new Rectangle2D.Double(-0.5, -0.5, 1, 1);\r
34         g2d.draw(rect);\r
35         \r
36         // Reset stats\r
37         g2d.setColor(oldColor);\r
38         \r
39         g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, aaHint);\r
40         \r
41         if (ot != null)\r
42             g2d.setTransform(ot);\r
43     }\r
44 \r
45     @Override\r
46     public Rectangle2D getBoundsInLocal() {\r
47         return new Rectangle2D.Double(-0.5, -0.5, 1, 1);\r
48     }\r
49 \r
50     public void setVertex(DistrictNetworkVertex vertex) {\r
51         this.vertex = vertex;\r
52     }\r
53 \r
54 }\r