javax.swing.text.html

Class TableView.RowView

Enclosing Class:
javax.swing.text.html.TableView
Implemented Interfaces:
SwingConstants

public class TableView.RowView
extends BoxView

View of a row in a row-centric table.

Field Summary

Fields inherited from class javax.swing.text.View

BadBreakWeight, ExcellentBreakWeight, ForcedBreakWeight, GoodBreakWeight, X_AXIS, Y_AXIS

Fields inherited from interface javax.swing.SwingConstants

BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST

Constructor Summary

RowView(Element elem)
Constructs a TableView for the given element.

Method Summary

protected SizeRequirements
calculateMajorAxisRequirements(int axis, SizeRequirements r)
protected SizeRequirements
calculateMinorAxisRequirements(int axis, SizeRequirements r)
Calculate the height requirements of the table row.
void
changedUpdate(DocumentEvent e, Shape a, ViewFactory f)
Gives notification from the document that attributes were changed in a location that this view is responsible for.
AttributeSet
getAttributes()
Fetches the attributes to use when rendering.
float
getMaximumSpan(int axis)
Determines the maximum span for this view along an axis.
float
getMinimumSpan(int axis)
Determines the minimum span for this view along an axis.
float
getPreferredSpan(int axis)
Determines the preferred span for this view along an axis.
int
getResizeWeight(int axis)
Determines the resizability of the view along the given axis.
protected StyleSheet
getStyleSheet()
protected View
getViewAtPosition(int pos, Rectangle a)
Fetches the child view that represents the given position in the model.
protected void
layoutMajorAxis(int targetSpan, int axis, int[] offsets, int[] spans)
Perform layout for the major axis of the box (i.e.
protected void
layoutMinorAxis(int targetSpan, int axis, int[] offsets, int[] spans)
Perform layout for the minor axis of the box (i.e.
void
paint(Graphics g, Shape allocation)
Renders using the given rendering surface and area on that surface.
void
preferenceChanged(View child, boolean width, boolean height)
This is called by a child to indicate its preferred span has changed.
void
replace(int offset, int length, View[] views)
Change the child views.

Methods inherited from class javax.swing.text.BoxView

baselineLayout, baselineRequirements, calculateMajorAxisRequirements, calculateMinorAxisRequirements, childAllocation, flipEastAndWestAtEnds, forwardUpdate, getAlignment, getAxis, getChildAllocation, getHeight, getMaximumSpan, getMinimumSpan, getOffset, getPreferredSpan, getResizeWeight, getSpan, getViewAtPoint, getWidth, isAfter, isAllocationValid, isBefore, isLayoutValid, layout, layoutChanged, layoutMajorAxis, layoutMinorAxis, modelToView, paint, paintChild, preferenceChanged, replace, setAxis, setSize, viewToModel

Methods inherited from class javax.swing.text.CompositeView

childAllocation, flipEastAndWestAtEnds, getBottomInset, getChildAllocation, getInsideAllocation, getLeftInset, getNextEastWestVisualPositionFrom, getNextNorthSouthVisualPositionFrom, getNextVisualPositionFrom, getRightInset, getTopInset, getView, getViewAtPoint, getViewAtPosition, getViewCount, getViewIndex, getViewIndexAtPosition, isAfter, isBefore, loadChildren, modelToView, modelToView, replace, setInsets, setParagraphInsets, setParent, viewToModel

Methods inherited from class javax.swing.text.View

Shape modelToView, append, breakView, changedUpdate, createFragment, forwardUpdate, forwardUpdateToView, getAlignment, getAttributes, getBreakWeight, getChildAllocation, getContainer, getDocument, getElement, getEndOffset, getGraphics, getMaximumSpan, getMinimumSpan, getNextVisualPositionFrom, getParent, getPreferredSpan, getResizeWeight, getStartOffset, getToolTipText, getView, getViewCount, getViewFactory, getViewIndex, getViewIndex, insert, insertUpdate, int viewToModel, isVisible, modelToView, modelToView, paint, preferenceChanged, remove, removeAll, removeUpdate, replace, setParent, setSize, updateChildren, updateLayout, viewToModel

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

RowView

public RowView(Element elem)
Constructs a TableView for the given element.
Parameters:
elem - the element that this view is responsible for

Method Details

calculateMajorAxisRequirements

protected SizeRequirements calculateMajorAxisRequirements(int axis,
                                                          SizeRequirements r)
Overrides:
calculateMajorAxisRequirements in interface BoxView

calculateMinorAxisRequirements

protected SizeRequirements calculateMinorAxisRequirements(int axis,
                                                          SizeRequirements r)
Calculate the height requirements of the table row. The requirements of multi-row cells are not considered for this calculation. The table itself will check and adjust the row requirements for all the rows that have multi-row cells spanning them. This method updates the multi-row flag that indicates that this row and rows below need additional consideration.
Overrides:
calculateMinorAxisRequirements in interface BoxView

changedUpdate

public void changedUpdate(DocumentEvent e,
                          Shape a,
                          ViewFactory f)
Gives notification from the document that attributes were changed in a location that this view is responsible for. To reduce the burden to subclasses, this functionality is spread out into the following calls that subclasses can reimplement:
  1. updateChildren is called if there were any changes to the element this view is responsible for. If this view has child views that are represent the child elements, then this method should do whatever is necessary to make sure the child views correctly represent the model.
  2. forwardUpdate is called to forward the DocumentEvent to the appropriate child views.
  3. updateLayout is called to give the view a chance to either repair its layout, to reschedule layout, or do nothing.
Overrides:
changedUpdate in interface View
Parameters:
e - the change information from the associated document
a - the current allocation of the view
f - the factory to use to rebuild if the view has children

getAttributes

public AttributeSet getAttributes()
Fetches the attributes to use when rendering. This is implemented to multiplex the attributes specified in the model with a StyleSheet.
Overrides:
getAttributes in interface View

getMaximumSpan

public float getMaximumSpan(int axis)
Determines the maximum span for this view along an axis.
Overrides:
getMaximumSpan in interface BoxView
Parameters:
axis - may be either View.X_AXIS or View.Y_AXIS
Returns:
the maximum span the view can be rendered into

getMinimumSpan

public float getMinimumSpan(int axis)
Determines the minimum span for this view along an axis.
Overrides:
getMinimumSpan in interface BoxView
Parameters:
axis - may be either View.X_AXIS or View.Y_AXIS
Returns:
the minimum span the view can be rendered into

getPreferredSpan

public float getPreferredSpan(int axis)
Determines the preferred span for this view along an axis.
Overrides:
getPreferredSpan in interface BoxView
Parameters:
axis - may be either View.X_AXIS or View.Y_AXIS
Returns:
the span the view would like to be rendered into. Typically the view is told to render into the span that is returned, although there is no guarantee. The parent may choose to resize or break the view

getResizeWeight

public int getResizeWeight(int axis)
Determines the resizability of the view along the given axis. A value of 0 or less is not resizable.
Overrides:
getResizeWeight in interface BoxView
Parameters:
axis - may be either View.X_AXIS or View.Y_AXIS
Returns:
the resize weight
Throws:
IllegalArgumentException - for an invalid axis

getStyleSheet

protected StyleSheet getStyleSheet()

getViewAtPosition

protected View getViewAtPosition(int pos,
                                 Rectangle a)
Fetches the child view that represents the given position in the model. This is implemented to walk through the children looking for a range that contains the given position. In this view the children do not necessarily have a one to one mapping with the child elements.
Overrides:
getViewAtPosition in interface CompositeView
Parameters:
pos - the search position >= 0
a - the allocation to the table on entry, and the allocation of the view containing the position on exit
Returns:
the view representing the given position, or null if there isn't one

layoutMajorAxis

protected void layoutMajorAxis(int targetSpan,
                               int axis,
                               int[] offsets,
                               int[] spans)
Perform layout for the major axis of the box (i.e. the axis that it represents). The results of the layout should be placed in the given arrays which represent the allocations to the children along the major axis.

This is re-implemented to give each child the span of the column width for the table, and to give cells that span multiple columns the multi-column span.

Overrides:
layoutMajorAxis in interface BoxView
Parameters:
targetSpan - the total span given to the view, which whould be used to layout the children
axis - the axis being layed out
offsets - the offsets from the origin of the view for each of the child views; this is a return value and is filled in by the implementation of this method
spans - the span of each child view; this is a return value and is filled in by the implementation of this method

layoutMinorAxis

protected void layoutMinorAxis(int targetSpan,
                               int axis,
                               int[] offsets,
                               int[] spans)
Perform layout for the minor axis of the box (i.e. the axis orthoginal to the axis that it represents). The results of the layout should be placed in the given arrays which represent the allocations to the children along the minor axis. This is called by the superclass whenever the layout needs to be updated along the minor axis.

This is implemented to delegate to the superclass, then adjust the span for any cell that spans multiple rows.

Overrides:
layoutMinorAxis in interface BoxView
Parameters:
targetSpan - the total span given to the view, which whould be used to layout the children
axis - the axis being layed out
offsets - the offsets from the origin of the view for each of the child views; this is a return value and is filled in by the implementation of this method
spans - the span of each child view; this is a return value and is filled in by the implementation of this method

paint

public void paint(Graphics g,
                  Shape allocation)
Renders using the given rendering surface and area on that surface. This is implemented to delegate to the css box painter to paint the border and background prior to the interior.
Overrides:
paint in interface BoxView
Parameters:
g - the rendering surface to use
allocation - the allocated region to render into

preferenceChanged

public void preferenceChanged(View child,
                              boolean width,
                              boolean height)
This is called by a child to indicate its preferred span has changed. This is implemented to execute the superclass behavior and well as try to determine if a row with a multi-row cell hangs across this row. If a multi-row cell covers this row it also needs to propagate a preferenceChanged so that it will recalculate the multi-row cell.
Overrides:
preferenceChanged in interface BoxView
Parameters:
child - the child view
width - true if the width preference should change
height - true if the height preference should change

replace

public void replace(int offset,
                    int length,
                    View[] views)
Change the child views. This is implemented to provide the superclass behavior and invalidate the grid so that rows and columns will be recalculated.
Overrides:
replace in interface BoxView