JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.page
Class JCPrinter

java.lang.Object
  |
  +--com.klg.jclass.page.JCPrinter
Direct Known Subclasses:
JCAWTPrinter, JCAWTScreenPrinter, JCEPSPrinter, JCHTMLPrinter, JCPCLPrinter, JCPDFPrinter, JCPostScriptPrinter

public abstract class JCPrinter
extends Object

Deprecated, not for public usage. Interface methods for document handling.


Field Summary
protected  TreeModel bookmarkTree
          The Bookmark Tree used for this output -- usually a DefaultTreeModel class.
protected  boolean bookmarkTreeVisible
          The visibility of the Bookmark Tree.
protected  boolean collate
          Are multiple copies interleaved (as opposed to each page copied in turn).
protected  boolean compressed
          True if output should be compressed.
protected  int endPage
          The last page which will be printed (-1 indicates last available).
protected  Graphics2D graphics
          The graphics which represent the output drawable for this printer.
 int imageNumber
          The number of the next image created on a page.
protected  boolean isDocOpen
          Flags if the document is open for printing.
protected  int numCopies
          The number of copies of each page printed.
protected  int orientation
          The orientation of the current page printing.
protected  OutputStream os
          Current output stream on which "printed" graphics are written.
protected  int pageCount
          The number of pages which have been printed.
protected  com.klg.jclass.util.JCListenerList printListeners
          The listeners for flow events.
protected  boolean reverseOrder
          Are pages output last-page-first.
protected  int startPage
          The first page which will be printed (zero-based).
 
Constructor Summary
JCPrinter()
          Constructor
 
Method Summary
 void addPrintListener(com.klg.jclass.page.JCPrintListener listener)
          Adds a listener for print events.
 void beginPage(Rectangle2D pageSize, int pageNumber)
          Starts a page, since there may be printer-specific actions to take (for example, PS Document Structuring Conventions comments, page orientation...).
 void closeDocument(Rectangle2D pageSize)
          Document completion (for example, PDF cross-ref table and trailer) and event notification.
 void endPage(Rectangle2D pageSize)
          Ends a page (PDF Page bounding box...) and sends event notification.
 boolean getCollate()
          Gets the collate flag.
 List getFontFamilies()
          Gets a list of available font families.
 Graphics getGraphics()
          Gets the graphics context used by this printer.
 int getNumCopies()
          Gets number of copies.
protected  int getOrientation()
          Gets the page orientation.
 int getOutputPageEnd()
          Gets end page in the range to print.
 int getOutputPageStart()
          Gets the first page in the range to print.
 OutputStream getOutputStream()
          Gets output stream.
 boolean getReverseOrder()
          Gets reverse order
 boolean isBookmarkTreeVisible()
          Not supported in PageLayout.
 boolean isCompressed()
          Gets the value of the Compressed property, which determines whether the content of pages will be compressed.
 boolean isDocumentOpen()
          Checks if the document is open
abstract  boolean isImageScalable()
          Returns true if printer does own image scaling (as in PDF, PostScript and PCL) or false if we need to tell the java Image class to scale itself.
protected  boolean isLandscape(double width, double height)
          Is this a landscape page? The method returns true if the width is greater than the height.
 void openDocument(Rectangle2D pageSize)
          Any required initialization and event notification.
protected  void output(byte oneByte)
          Write the specified byte to the output stream.
protected  void output(byte[] bytes)
          Write the given bytes to the output stream.
protected  void output(byte[] bytes, int off, int len)
          Write the specified bytes to the output stream.
protected  void output(String string)
          Writes the given String to the output stream, adjusting as necessary.
 void removePrintListener(com.klg.jclass.page.JCPrintListener listener)
          Removes a listener for print events.
 void setCollate(boolean collate)
          Sets the collate flag.
 void setCompressed(boolean compressed)
          Sets the value of the Compressed property, which determines whether the content of pages will be compressed.
 void setNumCopies(int numCopies)
          Sets number of copies.
