All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.wildcrest.TextPrinter

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----com.wildcrest.TextPrinter

public class TextPrinter
extends Canvas
(C) Copyright 1998, Wildcrest Associates (http://www.wildcrest.com). All rights reserved.

A class to perform hardcopy printing of multipage single font text documents. Supports pagination, line wrap, line separators, line spacing, tab expansion, margins, headers and footers, dates and page numbering, and font selection.


Constructor Index

 o TextPrinter()
Construct a TextPrinter object

Method Index

 o addPropertyChangeListener(PropertyChangeListener)
 o getBottomMargin()
Returns the bottom margin of the document.
 o getFont()
Returns the font specified for printing.
 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 getInchesPerTab()
Returns the inches per tab stop.
 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 getLineSpacing()
Returns the line spacing of the 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 getText()
Returns the text string to be printed.
 o getTopMargin()
Returns the top margin of the document.
 o getWrap()
Returns whether automatic line wrapping is enabled or disabled.
 o paint(Graphics)
 o print()
Same as print(String) but uses string from most recent setText call
 o print(String)
Print a multipage single font text document, including pagination, line wrap, line separators, line spacing, tab expansion, margins, headers, footers, date and page numbering, and font selection.
 o removePropertyChangeListener(PropertyChangeListener)
 o setBottomMargin(double)
Sets the bottom margin below footer in inches.
 o setFont(Font)
Sets the font for printing the body 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 setInchesPerTab(double)
Sets the inches per tab stop.
 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 setLineSpacing(double)
Sets the line spacing, in multiples of fontHeight.
 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 setText(String)
Sets the (long) text string comprising the entire text document to be printed.
 o setTopMargin(double)
Sets the top margin above header in inches.
 o setWrap(boolean)
Sets whether automatic line wrap is enabled or disabled.

Constructors

 o TextPrinter
 public TextPrinter()
Construct a TextPrinter object

Methods

 o setText
 public void setText(String string)
Sets the (long) text string comprising the entire text document to be printed. Can have embedded line.separators to indicate hard line boundaries or can rely on line wrapping feature to break lines.

Parameters:
string - the (long) string to be printed
 o getText
 public synchronized String getText()
Returns the text string to be printed.

 o setInchesPerTab
 public void setInchesPerTab(double inchesPerTab)
Sets the inches per tab stop.

Parameters:
inchesPerTab - inches per tab stop. Default: 0.5
 o getInchesPerTab
 public synchronized double getInchesPerTab()
Returns the inches per tab stop.

 o setLineSpacing
 public void setLineSpacing(double lineSpacing)
Sets the line spacing, in multiples of fontHeight.

Parameters:
lineSpacing - in multiples of fontHeight (1.0 = single spacing, 2.0 = double spacing, etc.) Default: 1.0
 o getLineSpacing
 public synchronized double getLineSpacing()
Returns the line spacing of the document.

 o setFont
 public void setFont(Font font)
Sets the font for printing the body of the document.

Parameters:
font - font used for printing body of document. Default: SansSerif, PLAIN, 14
Overrides:
setFont in class Component
 o getFont
 public synchronized Font getFont()
Returns the font specified for printing.

Overrides:
getFont in class Component
 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 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: |||EEE, MMM d, yyyy 'at' hh:mm:ss a zzz|||
See Also:
SimpleDateFormat
 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: TextPrinter 1.0, (C) Copyright 1998
NOTE: value cannot be changed in free version.
See Also:
SimpleDateFormat
 o getLeftHeader
 public synchronized String getLeftHeader()
Returns the left 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: Wildcrest Associates (http://www.wildcrest.com)
NOTE: value cannot be changed in free version.
See Also:
SimpleDateFormat
 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 - left margin in inches (in addition to physical margin). Default: 0.0
 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 - right margin in inches (in addition to physical margin). Default: 0.3
NOTE: due to cumulative font metrics and page width being imprecise on certain platforms, setting rightMargin greater than 0 is recommended to avoid clipping of rightmost characters. Also, due to a bug in the Windows port of JDK 1.1.4 and earlier, printer pageWidth is underreported by about 1.65 inches. To compensate, negative values are also allowed for the rightMargin and a value of -1.65 is recommended on Windows platforms.
 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 - top margin above header in inches (in addition to physical margin). Default: 0.0
 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 - bottom margin below footer in inches (in addition to physical margin). Default 0.0
NOTE: due to a bug in the Windows port of JDK 1.1.4 and earlier, printer pageHeight is underreported by about 2.0 inches. To compensate, negative values are allowed for the bottomMargin and a value of -2.0 is recommended on Windows platforms.
 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 - gap between the header and first line of text. Default 0.3
 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 - gap between the last line of text and the footer in inches. Default 0.3
 o getGapAboveFooter
 public synchronized double getGapAboveFooter()
Returns the gap between the last line and the footer in inches.

 o setWrap
 public void setWrap(boolean wrap)
Sets whether automatic line wrap is enabled or disabled.

Parameters:
wrap - whether automatic line wrap is enabled or disabled. Default: true
 o getWrap
 public synchronized boolean getWrap()
Returns whether automatic line wrapping is enabled or disabled.

 o addPropertyChangeListener
 public void addPropertyChangeListener(PropertyChangeListener l)
 o removePropertyChangeListener
 public void removePropertyChangeListener(PropertyChangeListener l)
 o print
 public void print(String string)
Print a multipage single font text document, including pagination, line wrap, line separators, line spacing, tab expansion, margins, headers, footers, date and page numbering, and font selection.

Parameters:
string - a (long) string containing entire document to be printed, which may (or may not) have embedded line.separators and tabs
 o print
 public void print()
Same as print(String) but uses string from most recent setText call

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

All Packages  Class Hierarchy  This Package  Previous  Next  Index