|
Re: How to change Papyrs-rt model color programmatically? [message #1714387 is a reply to message #1714074] |
Thu, 12 November 2015 10:29 |
Camille Letavernier Messages: 952 Registered: February 2011 |
Senior Member |
|
|
Hi,
There are basically two options for modifying the appearance of nodes in Papyrus (Not specific to Papyrus-RT):
1) Change the Notation model directly
2) Use a CSS Stylesheet and apply it to your project, model or diagram
For the first option, you need to:
- Find the Notation View associated to your UML Element. Usually, it is the first view (Shape, or Connector...) with a reference to your element (e.g. <Shape element="model.uml#yourElementID" ... />)
- Use the View#setFillColor(int) method to change the color
The pseudo-code looks like:
State myState = ...;
Shape stateRepresenation = findView(myState);
stateRepresentation.setFillColor(123456); //The color is a 24-bits integer representing the RGB code
Note that you need to start a transaction before being able to modify a Papyrus model; otherwise the change will be rejected. This can be achieved by executing a Command on the model's CommandStack
For the second option, you need to:
- Create a *.css text file which will contain the rules to change the colors
- Generate some rules matching the following pattern inside this *.css file:
State[name="MyState"]{
fillColor: red;
}
State[name="MyOtherState"]{
fillColor: rgb(125, 255, 32);
}
Then apply this stylesheet to your project, model or diagram
Please feel free to ask if you need additional information for these steps
HTH,
Camille
Camille Letavernier
|
|
|
|
Powered by
FUDForum. Page generated in 0.03199 seconds