Skip to main content
summaryrefslogtreecommitdiffstats
blob: 1e20a5438df49d29c07050dac68204cff2254c4d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
--Author Manel Fredj-CEA LIST

library HelpersEdge;
import GeneralMappingsandHelpers;
import CompositeDiagVisualIDs;

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::compositeDiagEdge2Edge() : 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().isGeneralization()) then {
	 		type := VisualId_Edge_GeneralizationComp;
	 		--adding children
			children := setChildrenForGeneralization();
		} endif;
		if (self.getElement().oclIsTypeOf(uml::Connector)) then {
			type := VisualId_Edge_Link;
			--adding children
			children:=setChildrenForConnector();
		} endif;
	} 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 setChildrenForGeneralization(): 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_DecoNodeGeneralizationComp;
		layoutConstraint := object notation::Location {
			y := 40;
		};
	};
	
	return OrderedSet {child1};
}



helper setChildrenForConnector(): OrderedSet(notation::Node)
{    
	 --<children xmi:type="notation:DecorationNode"   type="6025">
     -- <layoutConstraint xmi:type="notation:Location"  y="60"/>
     --</children>
 
	var child1 := object notation::DecorationNode {
		--the id is set automatically
		type := VisualId_Edge_Connector_Child;
		layoutConstraint := object notation::Location {
			y := 60;
		};
	};
	
	return OrderedSet {child1};
}


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;
}

Back to the top