int height = (int)pageFormat.getImageableHeight();
int maxLinesPerPage = (int)pageFormat.getImageableHeight() / fontHeight;
int maxLinesPerPage = (int)pageFormat.getImageableHeight() / fontHeight;
final double imageableHeight = pageFormat.getImageableHeight();
public class HTMLPrinter implements Printable{ private final JEditorPane printPane; public HTMLPrinter(JEditorPane editorPane){ printPane = editorPane; } public int print(Graphics graphics, PageFormat pageFormat, int pageIndex){ if (pageIndex >= 1) return Printable.NO_SUCH_PAGE; Graphics2D g2d = (Graphics2D)graphics; g2d.setClip(0, 0, (int)pageFormat.getImageableWidth(), (int)pageFormat.getImageableHeight()); g2d.translate((int)pageFormat.getImageableX(), (int)pageFormat.getImageableY()); RepaintManager rm = RepaintManager.currentManager(printPane); boolean doubleBuffer = rm.isDoubleBufferingEnabled(); rm.setDoubleBufferingEnabled(false); printPane.setSize((int)pageFormat.getImageableWidth(), 1); printPane.print(g2d); rm.setDoubleBufferingEnabled(doubleBuffer); return Printable.PAGE_EXISTS; } }
System.out.println("[Print] " + dump(pageFormat)); double width = pageFormat.getImageableWidth(); double height = pageFormat.getImageableHeight(); g2d.translate((int) pageFormat.getImageableX(), (int) pageFormat.getImageableY());
final int maxLinesPerPage = (int)pageFormat.getImageableHeight() / fontHeight;
/** * Returns the total height of the logical page. * * @return the height of the page. */ public float getHeight() { return (float) ( format.getImageableHeight() * pageCountVertical ); }
private double getPageHeightInPixel(PageFormat pageFormat) { return pageFormat.getImageableHeight(); }
/** * Gets the number of rows currently required for the printout * * @return the number of rows (>= 1) */ private int getRows() { return (int) Math.max(1, Math.ceil(bounds.getHeight() * scaleGraph / pageFormat.getImageableHeight())); }
public int print(Graphics g, PageFormat pf, int pageIndex) { Component myPanel =...; g.translate(pf.getImageableX() + pf.getImageableWidth() / 2 - myPanel.getWidth() / 2, pf.getImageableY() + pf.getImageableHeight() / 2 - myPanel.getHeight() / 2); //Graphics object has been set up so the printing myPanel with it should now be centered myPanel.print(g); }
public int print(Graphics g, PageFormat format, int pageIndex) { Graphics2D g2d = (Graphics2D) g; g2d.translate(format.getImageableX(), format.getImageableY()); double dw = format.getImageableWidth(); double dh = format.getImageableHeight(); setScales(); double xScale = dw / (targetComponent.getWidth() * xScaleFactor); // double yScale = dh / (targetComponent.getHeight() * // yScaleFactor); g2d.scale(xScale, xScale); targetComponent.paint(g2d); return Printable.PAGE_EXISTS; }
private void splitToPagesForCurrentFormat() { final MMDPrint printer = new MMDPrint(this.printableObject, (int) this.pageFormat.getImageableWidth(), (int) this.pageFormat.getImageableHeight(), this.options); this.pages = printer.getPages(); }
public static void printPageFormat(PageFormat pf) { System.out.println("paper size:" + pf.getWidth() + "x" + pf.getHeight() + " orientation:" + pf.getOrientation()); System.out.println("imageable position: X=" + pf.getImageableX() + " Y=" + pf.getImageableY()); System.out.println("imageable size:" + pf.getImageableWidth() + "x" + pf.getImageableHeight()); }
/** Patch for a bug in the PageFormat class * @param pf PageFormat * @return imageable y coordination for this page format */ private float getImageableYPatch(PageFormat pf) { if (pf.getOrientation() == PageFormat.LANDSCAPE) { double ret = pf.getPaper().getWidth() - (pf.getImageableY() + pf.getImageableHeight()); return (float) Math.round(ret); } else { return (float) pf.getImageableY(); } }
/** * Draws the object. * * @param g2 * the graphics device. * @param area * the area inside which the object should be drawn. */ public void draw( final Graphics2D g2, final Rectangle2D area ) { g2.translate( pageFormat.getImageableX(), pageFormat.getImageableY() ); pageDrawable.draw( g2, new Rectangle2D.Double( StrictGeomUtility.toExternalValue( globalX ), StrictGeomUtility .toExternalValue( globalY ), pageFormat.getImageableWidth(), pageFormat.getImageableHeight() ) ); }
/** Patch for a bug in the PageFormat class * @param pf PageFormat * @return imageable y coordination for this page format */ private float getImageableYPatch(PageFormat pf) { if (pf.getOrientation() == PageFormat.LANDSCAPE) { double ret = pf.getPaper().getWidth() - (pf.getImageableY() + pf.getImageableHeight()); return (float) Math.round(ret); } else { return (float) pf.getImageableY(); } }
/** Patch for a bug in the PageFormat class * @param pf PageFormat * @return imageable y coordination for this page format */ private float getImageableYPatch(PageFormat pf) { if (pf.getOrientation() == PageFormat.LANDSCAPE) { double ret = pf.getPaper().getWidth() - (pf.getImageableY() + pf.getImageableHeight()); return (float) Math.round(ret); } else { return (float) pf.getImageableY(); } }
public Insets getPageMargins( final PageFormat format ) { final int marginLeft = (int) format.getImageableX(); final int marginRight = (int) ( format.getWidth() - format.getImageableWidth() - format.getImageableX() ); final int marginTop = (int) ( format.getImageableY() ); final int marginBottom = (int) ( format.getHeight() - format.getImageableHeight() - format.getImageableY() ); return new Insets( marginTop, marginLeft, marginBottom, marginRight ); }
public PhysicalPageBox( final PageFormat pageFormat, final long globalX, final long globalY ) { this.width = StrictGeomUtility.toInternalValue( pageFormat.getWidth() ); this.height = StrictGeomUtility.toInternalValue( pageFormat.getHeight() ); this.imageableX = StrictGeomUtility.toInternalValue( pageFormat.getImageableX() ); this.imageableY = StrictGeomUtility.toInternalValue( pageFormat.getImageableY() ); this.imageableWidth = StrictGeomUtility.toInternalValue( pageFormat.getImageableWidth() ); this.imageableHeight = StrictGeomUtility.toInternalValue( pageFormat.getImageableHeight() ); this.globalX = globalX; this.globalY = globalY; this.orientation = pageFormat.getOrientation(); }