]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - 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
diff --git a/bundles/org.simantics.graphviz/scl/Visualization/Graphviz/Node.scl b/bundles/org.simantics.graphviz/scl/Visualization/Graphviz/Node.scl
new file mode 100644 (file)
index 0000000..0cbe57b
--- /dev/null
@@ -0,0 +1,26 @@
+import "Visualization/Graphviz/AbstractTypes"\r
+import "Visualization/Graphviz/Property"\r
+import "JavaBuiltin" as Java\r
+\r
+importJava "org.simantics.graphviz.Node" where\r
+    data Node\r
+    @JavaName "<init>"\r
+    newPrimitiveNode :: IGraph -> <Proc> Node\r
+    setLabel :: Node -> String -> <Proc> ()\r
+    setShape :: Node -> String -> <Proc> ()\r
+    @JavaName set\r
+    setGenericProperty :: Node -> String -> String -> <Proc> ()\r
+    \r
+instance Identifiable Node where\r
+    identifiable = Java.unsafeCoerce\r
+\r
+applyNodeProperty :: Node -> Property -> <Proc> ()\r
+applyNodeProperty graph (Label str) = setLabel graph str\r
+applyNodeProperty graph (Shape str) = setShape graph str\r
+applyNodeProperty graph (GenericProperty property str) = setGenericProperty graph property str\r
+    \r
+newNode :: IGraph a => a -> [Property] -> <Proc> Node\r
+newNode graph properties = node\r
+  where\r
+    node = newPrimitiveNode (iGraph graph)\r
+    for properties (applyNodeProperty node)
\ No newline at end of file