Skip to main content



      Home
Home » Eclipse Projects » Sirius » Programmatically change border color
Programmatically change border color [message #1717795] Wed, 16 December 2015 13:51 Go to next message
Eclipse UserFriend
Hi all,

I am trying to change programmatically the border color of an element. The reason why I am doing this is because I need to update the color using an external java action.

I am using a code like this now (see below) and it works pretty well EXCEPT that it changes the color for ALL the elements with the same style. I am wondering how I can change the color ONLY for the selected element. Any hint/help for doing it?

Thanks!



Node node = (Node) dnode.getTarget();
System.out.println ("[ImpactAction] node=" + node);

Style style = dnode.getStyle();
SquareDescription sd = (SquareDescription)style.getDescription();

ColorDescription cd = sd.getBorderColor();
SystemColor sc = (SystemColor) cd;
LineStyle ls = sd.getBorderLineStyle();

sc.setBlue(0);
sc.setGreen(255);
sc.setRed(0);
sd.setBorderColor(sc);
sd.setWidth(10);
sd.setBorderSizeComputationExpression("2");

Re: Programmatically change border color [message #1718622 is a reply to message #1717795] Mon, 28 December 2015 06:08 Go to previous message
Eclipse UserFriend
Hi Julien,

ColorDescription is a EClass from odesign metamodel, which is used only
when defining your modeler, your need is about customize the border
color from diagram editor. By hand this can be done through properties
view or tabbar and after customization the "Reset style properties to
default values" action is enabled because the style is noted customized
in aird resource using Customizable.customFeatures attribute.
Then to do the same programmatically :

1. you get the BorderedStyle of your node as in the beginning of your code
2. Set the wished color
3. Add the customized feature in BorderedStyle.customFeatures list by
calling
borderStyle.getCustomFeatures().add(DiagramPackage.Literals.BORDERED_STYLE__BORDER_COLOR.getName());

Best Regards.

Le 16/12/2015 19:51, Julien Delange a écrit :
> Hi all,
>
> I am trying to change programmatically the border color of an element.
> The reason why I am doing this is because I need to update the color
> using an external java action.
>
> I am using a code like this now (see below) and it works pretty well
> EXCEPT that it changes the color for ALL the elements with the same
> style. I am wondering how I can change the color ONLY for the selected
> element. Any hint/help for doing it?
>
> Thanks!
>
>
>
> Node node = (Node) dnode.getTarget();
> System.out.println ("[ImpactAction] node=" + node);
>
> Style style = dnode.getStyle();
> SquareDescription sd =
> (SquareDescription)style.getDescription();
>
> ColorDescription cd = sd.getBorderColor();
> SystemColor sc = (SystemColor) cd;
> LineStyle ls = sd.getBorderLineStyle();
>
> sc.setBlue(0);
> sc.setGreen(255);
> sc.setRed(0);
> sd.setBorderColor(sc);
> sd.setWidth(10);
> sd.setBorderSizeComputationExpression("2");
>
>



--
Esteban Dugueperoux - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Previous Topic:Label Expression with String
Next Topic:Expand a newly created Tree element from the create tool
Goto Forum:
  


Current Time: Sat Nov 08 16:58:46 EST 2025

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

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

Back to the top