javax.swing.text.html
Class TableView.RowView

java.lang.Object
  extended byjavax.swing.text.View
      extended byjavax.swing.text.CompositeView
          extended byjavax.swing.text.BoxView
              extended byjavax.swing.text.html.TableView.RowView
All Implemented Interfaces:
SwingConstants
Enclosing class:
TableView

public class TableView.RowView
extends BoxView

View of a row in a row-centric table.


Field Summary
private  AttributeSet attr
           
(package private)  BitSet fillColumns
          columns filled by multi-column or multi-row cells
(package private)  boolean multiRowCells
          Does this table row have cells that span multiple rows?
private  StyleSheet.BoxPainter painter
           
(package private)  int rowIndex
          The row index within the overall grid
(package private)  int viewIndex
          The view index (for row index to view index conversion).
 
Fields inherited from class javax.swing.text.BoxView
 
Fields inherited from class javax.swing.text.CompositeView
 
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
TableView.RowView(Element elem)
          Constructs a TableView for the given element.
 
Method Summary
protected  SizeRequirements calculateMajorAxisRequirements(int axis, SizeRequirements r)
          Calculates the size requirements for the major axis axis.
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.
(package private)  void clearFilledColumns()
           
(package private)  void fillColumn(int col)
           
(package private)  View findViewAtPoint(int x, int y, Rectangle alloc)
           
 AttributeSet getAttributes()
          Fetches the attributes to use when rendering.
(package private)  int getColumnCount()
          The number of columns present in this row.
 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.
(package private)  boolean isFilled(int col)
           
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).
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).
 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.
(package private)  void setPropertiesFromAttributes()
          Update any cached values that come from attributes.
 
Methods inherited from class javax.swing.text.BoxView
baselineLayout, baselineRequirements, childAllocation, flipEastAndWestAtEnds, forwardUpdate, getAlignment, getAxis, getChildAllocation, getHeight, getOffset, getSpan, getViewAtPoint, getWidth, isAfter, isAllocationValid, isBefore, isLayoutValid, layout, layoutChanged, modelToView, paintChild, setAxis, setSize, viewToModel
 
Methods inherited from class javax.swing.text.CompositeView
getBottomInset, getInsideAllocation, getLeftInset, getNextEastWestVisualPositionFrom, getNextNorthSouthVisualPositionFrom, getNextVisualPositionFrom, getRightInset, getTopInset, getView, getViewCount, getViewIndex, getViewIndexAtPosition, loadChildren, modelToView, setInsets, setParagraphInsets, setParent
 
Methods inherited from class javax.swing.text.View
append, breakView, createFragment, forwardUpdateToView, getBreakWeight, getContainer, getDocument, getElement, getEndOffset, getGraphics, getParent, getStartOffset, getToolTipText, getViewFactory, getViewIndex, insert, insertUpdate, isVisible, modelToView, remove, removeAll, removeUpdate, updateChildren, updateLayout, viewToModel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

painter

private StyleSheet.BoxPainter painter

attr

private AttributeSet attr

fillColumns

BitSet fillColumns
columns filled by multi-column or multi-row cells


rowIndex

int rowIndex
The row index within the overall grid


viewIndex

int viewIndex
The view index (for row index to view index conversion). This is set by the updateGrid method.


multiRowCells

boolean multiRowCells
Does this table row have cells that span multiple rows?

Constructor Detail

TableView.RowView

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

Parameters:
elem - the element that this view is responsible for
Method Detail

clearFilledColumns

void clearFilledColumns()

fillColumn

void fillColumn(int col)

isFilled

boolean isFilled(int col)

getColumnCount

int getColumnCount()
The number of columns present in this row.


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 class View

findViewAtPoint

View findViewAtPoint(int x,
                     int y,
                     Rectangle alloc)

getStyleSheet

protected StyleSheet getStyleSheet()

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 class BoxView
Parameters:
child - the child view
width - true if the width preference should change
height - true if the height preference should change

calculateMajorAxisRequirements

protected SizeRequirements calculateMajorAxisRequirements(int axis,
                                                          SizeRequirements r)
Description copied from class: BoxView
Calculates the size requirements for the major axis axis.

Overrides:
calculateMajorAxisRequirements in class BoxView
Parameters:
axis - the axis being studied
r - the SizeRequirements object; if null one will be created
Returns:
the newly initialized SizeRequirements object
See Also:
SizeRequirements

getMinimumSpan

public float getMinimumSpan(int axis)
Description copied from class: BoxView
Determines the minimum span for this view along an axis.

Overrides:
getMinimumSpan in class BoxView
Parameters:
axis - may be either View.X_AXIS or View.Y_AXIS
Returns:
the span the view would like to be rendered into >= 0; 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

getMaximumSpan

public float getMaximumSpan(int axis)
Description copied from class: BoxView
Determines the maximum span for this view along an axis.

Overrides:
getMaximumSpan in class BoxView
Parameters:
axis - may be either View.X_AXIS or View.Y_AXIS
Returns:
the span the view would like to be rendered into >= 0; 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

getPreferredSpan

public float getPreferredSpan(int axis)
Description copied from class: BoxView
Determines the preferred span for this view along an axis.

Overrides:
getPreferredSpan in class BoxView
Parameters:
axis - may be either View.X_AXIS or View.Y_AXIS
Returns:
the span the view would like to be rendered into >= 0; 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

changedUpdate

public void changedUpdate(DocumentEvent e,
                          Shape a,
                          ViewFactory f)
Description copied from class: View
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 class 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
See Also:
View.changedUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)

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 class BoxView
Parameters:
g - the rendering surface to use
allocation - the allocated region to render into
See Also:
View.paint(java.awt.Graphics, java.awt.Shape)

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 class BoxView
Parameters:
offset - the starting index into the child views to insert the new views; this should be a value >= 0 and <= getViewCount
length - the number of existing child views to remove; This should be a value >= 0 and <= (getViewCount() - offset)
views - the child views to add; this value can be nullto indicate no children are being added (useful to remove)

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 class BoxView
Parameters:
axis - the axis being studied
r - the SizeRequirements object; if null one will be created
Returns:
the newly initialized SizeRequirements object
See Also:
SizeRequirements

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 class 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
Returns:
the offset and span for each child view in the offsets and spans parameters

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 class 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
Returns:
the offset and span for each child view in the offsets and spans parameters

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 class BoxView
Parameters:
axis - may be either View.X_AXIS or View.Y_AXIS
Returns:
the resize weight
Throws:
IllegalArgumentException - for an invalid axis

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 class 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

setPropertiesFromAttributes

void setPropertiesFromAttributes()
Update any cached values that come from attributes.