All Packages Class Hierarchy This Package Previous Next Index
Class datarep.common.TextPrinter
java.lang.Object
|
+----datarep.common.TextPrinter
- public class TextPrinter
- extends Object
datarep.common.TextPrinter is a class which provides easy yet flexible printing of text. The
print methods can be used for extremely quick printing; other methods provide more control over
the output.
Unless the print convenience methods are being used, you should follow the following procedure.
- Create a new TextPrinter object.
- use any number of methods (e.g. write, setFont, setWrap, etc.) to acheive the desired output.
- use the dispose() method to send the job to the printer.
- Version:
- 1.2
- Author:
- Data Representations, Inc.
-
TextPrinter()
- default constructor.
-
TextPrinter(String)
- Creates a TextPrinter with the specified title, and using the default font.
-
TextPrinter(String, Font)
- Creates a TextPrinter with the specified title and font.
-
dispose()
- dispose: sends the print job to the printer.
-
formFeed()
- formFeed:
add a form feed.
-
getColor()
- getColor:
returns the currently used color.
-
getFont()
- getFont:
returns the font which is currently being used.
-
getMargins()
- getMargins:
returns an integer array of the current margins.
-
getTab()
- getTab:
gets the current tab stops, in inches.
-
getWordWrap()
- getWordWrap:
returns true if word wrap is on; false if off.
-
main(String[])
- prints files.
-
newLine()
- newLine:
start a new line.
-
print(String)
- print(String text):
A convenience method.
-
print(String, String)
- print(String text, String title):
A convenience method.
-
print(String, String, Font)
- print(String text, String title, Font font):
A convenience method.
-
setColor(Color)
- setColor:
sets the color of the text to be printed.
-
setFont(Font)
- setFont:
changes the font to the new value.
-
setMargins(float, float, float, float)
- setMargins:
sets the page margins.
-
setTab(float)
- setTab:
sets the tab stops, in inches.
-
setWordWrap(boolean)
- setWordWrap:
Sets whether or not lines will wrap.
-
write(String)
- write:
include text to be printed in the current print job.
TextPrinter
public TextPrinter()
- default constructor. Creates a TextPrinter without a title, and using the default font.
Other settings are also set to default values: the tab stop at 0.5 inches, margins on top,
bottom, and sides to 1 inch, and the color to black.
TextPrinter
public TextPrinter(String name)
- Creates a TextPrinter with the specified title, and using the default font.
Other settings are also set to default values: the tab stop at 0.5 inches, margins on top,
bottom, and sides to 1 inch, and the color to black.
TextPrinter
public TextPrinter(String name,
Font font)
- Creates a TextPrinter with the specified title and font.
Other settings are also set to default values: the tab stop at 0.5 inches, margins on top,
bottom, and sides to 1 inch, and the color to black.
print
public static void print(String text)
- print(String text):
A convenience method. Prints the text, using the default font and no title.
This is the simplest way to print.
- Parameters:
- text - a String, which is the text to print
print
public static void print(String text,
String title)
- print(String text, String title):
A convenience method. Prints the text, using the default font and the specified title.
- Parameters:
- text - a String, which is the text to print
- title - a String, which is the title.
print
public static void print(String text,
String title,
Font font)
- print(String text, String title, Font font):
A convenience method.
Prints the text, with the specified font and title.
dispose
public void dispose()
- dispose: sends the print job to the printer.
This is a very important method, because it sends the print job to the printer. If
you do not call dispose, nothing will be printed (unless the print methods are used).
write
public void write(String text)
- write:
include text to be printed in the current print job.
- Parameters:
- text - text to be printed
newLine
public void newLine()
- newLine:
start a new line. If necessary, a new page is started.
formFeed
public void formFeed()
- formFeed:
add a form feed. (additional text will be printed on the next page).
setFont
public void setFont(Font font)
- setFont:
changes the font to the new value.
getFont
public Font getFont()
- getFont:
returns the font which is currently being used.
setColor
public void setColor(Color color)
- setColor:
sets the color of the text to be printed.
getColor
public Color getColor()
- getColor:
returns the currently used color.
setTab
public void setTab(float tab)
- setTab:
sets the tab stops, in inches.
getTab
public int getTab()
- getTab:
gets the current tab stops, in inches.
setWordWrap
public void setWordWrap(boolean wrap)
- setWordWrap:
Sets whether or not lines will wrap.
- Parameters:
- wrap - if true, word wrap is on. If false, it is off.
getWordWrap
public boolean getWordWrap()
- getWordWrap:
returns true if word wrap is on; false if off.
setMargins
public void setMargins(float top,
float bottom,
float left,
float right)
- setMargins:
sets the page margins. The top, bottom, left, and right margins are set in inches.
getMargins
public int[] getMargins()
- getMargins:
returns an integer array of the current margins.
- Returns:
- returns an integer array of the top, bottom, left, and right margins in inches.
main
public static void main(String args[])
- prints files.
All Packages Class Hierarchy This Package Previous Next Index