Skip to main content
summaryrefslogblamecommitdiffstats
blob: becc23eefc95e5344908fc3016230141041e7a45 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16















                                                                                                                         
                                                                   
 




                                                                                         



                                                                
                                                                                                       
 









                                                                                               














                                                                                                      














                                                                                                                         








                                                                                                                         
 









                                                                                                

                                                      







                                                                  

                                                               







                                                                  

                                                      






                                                 









                                                                                       

                                                              




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