Community
Participate
Working Groups
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