javax.swing.text
Class TableView

java.lang.Object
  extended by javax.swing.text.View
      extended by javax.swing.text.CompositeView
          extended by javax.swing.text.BoxView
              extended by javax.swing.text.TableView
All Implemented Interfaces:
SwingConstants

public abstract class TableView
extends BoxView

A View implementation for rendering tables inside styled text. Tables are rendered as vertical boxes (see BoxView). These boxes have a number of child views, which are the rows of the table. These are horizontal boxes containing the actuall cells of the table. These cells can be arbitrary view implementations and are fetched via the ViewFactory returned by View.getViewFactory().


Nested Class Summary
 class TableView.TableCell
          Deprecated. Table cells are now rendered by an arbitrary View implementation.
 class TableView.TableRow
          A view implementation that renders a row of a TableView.
 
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
TableView(Element el)
          Creates a new instance of TableView.
 
Method Summary
protected  SizeRequirements calculateMinorAxisRequirements(int axis, SizeRequirements req)
          Calculates the requirements of this view for the minor (== horizontal) axis.
protected  TableView.TableCell createTableCell(Element el)
          Deprecated. Table cells are now rendered by an arbitrary View implementation.
protected  TableView.TableRow createTableRow(Element el)
          Creates a view for a table row.
protected  void forwardUpdate(DocumentEvent.ElementChange ec, DocumentEvent e, Shape a, ViewFactory vf)
          Forwards the DocumentEvent to child views that need to get notified of the change to the model.
protected  View getViewAtPosition(int pos, Rectangle a)
          Returns the child view that represents the specified position in the model.
protected  void layoutColumns(int targetSpan, int[] offsets, int[] spans, SizeRequirements[] reqs)
          Lays out the columns to fit within the specified target span.
protected  void layoutMinorAxis(int targetSpan, int axis, int[] offsets, int[] spans)
          Lays out the child views along the minor axis of the table (that is the horizontal axis).
 void replace(int offset, int length, View[] views)
          Replaces a number of child views with a set of new child views.
 
Methods inherited from class javax.swing.text.BoxView
baselineLayout, baselineRequirements, calculateMajorAxisRequirements, childAllocation, flipEastAndWestAtEnds, getAlignment, getAxis, getChildAllocation, getHeight, getMaximumSpan, getMinimumSpan, getOffset, getPreferredSpan, getResizeWeight, getSpan, getViewAtPoint, getWidth, isAfter, isAllocationValid, isBefore, isLayoutValid, layout, layoutChanged, layoutMajorAxis, modelToView, paint, paintChild, preferenceChanged, 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, changedUpdate, createFragment, dump, forwardUpdateToView, getAttributes, 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
 

Constructor Detail

TableView

public TableView(Element el)
Creates a new instance of TableView.

Parameters:
el - the element for which to create a table view
Method Detail

replace

public void replace(int offset,
                    int length,
                    View[] views)
Replaces a number of child views with a set of new child views. This is implemented to call the superclass behaviour and invalidate the layout.

Overrides:
replace in class BoxView
Parameters:
offset - the offset at which to replace child views
length - the number of child views to remove
views - the new set of views

createTableRow

protected TableView.TableRow createTableRow(Element el)
Creates a view for a table row.

Parameters:
el - the element that represents the table row
Returns:
a view for rendering the table row

createTableCell

protected TableView.TableCell createTableCell(Element el)
Deprecated. Table cells are now rendered by an arbitrary View implementation.

Creates a view for a table cell. This method is deprecated and not used anymore.

Parameters:
el - the element that represents the table cell
Returns:
a view for rendering the table cell

forwardUpdate

protected void forwardUpdate(DocumentEvent.ElementChange ec,
                             DocumentEvent e,
                             Shape a,
                             ViewFactory vf)
Description copied from class: View
Forwards the DocumentEvent to child views that need to get notified of the change to the model. This calles View.forwardUpdateToView(javax.swing.text.View, javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory) for each View that must be forwarded to. If ec is not null (this means there have been structural changes to the element that this view is responsible for) this method should recognize this and don't notify newly added child views.

Overrides:
forwardUpdate in class BoxView
Parameters:
ec - the ElementChange describing the element changes (may be null if there were no changes)
e - the DocumentEvent describing the changes to the model
a - the current allocation of the view
vf - the ViewFactory used to create new Views

layoutColumns

protected void layoutColumns(int targetSpan,
                             int[] offsets,
                             int[] spans,
                             SizeRequirements[] reqs)
Lays out the columns to fit within the specified target span.

Parameters:
targetSpan - the total span for the columns
offsets - an array that holds the offsets of the columns when this method returns
spans - an array that holds the spans of the columns when this method returns
reqs - the size requirements for each column

layoutMinorAxis

protected void layoutMinorAxis(int targetSpan,
                               int axis,
                               int[] offsets,
                               int[] spans)
Lays out the child views along the minor axis of the table (that is the horizontal axis). This is implemented to call layoutColumns(int, int[], int[], javax.swing.SizeRequirements[]) to layout the column layout of this table, and then forward to the superclass to actually lay out the rows.

Overrides:
layoutMinorAxis in class BoxView
Parameters:
targetSpan - the available span along the minor (horizontal) axis
axis - the axis
offsets - an array that holds the offsets of the columns when this method returns
spans - an array that holds the spans of the columns when this method returns

calculateMinorAxisRequirements

protected SizeRequirements calculateMinorAxisRequirements(int axis,
                                                          SizeRequirements req)
Calculates the requirements of this view for the minor (== horizontal) axis. This is reimplemented to calculate the requirements as the sum of the size requirements of the columns.

Overrides:
calculateMinorAxisRequirements in class BoxView
Parameters:
axis - the axis
req - the size requirements object to use, if null a new one will be created
Returns:
the size requirements for this BoxView along the specified axis

getViewAtPosition

protected View getViewAtPosition(int pos,
                                 Rectangle a)
Returns the child view that represents the specified position in the model. This is reimplemented because in this view we do not necessarily have a one to one mapping of child elements to child views.

Overrides:
getViewAtPosition in class CompositeView
Parameters:
pos - the model position for which to query the view
a - the allocation of this view
Returns:
the view that corresponds to the specified model position or null if there is none