Community
Participate
Working Groups
The problem seems to be that 1/2 pixel is being added for draw operations (but not for fills) when the line width is an odd number, which is why even the 100% case is not working. Here's a modified version of the snippet that applies the same 1/2-pixel shift for fillOval, which gives the expected results: public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setText("Shell"); shell.setBackground(display.getSystemColor(SWT.COLOR_BLUE)); final Color YELLOW = display.getSystemColor(SWT.COLOR_YELLOW); shell.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { GC gc = e.gc; // gc.setAntialias(SWT.ON); gc.setLineWidth(1); Transform t = new Transform(null); gc.setTransform(t); gc.setBackground(YELLOW); paintOval(gc, t, 0.5f); t.scale(3f, 3f); gc.setTransform(t); paintOval(gc, t, 0.5f/3); t.dispose(); } private void paintOval(GC gc, Transform t, float correction) { t.translate(correction, correction); //Apply the missing 1/2-pixel shift when filling gc.setTransform(t); gc.fillOval(10, 10, 20, 20); t.translate(-correction, -correction); gc.setTransform(t); gc.drawOval(10, 10, 20, 20); } }); shell.setSize(200, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
To see same problem for Paths, "apply" this "patch": final Color YELLOW = display.getSystemColor(SWT.COLOR_YELLOW); + final Path path = new Path(display); + path.moveTo(40, 15); + path.lineTo(60, 5); + path.lineTo(80, 15); + path.lineTo(60, 25); + path.close(); and gc.setTransform(t); gc.fillOval(10, 10, 20, 20); + gc.fillPath(path); t.translate(-correction, -correction); gc.setTransform(t); gc.drawOval(10, 10, 20, 20); + gc.drawPath(path);
See related bug 242280. Because of it, the problem shown here disappears for scale factor 2.0.
*** This bug has been marked as a duplicate of bug 146179 ***
Sorry, I meant to resolve another GEF bug as duplicate, not this one. Reopened.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.