Summary: | ScaledGraphics does not support setClip(Path) | ||
---|---|---|---|
Product: | [Tools] GEF | Reporter: | Zac <mjuju16> |
Component: | GEF-Legacy Draw2d | Assignee: | Lidija Grahek <lgrahek> |
Status: | RESOLVED WORKSFORME | QA Contact: | |
Severity: | enhancement | ||
Priority: | P3 | CC: | ahunter.eclipse, dsciamma, hudsonr, ljpm27, manderse, nyssen |
Version: | 3.1.1 | Flags: | ahunter.eclipse:
galileo+
|
Target Milestone: | 3.7.1 (Indigo) M7 | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Whiteboard: |
Description
Zac
2007-04-29 22:04:05 EDT
This actually affects any figures and I think the bug should rather be called "ScaledGraphics does no support gradient" In reply to comment #1) > This actually affects any figures and I think the bug should rather be called > "ScaledGraphics does no support gradient" The problem is with setClip(Path), not fillGradient. zoomPath was recently added for fillPath(Path) and drawPath(Path) in ScaledGraphics, so maybe this method could be used to implement setClip(Path). Note that the more useful method "clip(Path)" which intersects the Path and the current clipping is still not defined nor easily implemented given the lack of intersection support. Ok - so I should create a seperate bug for the missing gradient support in scaledgraphics ? (In reply to comment #3) > Ok - so I should create a seperate bug for the missing gradient support in > scaledgraphics ? > It would appear that we need this. We have Bug 132361 as well. > It would appear that we need this. We have Bug 132361 as well.
Patterns don't work either, but the above code uses the basic rectangular fill.
These issues seem to have been fixed by means of bug #267728. The following snippet may be used to demonstrate that this is working now. Resolving as WORKSFORME. import org.eclipse.draw2d.SWTGraphics; import org.eclipse.draw2d.ScaledGraphics; import org.eclipse.draw2d.geometry.PrecisionRectangle; import org.eclipse.swt.SWT; import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.graphics.Path; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; public class PathWithGradient { public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setText("Shell"); shell.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { SWTGraphics nativeGraphics = new SWTGraphics(e.gc); ScaledGraphics graphics = new ScaledGraphics(nativeGraphics); float scale = 10.0f; graphics.scale(scale); // Add 2 arcs to create a path/clip for an oval Path path = new Path(display); int diameter = 20; // path.addArc(x, y, width, height, startAngle, arcAngle) path.addArc(0, 0, diameter + 20, diameter, 0, 360); path.addArc(10, 10, diameter + 20, diameter, 0, 360); // path.addString("SWT", 0, 0, display.getSystemFont()); graphics.setBackgroundColor(display .getSystemColor(SWT.COLOR_GREEN)); graphics.setForegroundColor(display .getSystemColor(SWT.COLOR_BLUE)); graphics.setClip(path); float[] bounds = new float[4]; path.getBounds(bounds); // compensate for different rectangle calculations in SWT and Draw2d graphics.fillGradient( new PrecisionRectangle(bounds[0], bounds[1], bounds[2] + 1 * scale, bounds[3] + 1 * scale), true); } }); shell.setSize(800, 800); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } } |