Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'deprecated/org.eclipse.papyrus.conversion.di2todi/TransfoQvtoDi2toDi/StateDiagEdges.qvto')
-rw-r--r--deprecated/org.eclipse.papyrus.conversion.di2todi/TransfoQvtoDi2toDi/StateDiagEdges.qvto160
1 files changed, 160 insertions, 0 deletions
diff --git a/deprecated/org.eclipse.papyrus.conversion.di2todi/TransfoQvtoDi2toDi/StateDiagEdges.qvto b/deprecated/org.eclipse.papyrus.conversion.di2todi/TransfoQvtoDi2toDi/StateDiagEdges.qvto
new file mode 100644
index 00000000000..bfbe84eb39b
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.conversion.di2todi/TransfoQvtoDi2toDi/StateDiagEdges.qvto
@@ -0,0 +1,160 @@
+--Author Manel Fredj-CEA LIST
+
+library HelpersEdge;
+import GeneralMappingsandHelpers;
+import StateDiagVisualIDs;
+
+modeltype di2 uses 'http://www.papyrusuml.org/di2';
+modeltype notation uses 'http://www.eclipse.org/gmf/runtime/1.0.2/notation';
+modeltype uml uses 'http://www.eclipse.org/uml2/2.1.0/UML';
+
+mapping di2::GraphEdge::stateDiagEdge2Edge() : notation::Connector inherits di2::GraphEdge::edge2Connector
+{
+ -----------------------------------------------------------------------
+ --under an Edge "association"
+ -----------------------------------------------------------------------
+ --In the case that we have an association we will have:
+ --1 edge with a xmi:type:="notation:Connector", a geneerated Id, type= "4001", a target and a source that includes:
+ -- 6 "children" typed with decoration nodes
+ -- 1 "styles
+ -- 1 element
+ -- 1 bendpoints
+ --1 sourceAnchor
+ --1targetAnchor
+ -----------------------------------------------------------------------
+
+ --setting the type and children
+ if (self.getElement() != null) then {
+
+ if (self.getElement().oclIsTypeOf(uml::Transition)) then {
+ type := VisualId_Edge_Transition;
+ --adding children
+ children := setChildrenForTransition();
+ } endif;
+ }
+ else {
+ --type := VisualId_Edge_Link;
+ --adding children
+ } endif;
+
+ --setting the source and target Anchors
+ var anchors : OrderedSet (di2::GraphConnector) := self.anchor;
+ anchors->forEach (gc) {
+ --log("the anchor is "+ gc.graphElement.repr());
+ gc.graphElement;
+ };
+ source := anchors->first().graphElement.oclAsType(di2::GraphNode).late resolveone(notation::Shape);
+ target := anchors->last().graphElement.oclAsType(di2::GraphNode).late resolveone(notation::Shape);
+ --adding style
+ styles := setStyleForEdge();
+
+ --adding element: already done in View
+
+ --adding the bend points
+ bendpoints := setBendpointsForEdge();
+
+ --adding the source and target Anchor
+ sourceAnchor := setSourceAnchor();
+ targetAnchor := setTargetAnchor();
+}
+
+
+--Helpers related to an Edge
+--------------------------------
+
+
+--generic helper for an edge with two children
+--takes as input the visual ids of the the two children
+
+helper setChildrenForEdge2Children(in VisualId1: String, in VisualId2: String): OrderedSet(notation::Node)
+{
+ var child1 := object notation::DecorationNode {
+ --the id is set automatically
+ type := VisualId1;
+ layoutConstraint := object notation::Location {
+ y := 40;
+ };
+ };
+
+ --second child
+ var child2 :=object notation::DecorationNode {
+ --the id is set automatically
+ type := VisualId2;
+ layoutConstraint := object notation::Location {
+ y := 60;
+ };
+ };
+
+ return OrderedSet {child1,child2};
+}
+
+
+helper setChildrenForTransition(): OrderedSet(notation::Node)
+{
+ --<children xmi:type="notation:DecorationNode" type="6007">
+ -- <layoutConstraint xmi:type="notation:Location" y="40"/>
+ --</children>
+
+ var child1 := object notation::DecorationNode {
+ --the id is set automatically
+ --type := VisualId_DecoNodeGeneralization;
+ type := VisualId_Edge_Transition_DecoNode1;
+ layoutConstraint := object notation::Location {
+ y := 10;
+ };
+ };
+ var child2 := object notation::DecorationNode {
+ --the id is set automatically
+ --type := VisualId_DecoNodeGeneralization;
+ type := VisualId_Edge_Transition_DecoNode2;
+ layoutConstraint := object notation::Location {
+ y := 20;
+ };
+ };
+ var child3 := object notation::DecorationNode {
+ --the id is set automatically
+ --type := VisualId_DecoNodeGeneralization;
+ type := VisualId_Edge_Transition_DecoNode3;
+ layoutConstraint := object notation::Location {
+ y := 20;
+ };
+ };
+
+ return OrderedSet {
+ child1, child2, child3
+ };
+}
+
+
+helper setStyleForEdge() : OrderedSet(notation::Style)
+{
+ --<styles xmi:type="notation:FontStyle" fontName="Sans Serif"/>
+ var style := object notation::FontStyle {
+ --the id is set automatically
+ --fontName="Sans Serif";
+ };
+
+ return OrderedSet{style};
+}
+
+helper setSourceAnchor() : notation::Anchor
+{
+ return object notation::IdentityAnchor { };
+}
+
+
+helper setTargetAnchor():notation::Anchor
+{
+ return object notation::IdentityAnchor { };
+}
+
+
+helper setBendpointsForEdge():notation::RelativeBendpoints
+{
+ --<bendpoints xmi:type="notation:RelativeBendpoints" points="[-7, -2, 323, 58]$[-282, -65, 48, -5]"/>
+ // var pts : notation::RelativeBendpointList;
+ // var bendpoints:=object notation::RelativeBendpoints { };
+ var bendpoints := createBendpoints().oclAsType (notation::RelativeBendpoints);
+
+ return bendpoints;
+} \ No newline at end of file

Back to the top