public class ReportPrinter
extends java.lang.Object
implements java.awt.print.Printable
Constructor and Description |
---|
ReportPrinter()
Construct a report printer for printing in portrait orientation.
|
ReportPrinter(boolean portrait)
Construct a report printer for printing in portrait (true) or landscape (false) orientation.
|
Modifier and Type | Method and Description |
---|---|
void |
addField() |
void |
addField(java.text.Format fmt) |
void |
addField(java.text.Format fmt,
int width) |
void |
addField(int width) |
void |
addField(java.lang.String name) |
void |
addField(java.lang.String name,
java.text.Format fmt) |
void |
addField(java.lang.String name,
java.text.Format fmt,
int width) |
void |
addField(java.lang.String name,
int width) |
void |
addField(java.lang.String name,
java.lang.String label) |
void |
addField(java.lang.String name,
java.lang.String label,
java.text.Format fmt) |
void |
addField(java.lang.String name,
java.lang.String label,
java.text.Format fmt,
int width)
Adds a field to the report with specified name, label, default format and field width.
|
void |
addField(java.lang.String name,
java.lang.String label,
int width) |
void |
close()
Prints the report by prompting user with a print dialogue box, and closes the ReportPrinter.
|
int |
getLineNumber()
Returns the current line number on the current page.
|
int |
getPageNumber()
Returns the current page number of the current page.
|
void |
newLine()
Ends the current line and the next write is done to the first field on the next line on the page.
|
void |
newPage()
Ends the current page and creates a new page with titles and field labels.
|
int |
print(java.awt.Graphics g,
java.awt.print.PageFormat pf,
int page)
This method is used by Java for printing.
|
void |
setTitle(java.lang.String... lines)
Set the title on the report by passing a var args of strings to this method.
|
void |
writeBoolean(boolean b) |
void |
writeBoolean(boolean b,
java.text.Format fmt) |
void |
writeBoolean(java.lang.String name,
boolean b) |
void |
writeBoolean(java.lang.String name,
boolean b,
java.text.Format fmt)
Writes the boolean value to the field with the specified name and left justifying the output.
|
void |
writeByte(byte b) |
void |
writeByte(byte b,
java.text.Format fmt) |
void |
writeByte(java.lang.String name,
byte b) |
void |
writeByte(java.lang.String name,
byte b,
java.text.Format fmt)
Writes the byte value to the field with the specified name and right justifying the output.
|
void |
writeChar(char c) |
void |
writeChar(char c,
java.text.Format fmt) |
void |
writeChar(java.lang.String name,
char c) |
void |
writeChar(java.lang.String name,
char c,
java.text.Format fmt)
Writes the char value to the field with the specified name and left justifying the output.
|
void |
writeDouble(double d) |
void |
writeDouble(double d,
java.text.Format fmt) |
void |
writeDouble(java.lang.String name,
double d) |
void |
writeDouble(java.lang.String name,
double d,
java.text.Format fmt)
Writes the double value to the field with the specified name and right justifying the output.
|
void |
writeFloat(float f) |
void |
writeFloat(float f,
java.text.Format fmt) |
void |
writeFloat(java.lang.String name,
float f) |
void |
writeFloat(java.lang.String name,
float f,
java.text.Format fmt)
Writes the float value to the field with the specified name and right justifying the output.
|
void |
writeInt(int i) |
void |
writeInt(int i,
java.text.Format fmt) |
void |
writeInt(java.lang.String name,
int i) |
void |
writeInt(java.lang.String name,
int i,
java.text.Format fmt)
Writes the int value to the field with the specified name and right justifying the output.
|
void |
writeLine(java.lang.String s) |
void |
writeLine(java.lang.String s,
java.text.Format fmt)
Writes a string to the report immediately following the previous field and ending the line.
|
void |
writeLong(long l) |
void |
writeLong(long l,
java.text.Format fmt) |
void |
writeLong(java.lang.String name,
long l) |
void |
writeLong(java.lang.String name,
long l,
java.text.Format fmt)
Writes the long value to the field with the specified name and right justifying the output.
|
void |
writeShort(short s) |
void |
writeShort(short s,
java.text.Format fmt) |
void |
writeShort(java.lang.String name,
short s) |
void |
writeShort(java.lang.String name,
short s,
java.text.Format fmt)
Writes the short value to the field with the specified name and right justifying the output.
|
void |
writeString(java.lang.String s) |
void |
writeString(java.lang.String s,
java.text.Format fmt) |
void |
writeString(java.lang.String name,
java.lang.String s) |
void |
writeString(java.lang.String name,
java.lang.String s,
java.text.Format fmt)
Writes the String value to the field with the specified name and left justifying the output.
|
public ReportPrinter()
public ReportPrinter(boolean portrait)
public int getLineNumber()
public int getPageNumber()
public void setTitle(java.lang.String... lines)
lines
- a var args of Strings, each String becomes a line in the title.public void addField(java.lang.String name, java.lang.String label, java.text.Format fmt, int width)
name
- The name of the field. The field can be accessed for write operations by providing the name. For details
of behaviour of writing by specifying a name and without a name see "Writing to a field" above.label
- The label of the field column to be displayed on the report. The label is centered over the field.fmt
- A default format for writing to the field.width
- The width of the field.public void addField(java.lang.String name, java.lang.String label, java.text.Format fmt)
public void addField(java.lang.String name, java.lang.String label)
public void addField(java.lang.String name)
public void addField(java.lang.String name, java.text.Format fmt, int width)
public void addField(java.lang.String name, java.text.Format fmt)
public void addField(java.lang.String name, java.lang.String label, int width)
public void addField(java.lang.String name, int width)
public void addField(java.text.Format fmt, int width)
public void addField(java.text.Format fmt)
public void addField(int width)
public void addField()
public void close()
public void newPage()
public void newLine()
public void writeBoolean(java.lang.String name, boolean b, java.text.Format fmt)
name
- the name of the field.b
- the value to writefmt
- a format object to format the data with.public void writeBoolean(java.lang.String name, boolean b)
( String name, boolean b, Format fmt )
public void writeBoolean(boolean b, java.text.Format fmt)
( String name, boolean b, Format fmt )
public void writeBoolean(boolean b)
( String name, boolean b, Format fmt )
public void writeByte(java.lang.String name, byte b, java.text.Format fmt)
name
- the name of the field.b
- the value to writefmt
- a format object to format the data with.public void writeByte(java.lang.String name, byte b)
( String name, byte b, Format fmt )
public void writeByte(byte b, java.text.Format fmt)
( String name, byte b, Format fmt )
public void writeByte(byte b)
( String name, byte b, Format fmt )
public void writeChar(java.lang.String name, char c, java.text.Format fmt)
name
- the name of the field.c
- the value to writefmt
- a format object to format the data with.public void writeChar(java.lang.String name, char c)
( String name, char c, Format fmt )
public void writeChar(char c, java.text.Format fmt)
( String name, char c, Format fmt )
public void writeChar(char c)
( String name, char c, Format fmt )
public void writeDouble(java.lang.String name, double d, java.text.Format fmt)
name
- the name of the field.d
- the value to writefmt
- a format object to format the data with.public void writeDouble(java.lang.String name, double d)
( String name, double d, Format fmt )
public void writeDouble(double d, java.text.Format fmt)
( String name, double d, Format fmt )
public void writeDouble(double d)
( String name, double d, Format fmt )
public void writeFloat(java.lang.String name, float f, java.text.Format fmt)
name
- the name of the field.f
- the value to writefmt
- a format object to format the data with.public void writeFloat(java.lang.String name, float f)
( String name, float fmt, Format fmt )
public void writeFloat(float f, java.text.Format fmt)
( String name, float fmt, Format fmt )
public void writeFloat(float f)
( String name, float fmt, Format fmt )
public void writeInt(java.lang.String name, int i, java.text.Format fmt)
name
- the name of the field.i
- the value to writefmt
- a format object to format the data with.public void writeInt(java.lang.String name, int i)
( String name, int i, Format fmt )
public void writeInt(int i, java.text.Format fmt)
( String name, int i, Format fmt )
public void writeInt(int i)
( String name, int i, Format fmt )
public void writeLong(java.lang.String name, long l, java.text.Format fmt)
name
- the name of the field.l
- the value to writefmt
- a format object to format the data with.public void writeLong(java.lang.String name, long l)
( String name, long l, Format fmt )
public void writeLong(long l, java.text.Format fmt)
( String name, long l, Format fmt )
public void writeLong(long l)
( String name, long l, Format fmt )
public void writeShort(java.lang.String name, short s, java.text.Format fmt)
name
- the name of the field.s
- the value to writefmt
- a format object to format the data with.public void writeShort(java.lang.String name, short s)
( String name, short s)
public void writeShort(short s, java.text.Format fmt)
( String name, short s)
public void writeShort(short s)
( String name, short s)
public void writeString(java.lang.String name, java.lang.String s, java.text.Format fmt)
name
- the name of the field.s
- the value to writefmt
- a format object to format the data with.public void writeString(java.lang.String name, java.lang.String s)
( String name, String s, Format fmt )
public void writeString(java.lang.String s, java.text.Format fmt)
( String name, String s, Format fmt )
public void writeString(java.lang.String s)
( String name, String s, Format fmt )
public void writeLine(java.lang.String s, java.text.Format fmt)
s
- the String to write to the report.fmt
- an optional format object to format the string.public void writeLine(java.lang.String s)
writeLine( String s, Format fmt )
public int print(java.awt.Graphics g, java.awt.print.PageFormat pf, int page) throws java.awt.print.PrinterException
print
in interface java.awt.print.Printable
java.awt.print.PrinterException