Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Unable to change shape Background color
Unable to change shape Background color [message #1725481] Thu, 03 March 2016 18:37 Go to next message
maria  finkelstein is currently offline maria finkelsteinFriend
Messages: 19
Registered: December 2011
Location: New York, NY
Junior Member
hi,
i can't change my shape Background color, i tried both style object and set setBackground method on shape. both do nothing. maybe i do something wrong..
there is the code to create a shape


Ellipse ellipse = gaService.createPlainEllipse(anchor);
ellipse.setBackground(Graphiti.getGaService().manageColor(getDiagram(),new ColorConstant(98, 131, 167)));
ellipse.setFilled(true);
ellipse.setLineWidth(2);

there is how i reset the color:
Color mapColor = Graphiti.getGaService().manageColor(diagram,new ColorConstant(0, 153, 153));

GraphicsAlgorithm ga = anchor.getGraphicsAlgorithm();
if( ga instanceof Ellipse){
Ellipse ellipse = (Ellipse) ga;
ellipse.setBackground(mapColor);

}

setForeground is works but setBackground doesn't ... is there any way around?

[Updated on: Thu, 10 March 2016 17:36]

Report message to a moderator

Re: Unable to change shape Background color [message #1725889 is a reply to message #1725481] Tue, 08 March 2016 09:59 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Maria,

that's strange. I just modified the tutorial TutorialAddEClassFeature so that the ellipse for the anchor uses your background color. This is the modified end of the add method, starting with line 134:
// create an additional box relative anchor at middle-right
final BoxRelativeAnchor boxAnchor = peCreateService.createBoxRelativeAnchor(containerShape);
boxAnchor.setRelativeWidth(1.0);
boxAnchor.setRelativeHeight(0.38); // Use golden section

// anchor references visible rectangle instead of invisible rectangle
boxAnchor.setReferencedGraphicsAlgorithm(roundedRectangle);

// assign a graphics algorithm for the box relative anchor
final Ellipse ellipse = gaService.createPlainEllipse(boxAnchor);

// anchor is located on the right border of the visible rectangle
// and touches the border of the invisible rectangle
final int w = INVISIBLE_RECT_RIGHT;
gaService.setLocationAndSize(ellipse, -w, -w, 2 * w, 2 * w);
// ellipse.setStyle(StyleUtil.getStyleForEClass(getDiagram()));
ellipse.setFilled(true);
ellipse.setLineWidth(2);
ellipse.setBackground(Graphiti.getGaService().manageColor(getDiagram(), new ColorConstant(0, 153, 153)));
ellipse.setForeground(Graphiti.getGaService().manageColor(getDiagram(), new ColorConstant(100, 100, 100)));

// call the layout feature
layoutPictogramElement(containerShape);

return containerShape;

It results in the anchor ellipse having both background and foreground colors. Can you compare to your implementation? Not sure what your intention of the reset color is and where that is implemented. In case it does not help can you share the complete add method?

Michael
Re: Unable to change shape Background color [message #1726244 is a reply to message #1725889] Thu, 10 March 2016 17:19 Go to previous messageGo to next message
maria  finkelstein is currently offline maria finkelsteinFriend
Messages: 19
Registered: December 2011
Location: New York, NY
Junior Member
Michael,

Sorry i must wasn't explaining my self right.. setBackground method works only on the very first time when shape is created.. if you try to reset the color with Update Feature , the new color is not set

Maria
Re: Unable to change shape Background color [message #1726334 is a reply to message #1726244] Fri, 11 March 2016 14:09 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Maria,

so, do you call that functionality from within your update feature. Does the update method return a true reason?

Michael
Re: Unable to change shape Background color [message #1726547 is a reply to message #1726334] Mon, 14 March 2016 14:55 Go to previous messageGo to next message
maria  finkelstein is currently offline maria finkelsteinFriend
Messages: 19
Registered: December 2011
Location: New York, NY
Junior Member
Michael,

I am not using update feature. In my diagram i am just changing anchor colors on connection between 2 shapes
I was able to repro it with tutorial sample, i am attaching TutorialAddEReferenceFeature, look on reproBackgroundColorChange method.
I am changing both Background and Foreground colors, only Foreground is updated.


Regards,
Maria
Re: Unable to change shape Background color [message #1726626 is a reply to message #1726547] Tue, 15 March 2016 08:20 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Maria,

The style setting on the ellipse for the anchor interferes with changing the background color in this case. When I additionally to your change remove setting of the style for the anchor ellipse (just commenting line 148 in TutorialAddEClassFeature) will enable the set background color. The problem is that the style define a color gradient which will overrule the background color you try to set.

Michael
Re: Unable to change shape Background color [message #1726668 is a reply to message #1726626] Tue, 15 March 2016 14:20 Go to previous message
maria  finkelstein is currently offline maria finkelsteinFriend
Messages: 19
Registered: December 2011
Location: New York, NY
Junior Member
finally made it to work!!!

thanks
Previous Topic:removing shape with attached connection issue
Next Topic:Support for using SVG figures/shapes (GSoC 2016?)
Goto Forum:
  


Current Time: Tue Oct 08 13:10:49 GMT 2024

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

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

Back to the top