com.openpcl.viewer.printing
Class PosPrintPageableInterface
java.lang.Object
com.openpcl.viewer.printing.PosPrintPageableInterface
- All Implemented Interfaces:
- Pageable
public class PosPrintPageableInterface
- extends Object
- implements Pageable
Specify the Pageable interface 3 methods for the PrinterJob to call at the start of printing each page.
- Author:
- howard 8/24/06
This class is tricky to understand and use but here's the explanation:
The JDK java.awt.print.Pageable interface that this class implements, specifies 3 getters
that the JDK java.awt.print.PrinterJob calls at the start of printing each page.
You set this Pageable object on the PrinterJob object using: PrinterJob.setPageable(pageableObject);
Whatever these 3 getters return, controls the printing for each page.
The 3 getters are:
1. Get the total number of pages. public int getNumberOfPages()
2. Get the JDK java.awt.print.PageFormat instance object.
public PageFormat getPageFormat(int pForPageNumber)
3. Get the JDK java.awt.print.Printable instance object.
public Printable getPrintable(int pageIndex)
which then for each page, PrinterJob calls this Printable interface specified method:
print(Graphics g, PageFormat pPageFormat, int pPageNumber)
that passes to the PageFormat object returned from the Pageable object (#2 just above this).
and yes, it's confusing to try to understand how it all works but this is how the Sun JDK Java printing
is set up so that's why we've got to do it this way here.
Where to get the number of pages from and how to decide if a page is letter or legal and what to
draw on the page using Graphics drawing commands, comes from the print ArrayList that has the
PosTreeNode for each page to print, which has all the DSP values from the Blockument file,
plus all the original PCL bytes.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PosPrintPageableInterface
public PosPrintPageableInterface(PosView pPosView)
getNumberOfPages
public int getNumberOfPages()
- Specified by:
getNumberOfPages
in interface Pageable
getPageFormat
public PageFormat getPageFormat(int pForPageNumber)
throws IndexOutOfBoundsException
- Specified by:
getPageFormat
in interface Pageable
- Throws:
IndexOutOfBoundsException
getPrintable
public Printable getPrintable(int pForPageNumber)
throws IndexOutOfBoundsException
- Specified by:
getPrintable
in interface Pageable
- Throws:
IndexOutOfBoundsException
setPrintable
public void setPrintable(Printable pPrintableInterface)
setPagesToPrint
public void setPagesToPrint(ArrayList<PosTreeNode> pPagesToPrintArrayList)
setPosPrintSetupDialogChoices
public void setPosPrintSetupDialogChoices(PosPrintSetupDialogChoices pPosPrintSetupDialogChoices)
OpenPCL http://www.openpcl.com