]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.graphviz/scl/Visualization/Graphviz/Node.scl
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.graphviz / scl / Visualization / Graphviz / Node.scl
1 import "Visualization/Graphviz/AbstractTypes"\r
2 import "Visualization/Graphviz/Property"\r
3 import "JavaBuiltin" as Java\r
4 \r
5 importJava "org.simantics.graphviz.Node" where\r
6     data Node\r
7     @JavaName "<init>"\r
8     newPrimitiveNode :: IGraph -> <Proc> Node\r
9     setLabel :: Node -> String -> <Proc> ()\r
10     setShape :: Node -> String -> <Proc> ()\r
11     @JavaName set\r
12     setGenericProperty :: Node -> String -> String -> <Proc> ()\r
13     \r
14 instance Identifiable Node where\r
15     identifiable = Java.unsafeCoerce\r
16 \r
17 applyNodeProperty :: Node -> Property -> <Proc> ()\r
18 applyNodeProperty graph (Label str) = setLabel graph str\r
19 applyNodeProperty graph (Shape str) = setShape graph str\r
20 applyNodeProperty graph (GenericProperty property str) = setGenericProperty graph property str\r
21     \r
22 newNode :: IGraph a => a -> [Property] -> <Proc> Node\r
23 newNode graph properties = node\r
24   where\r
25     node = newPrimitiveNode (iGraph graph)\r
26     for properties (applyNodeProperty node)