com.klg.jclass.page.awt
Class JCAWTPrinter.PrinterThread
java.lang.Object
|
+--com.klg.jclass.page.awt.JCAWTPrinter.PrinterThread
- All Implemented Interfaces:
- Printable, Runnable
- Enclosing class:
- JCAWTPrinter
- protected class JCAWTPrinter.PrinterThread
- extends Object
- implements Runnable, Printable
To get proper metrics for the printer we need to get
its graphics. But, you cannot get a printer's graphics
unless you actually print something. Classic chicken and
egg problem. That is, we don't know what to print until
we have used the metrics to figure out what will fit on a
page. So, we start a print job to get the graphics context.
Once we have it we immediately suspend the printing thread
so we now have the luxury of using the gc. Once we have
rendered all the document's pages using said gc we awake
the printing thread to print those pages.
Method Summary |
int |
print(Graphics g,
PageFormat pf,
int pageIndex)
Called by the Java2 printing mechanism. |
void |
run()
This will be run on the "PageLayout print thread" thread. |
void |
wakeUp()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
pj
protected PrinterJob pj
copies
protected int copies
first
protected int first
last
protected int last
pageCount
protected int pageCount
collate
protected boolean collate
reverse
protected boolean reverse
currentPage
protected int currentPage
lastPageIndex
protected int lastPageIndex
pageIncr
protected int pageIncr
numPages
protected int numPages
firstPass
protected boolean firstPass
JCAWTPrinter.PrinterThread
public JCAWTPrinter.PrinterThread(PrinterJob pj)
run
public void run()
- This will be run on the "PageLayout print thread" thread.
It will start the print job. Java2 printing uses a callback
method of printing. The callback is made to the "print" method
below. The coveted Graphics object is passed in.
- Specified by:
run
in interface Runnable
print
public int print(Graphics g,
PageFormat pf,
int pageIndex)
throws PrinterException
- Called by the Java2 printing mechanism.
- Specified by:
print
in interface Printable
PrinterException
wakeUp
public void wakeUp()