|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--org.PingOO.DLAI.lib.util.TextPrintable
The class is a printable object used to print plain text.
It will format and prepare pages of text as the printer request them.
Printing text is exactly the same thing than drawing on screen.
Since I could not find any implemetnation of Printable for text, I had to do it myself.
Printable| Field Summary | |
private boolean |
allowHeader
Indicates if the header is to be printed. |
(package private) int |
currentPage
The current page number. |
private java.awt.Font |
font
The current font used to render the text. |
private static java.awt.Font |
FONT
The font used to render text. |
private java.awt.print.PageFormat |
pageFormat
The current page format. |
private java.util.Vector |
pageVector
The vector containing pre-computed pages. |
static int |
TAB_SIZE
The default number of space used to transform a tabulation. |
private java.lang.String |
text
The full text to print. |
| Constructor Summary | |
TextPrintable(java.lang.String text)
Creates a new printable object used to render plain text. |
|
TextPrintable(java.lang.String text,
boolean allowHeader)
Creates a new printable object used to render plain text. |
|
TextPrintable(java.lang.String text,
java.awt.Font font)
Creates a new printable object used to render plain text. |
|
TextPrintable(java.lang.String text,
java.awt.Font font,
boolean allowHeader)
Creates a new printable object used to render plain text. |
|
| Method Summary | |
protected void |
preparePages(java.awt.Graphics graphics,
java.awt.print.PageFormat pageFormat)
|
int |
print(java.awt.Graphics graphics,
java.awt.print.PageFormat pageFormat,
int pageIndex)
Prints the page at the specified index into the specified Graphics context in the specified format. |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
public static final int TAB_SIZE
private static final java.awt.Font FONT
private boolean allowHeader
private java.awt.Font font
private java.lang.String text
private java.util.Vector pageVector
private java.awt.print.PageFormat pageFormat
int currentPage
| Constructor Detail |
public TextPrintable(java.lang.String text)
text - The text to print.
public TextPrintable(java.lang.String text,
java.awt.Font font)
font - The font used to render this text on the printer.
public TextPrintable(java.lang.String text,
boolean allowHeader)
allowHeader - If true a header will be displayed on top of the page containing the page number and the current date.
public TextPrintable(java.lang.String text,
java.awt.Font font,
boolean allowHeader)
font - The font used to render this text on the printer.allowHeader - If true a header will be displayed on top of the page containing the page number and the current date.| Method Detail |
protected void preparePages(java.awt.Graphics graphics,
java.awt.print.PageFormat pageFormat)
public int print(java.awt.Graphics graphics,
java.awt.print.PageFormat pageFormat,
int pageIndex)
throws java.awt.print.PrinterException
graphics - The context into which the page is drawn.pageFormat - The size and orientation of the page being drawn.pageIndex - The zero based index of the page to be drawnPrintable.PAGE_EXISTS if the page is rendered successfully or Printable.NO_SUCH_PAGE if pageIndex specifies a non-existent page.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||