All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.wildcrest.JTextPrinter

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----com.sun.java.swing.JComponent
                           |
                           +----com.wildcrest.JTextPrinter

public class JTextPrinter
extends JComponent
(C) Copyright 1999, Wildcrest Associates (http://www.wildcrest.com). All rights reserved.

A Swing (JFC) component for printing multipage rich text documents.

Prints the contents of any JTextPane (any StyledDocument) including embedded graphics and components. Supports pagination, headers, footers, margins, date and page numbering, multiple columns with optional title section, page breaks, page ranges, and print monitor job name control.


Constructor Index

 o JTextPrinter()
Construct a TextPrinter object

Method Index

 o addPropertyChangeListener(PropertyChangeListener)
 o getBottomMargin()
Returns the bottom margin of the document.
 o getCenterFooter()
Returns the center footer of the document.
 o getCenterHeader()
Returns the center header of the document.
 o getGapAboveFooter()
Returns the gap between the last line and the footer in inches.
 o getGapBelowHeader()
Returns the gap between the header and first line in inches.
 o getGapBetweenColumns()
Returns size of gap between columns in inches.
 o getHeaderFooterFont()
Returns the font specified for headers and footers.
 o getLeftFooter()
Returns the left footer of the document.
 o getLeftHeader()
Returns the left header of the document.
 o getLeftMargin()
Returns the left margin of the document.
 o getMainPane()
Returns the JTextPane containing the main body of the document to be printed.
 o getMaximumColumnWidth()
Returns maximum column width in pixels (negative value means no limit).
 o getNumberOfColumns()
Returns number of columns per page.
 o getPageRange()
Returns the page range of pages to be printed.
 o getPrintJobName()
Returns the print job name for this document.
 o getRightFooter()
Returns the right footer of the document.
 o getRightHeader()
Returns the right header of the document.
 o getRightMargin()
Returns the right margin of the document.
 o getTitlePane()
Returns the JTextPane containing an initial title section to be printed in single column mode.
 o getTopMargin()
Returns the top margin of the document.
 o isBoxAroundFooter()
Returns whether a box will be drawn around the footer.
 o isBoxAroundHeader()
Returns whether a box will be drawn around the header.
 o isLineAboveFooter()
Returns whether a line will be drawn above the footer.
 o isLineBelowHeader()
Returns whether a line will be drawn below the header.
 o paint(Graphics)
 o print()
Method for printing the currently specified single column title section (specified using setTitlePane) followed by the currently specified single or multiple column main document (specified using setMainPane)
 o print(JTextPane)
Method for printing the StyledDocument of a JTextPane as the main document with no title section
 o print(JTextPane, JTextPane)
Method for printing the StyledDocument of a first JTextPane as a single column title section followed by the StyledDocument of a second JTextPane as the main (single or multiple column) document
 o removePropertyChangeListener(PropertyChangeListener)
 o setBottomMargin(double)
Sets the bottom margin below footer in inches.
 o setBoxAroundFooter(boolean)
Sets whether to draw a box around the footerr.
 o setBoxAroundHeader(boolean)
Sets whether to draw a box around the header.
 o setCenterFooter(String)
Sets the center footer of the document.
 o setCenterHeader(String)
Sets the center header of the document.
 o setGapAboveFooter(double)
Sets the gap between the last line of text and the footer in inches.
 o setGapBelowHeader(double)
Sets the gap between the header and first line of text in inches.
 o setGapBetweenColumns(double)
Sets gap between columns in inches
 o setHeaderFooterFont(Font)
Sets the font for printing the headers and footers of the document.
 o setLeftFooter(String)
Sets the left footer of the document.
 o setLeftHeader(String)
Sets the left header of the document.
 o setLeftMargin(double)
Sets the left margin in inches.
 o setLineAboveFooter(boolean)
Sets whether to draw a line above the footerr.
 o setLineBelowHeader(boolean)
Sets whether to draw a line below the header.
 o setMainPane(JTextPane)
Sets the JTextPane containing the main body of the document to be printed.
 o setMaximumColumnWidth(int)
Sets maximum column width in pixels
 o setNumberOfColumns(int)
Sets number of columns per page.
 o setPageRange(String)
Sets the page range of pages to be printed.
 o setPrintJobName(String)
Sets the print job name that appears in the system print monitor.
 o setRightFooter(String)
Sets the right footer of the document.
 o setRightHeader(String)
Sets the right header of the document.
 o setRightMargin(double)
Sets the right margin in inches.
 o setTitlePane(JTextPane)
Sets the (optional) JTextPane containing a title section to be printed in single column mode before the main document.
 o setTopMargin(double)
Sets the top margin above header in inches.

Constructors

 o JTextPrinter
 public JTextPrinter()
Construct a TextPrinter object

Methods

 o setMainPane
 public void setMainPane(JTextPane mainPane)
Sets the JTextPane containing the main body of the document to be printed.

Parameters:
mainPane - the JTextPane containing the main body of the document to be printed
 o getMainPane
 public synchronized JTextPane getMainPane()
Returns the JTextPane containing the main body of the document to be printed.

 o setTitlePane
 public void setTitlePane(JTextPane titlePane)
Sets the (optional) JTextPane containing a title section to be printed in single column mode before the main document. Used for specifying an optional single column title section or cover page of a multiple column document.

Parameters:
titlePane - a JTextPane containing an initial title section to be printed in single column mode
 o getTitlePane
 public synchronized JTextPane getTitlePane()
Returns the JTextPane containing an initial title section to be printed in single column mode.

 o setHeaderFooterFont
 public void setHeaderFooterFont(Font font)
Sets the font for printing the headers and footers of the document.

Parameters:
font - font used for printing headers and footers of document. Default: Serif, PLAIN, 10 NOTE: value cannot be changed in free version.
 o getHeaderFooterFont
 public synchronized Font getHeaderFooterFont()
Returns the font specified for headers and footers.

 o setLeftFooter
 public void setLeftFooter(String leftFooter)
Sets the left footer of the document.

Parameters:
leftFooter - string representing the leftFooter. All occurrences of ### (3 pound signs) replaced by current page number. All strings between pairs of ||| (3 vertical bars) passed to Java SimpleDateFormat class and used to format the current date & time. Default: Page ###
See Also:
SimpleDateFormat
 o getLeftFooter
 public synchronized String getLeftFooter()
Returns the left footer of the document.

 o setCenterFooter
 public void setCenterFooter(String centerFooter)
Sets the center footer of the document.

Parameters:
centerFooter - string representing the center footer. Page number and data & time formatting same as for setLeftFooter. Default: |||EEE, MMM d, yyyy|||
 o getCenterFooter
 public synchronized String getCenterFooter()
Returns the center footer of the document.

 o setRightFooter
 public void setRightFooter(String rightFooter)
Sets the right footer of the document.

Parameters:
rightFooter - string representing the right footer. Page number and data & time formatting same as for setLeftFooter. Default: |||hh:mm:ss a zzz|||
 o getRightFooter
 public synchronized String getRightFooter()
Returns the right footer of the document.

 o setLeftHeader
 public void setLeftHeader(String leftHeader)
Sets the left header of the document.

Parameters:
leftHeader - string representing the left header Page number and data & time formatting same as for setLeftFooter. Default: JTextPrinter Wildcrest Associates copyright notice
NOTE: value cannot be changed in free version.
 o getLeftHeader
 public synchronized String getLeftHeader()
Returns the left header of the document.

 o setCenterHeader
 public void setCenterHeader(String centerHeader)
Sets the center header of the document.

Parameters:
centerHeader - string representing the center header Page number and data & time formatting same as for setLeftFooter. Default: empty
NOTE: value cannot be changed in free version.
 o getCenterHeader
 public synchronized String getCenterHeader()
Returns the center header of the document.

 o setRightHeader
 public void setRightHeader(String rightHeader)
Sets the right header of the document.

Parameters:
rightHeader - string representing the right header Page number and data & time formatting same as for setLeftFooter. Default: JTextPrinter Wildcrest Associates copyright notice
NOTE: value cannot be changed in free version.
 o getRightHeader
 public synchronized String getRightHeader()
Returns the right header of the document.

 o setLeftMargin
 public void setLeftMargin(double leftMargin)
Sets the left margin in inches.

Parameters:
leftMargin - double representing left margin in inches. Default: JDK and OS specific (see documentation)
 o getLeftMargin
 public synchronized double getLeftMargin()
Returns the left margin of the document.

 o setRightMargin
 public void setRightMargin(double rightMargin)
Sets the right margin in inches.

Parameters:
rightMargin - double representing right margin in inches. Default: JDK and OS specific (see documentation)
 o getRightMargin
 public synchronized double getRightMargin()
Returns the right margin of the document.

 o setTopMargin
 public void setTopMargin(double topMargin)
Sets the top margin above header in inches.

Parameters:
topMargin - double representing top margin above header in inches. Default: JDK and OS specific (see documentation)
 o getTopMargin
 public synchronized double getTopMargin()
Returns the top margin of the document.

 o setBottomMargin
 public void setBottomMargin(double bottomMargin)
Sets the bottom margin below footer in inches.

Parameters:
bottomMargin - double representing bottom margin below footer in inches. Default JDK and OS specific (see documentation)
 o getBottomMargin
 public synchronized double getBottomMargin()
Returns the bottom margin of the document.

 o setGapBelowHeader
 public void setGapBelowHeader(double gapBelowHeader)
Sets the gap between the header and first line of text in inches.

Parameters:
gapBelowHeader - double representing gap between the header and first line of text. Default 0.25
 o getGapBelowHeader
 public synchronized double getGapBelowHeader()
Returns the gap between the header and first line in inches.

 o setGapAboveFooter
 public void setGapAboveFooter(double gapAboveFooter)
Sets the gap between the last line of text and the footer in inches.

Parameters:
gapAboveFooter - double representing gap between the last line of text and the footer in inches. Default 0.125
 o getGapAboveFooter
 public synchronized double getGapAboveFooter()
Returns the gap between the last line and the footer in inches.

 o setPrintJobName
 public void setPrintJobName(String printJobName)
Sets the print job name that appears in the system print monitor.

Parameters:
printJobName - string representing the print job name. Default: "JTextPrinter print document"
 o getPrintJobName
 public synchronized String getPrintJobName()
Returns the print job name for this document.

 o setPageRange
 public void setPageRange(String pageRange)
Sets the page range of pages to be printed. Page ranges specified using same syntax as Microsoft Word, i.e., values separated by commas, values may be a single page number or two page numbers separated by a hyphen. Examples: 1,3,5 1-3,6,8-12 0-1000 Empty string means print all pages. Pages print in order regardless of order in page range.

Parameters:
pageRange - string representing the page range of pages to be printed. Default: "" (= all)
 o getPageRange
 public synchronized String getPageRange()
Returns the page range of pages to be printed.

 o setLineBelowHeader
 public void setLineBelowHeader(boolean lineBelowHeader)
Sets whether to draw a line below the header.

Parameters:
lineBelowHeader - boolean representing whether to draw a line below the header. Default: false
 o isLineBelowHeader
 public synchronized boolean isLineBelowHeader()
Returns whether a line will be drawn below the header.

 o setLineAboveFooter
 public void setLineAboveFooter(boolean lineAboveFooter)
Sets whether to draw a line above the footerr.

Parameters:
lineAboveFooter - boolean representing whether to draw a line above the footer. Default: true
 o isLineAboveFooter
 public synchronized boolean isLineAboveFooter()
Returns whether a line will be drawn above the footer.

 o setBoxAroundHeader
 public void setBoxAroundHeader(boolean boxAroundHeader)
Sets whether to draw a box around the header.

Parameters:
boxAroundHeader - boolean representing whether to draw a box around the header. Default: true
 o isBoxAroundHeader
 public synchronized boolean isBoxAroundHeader()
Returns whether a box will be drawn around the header.

 o setBoxAroundFooter
 public void setBoxAroundFooter(boolean boxAroundFooter)
Sets whether to draw a box around the footerr.

Parameters:
boxAroundFooter - boolean representing whether to draw a box around the footer. Default: false
 o isBoxAroundFooter
 public synchronized boolean isBoxAroundFooter()
Returns whether a box will be drawn around the footer.

 o setNumberOfColumns
 public void setNumberOfColumns(int numberOfColumns)
Sets number of columns per page.

Parameters:
numberOfColumns - int representing how many columns per page in main document. Default: 1
 o getNumberOfColumns
 public synchronized int getNumberOfColumns()
Returns number of columns per page.

 o setGapBetweenColumns
 public void setGapBetweenColumns(double gapBetweenColumns)
Sets gap between columns in inches

Parameters:
gapBetweenColumns - double representing size of gap between columns in inches. Default: 0.1
 o getGapBetweenColumns
 public synchronized double getGapBetweenColumns()
Returns size of gap between columns in inches.

 o setMaximumColumnWidth
 public void setMaximumColumnWidth(int maximumColumnWidth)
Sets maximum column width in pixels

Parameters:
maximumColumnWidth - int representing maximum column width in pixels (negative value means no limit). Default: -1
 o getMaximumColumnWidth
 public synchronized int getMaximumColumnWidth()
Returns maximum column width in pixels (negative value means no limit).

 o addPropertyChangeListener
 public void addPropertyChangeListener(PropertyChangeListener l)
Overrides:
addPropertyChangeListener in class JComponent
 o removePropertyChangeListener
 public void removePropertyChangeListener(PropertyChangeListener l)
Overrides:
removePropertyChangeListener in class JComponent
 o print
 public void print(JTextPane mainPane)
Method for printing the StyledDocument of a JTextPane as the main document with no title section

Parameters:
mainPane - JTextPane whose StyledDocument is to be printed
 o print
 public void print(JTextPane titlePane,
                   JTextPane mainPane)
Method for printing the StyledDocument of a first JTextPane as a single column title section followed by the StyledDocument of a second JTextPane as the main (single or multiple column) document

Parameters:
titlePane - JTextPane whose StyledDocument is to be printed as the title section
mainPane - JTextPane whose StyledDocument is to be printed as the main document
 o print
 public void print()
Method for printing the currently specified single column title section (specified using setTitlePane) followed by the currently specified single or multiple column main document (specified using setMainPane)

 o paint
 public synchronized void paint(Graphics g)
Overrides:
paint in class JComponent

All Packages  Class Hierarchy  This Package  Previous  Next  Index