JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.page.awt
Class JCAWTPrinter

java.lang.Object
  |
  +--com.klg.jclass.page.JCPrinter
        |
        +--com.klg.jclass.page.awt.JCAWTPrinter

public class JCAWTPrinter
extends JCPrinter

Implements PrinterDriver interface.


Nested Class Summary
static class JCAWTPrinter.PrinterJobCancelledException
           
protected  class JCAWTPrinter.PrinterThread
          To get proper metrics for the printer we need to get its graphics.
 
Field Summary
protected  boolean abort
           
protected  boolean actuallyPrinting
           
protected  Stack clipStack
           
protected  com.klg.jclass.page.JCDocument document
           
protected  com.klg.jclass.page.JCPage firstPage
          First template page in document, used to set up correct PageFormat properties for initial page.
protected  int firstToPrint
           
protected  int lastToPrint
           
protected  PageFormat pageFormat
           
protected  PrinterJob printerJob
           
protected  JCAWTPrinter.PrinterThread printerThread
           
protected  boolean showDialog
           
protected  Thread thread
           
protected  PrinterException threadException
           
protected  boolean updatePageFormat
          True if the PageFormat should be updated with information from the passed page template (for the first page) or the document (for other pages).
 
Fields inherited from class com.klg.jclass.page.JCPrinter
bookmarkTree, bookmarkTreeVisible, collate, compressed, endPage, graphics, imageNumber, isDocOpen, numCopies, orientation, os, pageCount, printListeners, reverseOrder, startPage
 
Constructor Summary
JCAWTPrinter()
          Constructor -- uses 8.5 x 11 default page.
JCAWTPrinter(boolean showDialog)
          Constructor -- uses 8.5 x 11 default page.
JCAWTPrinter(List templates)
          Constructor with template list.
JCAWTPrinter(List templates, boolean showDialog)
          Constructor with template list.
JCAWTPrinter(PageFormat pageFormat)
          Constructor taking specialized PageFormat class.
JCAWTPrinter(PageFormat pageFormat, boolean showDialog)
          Constructor taking specialized PageFormat class.
JCAWTPrinter(PageFormat pageFormat, List templates)
          Constructor taking specialized PageFormat class and list of page templates.
JCAWTPrinter(PageFormat pageFormat, List templates, boolean showDialog)
          Constructor taking specialized PageFormat class and list of page templates.
JCAWTPrinter(PrinterJob printerJob, PageFormat pageFormat)
          Constructor taking specific PrinterJob and PageFormat.
JCAWTPrinter(PrinterJob printerJob, PageFormat pageFormat, boolean showDialog)
          Constructor taking specific PrinterJob and PageFormat.
JCAWTPrinter(PrinterJob printerJob, PageFormat pageFormat, List templates)
          Constructor taking specific PrinterJob and PageFormat as well as a list of page templates.
JCAWTPrinter(PrinterJob printerJob, PageFormat pageFormat, List templates, boolean showDialog)
          Constructor taking specific PrinterJob and PageFormat as well as a list of page templates.
 
Method Summary
 void beginPage(Rectangle2D pageSize, int pageNumber)
          PS Document Structuring Conventions comments, page orientation...
 void cancel()
          Cancel the pending job and kill the waiting thread.
 void cancelFromPrinterThread(PrinterException e)
          Cancel the pending job and note the exception that caused the printer thread to fail.
