draw2d behaves wrongly on Ubuntu 10.10 [message #667493] |
Fri, 29 April 2011 03:27  |
Eclipse User |
|
|
|
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 06:06] by Moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03404 seconds