Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Change color of UML element
Change color of UML element [message #1374802] Thu, 22 May 2014 20:18 Go to next message
Vinicius Pereira is currently offline Vinicius PereiraFriend
Messages: 29
Registered: March 2014
Junior Member
Hi everyone,

I can find and access a UML element in Model Explorer and Editor, using ID (from "XML schema") to find it.

ModelSet papyrusModelSet = registry.getService(ModelSet.class);
UmlModel umlModel = (UmlModel)papyrusModelSet.getModel(UmlModel.MODEL_ID);
EObject modelRoot = umlModel.lookupRoot();
			
Resource umlResource = modelRoot.eResource(); 
			
EObject umlElement = umlResource.getEObject(elementID.trim());


This UML element can be a State, a Transition, a Parameter, a Message...

In the case of State, the umlElement is a EObject/StateImpl. I know that I need to change the color in Shape#setFillColor(), but how I go from EObject/StateImpl to Shape/ShapeImpl?

I'm using Papyrus 1.0 in Eclipse Luna.

thank you

[Updated on: Mon, 14 July 2014 23:43]

Report message to a moderator

Re: Change color of UML element [message #1400943 is a reply to message #1374802] Mon, 14 July 2014 23:43 Go to previous messageGo to next message
Vinicius Pereira is currently offline Vinicius PereiraFriend
Messages: 29
Registered: March 2014
Junior Member
Anyone?
Re: Change color of UML element [message #1401270 is a reply to message #1374802] Tue, 15 July 2014 11:22 Go to previous messageGo to next message
Christian W. Damus is currently offline Christian W. DamusFriend
Messages: 933
Registered: July 2009
Senior Member
Hi,

To get the View that visualizes your model element in a particular
diagram (this view may be a Shape or Edge of some kind), you can use
the org.eclipse.papyrus.uml.diagram.common.util.CrossReferenceUtil API.

Once you have the view, you can set colours and other visual attributes
in the notation model styles, yes, but you can also use CSS to specify
the same visual attributes. With a CSS stylesheet you can apply these
attributes more broadly for a diagram or all of the diagrams in a
project, using selectors to apply them automatically to views of
elements matching some criteria. See the on-line help for details.

HTH,

Christian

On 2014-05-22 20:18:35 +0000, Vinicius Pereira said:

> Hi everyone,
>
> I can find and access a UML element in Model Explorer and Editor, using
> ID (from "XML schema") to find it.
>
>
> ModelSet papyrusModelSet = registry.getService(ModelSet.class);
> UmlModel umlModel = (UmlModel)papyrusModelSet.getModel(UmlModel.MODEL_ID);
> EObject modelRoot = umlModel.lookupRoot();
>
> Resource umlResource = modelRoot.eResource();
> EObject umlElement = umlResource.getEObject(elementID.trim());
>
>
> This UML element can be a State, a Transition, a Parameter, a Message...
>
> In the case of State, the umlElement is a EObject/StateImpl. I know
> that I need to change the color in Shape#setFillColor(), but how I go
> from EObject/StateImpl to Shape/ShapeImpl?
>
>
> Another thing: for State I need Shape, for Transition I need Connector
> and Message I need Edge... but why I cannot change edge's color?
>
> I'm using Papyrus 1.0 in Eclipse Luna M7.
>
> thank you
Re: Change color of UML element [message #1402158 is a reply to message #1401270] Wed, 16 July 2014 15:58 Go to previous messageGo to next message
Vinicius Pereira is currently offline Vinicius PereiraFriend
Messages: 29
Registered: March 2014
Junior Member
Christian W. Damus wrote on Tue, 15 July 2014 07:22
Hi,

To get the View that visualizes your model element in a particular
diagram (this view may be a Shape or Edge of some kind), you can use
the org.eclipse.papyrus.uml.diagram.common.util.CrossReferenceUtil API.


Thanks for the tip! I will try.

Christian W. Damus wrote on Tue, 15 July 2014 07:22

Once you have the view, you can set colours and other visual attributes
in the notation model styles, yes, but you can also use CSS to specify
the same visual attributes. With a CSS stylesheet you can apply these
attributes more broadly for a diagram or all of the diagrams in a
project, using selectors to apply them automatically to views of
elements matching some criteria. See the on-line help for details.


For the CSS I saw that I cannot apply styles for each element. For example, State A with Blue and State B with Green.

But if I manage to get to Shape and use setFillColor() I will be happy Smile

Thanks
Re: Change color of UML element [message #1402201 is a reply to message #1402158] Wed, 16 July 2014 17:25 Go to previous messageGo to next message
Christian W. Damus is currently offline Christian W. DamusFriend
Messages: 933
Registered: July 2009
Senior Member
Hi,

I suppose it depends on what the colours and other styling
characteristics are intended to signify. If they are meant to indicate
some kind of abstract properties of your model elements, then likely
you can devise selector criteria in your CSS rules based on the
attributes of those elements (including stereotypes applied to them):
the selector language pretty much has full access to the UML metamodel
(and applied profiles).

If it's just a matter of colour-coding specific elements using
arbitrary, then yes, the basic GMF notation styles should be sufficient.

Cheers,

Christian

On 2014-07-16 15:58:21 +0000, Vinicius Pereira said:

> Christian W. Damus wrote on Tue, 15 July 2014 07:22
>> Hi,
>>
>> To get the View that visualizes your model element in a particular
>> diagram (this view may be a Shape or Edge of some kind), you can use
>> the org.eclipse.papyrus.uml.diagram.common.util.CrossReferenceUtil API.
>
>
> Thanks for the tip! I will try.
>
> Christian W. Damus wrote on Tue, 15 July 2014 07:22
>> Once you have the view, you can set colours and other visual attributes
>> in the notation model styles, yes, but you can also use CSS to specify
>> the same visual attributes. With a CSS stylesheet you can apply these
>> attributes more broadly for a diagram or all of the diagrams in a
>> project, using selectors to apply them automatically to views of
>> elements matching some criteria. See the on-line help for details.
>
>
> For the CSS I saw that I cannot apply styles for each element. For
> example, State A with Blue and State B with Green.
>
> But if I manage to get to Shape and use setFillColor() I will be happy :)
>
> Thanks
Re: Change color of UML element [message #1403222 is a reply to message #1402201] Tue, 22 July 2014 12:56 Go to previous messageGo to next message
Vinicius Pereira is currently offline Vinicius PereiraFriend
Messages: 29
Registered: March 2014
Junior Member
Christian W. Damus wrote on Wed, 16 July 2014 13:25
Hi,

I suppose it depends on what the colours and other styling
characteristics are intended to signify. If they are meant to indicate
some kind of abstract properties of your model elements, then likely
you can devise selector criteria in your CSS rules based on the
attributes of those elements (including stereotypes applied to them):
the selector language pretty much has full access to the UML metamodel
(and applied profiles).

If it's just a matter of colour-coding specific elements using
arbitrary, then yes, the basic GMF notation styles should be sufficient.

Cheers,

Christian


I would like to use colors to show something like "right now (in this moment) I'm in State A... now (next moment) I'm in State B". Just to be better visualize by the user.
Re: Change color of UML element [message #1403298 is a reply to message #1403222] Tue, 22 July 2014 17:39 Go to previous message
Vinicius Pereira is currently offline Vinicius PereiraFriend
Messages: 29
Registered: March 2014
Junior Member
And thanks Christian!! I changed colors in Shape format Very Happy
Previous Topic:Requirements management in PAPYRUS
Next Topic:Alf verifier or validator
Goto Forum:
  


Current Time: Wed May 06 17:32:18 GMT 2015

Powered by FUDForum. Page generated in 0.02399 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software