template.setActivePage(pageIndex);
//Paper paper = pageFormat.getPaper();
//paper.setImageableArea(MARGIN, MARGIN, paper.getWidth() - MARGIN*2, paper.getHeight() - MARGIN*2);
//pageFormat.setPaper(paper);
Page page = makePage(map, pageFormat, template, showRasters, scaleHint);
Graphics2D graphics2d = (Graphics2D) graphics;
AffineTransform at = graphics2d.getTransform();
double dpi = at.getScaleX() * 72;
if (PrintingPlugin.isDebugging(TRACE_PRINTING)) {
PrintingPlugin.log("-Printing page " + pageIndex, null); //$NON-NLS-1$
System.out.println("-PageFormat: " + pageFormat); //$NON-NLS-1$
System.out.println("-PageFormat height: " + pageFormat.getHeight()); //$NON-NLS-1$
System.out.println("-PageFormat width: " + pageFormat.getWidth()); //$NON-NLS-1$
System.out.println("-PageFormat imageableX,Y " + pageFormat.getImageableX() + ", " + pageFormat.getImageableY()); //$NON-NLS-1$ //$NON-NLS-2$
System.out.println("-PageFormat imageable height: " + pageFormat.getImageableHeight()); //$NON-NLS-1$
System.out.println("-PageFormat imageable width: " + pageFormat.getImageableWidth()); //$NON-NLS-1$
System.out.println("-PageFormat orientation (LANDSCAPE=" + PageFormat.LANDSCAPE + ", PORTRAIT=" + PageFormat.PORTRAIT + "): " + pageFormat.getOrientation()); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
System.out.println("-Graphics: clip bounds: " + graphics2d.getClipBounds()); //$NON-NLS-1$
System.out.println("-Transform: scaleX: " + at.getScaleX()); //$NON-NLS-1$
System.out.println("-Transform: scaleY: " + at.getScaleY()); //$NON-NLS-1$
System.out.println("-DPI?? : " + dpi); //$NON-NLS-1$
}
graphics2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
Iterator<Box> iter = page.getBoxes().iterator();
while( iter.hasNext() ) {
Box box = iter.next();
graphics2d = (Graphics2D) graphics.create(box.getLocation().x, box.getLocation().y, box
.getSize().width, box.getSize().height);