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 133345 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
Codes to compare working and non working solution
TestWindow.java (text/plain), 4.37 KB, created by
Vincent Raman
on 2009-04-27 08:51:33 EDT
(
hide
)
Description:
Codes to compare working and non working solution
Filename:
MIME Type:
Creator:
Vincent Raman
Created:
2009-04-27 08:51:33 EDT
Size:
4.37 KB
patch
obsolete
>/** > * > */ >package test; > >import internal.Kernel; > >import org.eclipse.jface.window.ApplicationWindow; >import org.eclipse.swt.SWT; >import org.eclipse.swt.events.PaintEvent; >import org.eclipse.swt.events.PaintListener; >import org.eclipse.swt.graphics.GC; >import org.eclipse.swt.graphics.Transform; >import org.eclipse.swt.widgets.Canvas; >import org.eclipse.swt.widgets.Composite; >import org.eclipse.swt.widgets.Control; >import org.eclipse.swt.widgets.Display; >import org.eclipse.swt.widgets.Shell; > >/** > * @author Vincent > * > */ >public class TestWindow extends ApplicationWindow implements PaintListener { > > /** > * @param parentShell > */ > public TestWindow(Shell shell) { > super(shell); > } > > > > /* (non-Javadoc) > * @see org.eclipse.jface.window.Window#createContents(org.eclipse.swt.widgets.Composite) > */ > @Override > protected Control createContents(Composite parent) { > getShell().setMaximized(true); > Canvas c = new Canvas(parent,SWT.NO_BACKGROUND | SWT.BORDER); > c.addPaintListener(this); > return c; > } > > > > /* (non-Javadoc) > * @see org.eclipse.swt.events.PaintListener#paintControl(org.eclipse.swt.events.PaintEvent) > */ > public void paintControl(PaintEvent e) { > final GC gc = e.gc; > final float[] angles=new float[] {0,30,40,44,45,46,50,60,90}; > final Transform t = new Transform(Display.getDefault()); > t.translate(200,10); > gc.setTransform(t); > gc.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); > > /********************************** > * CREATE FIGURES WITH BAD DRAWING > ***********************************/ > System.out.println("\n********BAAAAD******\n"); > for(int i=0;i<angles.length;++i) { > Transform t2 = new Transform(Display.getDefault()); > gc.getTransform(t2); > t2.translate(200*(i%2), 150*(float)Math.floor(i/2)); > t2.rotate(angles[i]); > gc.setTransform(t2); > System.out.println("______________________"); > System.out.println("Angle "+angles[i]); > System.out.println("Before : xoffset : "+gc.getGCData().drawXOffset); > System.out.println("Before : yoffset : "+gc.getGCData().drawYOffset); > Paintfigure(gc); > System.out.println("After : xoffset : "+gc.getGCData().drawXOffset); > System.out.println("After : yoffset : "+gc.getGCData().drawYOffset); > t2.dispose(); > gc.setTransform(t); > } > gc.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE)); > for(int i=0;i<angles.length;++i) { > Transform t2 = new Transform(Display.getDefault()); > gc.getTransform(t2); > t2.translate(200*(i%2)-100, 150*(float)Math.floor(i/2)); > gc.setTransform(t2); > gc.drawString(angles[i]+"°", 0, 0); > t2.dispose(); > gc.setTransform(t); > } > > /************************ > * CREATE GOOD FIGURES > ***********************/ > System.out.println("\n********GOOOD******\n"); > gc.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_BLUE)); > for(int i=0;i<angles.length;++i) { > Transform t2 = new Transform(Display.getDefault()); > gc.getTransform(t2); > t2.translate(500+200*(i%2), 150*(float)Math.floor(i/2)); > t2.rotate(angles[i]); > gc.setTransform(t2); > > /******************************************** > * Add to GC data state the DRAW_OFFSET mask > ********************************************/ > gc.getGCData().state |= 1 << 9; > > System.out.println("______________________"); > System.out.println("Angle "+angles[i]); > System.out.println("Before : xoffset : "+gc.getGCData().drawXOffset); > System.out.println("Before : yoffset : "+gc.getGCData().drawYOffset); > Paintfigure(gc); > System.out.println("After : xoffset : "+gc.getGCData().drawXOffset); > System.out.println("After : yoffset : "+gc.getGCData().drawYOffset); > t2.dispose(); > gc.setTransform(t); > } > gc.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE)); > for(int i=0;i<angles.length;++i) { > Transform t2 = new Transform(Display.getDefault()); > gc.getTransform(t2); > t2.translate(400+200*(i%2), 150*(float)Math.floor(i/2)); > gc.setTransform(t2); > gc.drawString(angles[i]+"°", 0, 0); > t2.dispose(); > gc.setTransform(t); > } > > t.dispose(); > } > > private void Paintfigure(GC gc) { > final int[] polygon = new int[] {0,0,0,100,100,75}; > gc.fillPolygon(polygon); > gc.drawPolygon(polygon); > } > > public static void main(String[] args) { > Display display = new Display(); > Shell shell = new Shell(display); > TestWindow w = new TestWindow(shell); > w.setBlockOnOpen(true); > w.open(); > Display.getCurrent().dispose(); > System.exit(1); > } >}
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