Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Changing the colour of existing shapes (gradient start/stop?)
Changing the colour of existing shapes (gradient start/stop?) [message #1738685] Fri, 22 July 2016 08:53 Go to next message
Rob Stewart is currently offline Rob StewartFriend
Messages: 2
Registered: July 2016
Junior Member

I'm looking for a programmatic way to modify the gradients for existing shapes in a diagram. I have got as far as understanding how to set the foreground and background for a shape, with:

EList<Shape> shapes = diagram.getChildren();
IColorConstant E_CLASS_FOREGROUND = new ColorConstant(255, 178, 21); // orange
IGaService service = GraphitiUi.getGaService();
for (Shape shape : shapes) {
    GraphicsAlgorithm ga = shape.getGraphicsAlgorithm();	
    ga.setBackground(service.manageColor(diagram, E_CLASS_FOREGROUND));

Which modifies all shapes to have this appearance:

I am following the "Styles" and "Color Schemes" documentation pages here:

In order to change the colour of the entire shape, my understanding is that I need to gradient start and stop values, is that correct? E.g. to change the colour of all shapes to green, I was hoping to have this kind of API usage:

for (Shape shape : shapes) {
    GraphicsAlgorithm ga = shape.getGraphicsAlgorithm();	

I cannot find such API methods. What are the API methods to change the entire colour of an existing shape in a diagram?
Re: Changing the colour of existing shapes (gradient start/stop?) [message #1740114 is a reply to message #1738685] Tue, 09 August 2016 12:10 Go to previous message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1929
Registered: July 2009
Location: Walldorf, Germany
Senior Member

not sure what exactly you try to do.

For setting just one color for the entire shape you need to set the background color for the shape with setBackgroundColor(...). The way you do the retrieval of the shapes in the snippet above will therfore do that for all root shapes, but not for any child shapes embedded within.

For setting a gradient (a smooth change form one to another color within the shape) you will need to define more than the gradient start and end. For details on that see the docu at .

Previous Topic:Create svg from diagram programmtically
Next Topic:Graphiti API should have similar method like isStayActiveAfterExecution for IObjectCreationToolEntry
Goto Forum:

Current Time: Thu Jun 08 13:20:11 GMT 2023

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

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

Back to the top