public class HeaderAndFooterPainter
extends java.lang.Object
The ViewPrinter
maintains six HeaderAndFooterPainter
objects.
It maintains HeaderAndFooterPainter
objects for left, center,
and right headers, and for left, center, and right footers.
Headers appear at the top of the page, and footers appear at the bottom.
ViewPrinter
Modifier and Type | Field and Description |
---|---|
static int |
DATE
ContentType: This header or footer displays the current date.
|
static int |
NONE
ContentType: This header or footer displays no information.
|
static int |
PAGE_NUMBER
ContentType: This header or footer displays the physical page number.
|
static int |
STRINGS
ContentType: This header or footer displays an array of strings.
|
Constructor and Description |
---|
HeaderAndFooterPainter(boolean header,
java.awt.Font font,
java.lang.String string,
boolean showString,
boolean showDate,
boolean showPageNum)
Deprecated.
As of 1.6.0.9, replaced by
HeaderAndFooterPainter(Dataview, int, Font, Object[], int) |
HeaderAndFooterPainter(Dataview view,
int headerOrFooterID,
java.awt.Font font,
java.lang.Object[] content,
int contentType)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected int |
calcMaximumHeight(java.awt.Graphics g,
CustomHeaderAndFooterCallback callback,
int physPageNumber,
int[] hPos) |
int |
getContentType()
Retrieves the kind of information that this header or footer displays.
|
java.awt.Font |
getFont()
Retrieves the
Font that specifies formatting for this header
or footer. |
int |
getHorizontalAlignment()
Retrieves the horizontal alignment of this header or footer.
|
protected int |
getMargin() |
int |
getMaximumHeight()
Retrieves the maximum height of the area for this header or footer.
|
int |
getMinimumHeight(java.awt.Graphics g)
Deprecated.
Replaced by
getMaximumHeight() |
int |
getPageNumber() |
java.lang.String |
getString()
Deprecated.
As of 1.6.0.9, replaced by
getStrings() |
java.lang.String[] |
getStrings()
Retrieves the array of strings that are displayed in this header
or footer.
|
TokenSubstitution |
getTokenSubstitution()
Retrieves the handler for token substitution in this header or footer.
|
boolean |
isShowDate()
Deprecated.
As of 1.6.0.9, replaced by
getContentType() |
boolean |
isShowPageNumber()
Deprecated.
As of 1.6.0.9, replaced by
getContentType() |
boolean |
isShowString()
Deprecated.
As of 1.6.0.9, replaced by
getContentType() |
void |
paint(java.awt.Graphics g,
int x,
int y,
int width,
int height)
Deprecated.
As of 1.6.0.9, replaced by
paint(Graphics, int, int, int, int, CustomHeaderAndFooterCallback, int, int[]) |
void |
paint(java.awt.Graphics g,
int x,
int y,
int width,
int height,
CustomHeaderAndFooterCallback callback,
int physPageNum,
int[] hPos)
Paints the header or footer.
|
void |
setContentType(int contentType)
Specifies the kind of information that this header or footer displays.
|
void |
setFont(java.awt.Font font)
Specifies the
Font that specifies formatting for this header
or footer. |
void |
setHorizontalAlignment(int hAlignment)
Specifies the horizontal alignment of this header or footer.
|
protected void |
setMargin(int margin) |
void |
setPageNumber(int pageNum) |
void |
setShowDate(boolean showDate)
Deprecated.
As of 1.6.0.9, replaced by
setContentType(int) |
void |
setShowPageNumber(boolean showPageNum)
Deprecated.
As of 1.6.0.9, replaced by
setContentType(int) |
void |
setShowString(boolean showString)
Deprecated.
As of 1.6.0.9, replaced by
setContentType(int) |
void |
setString(java.lang.String str)
Deprecated.
As of 1.6.0.9, replaced by
setStrings(String[]) |
void |
setStrings(java.lang.String[] str)
Specifies the array of strings to display in this header or footer.
|
void |
setTokenSubstitution(TokenSubstitution token)
Specifies a handler for token substitution in this header or footer.
|
public static final int NONE
public static final int DATE
public static final int PAGE_NUMBER
public static final int STRINGS
setStrings
to specify the strings that are displayed.public HeaderAndFooterPainter(Dataview view, int headerOrFooterID, java.awt.Font font, java.lang.Object[] content, int contentType)
ViewPrinter
automatically constructs this object six times,
for each of the three regions in headers and footers.
These painters are constructed with null
for font
and content
.
For all headers and the center footer, the contentType
is STRINGS
.
For the left footer, the contentType
is DATE
.
For the right footer, the contentType
is
PAGE_NUMBER
.view
- The DataView
that this
HeaderAndFooterPainter
belongs with.headerOrFooterID
- A constant that represents the location of
the header or footer, and whether it is a
header or footer. The constants are defined in the
ViewPrinter
class, and they begin
with HEADER_ or FOOTER_.font
- The font for the header or footer.content
- The string or strings that will appear in the
header or footer painter, when
contentType
is STRINGS
.contentType
- A constant that represents whether
content
is an array of strings,
the date, or the page number. Valid
values are NONE
, STRINGS
,
PAGE_NUMBER
, and DATE
.NONE
,
STRINGS
,
PAGE_NUMBER
,
DATE
,
ViewPrinter.HEADER_LEFT
,
ViewPrinter.HEADER_CENTER
,
ViewPrinter.HEADER_RIGHT
,
ViewPrinter.FOOTER_LEFT
,
ViewPrinter.FOOTER_CENTER
,
ViewPrinter.FOOTER_RIGHT
public HeaderAndFooterPainter(boolean header, java.awt.Font font, java.lang.String string, boolean showString, boolean showDate, boolean showPageNum)
HeaderAndFooterPainter(Dataview, int, Font, Object[], int)
public void setString(java.lang.String str)
setStrings(String[])
public java.lang.String getString()
getStrings()
public void setShowString(boolean showString)
setContentType(int)
setContentType
, passing
STRING
.
Then, call setStrings
, passing the array of strings that
you want to display.public boolean isShowString()
getContentType()
true
if the header or
footer displays a string, getContentType
returns
STRINGS
.public void setShowDate(boolean showDate)
setContentType(int)
setContentType
, passing DATE
.public boolean isShowDate()
getContentType()
true
if the current
header or footer displayed the date, getContentType
returns DATE
.public void setShowPageNumber(boolean showPageNum)
setContentType(int)
setContentType
, passing DATE
.public boolean isShowPageNumber()
getContentType()
true
if the header or footer
displayed a page number, the getContentType
method
returns PAGE_NUMBER
.public void setStrings(java.lang.String[] str)
ContentType
is set to
STRINGS
.
The strings can contain keys that the TokenSubstitution
will parse.str
- The array of strings to display.setContentType(int)
,
TokenSubstitution
public java.lang.String[] getStrings()
getContentType
method
returns STRINGS
.
The strings can contain keys that the TokenSubstitution
will parse.setContentType(int)
,
TokenSubstitution
public void setContentType(int contentType)
contentType
- A constant that represents the kind of information
to display.NONE
,
STRINGS
,
PAGE_NUMBER
,
DATE
public int getContentType()
NONE
,
STRINGS
,
PAGE_NUMBER
,
DATE
public void setHorizontalAlignment(int hAlignment)
hAlignment
- A swing
constant that represents the
horizontal alignment for this header or footer.SwingConstants.LEFT
,
SwingConstants.CENTER
,
SwingConstants.RIGHT
public int getHorizontalAlignment()
swing
constant that represents the horozontal alignment
for this header or footer.SwingConstants.LEFT
,
SwingConstants.CENTER
,
SwingConstants.RIGHT
public void setPageNumber(int pageNum)
public int getPageNumber()
public void setFont(java.awt.Font font)
Font
that specifies formatting for this header
or footer.font
- The Font
for this header or footer.public java.awt.Font getFont()
Font
that specifies formatting for this header
or footer.Font
for this header or footer.protected int calcMaximumHeight(java.awt.Graphics g, CustomHeaderAndFooterCallback callback, int physPageNumber, int[] hPos)
public int getMaximumHeight()
public int getMinimumHeight(java.awt.Graphics g)
getMaximumHeight()
g
- The graphics object.protected void setMargin(int margin)
protected int getMargin()
public void paint(java.awt.Graphics g, int x, int y, int width, int height)
paint(Graphics, int, int, int, int, CustomHeaderAndFooterCallback, int, int[])
paint
method supports the
CustomHeaderAndFooterCallback
, which allows you to
display different headers and footers on different pages of a print
job.
Application code should not have any calls to either paint
method, because the ViewPrinter
calls paint
.
public void paint(java.awt.Graphics g, int x, int y, int width, int height, CustomHeaderAndFooterCallback callback, int physPageNum, int[] hPos)
ViewPrinter
calls this method.
Application developers should not need to call it.g
- The graphics object to which the header or footer should be
painted.x
- The starting x position, in the graphics object, where the
painting should begin.y
- The starting y position, in the graphics object, where the
painting should begin.width
- The width available for header or footer, in pixels.height
- The height available for header or footer, in pixels.callback
- An implementation of the CustomHeaderAndFooterCallback
interface, which has been registered with the
ViewPrinter
by calling
ViewPrinter.setCustomHeaderAndFooterCallback
.physNum
- The current physical page.hPos
- The current logical page.ViewPrinter.setCustomHeaderAndFooterCallback(oracle.dss.dataView.CustomHeaderAndFooterCallback)
,
ViewPrinter.setHeadersAndFootersUsingCallback(int)
public void setTokenSubstitution(TokenSubstitution token)
TokenSubstitution
on this header or footer is null;
To support token substitution, you must call this method to specify
a TokenSubstitution
.token
- The token substitution handler for this header or footer.public TokenSubstitution getTokenSubstitution()
TokenSubstitution
on this header or footer is null;
to support token substitution, you must set a TokenSubstitution
by calling setTokenSubstitution
.TokenSubstitution