Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Transform.rotate(45)
Transform.rotate(45) [message #653377] Wed, 09 February 2011 15:15 Go to next message
Eclipse UserFriend
Originally posted by: m.swillus.qualitype.de

Hej,

I am noticing a strange effect when rotating a GC by 45 degrees (135,
225 and 315 as well), and afterwards drawing some elements on it.

Especially drawOval() is painted on another position than fillOval(),
given the same coordinates. While fillOval() seems to get painted right,
drawOval() and drawLine() seem not. A goofy behaviour can also be
observed within the close proximity of the axes angle bisectors (45,
135, 225, 315 degrees).

Please find a rudimental snippet attached, which continuously rotates an
oval and a fillOval. In the proximity of the described angles you will
observe some strange deviations of the drawOval() output.

I already searched bugzilla, with no success though. Please give me a
hint if this one is a real bug or I am misusing the API.

Thanks in advance and best regards from Dresden,
Mirko Swillus

// snippet

package test;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Transform;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class TransformTest {
public static void main(String[] args) throws InterruptedException {

Display display = new Display();
final Shell shell = new Shell(display, SWT.DOUBLE_BUFFERED
| SWT.NO_BACKGROUND);
final Transform transform = new Transform(display);

shell.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
e.gc.setBackground(e.gc.getDevice().getSystemColor(
SWT.COLOR_RED));
e.gc.setForeground(e.gc.getDevice().getSystemColor(
SWT.COLOR_RED));
e.gc.setTransform(transform);
e.gc.fillOval(50, 50, 10, 10);
e.gc.drawOval(46, 46, 18, 18);
}
});

shell.pack();
shell.open();
shell.setSize(200, 200);
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
Thread.sleep(5);
transform.translate(100, 100);
transform.rotate(1);
transform.translate(-100, -100);
shell.redraw();
}
display.dispose();
}
}
Re: Transform.rotate(45) [message #653600 is a reply to message #653377] Thu, 10 February 2011 11:34 Go to previous messageGo to next message
Lakshmi ShanmugamFriend
Messages: 276
Registered: July 2009
Location: India
Senior Member
Hi,

Looks like you are seeing this bug --> https://bugs.eclipse.org/bugs/show_bug.cgi?id=253670
I just verified that the workaround specified in the comment 2 of the bug seems to fix the problem for your snippet too.
It requires you to set the GC data state mask after rotation but before drawing ---> e.gc.getGCData().state |= <GC#DRAW_OFFSET value for your platform>


Lakshmi P Shanmugam
Re: Transform.rotate(45) [message #653615 is a reply to message #653600] Thu, 10 February 2011 12:28 Go to previous message
Eclipse UserFriend
Originally posted by: m.swillus.qualitype.de

Hej,
Am 10.02.2011 12:34, schrieb Lakshmi Shanmugam:

> Looks like you are seeing this bug -->
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=253670

Thanks a lot! Obviously, my bugzilla search skills are a little
expandable.

> I just verified that the workaround specified in the
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=253670#c2 of the bug seems
> to fix the problem for your snippet too.
> It requires you to set the GC data state mask after rotation but before
> drawing ---> e.gc.getGCData().state |= <GC#DRAW_OFFSET value for your
> platform>

I'm on XP, so I guess 1 << 14 is fine by me, which actually did the
trick. Best regards,

Mirko Swillus
Previous Topic:WebKit browser
Next Topic:TableColumn setAlignment not working for images on Windows?
Goto Forum:
  


Current Time: Sat Mar 28 19:20:19 GMT 2020

Powered by FUDForum. Page generated in 0.01682 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top