| Unable to change shape Background color [message #1725481] | 
Thu, 03 March 2016 13: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 12:36] by Moderator  
 |  
 |  
  | 
| Re: Unable to change shape Background color [message #1725889 is a reply to message #1725481] | 
Tue, 08 March 2016 04: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
 |  
 |  
  | 
 | 
 | 
 | 
 | 
 | 
Powered by 
FUDForum. Page generated in 0.05458 seconds