# Defines how elements in the sequence diagram are drawn.

#----------View Maps------------------------------------------------------------
#
#  Object On Sequence diagram
#
#\   setGraphicObject( "RectangleInvisible" );
#\   setGraphicObject( "$GraphRectangleTransparent" );
view.map.*.Object.( isOnTopLevelDiagram() && isTopLevel() && %diagram%->hasPropertyValue( "$shapeType", "SequenceDiagram" ) && !%diagram%->hasProperty( "$viewType" ) ) =
\
\   setGraphicObject( "$GraphRectangleTransparent" );
\   setGraphicProperty( "$shapeType", "Object" );
\   setGraphicProperty( "__UID", getProperty( "$uniqueName" ) );
\   setGraphicProperty( "$createdObject", getProperty( "$createdObject" ) );
\   setGraphicProperty( "$destroyedObject", getProperty( "$destroyedObject" ) );
\   if( hasPropertyValue( "stereotype", "actor" ) || hasProperty( "concurrent" ),
\       setGraphicProperty( "alwaysActive", "true" )
\     );
\   setCanHaveLinks();
\   setCanContainChilds();
\   setLayoutConstraints( minWidth(30), minHeight(40), preferredWidth(90) );
\   classNameString = if( hasProperty( "$instantiatedClass" ),
\                         getProperty( findElement( getProperty( "$instantiatedClass" ) ), "$name" ),
\                         "" );
\   if( hasOption( "option.sequenceDiagram.showClassBelowObject" ) && !hasPropertyValue( "stereotype", "actor" ),
\       objectLabelString = getProperty( "$name" ),
\       objectLabelString = getProperty( "$name" ) +
\           if( classNameString != "",
\               ":" + classNameString,
\               "" )
\     );
\
\   if( hasPropertyValue( "stereotype", "actor" ),
\       shape = addCompartment( "ActorBold", "Shape" );
\       shape->setLayoutConstraints( preferredWidth(60), preferredHeight(52), fixedHeight(true) );
\       if (!hasViewProperty("2DLook"), shape->setShadow(2, RGB(0,0,128)));
\       names = addCompartment( "RectangleInvisible", "Names" );
\       names->setLayoutConstraints( preferredHeight(16), fixedHeight(true) )
\     ,
\       compartments = addCompartment( "RectangleObject", "Compartments" );
\       compartments->setLayoutConstraints( minHeight(40), preferredWidth(60), fixedHeight(true) );
\       if (!hasViewProperty("2DLook"), compartments->setShadow(3, RGB(0,0,128)));
\       names = compartments->addCompartment( "RectangleInvisible", "Names" );
\
\       if( hasOption( "option.sequenceDiagram.showClassBelowObject" ),
\           names->setLayoutConstraints( minHeight(55), fixedHeight(true) ),
\           names->setLayoutConstraints( minHeight(40), fixedHeight(true) )
\         );
\       markersCompartment = compartments->addCompartment( "RectangleInvisible", "MarkersCompartment" );
\       markersCompartment->setLayoutConstraints( minHeight(10), fixedHeight(true));
\       if( hasProperty("stereotype"),
\           stereoLabel = addToCompartment(label("<<"+getProperty("stereotype")+">>"), "Names");
\           stereoLabel->setInplaceEditor({property:="stereotype"});
\           stereoLabel->setFont(%defaultFontName%, "Plain", 12);
\           stereoLabel->setAlignment("Center");
\           stereoLabel->setLayoutConstraints(preferredHeight(16),fixedHeight(true))
\         );
\
\       if( hasViewProperty("$imported"),
\           markers = markersCompartment->addCompartment( "RectangleInvisible", "Markers" );
\           markers->setLayoutConstraints( widthAlign("parentDefined"), heightAlign("parentDefined"), toDecreaseWidth(true) );
\           markers->setLayout( "Move" );
\           importedMark=markers->addCompartment( "ShortcutMark", "shortcutMark" );
\           importedMark->setLayoutConstraints( minWidth(12), minHeight(10), horizontalAlign("left") )
\         )
\     );
\
\   nameLabel = addToCompartment( label( objectLabelString ), "Names" );
\   nameLabel->setAlignment( "Center" );
\   nameLabel->setWholeWordsOnly();
\   nameLabel->setUnderlined();
\   nameLabel->setFont( %defaultFontName%, "Bold", 12 );
\   nameLabel->setLayoutConstraints(preferredHeight(16),fixedHeight(true));
\   nameLabel->setInplaceEditor( {property:="$objectInplaceEditing", default:=true } );
\
\   if( hasOption( "option.sequenceDiagram.showClassBelowObject" ) && !hasPropertyValue( "stereotype", "actor" ),
\       classNameLabel = addToCompartment( label( classNameString ), "Names" );
\       classNameLabel->setAlignment("Center");
\       classNameLabel->setWholeWordsOnly();
\       classNameLabel->setFont(%defaultFontName%, "Plain", 12);
\       classNameLabel->setLayoutConstraints(preferredHeight(16),fixedHeight(true));
\       classNameLabel->setInplaceEditor( {property:="$instantiates" } )
\     );
\
\   if( hasProperty("$hyperLink" ) || hasProperty( "url" ), nameLabel->setForeground( RGB(0,0,255) ) );
\   lifeline = addCompartment( "$GraphSequenceObjectLifeLine", "Lifeline" );
\   lifeline->setGraphicProperty( "$toFocus", "true" );
\   lifeline->setCanHaveLinks();
\   lifeline->setLayoutConstraints( minHeight(20) );
\   lifeline->setLayout( "null" )



