]> gerrit.simantics Code Review - simantics/district.git/blob
6ae6097c183b5a3e8b4cef542a12794fd3cfc11f
[simantics/district.git] /
1 \r
2 package org.simantics.district.network.ui;\r
3 \r
4 import org.simantics.district.network.ui.nodes.NetworkDrawingNode;\r
5 import org.simantics.g2d.canvas.impl.SGNodeReflection.SGInit;\r
6 import org.simantics.g2d.diagram.IDiagram;\r
7 import org.simantics.g2d.diagram.participant.AbstractDiagramParticipant;\r
8 import org.simantics.scenegraph.g2d.G2DParentNode;\r
9 import org.simantics.utils.datastructures.hints.IHintContext.Key;\r
10 import org.simantics.utils.datastructures.hints.IHintContext.KeyOf;\r
11 \r
12 public class NetworkDrawingParticipant extends AbstractDiagramParticipant {\r
13 \r
14     /**\r
15      * A hint key for terminal pick distance in control pixels.\r
16      * @see #PICK_DIST\r
17      */\r
18     public static final Key KEY_PICK_DISTANCE = new KeyOf(Double.class, "PICK_DISTANCE");\r
19 \r
20     /**\r
21      * Default terminal pick distance in control pixels.\r
22      * @see #DEFAULT_PICK_DISTANCE\r
23      */\r
24     public static final double PICK_DIST = 10;\r
25     \r
26     private NetworkDrawingNode node;\r
27     \r
28     @SGInit\r
29     public void initSG(G2DParentNode parent) {\r
30         node = parent.addNode("networkDrawingNode", NetworkDrawingNode.class);\r
31         node.setNetworkDrawingParticipant(this);\r
32     }\r
33     \r
34     @Override\r
35     protected void onDiagramSet(IDiagram newDiagram, IDiagram oldDiagram) {\r
36         node.setDiagram(newDiagram);\r
37     }\r
38 \r
39 }\r