[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools.gef] Re: Capturing drawing image WITHOUT showing it on screen

Typically printing too has the same problem - only the last shape is drawn.

Here is the code...

//----------------------
final LightweightSystem lws = new LightweightSystem(shell);
final IFigure panel = new Figure();
panel.setLayoutManager(new FlowLayout());
lws.setContents(panel);

Clickable button = new Button("Click me");
Clickable checkbox = new CheckBox("Check box");
Shape ellipse = new Ellipse();
ellipse.setBackgroundColor(ColorConstants.yellow);
Shape rectangle = new RectangleFigure();
rectangle.setBackgroundColor(ColorConstants.lightBlue);

panel.add(button);
panel.add(checkbox);
panel.add(ellipse);
panel.add(rectangle);

final Display display = Display.getDefault();

Shell shell2 = new Shell();
PrintDialog dialog = new PrintDialog(shell2, SWT.NULL);
PrinterData data = dialog.open();
if (data != null) {
   PrintFigureOperation op = 
            new PrintFigureOperation(new Printer(data), panel);
   op.setPrintMode(PrintFigureOperation.TILE);
   op.run("demo2");
}
//---------------------end