#-------- Activation -------------------------------------------------------
;TO DO isTopLevel for a parent class.
view.map.*.Activation.true =
\   setGraphicObject( "RectangleInvisible" );
\   setCanHaveLinks();
\   if( !%diagram%->hasPropertyValue( "$shapeType", "SequenceDiagram" ) ||
\        %diagram%->hasPropertyValue( "$viewType", "collaborationView" ),
\       setSelectable( false );
\       setReshapable( false );
\       setVisible( false );
\       setLayoutConstraints( horizontalAlign("left"), verticalAlign("top"),
\                             widthAlign("parentDefined"), heightAlign("parentDefined") )
\       ,
\       setCompartment( "Lifeline" );
\       setLayoutConstraints( minWidth(14), minHeight(5),
\                             preferredWidth(14), preferredHeight(50),
\                             canShiftX(true), canShiftY(true) )
\     );
\   setGraphicProperty( "$shapeType", "Activation" );
\   setGraphicProperty( "activationMessage", getProperty( "activationMessage" ) )



#-------- MessageLink -------------------------------------------------------
view.map.*.MessageLink.true =
\   if( %diagram%->hasPropertyValue( "$shapeType", "SequenceDiagram" ) &&
\       !%diagram%->hasPropertyValue( "$viewType", "collaborationView" ),
\       setGraphicObject("$GraphSequenceInteraction") );
\
\   if( %diagram%->hasPropertyValue( "$shapeType", "SequenceDiagram" ) &&
\       !%diagram%->hasPropertyValue( "$viewType", "collaborationView" ),
\       if( hasPropertyValue( "controlFlowType", "call" ) || !hasProperty( "controlFlowType" ), arrowType = "ArrowCall" );
\       if( hasPropertyValue( "controlFlowType", "asynchronous" ), arrowType = "ArrowAsync" );
\       if( hasPropertyValue( "controlFlowType", "synchronous" ), arrowType = "ArrowSync" );
\       if( hasPropertyValue( "controlFlowType", "wait" ), arrowType = "ArrowWait" );
\       if( hasPropertyValue( "controlFlowType", "nowait" ), arrowType = "ArrowNowait" );
\       addIcon( arrowType, "OnDestination" )
\     );
\
\   operationNameText = "" +
\         if( hasProperty( "operation" ) && findElement( getProperty( "operation" ) ) != null,
\             operation = findElement( getProperty( "operation" ) );
\             if( operation->hasProperty( "$constructor" ), "<constructor>",
\                 if( operation->hasProperty( "$destructor" ), "<destructor>",
\                     operation->getProperty( "$name" )
\                   )
\               )
\           ,
\             if( hasProperty( "$messageOperationName" ),
\                 getProperty( "$messageOperationName" ),
\                 if( hasProperty( "return" ) || hasProperty( "arguments" ),
\                     "<undefined>", "" )
\               )
\           );
\
\   operationReturnTypeText =
\         if( !hasOptionValue( "option.detail", "Analysis" ),
\             operation = findElement( getProperty( "operation" ) );
\             if( operation == null ||
\                 operation->hasProperty( "$constructor" ) ||
\                 operation->hasProperty( "$destructor" ),
\                 "",
\                 ":" + operation->getProperty( "$returnType" )
\               )
\           ,
\             ""
\           );
\
\   operationClauseText = operationNameText +
\       if( hasProperty( "arguments" ),
\           "(" + getProperty( "arguments" ) + ")",
\           "" ) +
\  operationReturnTypeText;
\
\  operationClauseText =
\       if( hasOptionValue( "option.detail", "Analysis" ) || hasProperty( "arguments" ),
\           operationClauseText
\         ,
\           if( hasProperty( "$messageOperationName" ),
\               getProperty( "$messageOperationName" )
\             ,
\               if( hasProperty( "return" ) || hasProperty( "arguments" ),
\                   "<undefined>()", "" )
\           )
\         );
\
\   messageLabelString = "" +
\         if( hasOption( "option.sequenceDiagram.showMessageNumbers" ) ||
\             !%diagram%->hasPropertyValue( "$shapeType", "SequenceDiagram" ) ||
\             %diagram%->hasPropertyValue( "$viewType", "collaborationView" ),
\             getProperty( "sequenceNumber" ) + ":", "" ) +
\         if( hasProperty( "iteration" ), "*[" + getProperty( "iteration" ) + "]", "" ) +
\         if( hasProperty( "condition" ), "[" + getProperty( "condition" ) + "]", "" ) +
\         if( operationClauseText != "", " ", "" ) +
\         if( hasProperty( "return" ), getProperty( "return" ) + ":=", "" ) +
\         operationClauseText +
\         if( hasProperty( "label" ), " " + getProperty( "label" ), "" );
\
\   if( %diagram%->hasPropertyValue( "$shapeType", "SequenceDiagram" ) &&
\       !%diagram%->hasPropertyValue( "$viewType", "collaborationView" ),
\       if( getSource() != getDestination(),
\           messageLabel = addLabelIcon( messageLabelString, "AboveLeftSource" );
\           if( hasProperty( "sendTime" ), sendTimeIcon = addLabelIcon( getProperty( "sendTime" ), "UnderRightSource" ) );
\           if( hasProperty( "constraint" ), constraintIcon = addLabelIcon( "{" + getProperty( "constraint" ) + "}", "UnderRightCenter" ) );
\           if( hasProperty( "receiveTime" ), receiveTimeIcon = addLabelIcon( getProperty( "receiveTime" ), "UnderRightDestination" ) )
\           ,
\           if( hasProperty( "sendTime" ), sendTimeIcon = addLabelIcon( getProperty( "sendTime" ), "AboveLeftSource" ) );
\           if( hasProperty( "constraint" ), constraintIcon = addLabelIcon( "{" + getProperty( "constraint" ) + "}", "UnderRightDestination" ) );
\           if( hasProperty( "receiveTime" ), receiveTimeIcon = addLabelIcon( getProperty( "receiveTime" ), "UnderRightDestination" ) );
\           messageLabel = addLabelIcon( messageLabelString, "UnderRightDestination" )
\         );
\       sendTimeIcon->setInplaceEditor( { property:="sendTime" } );
\       constraintIcon->setInplaceEditor( { property:="constraint" } );
\       receiveTimeIcon->setInplaceEditor( { property:="receiveTime" } );
\       sendTimeIcon->setReshapable( false );
\       constraintIcon->setReshapable( false );
\       receiveTimeIcon->setReshapable( false )
\     ,
\       if( hasPropertyValue( "controlFlowType", "call" ) || !hasProperty( "controlFlowType" ), arrowType = "ArrowCompactCall" );
\       if( hasPropertyValue( "controlFlowType", "asynchronous" ), arrowType = "ArrowCompactAsync" );
\       if( hasPropertyValue( "controlFlowType", "synchronous" ), arrowType = "ArrowCompactSync" );
\       if( hasPropertyValue( "controlFlowType", "wait" ), arrowType = "ArrowCompactWait" );
\       if( hasPropertyValue( "controlFlowType", "nowait" ), arrowType = "ArrowCompactNowait" );
\       messageLabel = addArrowedLabelIcon( messageLabelString, "AsideCenter", arrowType )
\     );
\
\   if( %diagram%->hasPropertyValue( "$shapeType", "SequenceDiagram" ),
\       setGraphicProperty( "$viewType", %diagram%->getProperty( "$viewType" ) )
\     );
\
\   messageLabel->setReshapable( false );
\   messageLabel->setGraphicProperty( "messageLabel", messageLabelString );
\   messageLabel->setInplaceEditor( { property:="$messageInplaceEditing", default:=true } );
\   if( hasProperty( "$generatedCallImplementation" ),
\       messageLabel->setFont( %defaultFontName%, "Bold", 12 ) );
\   setGraphicProperty( "$shapeType", "MessageLink" );
\   setGraphicProperty( "__UID", getProperty( "$uniqueName" ) );
\   setGraphicProperty( "sequenceNumber", getProperty( "sequenceNumber" ) );
\   setGraphicProperty( "sendingInstant", getProperty( "sendingInstant" ) );
\   setGraphicProperty( "processingDuration", getProperty( "processingDuration" ) );
\   setGraphicProperty( "transmissionDuration", getProperty( "transmissionDuration" ) );
\   setGraphicProperty( "creationMessage", getProperty( "creationMessage" ) );
\   setGraphicProperty( "destructionMessage", getProperty( "destructionMessage" ) );
\   setGraphicProperty( "controlFlowType", getProperty( "controlFlowType" ) );
\   setGraphicProperty( "alternativeMessage", getProperty( "alternativeMessage" ) );
\   setGraphicProperty( "showReturnArrow", getProperty( "showReturnArrow" ) );
\   setForeground( RGB(50,50,0) );
\   setBackground( gray )


