The following shows what I have so far:
Printer printer = new Printer(data);
Graphics graphics = new PrinterGraphics(new SWTGraphics(new GC(printer, SWT.LEFT_TO_RIGHT)), printer);
Rectangle printRegion = getPrintRegion(printer);
printer.startJob(TournamentManager.get().getTournament().getDefinition()
.getName()
+ " Score Cards");
Figure root = new Figure();
root.setLayoutManager(new ToolbarLayout(false));
root.setForegroundColor(new Color(printer, 0,0,0));
root.setFont(printer.getSystemFont());
for (CompetitorStatus status : competitorStatuses) {
graphics.pushState();
IFigure page = buildFigure(status);
root.add(page);
Canvas c = new Canvas(new Shell(), SWT.None);
c.setLayout(new FillLayout());
LightweightSystem lwsTmp = new LightweightSystem(c);
lwsTmp.setContents(page);
c.setBounds(printRegion.x, printRegion.y, printRegion.width, printRegion.height);
c.layout();
printer.startPage();
graphics.translate(-printRegion.x, -printRegion.y);
graphics.getClip(printRegion);
printRegion.setLocation(printRegion.x, printRegion.y);
graphics.clipRect(printRegion);
page.paint(graphics);
printer.endPage();
graphics.popState();
}
printer.endJob();
No comments:
Post a Comment