Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » draw2d behaves wrongly on Ubuntu 10.10(draw2d: drawing oval/ polygon while scaling is involved shows wrong shapes in ubuntu 10.10)
draw2d behaves wrongly on Ubuntu 10.10 [message #667493] Fri, 29 April 2011 07:27 Go to next message
atieq.rehman is currently offline atieq.rehman
Messages: 12
Registered: March 2010
Junior Member
using draw2d with swt to draw figures behaves wrongly on ubuntu10.10

i m following the steps to paint figure
as

1. save the graphics state
2.apply alpha value
3. apply scale on graphics
4. draw oval using GC
5. pop the graphics state

also repeated the same steps for other figures fill rectangle and fill polygon

this gives correct output on window but wrong on ubuntu

A snapshot of differences:
http://img13.imageshack.us/i/swtanddraw2d.jpg/

sample code is given blow
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.LightweightSystem;
import org.eclipse.draw2d.XYLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class DrawTesting {
	public static void main(String[] args) {
		final Display display = new Display();
		Shell shell = new Shell(display);
		shell.setSize(250, 300);
		shell.open();

		LightweightSystem lws = new LightweightSystem(shell);
		
		IFigure eFigure = new Figure() {
			public void paintFigure(Graphics graphics) {
				graphics.pushState();
				graphics.setAlpha(128);
				
				int scaleFactor = 64;
				graphics.scale(1f/scaleFactor);
				graphics.setBackgroundColor(ColorConstants.red);

				// This does not draw oval properly due to scaling
				// GC->drawOval ->checkGC() at line # 321
				graphics.drawOval(10 * scaleFactor, 10 * scaleFactor, 200 * scaleFactor, 200 * scaleFactor);
				graphics.popState();

				graphics.pushState();
				graphics.setAlpha(128);
				
				graphics.setBackgroundColor(ColorConstants.red);
				graphics.fillRectangle(10, 10, 200, 200);
				
				graphics.setBackgroundColor(ColorConstants.yellow);
				
				// This poly does not draw at the right position
				// GC->fillPolygon 
				graphics.fillPolygon(new int[]{
						10, 10, 
						210, 10, 
						210, 210,
						10, 210});
				
				graphics.popState();
			};
		};

		eFigure.setLayoutManager(new XYLayout());
		lws.setContents(eFigure);
		
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
	}
}


i am using eclipse 3.6

anyone having the reason behind.. it seems that linux implementation might have some issues as everything is working correctly on windows plateform

any comments and suggestions are welcomed

[Updated on: Tue, 03 May 2011 10:06]

Report message to a moderator

Re: draw2d behaves wrongly on Ubuntu 10.10 [message #668611 is a reply to message #667493] Fri, 06 May 2011 12:24 Go to previous message
atieq.rehman is currently offline atieq.rehman
Messages: 12
Registered: March 2010
Junior Member
any reply ???
Previous Topic:Fire a property change from View
Next Topic:[ZEST] node shape
Goto Forum:
  


Current Time: Mon Oct 20 04:31:10 GMT 2014

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

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