#-------- CollaborationLink -------------------------------------------------------
view.map.*.CollaborationLink.true =
\   setGraphicProperty( "$shapeType", "CollaborationLink" )


#-------- StatementBlock -------------------------------------------------------
view.map.*.StatementBlock.true =
\   setGraphicObject( "RectangleInvisible" );
\   setCanHaveLinks();
\   if( !%diagram%->hasPropertyValue( "$shapeType", "SequenceDiagram" ) ||
\        %diagram%->hasPropertyValue( "$viewType", "collaborationView" ),
\       setSelectable( false );
\       setReshapable( false );
\       setVisible( false );
\       setLayoutConstraints( horizontalAlign("left"), verticalAlign("top"),
\                             widthAlign("parentDefined"), heightAlign("parentDefined") )
\       ,
\       setCompartment( "Lifeline" );
\       setLayoutConstraints( minWidth(14), minHeight(5),
\                             preferredWidth(14), preferredHeight(50),
\                             canShiftX(true), canShiftY(true) );
\
\       setLayout( "null" );
\
\       labelString = getProperty( "statementType" );
\       if( !hasPropertyValue( "statementType", "else" ),
\           labelString = labelString + "(" + getProperty( "statementExpression" ) + ")"
\         );
\       icon = addLabelIcon( labelString, null );
\       if( !hasPropertyValue( "statementType", "else" ),
\           icon->setInplaceEditor( { property:="statementExpression", default:=true } )
\         );
\       icon->setGraphicProperty( "statementBlockLabel", labelString );
\       icon->setLayoutConstraints( preferredHeight(16), fixedHeight(true) );
\       icon->setForeground( RGB( 50, 50, 0 ) );
\       icon->setReshapable( false )
\
\     );
\   setGraphicProperty( "$shapeType", "StatementBlock" );
\   setGraphicProperty( "__UID", getProperty( "$uniqueName" ) );
\   setGraphicProperty( "container", getContainingNode()->getProperty( "$uniqueName" ) );
\   setGraphicProperty( "sequenceNumber", getProperty( "sequenceNumber" ) );
\   setGraphicProperty( "initialInstant", getProperty( "initialInstant" ) );
\   setGraphicProperty( "processingDuration", getProperty( "processingDuration" ) );
\   setGraphicProperty( "alternativeIfBlock", getProperty( "alternativeIfBlock" ) )


