JClass DesktopViews 6.3.0 API
Documentation

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.


Field Summary
protected  boolean collate
           
protected  int copies
           
protected  int currentPage
           
protected  int first
           
protected  boolean firstPass
           
protected  int last
           
protected  int lastPageIndex
           
protected  int numPages
           
protected  int pageCount
           
protected  int pageIncr
           
protected  PrinterJob pj
           
protected  boolean reverse
           
 
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Constructor Summary
JCAWTPrinter.PrinterThread(PrinterJob pj)
           
 
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
 

Field Detail

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
Constructor Detail

JCAWTPrinter.PrinterThread

public JCAWTPrinter.PrinterThread(PrinterJob pj)
Method Detail

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()

Copyright © 2004 Quest Software Inc..
All rights reserved.