|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
An object that can size and display a portion of a report. Views are
used behind the scenes by JReportPane
and its corresponding
ReportPaneUI
.
ReportPaneUI
s should ensure that views are
properly sized when they are rendered. Generally, they will take
the following steps to size a root view:
getPreferredLength
and/or getMinimumLength
along the first axissetLength
along the first axisgetPreferredLength
and/or getMinimumLength
along the second axissetLength
along the second axissetTopLeftCorner
to position the viewpaint
can be invoked on it.
breakView
. First fully break along the minor axis (usually the width)
and then break along the major axis (usually the height). Follow the
following pattern to break a view along a given axis:
getPreferredLength
and/or getMinimumLength
setLength
gatherBreakWeights
breakView
at a valid break positiongetNextBrokenView
and getPreviousBrokenView
.
Nested Class Summary | |
static class |
View.ResizeRequest
A way to indicate that a view's minimum and preferred lengths have possibly changed. |
Field Summary | |
static int |
X_AXIS
A constant that indicates the direction along the X axis (horizontal). |
static int |
Y_AXIS
A constant that indicates the direction along the Y axis (vertical). |
Method Summary | |
void |
breakView(int axis,
int newLength,
ViewFactory viewFactory)
Breaks this view at the specified offset along the specified axis and returns a view of the leftover portion. |
View |
elementToView(Element element)
Returns the view corresponding to the specified element, or null
if none is found. |
void |
forwardReportEvent(ReportEvent event)
Called by a child view to propagate changes to nested reports up the view hierarchy. |
void |
gatherBreakWeights(int axis,
BreakWeightRecorder recorder)
Determines the positions where this view can be broken. |
void |
gatherViewsAt(java.awt.Point point,
java.util.Collection views)
Adds this view and any of its children to the specified collection if they contain the specified point. |
void |
gatherViewsWithin(java.awt.Rectangle region,
java.util.Collection views)
Adds this view and any of its children to the specified collection if they contain any point in the specified region. |
Element |
getElement()
Returns this view's underlying element. |
int |
getLength(int axis)
Returns the length of this view along the specified axis. |
int |
getMinimumLength(int axis)
Returns the minimum length of this view along the specified axis, given this view's current state. |
View |
getNextBrokenView(int axis)
Returns the next broken portion along the specified axis, after breakView
has been called in this direction. |
int |
getOffset(int axis)
Returns the absolute offset of this view along the specified axis. |
View |
getParent()
Returns this view's parent view. |
int |
getPreferredLength(int axis)
Returns the preferred length of this view along the specified axis, given this view's current state. |
View |
getPreviousBrokenView(int axis)
Returns the previous broken portion along the specified axis. |
JReportPane |
getReportPane()
Returns the report pane hosting this view. |
java.lang.String |
getText()
Returns the text rendered by this view. |
java.lang.String |
getToolTipText(java.awt.Point point)
Returns this view's tool tip string, or null , if the tool tip
should be gotten by another means. |
void |
paint(java.awt.Graphics g)
Paints this view on the specified rendering surface. |
void |
reportChanged(ReportEvent event,
java.awt.Rectangle dirtyRegion,
ViewFactory viewFactory,
View.ResizeRequest resizeRequest)
Triggers a response to a report change. |
void |
setLength(int axis,
int length)
Set the length of this view along the specified axis. |
void |
setParent(View parent)
Sets this view's parent view. |
void |
setTopLeftCorner(int x,
int y)
Sets this view's x and y offsets. |
Field Detail |
public static final int X_AXIS
Y_AXIS
,
Constant Field Valuespublic static final int Y_AXIS
X_AXIS
,
Constant Field ValuesMethod Detail |
public void breakView(int axis, int newLength, ViewFactory viewFactory) throws java.lang.IllegalArgumentException, java.lang.NullPointerException
newLength
, where newLength
is relative to
this view. To avoid an InvalidBreakPosition
being thrown,
the client should invoke gatherBreakWeights
and select a break position
that is not BreakWeightRecorder.BAD_BREAK_WEIGHT
.
axis
- axis (either X_AXIS
or
Y_AXIS
) along which to break this viewnewLength
- offset at which to break this view
java.lang.IllegalArgumentException
- if axis
is not X_AXIS
or Y_AXIS
java.lang.IllegalStateException
- if this view has already been broken
along this axis or if this view has a previous broken view along the
opposite axis
InvalidBreakPosition
- if this view cannot be broken at newLength
java.lang.NullPointerException
- if viewFactory
is null
gatherBreakWeights(int, sos.reports.BreakWeightRecorder)
,
getNextBrokenView(int)
public void gatherBreakWeights(int axis, BreakWeightRecorder recorder)
BreakWeightRecorder.UNDEFINED_BREAK_WEIGHT
when this method returns. To set bits, an implementation may, for example, invoke
recorder.fill( BreakWeightRecorder.BAD_BREAK_WEIGHT );to signal that it cannot be broken, or
recorder.setWeight( 25, BreakWeightRecorder.FORCED_BREAK_WEIGHT );to signal that it must be broken at position 25. All positions are relative to this view. If this view contains child views, it should clip the recorder's range using
BreakWeightRecorder.createView(int, int)
and invoke gatherBreakWeights
on its children.
axis
- axis (either X_AXIS
or
Y_AXIS
) along which to break this viewrecorder
- an object that records
java.lang.IllegalArgumentException
- if axis
is not X_AXIS
or Y_AXIS
java.lang.NullPointerException
- if recorder
is null
public void gatherViewsAt(java.awt.Point point, java.util.Collection views)
point
is an absolute position.
The elements should be added to views
in the order that they should be
resolved. This order is the opposite order in which they are rendered
in BasicReportPaneUI
.
point
- (x,y) position to test for inclusionviews
- collection to which this view adds descendant views that
include point
java.lang.NullPointerException
- if point
or views
is null
gatherViewsWithin(java.awt.Rectangle, java.util.Collection)
public void gatherViewsWithin(java.awt.Rectangle region, java.util.Collection views)
region
is given
in absolute positions.
The elements should be added to views
in the order that they should be
resolved. This order is the opposite order in which they are rendered
in BasicReportPaneUI
.
region
- rectangle to test for intersectionviews
- collection to which this view adds descendant views that
intersect region
java.lang.NullPointerException
- if region
or views
is null
public int getLength(int axis)
axis
- axis (either X_AXIS
or
Y_AXIS
) along which the length is requested
axis
java.lang.IllegalArgumentException
- if axis
is not X_AXIS
or Y_AXIS
setLength(int, int)
public int getMinimumLength(int axis)
axis
- axis (either X_AXIS
or
Y_AXIS
) along which the length is requested
axis
java.lang.IllegalArgumentException
- if axis
is not X_AXIS
or Y_AXIS
public View getNextBrokenView(int axis)
breakView
has been called in this direction.
axis
- axis (either X_AXIS
or
Y_AXIS
) along which the next broken view is requested
axis
breakView(int, int, sos.reports.ViewFactory)
,
getPreviousBrokenView(int)
public View getPreviousBrokenView(int axis)
axis
- axis (either X_AXIS
or
Y_AXIS
) along which the previous broken view is requested
axis
breakView(int, int, sos.reports.ViewFactory)
,
getNextBrokenView(int)
public int getOffset(int axis)
axis
- axis (either X_AXIS
or
Y_AXIS
) along which the offset is requested
axis
java.lang.IllegalArgumentException
- if axis
is not X_AXIS
or Y_AXIS
setTopLeftCorner(int, int)
public int getPreferredLength(int axis)
axis
- axis (either X_AXIS
or
Y_AXIS
) along which the length is requested
axis
java.lang.IllegalArgumentException
- if axis
is not X_AXIS
or Y_AXIS
public JReportPane getReportPane()
public Element getElement()
public java.lang.String getText()
null
)public java.lang.String getToolTipText(java.awt.Point point)
null
, if the tool tip
should be gotten by another means.
point
- point at which the tool tip string is requested
public View elementToView(Element element)
null
if none is found. This method is recursive in that
it invokes getView
on the child views if appropriate.
If this view is a direct view of element
, it returns itself.
element
- report element for which the corresponding view is requested
element
java.lang.NullPointerException
- if element
is null
public void paint(java.awt.Graphics g)
g
- surface on which to render this view
java.lang.NullPointerException
- if g
is null
public void reportChanged(ReportEvent event, java.awt.Rectangle dirtyRegion, ViewFactory viewFactory, View.ResizeRequest resizeRequest)
ReportPaneUI
on the root view and flows downward along
the view hierarchy.
event
- the event describing how the report has changeddirtyRegion
- set by this view to indicate the region that needs to be repaintedviewFactory
- a means to create new views if necessaryresizeRequest
- set by this view to indicate how its preferences
have change as a result of the event
java.lang.UnsupportedOperationException
- if this view has been broken
and does not support report changespublic void forwardReportEvent(ReportEvent event)
event
- nested report changepublic void setParent(View parent)
parent
- view to be the parent of this viewgetParent()
public View getParent()
setParent(sos.reports.View)
public void setLength(int axis, int length)
axis
- axis (either X_AXIS
or
Y_AXIS
) along which the length is requestedlength
- the length of this view along axis
java.lang.IllegalArgumentException
- if axis
is not X_AXIS
or Y_AXIS
or if length < 0
getLength(int)
public void setTopLeftCorner(int x, int y)
x
- offset along the x-axisy
- offset along the y-axisgetOffset(int)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |