Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 329139

Summary: Gradient fill in scalable polygons ignore location when drawn
Product: [Modeling] GMF-Runtime Reporter: nigel.j.daniels
Component: GeneralAssignee: Project Inbox <gmf-runtime-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: Macintosh   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description nigel.j.daniels CLA 2010-10-30 11:05:47 EDT
Build Identifier: 20100917-0705

I overrode the fillShape method of a scalable polygon node to provide a gradient fill. At runtime the same code that works on standard shapes such as rectangle/ellipse resulted in an empty node. I had to use the following workaround in NodeEditPart->NodeFigure

		/**
		 * @generated NOT
		 */
		// MOD fillShape method added to fill with a gradient
		@Override
		protected void fillShape(Graphics graphics)
			{
			// Get the current rectangle to set the start and end locations of the gradient
			Rectangle r = getBounds().getCopy();
			Point topLeft = r.getTopLeft();
			Point bottomRight = r.getBottomRight();
			
			// Create the gradient pattern and set it, I'm going from the background colour to white
			Pattern pattern = new Pattern(Display.getCurrent(), topLeft.x,
					topLeft.y, bottomRight.x, bottomRight.y,
					ColorConstants.white, THIS_BACK);
			graphics.setBackgroundPattern(pattern);
			
			// Now apply the location offset to the polygons point list
			// NB This part only required for scalable polygons!
			PointList pointList = this.getScaledPoints();
			PointList positionList = new PointList();
			Point location = this.getLocation();
			
			for (int i=0;i<pointList.size();i++)
				{
				Point p = pointList.getPoint(i);
				Point newP = new Point(p.x+location.x, p.y+location.y);
				positionList.addPoint(newP);
				}
			// End of FIx

			// Fill the polygon and clean up
			graphics.fillPolygon(positionList); 
			// passing pointList much like passing a rectangle fails to work as implied  
			// by the behaviour of all of the other fill calls.
			graphics.setBackgroundPattern(null);
			pattern.dispose();
			}



Reproducible: Always

Steps to Reproduce:
1. Apply the code above without the fix
2. Open the runtime editor
3. Create a node, move it around... You only see the gradient fill in the region of the canvas origin