Skip to main content
summaryrefslogtreecommitdiffstats
blob: becc23eefc95e5344908fc3016230141041e7a45 (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
--Author Manel Fredj-CEA LIST
library GeneralMappings;

import Converter.Utils.ConverterLibs;
import NotationQueries;


modeltype di2 uses 'http://www.papyrusuml.org/di2';
modeltype notation uses 'http://www.eclipse.org/gmf/runtime/1.0.2/notation';
modeltype ecore uses 'http://www.eclipse.org/emf/2002/Ecore';
modeltype uml uses 'http://www.eclipse.org/uml2/2.1.0/UML';


-------------------------------------------------------------------------------------------------------------------------
----------------------------------------           Generic  Mappings              ---------------------------------------
-------------------------------------------------------------------------------------------------------------------------
abstract mapping di2::GraphElement::element2View() : notation::View
{
	--assign visibility attribute (it seems that this is not supported by Papyrus MDT
	--  if false, diagram is visible but has no contents
	--visible := self.isVisible;
	visible := true; 	

	element := self.getElement().oclAsType(ecore::EObject);	
}


mapping di2::GraphEdge::edge2Connector() : notation::Connector inherits di2::GraphElement::element2View
{
	lineColor := self.borderColor.rgb2int();
}

mapping di2::GraphNode::node2Shape() : notation::Shape inherits di2::GraphElement::element2View
{
	--assign colors	and bounds
	lineColor := self.borderColor.rgb2int();
	fillColor := self.backgroundColor.rgb2int();
	fontColor := self.fontColor.rgb2int();

	layoutConstraint := object notation::Bounds {
		var size : notation::Size := self.oclAsType(di2::GraphNode).size.map dimension2Size();

		var relativeLocation: notation::Location :=null;
	
		var location : notation::Location := self.position.map point2Location();
		x := location.x;
		y := location.y;
		width := size.width;
		height := size.height;
		if (self.container.oclIsTypeOf(di2::GraphNode)) then {
			// correct position (why necessary??) of nested items
			y := y - 20;
		} endif;
	}
}

-------------------------------------------------------------------------------------------------------------------------
----------------------------------------                    Mappings              ---------------------------------------
-------------------------------------------------------------------------------------------------------------------------

mapping di2::Dimension::dimension2Size() : notation::Size
{
	width := self.dimensionGetWidth();
 	height := self.dimensionGetHeight();
}

-- transformation mapping dimension into location
mapping  di2::Point::point2Location() : notation::Location
{
	x := self.pointGetX();
	y := self.pointGetY();
	
}

-------------------------------------------------------------------------------------------------------------------------
----------------------------------------                   Helpers                ---------------------------------------
-------------------------------------------------------------------------------------------------------------------------


--Set EAnnotation: not specific to a diagram (it is used in class diagram and composite diagram)
-------------------------------- 
helper setEAnnotations() : OrderedSet (ecore::EAnnotation)
{	
	-- first eAnnotation	
	var eAnnot1 := object ecore::EAnnotation {
		--the id is set automatically
		--eAnnot1.eModelElement:=self.resolveone(notation::Node);
		source := "ShadowFigure";
		details := object ecore::EStringToStringMapEntry {
			key   := "ShadowFigure_Value";
			value := "false";
		};
	};

	-- second annotation
	var eAnnot2 := object ecore::EAnnotation {
		--the id is set automatically
		source := "displayNameLabelIcon";
		details := object ecore::EStringToStringMapEntry {
			 key   := "displayNameLabelIcon_value";
			 value := "false";
		};
	};
	
	-- third annotation	
	var eAnnot3 := object ecore::EAnnotation {	
		-- the id is set automatically	
		source := "QualifiedName";
		details := object ecore::EStringToStringMapEntry {
			key   := "QualifiedNameDepth";
			value := "1000";
		};	
	};

	-- add the set of annotations to the node
	return OrderedSet {
		eAnnot1, eAnnot2, eAnnot3
	};
}

--suppresses showing type information for an element (used for associations by default)
helper noTypeEAnnotation() : OrderedSet (ecore::EAnnotation)
{
	var eAnnotationNoType := object ecore::EAnnotation {
		--the id is set automatically
		--eAnnot1.eModelElement:=self.resolveone(notation::Node);
		source := "CustomAppearance_Annotation";
		details := object ecore::EStringToStringMapEntry {
			key   := "CustomAppearance_MaskValue";
			value := "14";
		};
	};
	return OrderedSet {
		eAnnotationNoType
	};
}

Back to the top