Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 214841 Details for
Bug 253670
Line and Path not drawn when 45-degree rotation is applied
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Demonstrates rotate problem, and use of line attributes to fix
RotateTest.java (text/x-java), 3.74 KB, created by
Colin Sharples
on 2012-04-30 17:43:10 EDT
(
hide
)
Description:
Demonstrates rotate problem, and use of line attributes to fix
Filename:
MIME Type:
Creator:
Colin Sharples
Created:
2012-04-30 17:43:10 EDT
Size:
3.74 KB
patch
obsolete
>package nz.co.ctg.draw2d; > >import org.eclipse.swt.SWT; >import org.eclipse.swt.events.PaintEvent; >import org.eclipse.swt.events.PaintListener; >import org.eclipse.swt.events.SelectionAdapter; >import org.eclipse.swt.events.SelectionEvent; >import org.eclipse.swt.graphics.Color; >import org.eclipse.swt.graphics.Transform; >import org.eclipse.swt.layout.GridData; >import org.eclipse.swt.layout.GridLayout; >import org.eclipse.swt.layout.RowLayout; >import org.eclipse.swt.widgets.Button; >import org.eclipse.swt.widgets.Canvas; >import org.eclipse.swt.widgets.Composite; >import org.eclipse.swt.widgets.Display; >import org.eclipse.swt.widgets.Label; >import org.eclipse.swt.widgets.Shell; > >public class RotateTest { > static int rotation = 0; > > public static void main(String[] args) { > Display display = new Display (); > Shell shell = new Shell(display); > shell.setSize(400, 400); > shell.setLayout(new GridLayout(2, false)); > Composite b = new Composite(shell, SWT.NONE); > b.setLayout(new RowLayout(SWT.HORIZONTAL)); > GridData gd = new GridData(); > gd.horizontalSpan = 2; > b.setLayoutData(gd); > > Label l = new Label(shell, SWT.NONE); > l.setText("Good"); > l = new Label(shell, SWT.NONE); > l.setText("Bad"); > > final Canvas goodCanvas = new Canvas(shell, SWT.BORDER); > final Canvas badCanvas = new Canvas(shell, SWT.BORDER); > > Button left = new Button(b, SWT.ARROW | SWT.LEFT); > left.addSelectionListener(new SelectionAdapter() { > @Override > public void widgetSelected(SelectionEvent e) { > rotation -= 5; > if (rotation < 0) { > rotation += 360; > } > if (rotation >= 360) { > rotation -= 360; > } > goodCanvas.redraw(); > badCanvas.redraw(); > } > }); > Button right = new Button(b, SWT.ARROW | SWT.RIGHT); > right.addSelectionListener(new SelectionAdapter() { > @Override > public void widgetSelected(SelectionEvent e) { > rotation += 5; > if (rotation < 0) { > rotation += 360; > } > if (rotation >= 360) { > rotation -= 360; > } > goodCanvas.redraw(); > badCanvas.redraw(); > } > }); > > gd = new GridData(SWT.FILL, SWT.FILL, true, true); > gd.widthHint = 200; > gd.heightHint = 200; > goodCanvas.setLayoutData(gd); > goodCanvas.addPaintListener(new PaintListener() { > @Override > public void paintControl(PaintEvent e) { > e.gc.setForeground(new Color(Display.getCurrent(), 0, 0, 0)); > e.gc.setBackground(new Color(Display.getCurrent(), 255, 255, 255)); > Transform transform = new Transform(Display.getCurrent()); > transform.translate(100, 100); > transform.rotate(rotation); > e.gc.setTransform(transform); > e.gc.getGCData().state |= 1 << 9; // DRAW_OFFSET > e.gc.fillRectangle(0, 0, 20, 20); > e.gc.drawRectangle(0, 0, 20, 20); > } > }); > > gd = new GridData(SWT.FILL, SWT.FILL, true, true); > gd.widthHint = 200; > gd.heightHint = 200; > badCanvas.setLayoutData(gd); > badCanvas.addPaintListener(new PaintListener() { > @Override > public void paintControl(PaintEvent e) { > // e.gc.setLineAttributes(new LineAttributes(1, SWT.CAP_FLAT, SWT.JOIN_MITER)); > e.gc.setForeground(new Color(Display.getCurrent(), 0, 0, 0)); > e.gc.setBackground(new Color(Display.getCurrent(), 255, 255, 255)); > Transform transform = new Transform(Display.getCurrent()); > transform.translate(100, 100); > transform.rotate(rotation); > e.gc.setTransform(transform); > e.gc.fillRectangle(0, 0, 20, 20); > e.gc.drawRectangle(0, 0, 20, 20); > } > }); > > shell.open (); > while (!shell.isDisposed ()) { > if (!display.readAndDispatch ()) { > display.sleep (); > } > } > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 253670
:
133345
|
133346
| 214841