]> gerrit.simantics Code Review - simantics/sysdyn.git/blob
72e34cb61bc4c0609aac261c97eb78d724f98a88
[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.ReadGraph;\r
5 import org.simantics.db.Resource;\r
6 import org.simantics.db.WriteGraph;\r
7 import org.simantics.db.exception.DatabaseException;\r
8 import org.simantics.layer0.Layer0;\r
9 import org.simantics.sysdyn.SysdynResource;\r
10 import org.simantics.sysdyn.modelImport.model.WriteContext;\r
11 \r
12 public class Dependency extends Connection {\r
13         \r
14         private boolean showArrow;\r
15         private boolean showDelay;\r
16         private double angle;\r
17         \r
18         public Dependency(Symbol head, Symbol tail, boolean showArrow, boolean showDelay, double angle) {\r
19                 super(head, tail);\r
20                 this.showArrow = showArrow;\r
21                 this.showDelay = showDelay;\r
22                 this.angle = angle;\r
23         }\r
24 \r
25         @Override\r
26         public Resource write(WriteGraph graph, Resource parent, WriteContext context) throws DatabaseException {\r
27                 if (head == null || tail == null) {\r
28                         System.err.println("dependency missing head or tail");\r
29                         return null;\r
30                 }\r
31                 \r
32                 Layer0 l0 = Layer0.getInstance(graph);\r
33                 SysdynResource sr = SysdynResource.getInstance(graph);\r
34                 \r
35                 Resource dependency = super.write(graph, parent, context);\r
36                 graph.claimLiteral(dependency, l0.HasName, context.getNextDependency(), Bindings.STRING);\r
37                 \r
38                 graph.claimLiteral(getDiagramResource(), sr.Dependency_angle, angle, Bindings.DOUBLE);\r
39                 \r
40                 return dependency;\r
41         }\r
42         \r
43         @Override\r
44         public Resource getConnectionType(ReadGraph graph) {\r
45                 return SysdynResource.getInstance(graph).Dependency;\r
46         }\r
47         \r
48         @Override\r
49         public Resource getDiagramConnectionType(ReadGraph graph) {\r
50                 return SysdynResource.getInstance(graph).DependencyConnection;\r
51         }\r
52         \r
53 \r
54 }\r