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-1999, 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, date and page numbering,
font selection, margins, headers, footers, page range, page breaks, and print monitor job name.
-
TextPrinter()
- Construct a TextPrinter object
-
addPropertyChangeListener(PropertyChangeListener)
-
-
getAbsoluteTabs()
- Returns whether tabs are absolute or relative.
-
getBottomMargin()
- Returns the bottom margin of the document.
-
getCenterFooter()
- Returns the center footer of the document.
-
getCenterHeader()
- Returns the center header of the document.
-
getGapAboveFooter()
- Returns the gap between the last line and the footer in inches.
-
getGapBelowHeader()
- Returns the gap between the header and first line in inches.
-
getHeaderFooterFont()
- Returns the font specified for headers and footers.
-
getInchesPerTab()
- Returns the inches per tab stop.
-
getLeftFooter()
- Returns the left footer of the document.
-
getLeftHeader()
- Returns the left header of the document.
-
getLeftMargin()
- Returns the left margin of the document.
-
getLineSpacing()
- Returns the line spacing of the document.
-
getPageRange()
- Returns the page range of pages to be printed.
-
getPrinterFont()
- Returns the font specified for printing.
-
getPrintJobName()
- Returns the print job name for this document.
-
getRightFooter()
- Returns the right footer of the document.
-
getRightHeader()
- Returns the right header of the document.
-
getRightMargin()
- Returns the right margin of the document.
-
getTabStops()
- Returns the tab stop positions in inches.
-
getText()
- Returns the text string to be printed.
-
getTopMargin()
- Returns the top margin of the document.
-
getWrap()
- Returns whether automatic line wrapping is enabled or disabled.
-
paint(Graphics)
-
-
print()
- Same as print(String) but uses string from most recent setText call
-
print(String)
- Print a multipage single font text document, including
pagination, line wrap, line separators, line spacing, tab expansion, date and page numbering,
font selection, margins, headers, footers, page range, page breaks, and print monitor job name.
-
removePropertyChangeListener(PropertyChangeListener)
-
-
setAbsoluteTabs(boolean)
- Sets whether tabs are absolute (nth tab) or relative (next tab)
-
setBottomMargin(double)
- Sets the bottom margin below footer in inches.
-
setCenterFooter(String)
- Sets the center footer of the document.
-
setCenterHeader(String)
- Sets the center header of the document.
-
setGapAboveFooter(double)
- Sets the gap between the last line of text and the footer in inches.
-
setGapBelowHeader(double)
- Sets the gap between the header and first line of text in inches.
-
setHeaderFooterFont(Font)
- Sets the font for printing the headers and footers of the document.
-
setInchesPerTab(double)
- Sets the inches per tab stop.
-
setLeftFooter(String)
- Sets the left footer of the document.
-
setLeftHeader(String)
- Sets the left header of the document.
-
setLeftMargin(double)
- Sets the left margin in inches.
-
setLineSpacing(double)
- Sets the line spacing, in multiples of fontHeight.
-
setPageRange(String)
- Sets the page range of pages to be printed.
-
setPrinterFont(Font)
- Sets the font for printing the body of the document.
-
setPrintJobName(String)
- Sets the print job name that appears in the system print monitor.
-
setRightFooter(String)
- Sets the right footer of the document.
-
setRightHeader(String)
- Sets the right header of the document.
-
setRightMargin(double)
- Sets the right margin in inches.
-
setTabStops(double[])
- Sets tab stops.
-
setText(String)
- Sets (long) text string comprising entire text document to be printed.
-
setTopMargin(double)
- Sets the top margin above header in inches.
-
setWrap(boolean)
- Sets whether automatic line wrap is enabled or disabled.
TextPrinter
public TextPrinter()
- Construct a TextPrinter object
setText
public void setText(String string)
- Sets (long) text string comprising entire text document to be printed. Embedded
line.separators indicate hard line boundaries or line wraping feature will break lines.
- Parameters:
- string - the (long) string to be printed
getText
public synchronized String getText()
- Returns the text string to be printed.
setInchesPerTab
public void setInchesPerTab(double inchesPerTab)
- Sets the inches per tab stop.
- Parameters:
- inchesPerTab - inches per tab stop. Default: 0.5
getInchesPerTab
public synchronized double getInchesPerTab()
- Returns the inches per tab stop.
setTabStops
public void setTabStops(double tabStops[])
- Sets tab stops.
- Parameters:
- tabStops[] - tab stop positions in inches. Default: 0.5, 1.0, 1.5, 2.0, 2.5, ...
getTabStops
public synchronized double[] getTabStops()
- Returns the tab stop positions in inches.
setLineSpacing
public void setLineSpacing(double lineSpacing)
- Sets the line spacing, in multiples of fontHeight.
- Parameters:
- lineSpacing - in multiples of fontHeight (1.0=single space, 2.0=double space, etc.) Default: 1.0
getLineSpacing
public synchronized double getLineSpacing()
- Returns the line spacing of the document.
setPrinterFont
public void setPrinterFont(Font font)
- Sets the font for printing the body of the document.
- Parameters:
- font - font used for printing body of document. Default: SansSerif, PLAIN, 10
getPrinterFont
public synchronized Font getPrinterFont()
- Returns the font specified for printing.
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.
getHeaderFooterFont
public synchronized Font getHeaderFooterFont()
- Returns the font specified for headers and footers.
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 to format current date & time. Default: Page ###
- See Also:
- SimpleDateFormat
getLeftFooter
public synchronized String getLeftFooter()
- Returns the left footer of the document.
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|||
getCenterFooter
public synchronized String getCenterFooter()
- Returns the center footer of the document.
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|||
getRightFooter
public synchronized String getRightFooter()
- Returns the right footer of the document.
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 copyright notice
NOTE: value cannot be changed in free version.
getLeftHeader
public synchronized String getLeftHeader()
- Returns the left header of the document.
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.
getCenterHeader
public synchronized String getCenterHeader()
- Returns the center header of the document.
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: TextPrinter copyright notice
NOTE: value cannot be changed in free version.
getRightHeader
public synchronized String getRightHeader()
- Returns the right header of the document.
setLeftMargin
public void setLeftMargin(double leftMargin)
- Sets the left margin in inches.
- Parameters:
- leftMargin - left margin in inches. Default: 0.28
NOTE: optimum value depends on JDK version and OS (see documentation)
getLeftMargin
public synchronized double getLeftMargin()
- Returns the left margin of the document.
setRightMargin
public void setRightMargin(double rightMargin)
- Sets the right margin in inches.
- Parameters:
- rightMargin - right margin in inches. Default: 0.56
NOTE: optimum value depends on JDK version and OS (see documentation)
getRightMargin
public synchronized double getRightMargin()
- Returns the right margin of the document.
setTopMargin
public void setTopMargin(double topMargin)
- Sets the top margin above header in inches.
- Parameters:
- topMargin - top margin above header in inches. Default: 0.28
NOTE: optimum value depends on JDK version and OS (see documentation)
getTopMargin
public synchronized double getTopMargin()
- Returns the top margin of the document.
setBottomMargin
public void setBottomMargin(double bottomMargin)
- Sets the bottom margin below footer in inches.
- Parameters:
- bottomMargin - bottom margin below footer in inches. Default 0.7
>BR>NOTE: optimum value depends on JDK version and OS (see documentation)
getBottomMargin
public synchronized double getBottomMargin()
- Returns the bottom margin of the document.
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.25
getGapBelowHeader
public synchronized double getGapBelowHeader()
- Returns the gap between the header and first line in inches.
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.125
getGapAboveFooter
public synchronized double getGapAboveFooter()
- Returns the gap between the last line and the footer in inches.
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: "TextPrinter print document"
getPrintJobName
public synchronized String getPrintJobName()
- Returns the print job name for this document.
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)
getPageRange
public synchronized String getPageRange()
- Returns the page range of pages to be printed.
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
getWrap
public synchronized boolean getWrap()
- Returns whether automatic line wrapping is enabled or disabled.
setAbsoluteTabs
public void setAbsoluteTabs(boolean absoluteTabs)
- Sets whether tabs are absolute (nth tab) or relative (next tab)
- Parameters:
- whether - tabs are absolute or relative. Default: false
getAbsoluteTabs
public synchronized boolean getAbsoluteTabs()
- Returns whether tabs are absolute or relative.
addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener l)
removePropertyChangeListener
public void removePropertyChangeListener(PropertyChangeListener l)
print
public void print(String string)
- Print a multipage single font text document, including
pagination, line wrap, line separators, line spacing, tab expansion, date and page numbering,
font selection, margins, headers, footers, page range, page breaks, and print monitor job name.
- Parameters:
- string - a (long) string containing entire document to be printed,
which may (or may not) have embedded line.separators, tabs, formfeeds, etc.
print
public void print()
- Same as print(String) but uses string from most recent setText call
paint
public synchronized void paint(Graphics g)
- Overrides:
- paint in class Canvas
All Packages Class Hierarchy This Package Previous Next Index