javax.swing.text

Class TableView

public abstract class TableView extends BoxView

A {@link View} implementation for rendering tables inside styled text. Tables are rendered as vertical boxes (see {@link 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 {@link ViewFactory} returned by {@link View#getViewFactory}.
Nested Class Summary
classTableView.TableCell
This class is deprecated and not used anymore.
classTableView.TableRow
A view implementation that renders a row of a TableView.
Constructor Summary
TableView(Element el)
Creates a new instance of TableView.
Method Summary
protected SizeRequirementscalculateMinorAxisRequirements(int axis, SizeRequirements req)
Calculates the requirements of this view for the minor (== horizontal) axis.
protected TableView.TableCellcreateTableCell(Element el)
Creates a view for a table cell.
protected TableView.TableRowcreateTableRow(Element el)
Creates a view for a table row.
protected voidforwardUpdate(DocumentEvent.ElementChange ec, DocumentEvent e, Shape a, ViewFactory vf)
protected ViewgetViewAtPosition(int pos, Rectangle a)
Returns the child view that represents the specified position in the model.
protected voidlayoutColumns(int targetSpan, int[] offsets, int[] spans, SizeRequirements[] reqs)
Lays out the columns to fit within the specified target span.
protected voidlayoutMinorAxis(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).
voidreplace(int offset, int length, View[] views)
Replaces a number of child views with a set of new child views.

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

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.

Parameters: axis the axis req the size requirements object to use, if null a new one will be created

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

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

forwardUpdate

protected void forwardUpdate(DocumentEvent.ElementChange ec, DocumentEvent e, Shape a, ViewFactory vf)

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.

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

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 {@link #layoutColumns} to layout the column layout of this table, and then forward to the superclass to actually lay out the rows.

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

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.

Parameters: offset the offset at which to replace child views length the number of child views to remove views the new set of views