Package com.portal.common
Class HFPageFormat
java.lang.Object
java.awt.print.PageFormat
com.portal.common.HFPageFormat
Extension of the Java default PageFormat to privide a header, footer and a
description area printing capabilities.
- Author:
- Dachywan Wu
-
Field Summary
Fields inherited from class java.awt.print.PageFormat
LANDSCAPE, PORTRAIT, REVERSE_LANDSCAPE
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
-
Constructor Summary
ConstructorsConstructorDescriptionCreate the HFPageFormat using existing PageFormat. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Makes a copy of thisHFPageFormat
with the same contents as thisHFPageFormat
.int
Get the height of the description area inint
.Get the description array.Get the font for the description area.Get the footer font.int
Get the height of the footer area inint
.Get the header font.int
Get the height of the header area inint
.double
Override the member function ofPageFormat
to provide the header, footer and description area support.double
Override the member function ofPageFormat
to provide the header, footer and description area support.Get the left footer text.Get the left header text.Get the right footer text.Get the right header text.protected void
paintDescriptionArea
(Graphics g, PageFormat format, int pageIndex) Print the description area.protected void
paintFooter
(Graphics g, PageFormat format, int pageIndex) Print the footer.protected void
paintHeader
(Graphics g, PageFormat format, int pageIndex) Print the header.int
print
(Graphics g, PageFormat format, int pageIndex) Draws the header, description text area and footer.void
setDescArray
(ArrayList descList) Set the description array which will be printed in the description area.void
setDescFont
(Font f) Set the description area font.void
Set the footer font.void
Set the font for the header.void
setLeftFooterText
(String text) Set the left footer text.void
setLeftHeaderText
(String text) Set the header text at the left margin.void
Set the page format to print.void
setRightFooterText
(String text) Set the right footer text.void
setRightHeaderText
(String text) Set the right header text.Methods inherited from class java.awt.print.PageFormat
getHeight, getImageableWidth, getImageableX, getMatrix, getOrientation, getPaper, getWidth, setOrientation, setPaper
-
Constructor Details
-
HFPageFormat
Create the HFPageFormat using existing PageFormat. The HFPageFormat has the capabilities of printing page header, footer and a description area.- Parameters:
pf
- the existing PageFormat.
-
-
Method Details
-
setPageFormat
Set the page format to print.- Parameters:
pf
- the page format to print.
-
print
Draws the header, description text area and footer. -
clone
Makes a copy of thisHFPageFormat
with the same contents as thisHFPageFormat
.- Overrides:
clone
in classPageFormat
- Returns:
- a copy of this
HFPageFormat
.
-
getImageableHeight
public double getImageableHeight()Override the member function ofPageFormat
to provide the header, footer and description area support.- Overrides:
getImageableHeight
in classPageFormat
- Returns:
- the printable area height in
double
.
-
getImageableY
public double getImageableY()Override the member function ofPageFormat
to provide the header, footer and description area support.- Overrides:
getImageableY
in classPageFormat
- Returns:
- the printable area top lefe corner Y location in
double
.
-
getHeaderHeight
public int getHeaderHeight()Get the height of the header area inint
.- Returns:
- int the header area height.
-
getDescAreaHeight
public int getDescAreaHeight()Get the height of the description area inint
.- Returns:
- int the description area height.
-
setHeaderFont
Set the font for the header.- Parameters:
f
- the header font.
-
setDescFont
Set the description area font.- Parameters:
f
- the description font.
-
getHeaderFont
Get the header font.- Returns:
- the font of the header.
-
getDescFont
Get the font for the description area.- Returns:
- the description font.
-
setLeftHeaderText
Set the header text at the left margin.- Parameters:
text
- the left header text.
-
setRightHeaderText
Set the right header text.- Parameters:
text
- the right header text.
-
setDescArray
Set the description array which will be printed in the description area. The toString() for each item in the list will be called to print the item.- Parameters:
descList
- the Arraylist to be printed.
-
getLeftHeaderText
Get the left header text.- Returns:
- the left header text.
-
getRightHeaderText
Get the right header text.- Returns:
- the right header text.
-
getDescArray
Get the description array.- Returns:
- the ArrayList of the description array.
-
paintHeader
Print the header.- Parameters:
g
- the graphics context.format
- the pageformat.pageIndex
- the page index starting from 0.
-
paintDescriptionArea
Print the description area.- Parameters:
g
- the graphics context.format
- the PageFormat to print.pageIndex
- the page index.
-