protected  void setOrientation(int orient)
          Sets the orientation of the page to be printed.
 void setOutputPageEnd(int endPage)
          Sets end page in the range to print.
 void setOutputPageStart(int startPage)
          Sets the first page in the range to print.
 void setOutputStream(OutputStream os)
          Sets output stream for PostScript, PDF and PCL printers.
 void setReverseOrder(boolean reverseOrder)
          Sets reverse order
abstract  void setup()
          Creates default styles, any other one-time initialization.
 boolean supportsHyperlinks()
          Returns True if this printer supports hyperlinks.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

graphics

protected Graphics2D graphics
The graphics which represent the output drawable for this printer.


os

protected OutputStream os
Current output stream on which "printed" graphics are written.


collate

protected boolean collate
Are multiple copies interleaved (as opposed to each page copied in turn).


reverseOrder

protected boolean reverseOrder
Are pages output last-page-first.


numCopies

protected int numCopies
The number of copies of each page printed.


endPage

protected int endPage
The last page which will be printed (-1 indicates last available).


startPage

protected int startPage
The first page which will be printed (zero-based).


pageCount

protected int pageCount
The number of pages which have been printed.


printListeners

protected com.klg.jclass.util.JCListenerList printListeners
The listeners for flow events.


isDocOpen

protected boolean isDocOpen
Flags if the document is open for printing.


orientation

protected int orientation
The orientation of the current page printing.


compressed

protected boolean compressed
True if output should be compressed.


bookmarkTree

protected TreeModel bookmarkTree
The Bookmark Tree used for this output -- usually a DefaultTreeModel class.


bookmarkTreeVisible

protected boolean bookmarkTreeVisible
The visibility of the Bookmark Tree.


imageNumber

public int imageNumber
The number of the next image created on a page.

Constructor Detail

JCPrinter

public JCPrinter()
Constructor

Method Detail

setup

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


isImageScalable

public abstract boolean isImageScalable()
Returns true if printer does own image scaling (as in PDF, PostScript and PCL) or false if we need to tell the java Image class to scale itself.


openDocument

public void openDocument(Rectangle2D pageSize)
Any required initialization and event notification.

Parameters:
pageSize - a rectangle describing the size and location of the page

closeDocument

public void closeDocument(Rectangle2D pageSize)
Document completion (for example, PDF cross-ref table and trailer) and event notification.

Parameters:
pageSize - a rectangle describing the size and location of the page

beginPage

public void beginPage(Rectangle2D pageSize,
                      int pageNumber)
Starts a page, since there may be printer-specific actions to take (for example, PS Document Structuring Conventions comments, page orientation...). Does event notification, too.

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)
Ends a page (PDF Page bounding box...) and sends event notification.

Parameters:
pageSize - a rectangle describing the size and location of the page

isDocumentOpen

public boolean isDocumentOpen()
Checks if the document is open

Returns:
True if the document has been opened for printing

setCompressed

public void setCompressed(boolean compressed)
Sets the value of the Compressed property, which determines whether the content of pages will be compressed.
Note: Even when set to true, the functionality of this property depends upon the existence of compression in the output format.

Parameters:
compressed - true if compression should be performed; false otherwise

isCompressed

public boolean isCompressed()
Gets the value of the Compressed property, which determines whether the content of pages will be compressed.
Note: Even when set to true, the functionality of this property depends upon the existence of compression in the output format.

Returns:
true if compression will be performed; false otherwise

setCollate

public void setCollate(boolean collate)
Sets the collate flag.

Parameters:
collate - True means that the complete document is output for each copy

getCollate

public boolean getCollate()
Gets the collate flag.

Returns:
True means that the complete document is output for each copy

setNumCopies

public void setNumCopies(int numCopies)
Sets number of copies.

Parameters:
numCopies - integer indicating the number of copies to be printed

