Change component color through Java according to component characteristics

Hi all,

I come back to my need to change automatically the color of components in diagrams according to some criteria associated to these components, instead of manually changing this color.
I initially thought using the diagramstyler (see Diagram styler not working - Capella - Eclipse Capella Forum (mbse-capella.org).

Following last advices in this thread, I tried to have a small Java code that do so but did not succeed.
My understanding is that component color is defined in diagram but I don’t understand what/where would be the API.

Help please !

Hi,

I think this can be easily done using Capella viewpoint / Sirius.
Just copy paste the plugin Filtering org.polarsys.capella.filtering.sirius.analysis

Remove all non compiling stuff about Filtering in Manifest and Java
Then in the odesign file, you can add a Style customization based on the nature of the component,

then change the color of the intended color.

The trick to set the color is that you have to create a ContainerMapping with a GradientStyle first, choose the color in the values, then click on “Apply to all” to make it available on any other elements (like components in PAB,PBD,etc)

image

and voila! (i choose gray for node)

image

Then a bit of rebranding, replacing Filtering/org.polarsys with something else.

Regards,
Philippe

It seems quite good, I will try.
Thanks Philippe