Change color of UML element [message #1374802] |
Thu, 22 May 2014 16:18  |
Eclipse User |
|
|
|
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 19:43] by Moderator
|
|
|
|
Re: Change color of UML element [message #1401270 is a reply to message #1374802] |
Tue, 15 July 2014 07:22   |
Eclipse User |
|
|
|
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 11:58   |
Eclipse User |
|
|
|
Christian W. Damus wrote on Tue, 15 July 2014 07:22Hi,
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 #1402201 is a reply to message #1402158] |
Wed, 16 July 2014 13:25   |
Eclipse User |
|
|
|
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 #1732611 is a reply to message #1731249] |
Wed, 18 May 2016 02:32  |
Eclipse User |
|
|
|
Sorry for be late...
In my case, the user clicks at one line in a text view, then I check the UML element equivalent to that line, and change the color of the UML element.
I save the previous element, so at the click I change back the previous UML element to its default and change the color of the new UML element.
This works fine to me...
|
|
|
Powered by
FUDForum. Page generated in 0.10524 seconds