Skip to main content



      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 04:53 Go to next message
Eclipse UserFriend
Hi,

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.setLineStyle(LineStyle.DOT);
    ga.setFilled(true);
    ga.setForeground(manageColor(IColorConstant.GREEN));
    ga.setBackground(service.manageColor(diagram, E_CLASS_FOREGROUND));
}


Which modifies all shapes to have this appearance:

http://www.macs.hw.ac.uk/~rs46/files/graphiti-shape-colour.png

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

http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.graphiti.doc%2Fresources%2Fdocu%2Fgfw%2Fstyles.htm

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();	
    ga.setGradientStart(manageColor(IColorConstant.GREEN));
    ga.setGradientStop(manageColor(IColorConstant.GREEN));
}


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 08:10 Go to previous message
Eclipse UserFriend
Rob,

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 http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.graphiti.doc%2Fresources%2Fdocu%2Fgfw%2Fstyles.htm .

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


Current Time: Mon Apr 21 02:21:58 EDT 2025

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

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

Back to the top