]> gerrit.simantics Code Review - simantics/sysdyn.git/blob
576402bf923211664769a4542996acc3ef3e6b66
[simantics/sysdyn.git] /
1 package org.simantics.sysdyn.modelImport.model.element;\r
2 \r
3 import org.simantics.databoard.Bindings;\r
4 import org.simantics.db.Resource;\r
5 import org.simantics.db.WriteGraph;\r
6 import org.simantics.db.exception.DatabaseException;\r
7 import org.simantics.layer0.Layer0;\r
8 import org.simantics.sysdyn.SysdynResource;\r
9 import org.simantics.sysdyn.modelImport.model.WriteContext;\r
10 \r
11 public class Dependency2 extends Connection2 {\r
12         \r
13         private boolean showArrow;\r
14         private boolean showDelay;\r
15         private double angle;\r
16         \r
17         public Dependency2(Element2 head, Element2 tail, boolean showArrow, boolean showDelay, double angle) {\r
18                 super(head, tail);\r
19                 this.showArrow = showArrow;\r
20                 this.showDelay = showDelay;\r
21                 this.angle = angle;\r
22         }\r
23 \r
24         @Override\r
25         public void write(WriteGraph graph, Resource parent, WriteContext context) throws DatabaseException {\r
26                 if (head == null || tail == null) {\r
27                         System.err.println("dependency missing head or tail");\r
28                         return;\r
29                 }\r
30                 \r
31                 Layer0 l0 = Layer0.getInstance(graph);\r
32                 \r
33                 SysdynResource sr = SysdynResource.getInstance(graph);\r
34                 \r
35                 Resource dependency = createConnection(graph, sr.Dependency, parent, context);\r
36                 graph.claimLiteral(dependency, l0.HasName, context.getNextDependency(), Bindings.STRING);\r
37                 Resource symbol = createSymbol(graph, sr.DependencyConnection, dependency, parent, context);\r
38                 \r
39                 graph.claimLiteral(symbol, sr.Dependency_angle, angle, Bindings.DOUBLE);\r
40         }\r
41 \r
42 }\r