Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 329139 - Gradient fill in scalable polygons ignore location when drawn
Summary: Gradient fill in scalable polygons ignore location when drawn
Status: NEW
Alias: None
Product: GMF-Runtime
Classification: Modeling
Component: General (show other bugs)
Version: unspecified   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 normal
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-30 11:05 EDT by nigel.j.daniels CLA
Modified: 2010-10-30 11:05 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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