/** * Iterates through the Page's Boxes, drawing to the provided Graphics object * * @see java.awt.print.Printable#print(java.awt.Graphics, java.awt.print.PageFormat, int) */ public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException { if (pageIndex >= 1) { return Printable.NO_SUCH_PAGE; } 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 = diagram.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); box.getBoxPrinter().draw(graphics2d, monitor); } return Printable.PAGE_EXISTS; }