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 214839 Details for
Bug 351038
SWTGraphics.rotate should use GC data state mask to avoid rotate problems
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Demonstrates rotate problem with paintFill
Draw2DRotateTest.java (text/x-java), 4.12 KB, created by
Colin Sharples
on 2012-04-30 17:31:49 EDT
(
hide
)
Description:
Demonstrates rotate problem with paintFill
Filename:
MIME Type:
Creator:
Colin Sharples
Created:
2012-04-30 17:31:49 EDT
Size:
4.12 KB
patch
obsolete
>package nz.co.ctg.draw2d; > >import org.eclipse.draw2d.ColorConstants; >import org.eclipse.draw2d.FigureCanvas; >import org.eclipse.draw2d.FreeformLayeredPane; >import org.eclipse.draw2d.Graphics; >import org.eclipse.draw2d.Shape; >import org.eclipse.draw2d.geometry.Rectangle; >import org.eclipse.swt.SWT; >import org.eclipse.swt.events.SelectionAdapter; >import org.eclipse.swt.events.SelectionEvent; >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.Composite; >import org.eclipse.swt.widgets.Display; >import org.eclipse.swt.widgets.Label; >import org.eclipse.swt.widgets.Shell; > >public class Draw2DRotateTest { > private static final class RotatingRectangle extends Shape { > public RotatingRectangle() { > setFill(false); > setOutline(true); > setOpaque(true); > setBackgroundColor(ColorConstants.white); > setForegroundColor(ColorConstants.black); > setBounds(new Rectangle(50, 50, 150, 150)); > } > > @Override > protected void outlineShape(Graphics graphics) { > graphics.translate(100, 100); > graphics.rotate(rotation); > graphics.fillRectangle(0, 0, 20, 20); > graphics.drawRectangle(0, 0, 20, 20); > } > > @Override > protected void fillShape(Graphics graphics) { > } > } > > private static final class BadRotatingRectangle extends Shape { > public BadRotatingRectangle() { > setFill(true); > setOutline(false); > setOpaque(true); > setBackgroundColor(ColorConstants.white); > setForegroundColor(ColorConstants.black); > setBounds(new Rectangle(50, 50, 150, 150)); > } > > @Override > protected void outlineShape(Graphics graphics) { > } > > @Override > protected void fillShape(Graphics graphics) { > graphics.translate(100, 100); > graphics.rotate(rotation); > graphics.fillRectangle(0, 0, 20, 20); > graphics.drawRectangle(0, 0, 20, 20); > } > } > > 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 FigureCanvas goodFigureCanvas = new FigureCanvas(shell, SWT.BORDER); > final FigureCanvas badFigureCanvas = new FigureCanvas(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; > } > goodFigureCanvas.redraw(); > badFigureCanvas.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; > } > goodFigureCanvas.redraw(); > badFigureCanvas.redraw(); > } > }); > > gd = new GridData(SWT.FILL, SWT.FILL, true, true); > gd.widthHint = 200; > gd.heightHint = 200; > goodFigureCanvas.setLayoutData(gd); > FreeformLayeredPane root = new FreeformLayeredPane(); > goodFigureCanvas.setContents(root); > root.add(new RotatingRectangle()); > > gd = new GridData(SWT.FILL, SWT.FILL, true, true); > gd.widthHint = 200; > gd.heightHint = 200; > badFigureCanvas.setLayoutData(gd); > root = new FreeformLayeredPane(); > badFigureCanvas.setContents(root); > root.add(new BadRotatingRectangle()); > > 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 351038
: 214839