getNumCopies

public int getNumCopies()
Gets number of copies.

Returns:
numCopies integer indicating the number of copies to be printed

setOutputPageEnd

public void setOutputPageEnd(int endPage)
Sets end page in the range to print.

Parameters:
endPage - an int the last page to print

getOutputPageEnd

public int getOutputPageEnd()
Gets end page in the range to print.

Returns:
endPage an int the last page to print

setOutputPageStart

public void setOutputPageStart(int startPage)
Sets the first page in the range to print.

Parameters:
startPage - an int, the first page in the range to print

getOutputPageStart

public int getOutputPageStart()
Gets the first page in the range to print.

Returns:
startPage an int, the first page in the range to print

setOutputStream

public void setOutputStream(OutputStream os)
Sets output stream for PostScript, PDF and PCL printers.

Parameters:
os - the stream to which output will be written

getOutputStream

public OutputStream getOutputStream()
Gets output stream.

Returns:
the stream to which output will be written

setReverseOrder

public void setReverseOrder(boolean reverseOrder)
Sets reverse order

Parameters:
reverseOrder - True if pages are to be printed in reverse order

getReverseOrder

public boolean getReverseOrder()
Gets reverse order

Returns:
True if pages are to be printed in reverse order, false otherwise

getFontFamilies

public List getFontFamilies()
Gets a list of available font families.

Returns:
a list of font families supported by this printer

isBookmarkTreeVisible

public boolean isBookmarkTreeVisible()
Not supported in PageLayout. Exists for compatibility. Gets the state of the Bookmark Tree. In PDF output, a value of true means that the Bookmark tab will automatically expand when the document is opened by the viewer. A value of false (the default) means that the Bookmark tab will be existent, but not expanded until the user chooses to expand it.

Returns:
the visibility of the Bookmark tree

supportsHyperlinks

public boolean supportsHyperlinks()
Returns True if this printer supports hyperlinks. Should be overridden by printer subclasses that wish to support hyperlinks.

Returns:
True if printer supports hyperlinks; false otherwise

getGraphics

public Graphics getGraphics()
Gets the graphics context used by this printer.


setOrientation

protected void setOrientation(int orient)
Sets the orientation of the page to be printed. Used only for temporary storage; this is not a property of the printer. Valid values are JCPage.AUTOMATIC (to be determined by the page size), JCPage.PORTRAIT, or JCPage.LANDSCAPE.

Parameters:
orient - the orientation of this page

getOrientation

protected int getOrientation()
Gets the page orientation. Used only for temporary storage; this is not a property of the printer. Valid values are JCPage.AUTOMATIC (to be determined by the page size), JCPage.PORTRAIT, or JCPage.LANDSCAPE.

Returns:
the orientation of the page being printed.

isLandscape

protected boolean isLandscape(double width,
                              double height)
Is this a landscape page? The method returns true if the width is greater than the height.


output

protected void output(String string)
Writes the given String to the output stream, adjusting as necessary. Write a carriage return character after the end of the string, just to keep things nicely readable.

Parameters:
string - the commands or data to be written to the output stream

output

protected void output(byte[] bytes)
Write the given bytes to the output stream. Do *not* write a carriage return at the end of the bytes. Leave that up to the caller.


output

protected void output(byte[] bytes,
                      int off,
                      int len)
Write the specified bytes to the output stream. Do *not* write a carriage return at the end of the bytes. Leave that up to the caller.


output

protected void output(byte oneByte)
Write the specified byte to the output stream. Do *not* write a carriage return after the bytes. Leave that up to the caller.


addPrintListener

public void addPrintListener(com.klg.jclass.page.JCPrintListener listener)
Adds a listener for print events.

See Also:
JCPrintEvent, JCPrintListener

removePrintListener

public void removePrintListener(com.klg.jclass.page.JCPrintListener listener)
Removes a listener for print events.


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