protected  void clearThread()
          Called by the print thread after it has finished printing (but before waking up the main thread) to clear out the variable that would impede another thread being created.
 void closeDocument(Rectangle2D pageSize)
          document completion (e.g.
 void closeDocument(Rectangle2D pageSize, boolean superclass)
          Convenience method with bogus boolean to overload the method and call super, since VisualAge doesn't understand calling the superclass from an inner class.
 void endPage(Rectangle2D pageSize)
          Page bounding box...
 Graphics getGraphics()
          Retruns null if user cancel this print job.
 boolean getShowDialog()
          Is the print dialog to be shown when printing is requested? True means show it.
protected  void initPrinterJob()
           
 boolean isImageScalable()
          Returns false since images sent to AWT Printer are pre-scaled.
 void openDocument(Rectangle2D pageSize)
          Any required initialisation (e.g.
 void openDocument(Rectangle2D pageSize, boolean superclass)
          Convenience method with bogus boolean to overload the method and call super, since VisualAge doesn't understand calling the superclass from an inner class.
 void print(com.klg.jclass.page.JCDocument document)
          Deprecated. Use document.print() instead.
protected  void printPage(com.klg.jclass.page.JCDocument document, int pageIndex)
          Print a range
 void registerDocument(com.klg.jclass.page.JCDocument document)
          Store the document being printed in this object so callbacks to the document can be made by the printer thread This is for internal use only.
 void registerFirstLast(int first, int last)
          Store the first and last page to be printed so that when printing actually starts, we know what we're supposed to print.
protected  void setGraphics(Graphics2D g)
           
 void setShowDialog(boolean showDialog)
          Deprecated. Not implemented -- its intended functionality has been superceded by the constructors for this class which take the showDialog parameter.
 void setup()
          Creates default styles, any other one-time initialisation Builds font families from available fonts.
protected  void updatePageFormat(com.klg.jclass.page.JCPage page)
          Update the current PageFormat object with properties from the current page being printed.
protected  void wakeUpMainThread()
          Called by the print thread after it has finished printing the document.
 
Methods inherited from class com.klg.jclass.page.JCPrinter
addPrintListener, getCollate, getFontFamilies, getNumCopies, getOrientation, getOutputPageEnd, getOutputPageStart, getOutputStream, getReverseOrder, isBookmarkTreeVisible, isCompressed, isDocumentOpen, isLandscape, output, output, output, output, removePrintListener, setCollate, setCompressed, setNumCopies, setOrientation, setOutputPageEnd, setOutputPageStart, setOutputStream, setReverseOrder, supportsHyperlinks
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

printerThread

protected JCAWTPrinter.PrinterThread printerThread

thread

protected Thread thread

printerJob

protected PrinterJob printerJob

actuallyPrinting

protected boolean actuallyPrinting

document

protected com.klg.jclass.page.JCDocument document

showDialog

protected boolean showDialog

clipStack

protected Stack clipStack

pageFormat

protected PageFormat pageFormat

abort

protected boolean abort

firstToPrint

protected int firstToPrint

lastToPrint

protected int lastToPrint

threadException

protected PrinterException threadException

firstPage

protected com.klg.jclass.page.JCPage firstPage
First template page in document, used to set up correct PageFormat properties for initial page. Only used if template list passed in in constructor.


updatePageFormat

protected boolean updatePageFormat
True if the PageFormat should be updated with information from the passed page template (for the first page) or the document (for other pages).

Constructor Detail

JCAWTPrinter

public JCAWTPrinter()
             throws JCAWTPrinter.PrinterJobCancelledException,
                    PrinterException
Constructor -- uses 8.5 x 11 default page. The Print Dialog will be popped up so the user can indicate which printer to use for metrics and printing. This should only be used for standard 8.5 x 11 documents. Documents with special page requirements such as landscape orientation or other page sizes should use the contructor that takes a list of page templates.


JCAWTPrinter

public JCAWTPrinter(boolean showDialog)
             throws JCAWTPrinter.PrinterJobCancelledException,
                    PrinterException
Constructor -- uses 8.5 x 11 default page. This should only be used for standard 8.5 x 11 documents. Documents with special page requirements such as landscape orientation or other page sizes should use the contructor that takes a list of page templates.

Parameters:
showDialog - a boolean; true means show the dialog, false means do not show the dialog -- use the default printer.

JCAWTPrinter

public JCAWTPrinter(List templates)
             throws JCAWTPrinter.PrinterJobCancelledException,
                    PrinterException
Constructor with template list. The Print Dialog will be popped up so the user can indicate which printer to use for metrics and printing. This constructor will handle documents with special page requirements such as landscape orientation or page sizes other than 8.5 by 11 by copying such information to the default PageFormat object used in printing.

Parameters:
templates - a List of page templates, the same one that will later be passed to the JCDocument constructor.

JCAWTPrinter

public JCAWTPrinter(List templates,
                    boolean showDialog)
             throws JCAWTPrinter.PrinterJobCancelledException,
                    PrinterException
Constructor with template list. This constructor will handle documents with special page requirements such as landscape orientation or page sizes other than 8.5 by 11 by copying such information to the default PageFormat object used in printing.

Parameters:
templates - a List of page templates, the same one that will later be passed to the JCDocument constructor.
showDialog - a boolean; true means show the dialog, false means do not show the dialog -- use the default printer.

JCAWTPrinter

public JCAWTPrinter(PageFormat pageFormat)
             throws JCAWTPrinter.PrinterJobCancelledException,
                    PrinterException
Constructor taking specialized PageFormat class. The Print Dialog will be popped up so the user can indicate which printer to use for metrics and printing. This constructor should only be used when the passed PageFormat object contains all formatting information neeeded for printing the document. Properties set on the document, such as page orientation and page size, will not be copied to this PageFormat object. If this is not desired, use the constructor that takes both a PageFormat object and a List of page templates instead.

Parameters:
pageFormat - the PageFormat object to use for page information.

JCAWTPrinter

public JCAWTPrinter(PageFormat pageFormat,
                    boolean showDialog)
             throws JCAWTPrinter.PrinterJobCancelledException,
                    PrinterException
Constructor taking specialized PageFormat class. This constructor should only be used when the passed PageFormat object contains all formatting information neeeded for printing the document. Properties set on the document, such as page orientation and page size, will not be copied to this PageFormat object. If this is not desired, use the constructor that takes both a PageFormat object and a List of page templates instead.

Parameters:
pageFormat - the PageFormat object to use for page information.
showDialog - a boolean; true means show the dialog, false means do not show the dialog -- use the default printer.

JCAWTPrinter

public JCAWTPrinter(PageFormat pageFormat,
                    List templates)
             throws JCAWTPrinter.PrinterJobCancelledException,
                    PrinterException
Constructor taking specialized PageFormat class and list of page templates. The Print Dialog will be popped up so the user can indicate which printer to use for metrics and printing. Page information such as page orientation and page size will be copied from the document settings to the passed PageFormat object during printing.

Parameters:
pageFormat - the PageFormat object to use for page information.
templates - a List of page templates, the same one that will later be passed to the JCDocument constructor.

JCAWTPrinter

public JCAWTPrinter(PageFormat pageFormat,
                    List templates,
                    boolean showDialog)
             throws JCAWTPrinter.PrinterJobCancelledException,
                    PrinterException
Constructor taking specialized PageFormat class and list of page templates. Page information such as page orientation and page size will be copied from the document settings to the passed PageFormat object during printing.

Parameters:
pageFormat - the PageFormat object to use for page information.
templates - a List of page templates, the same one that will later be passed to the JCDocument constructor.
showDialog - a boolean; true means show the dialog, false means do not show the dialog -- use the default printer.

JCAWTPrinter

public JCAWTPrinter(PrinterJob printerJob,
                    PageFormat pageFormat)
             throws JCAWTPrinter.PrinterJobCancelledException,
                    PrinterException
Constructor taking specific PrinterJob and PageFormat. The Print Dialog will be popped up so the user can indicate which printer to use for metrics and printing. This constructor should only be used when the passed PageFormat object contains all formatting information neeeded for printing the document. Properties set on the document, such as page orientation and page size, will not be copied to this PageFormat object. If this is not desired, use the constructor that takes both a PageFormat object and a List of page templates instead.

Parameters:
printerJob - the PrinterJob whose information will be used for printing
pageFormat - the PageFormat object to use for page information.

JCAWTPrinter

public JCAWTPrinter(PrinterJob printerJob,
                    PageFormat pageFormat,
                    boolean showDialog)
             throws JCAWTPrinter.PrinterJobCancelledException,
                    PrinterException
Constructor taking specific PrinterJob and PageFormat. This constructor should only be used when the passed PageFormat object contains all formatting information neeeded for printing the document. Properties set on the document, such as page orientation and page size, will not be copied to this PageFormat object. If this is not desired, use the constructor that takes both a PageFormat object and a List of page templates instead.

Parameters:
printerJob - the PrinterJob whose information will be used for printing
pageFormat - the PageFormat object to use for page information.
showDialog - a boolean; true means show the dialog, false means do not show the dialog -- use the default printer.

JCAWTPrinter

public JCAWTPrinter(PrinterJob printerJob,
                    PageFormat pageFormat,
                    List templates)
             throws JCAWTPrinter.PrinterJobCancelledException,
                    PrinterException
Constructor taking specific PrinterJob and PageFormat as well as a list of page templates. The Print Dialog will be popped up so the user can indicate which printer to use for metrics and printing. Page information such as page orientation and page size will be copied from the document settings to the passed PageFormat object during printing.

Parameters:
printerJob - the PrinterJob whose information will be used for printing
pageFormat - the PageFormat object to use for page information.
templates - a List of page templates, the same one that will later be passed to the JCDocument constructor.

JCAWTPrinter

public JCAWTPrinter(PrinterJob printerJob,
                    PageFormat pageFormat,
                    List templates,
                    boolean showDialog)
             throws JCAWTPrinter.PrinterJobCancelledException,
                    PrinterException
Constructor taking specific PrinterJob and PageFormat as well as a list of page templates. Page information such as page orientation and page size will be copied from the document settings to the passed PageFormat object during printing.

Parameters:
printerJob - the PrinterJob whose information will be used for printing
pageFormat - the PageFormat object to use for page information.
templates - a List of page templates, the same one that will later be passed to the JCDocument constructor.
showDialog - a boolean; true means show the dialog, false means do not show the dialog -- use the default printer.
Method Detail

setup

public void setup()
Creates default styles, any other one-time initialisation Builds font families from available fonts.

Specified by:
setup in class JCPrinter

isImageScalable

public boolean isImageScalable()
Returns false since images sent to AWT Printer are pre-scaled.

Specified by:
isImageScalable in class JCPrinter

registerDocument

public void registerDocument(com.klg.jclass.page.JCDocument document)
Store the document being printed in this object so callbacks to the document can be made by the printer thread This is for internal use only.


registerFirstLast

public void registerFirstLast(int first,
                              int last)
Store the first and last page to be printed so that when printing actually starts, we know what we're supposed to print. This is for internal use only.


openDocument

public void openDocument(Rectangle2D pageSize)
Any required initialisation (e.g. PostScript document headers, etc.)

Overrides:
openDocument in class JCPrinter
Parameters:
pageSize - a rectangle describing the size and location of the page

openDocument

public void openDocument(Rectangle2D pageSize,
                         boolean superclass)
Convenience method with bogus boolean to overload the method and call super, since VisualAge doesn't understand calling the superclass from an inner class.


wakeUpMainThread

protected void wakeUpMainThread()
Called by the print thread after it has finished printing the document. It wakes up the main thread so it can resume its activities.


clearThread

protected void clearThread()
Called by the print thread after it has finished printing (but before waking up the main thread) to clear out the variable that would impede another thread being created.


print

public void print(com.klg.jclass.page.JCDocument document)
Deprecated. Use document.print() instead.


closeDocument

public void closeDocument(Rectangle2D pageSize)
document completion (e.g. PDF cross-ref table and trailer)

Overrides:
closeDocument in class JCPrinter
Parameters:
pageSize - a rectangle describing the size and location of the page

closeDocument

public void closeDocument(Rectangle2D pageSize,
                          boolean superclass)
Convenience method with bogus boolean to overload the method and call super, since VisualAge doesn't understand calling the superclass from an inner class.


beginPage

public void beginPage(Rectangle2D pageSize,
                      int pageNumber)
PS Document Structuring Conventions comments, page orientation...

Overrides:
beginPage in class JCPrinter
Parameters:
pageSize - a rectangle describing the size and location of the page
pageNumber - the number of the new page

endPage

public void endPage(Rectangle2D pageSize)
Page bounding box...

Overrides:
endPage in class JCPrinter
Parameters:
pageSize - a rectangle describing the size and location of the page

initPrinterJob

protected void initPrinterJob()

updatePageFormat

protected void updatePageFormat(com.klg.jclass.page.JCPage page)
Update the current PageFormat object with properties from the current page being printed. Currently, only orientation and paper size are set on the PageFormat object.

Parameters:
page - JCPage object (perhaps a template page, perhaps a real document page) to query for PageFormat properties

getGraphics

public Graphics getGraphics()
Retruns null if user cancel this print job.

Overrides:
getGraphics in class JCPrinter

printPage

protected void printPage(com.klg.jclass.page.JCDocument document,
                         int pageIndex)
Print a range


setGraphics

protected void setGraphics(Graphics2D g)

setShowDialog

public void setShowDialog(boolean showDialog)
Deprecated. Not implemented -- its intended functionality has been superceded by the constructors for this class which take the showDialog parameter.

Is the print dialog to be shown when printing is requested? True means show it.


getShowDialog

public boolean getShowDialog()
Is the print dialog to be shown when printing is requested? True means show it.


cancel

public void cancel()
Cancel the pending job and kill the waiting thread.


cancelFromPrinterThread

public void cancelFromPrinterThread(PrinterException e)
Cancel the pending job and note the exception that caused the printer thread to fail.


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