Unable to change shape Background color [message #1725481] |
Thu, 03 March 2016 18:37  |
Eclipse User |
|
|
|
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] by Moderator 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   |
Eclipse User |
|
|
|
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 #1726547 is a reply to message #1726334] |
Mon, 14 March 2016 14:55   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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
|
|
|
|
Powered by
FUDForum. Page generated in 0.04111 seconds