TableView (Java SE 15 & JDK 15) (original) (raw)
All Implemented Interfaces:
[SwingConstants](../SwingConstants.html "interface in javax.swing")
public abstract class TableView extends BoxView
Implements View interface for a table, that is composed of an element structure where the child elements of the element this view is responsible for represent rows and the child elements of the row elements are cells. The cell elements can have an arbitrary element structure under them, which will be built with the ViewFactory returned by the getViewFactory method.
TABLE ROW CELL CELL ROW CELL CELL
This is implemented as a hierarchy of boxes, the table itself is a vertical box, the rows are horizontal boxes, and the cells are vertical boxes. The cells are allowed to span multiple columns and rows. By default, the table can be thought of as being formed over a grid (i.e. somewhat like one would find in gridbag layout), where table cells can request to span more than one grid cell. The default horizontal span of table cells will be based upon this grid, but can be changed by reimplementing the requested span of the cell (i.e. table cells can have independent spans if desired).
See Also:
Nested Class Summary
Field Summary
Fields declared in interface javax.swing.SwingConstants
[BOTTOM](../SwingConstants.html#BOTTOM), [CENTER](../SwingConstants.html#CENTER), [EAST](../SwingConstants.html#EAST), [HORIZONTAL](../SwingConstants.html#HORIZONTAL), [LEADING](../SwingConstants.html#LEADING), [LEFT](../SwingConstants.html#LEFT), [NEXT](../SwingConstants.html#NEXT), [NORTH](../SwingConstants.html#NORTH), [NORTH_EAST](../SwingConstants.html#NORTH%5FEAST), [NORTH_WEST](../SwingConstants.html#NORTH%5FWEST), [PREVIOUS](../SwingConstants.html#PREVIOUS), [RIGHT](../SwingConstants.html#RIGHT), [SOUTH](../SwingConstants.html#SOUTH), [SOUTH_EAST](../SwingConstants.html#SOUTH%5FEAST), [SOUTH_WEST](../SwingConstants.html#SOUTH%5FWEST), [TOP](../SwingConstants.html#TOP), [TRAILING](../SwingConstants.html#TRAILING), [VERTICAL](../SwingConstants.html#VERTICAL), [WEST](../SwingConstants.html#WEST)
Constructor Summary
Constructors
Constructor | Description |
---|---|
TableView(Element elem) | Constructs a TableView for the given element. |
Method Summary
Modifier and Type | Method | Description |
---|---|---|
protected SizeRequirements | calculateMinorAxisRequirements(int axis,SizeRequirements r) | Calculate the requirements for the minor axis. |
protected TableView.TableCell | createTableCell(Element elem) | Deprecated. |
protected TableView.TableRow | createTableRow(Element elem) | Creates a new table row. |
protected View | getViewAtPosition(int pos,Rectangle a) | Fetches the child view that represents the given position in the model. |
protected void | layoutColumns(int targetSpan, int[] offsets, int[] spans,SizeRequirements[] reqs) | Lays out the columns to fit within the given target span. |
protected void | layoutMinorAxis(int targetSpan, int axis, int[] offsets, int[] spans) | Perform layout for the minor axis of the box (i.e. the axis orthogonal to the axis that it represents). |
void | replace(int offset, int length,View[] views) | Change the child views. |
Methods declared in class javax.swing.text.BoxView
[baselineLayout](BoxView.html#baselineLayout%28int,int,int%5B%5D,int%5B%5D%29), [baselineRequirements](BoxView.html#baselineRequirements%28int,javax.swing.SizeRequirements%29), [calculateMajorAxisRequirements](BoxView.html#calculateMajorAxisRequirements%28int,javax.swing.SizeRequirements%29), [childAllocation](BoxView.html#childAllocation%28int,java.awt.Rectangle%29), [flipEastAndWestAtEnds](BoxView.html#flipEastAndWestAtEnds%28int,javax.swing.text.Position.Bias%29), [forwardUpdate](BoxView.html#forwardUpdate%28javax.swing.event.DocumentEvent.ElementChange,javax.swing.event.DocumentEvent,java.awt.Shape,javax.swing.text.ViewFactory%29), [getAlignment](BoxView.html#getAlignment%28int%29), [getAxis](BoxView.html#getAxis%28%29), [getChildAllocation](BoxView.html#getChildAllocation%28int,java.awt.Shape%29), [getHeight](BoxView.html#getHeight%28%29), [getMaximumSpan](BoxView.html#getMaximumSpan%28int%29), [getMinimumSpan](BoxView.html#getMinimumSpan%28int%29), [getOffset](BoxView.html#getOffset%28int,int%29), [getPreferredSpan](BoxView.html#getPreferredSpan%28int%29), [getResizeWeight](BoxView.html#getResizeWeight%28int%29), [getSpan](BoxView.html#getSpan%28int,int%29), [getViewAtPoint](BoxView.html#getViewAtPoint%28int,int,java.awt.Rectangle%29), [getWidth](BoxView.html#getWidth%28%29), [isAfter](BoxView.html#isAfter%28int,int,java.awt.Rectangle%29), [isAllocationValid](BoxView.html#isAllocationValid%28%29), [isBefore](BoxView.html#isBefore%28int,int,java.awt.Rectangle%29), [isLayoutValid](BoxView.html#isLayoutValid%28int%29), [layout](BoxView.html#layout%28int,int%29), [layoutChanged](BoxView.html#layoutChanged%28int%29), [layoutMajorAxis](BoxView.html#layoutMajorAxis%28int,int,int%5B%5D,int%5B%5D%29), [modelToView](BoxView.html#modelToView%28int,java.awt.Shape,javax.swing.text.Position.Bias%29), [paint](BoxView.html#paint%28java.awt.Graphics,java.awt.Shape%29), [paintChild](BoxView.html#paintChild%28java.awt.Graphics,java.awt.Rectangle,int%29), [preferenceChanged](BoxView.html#preferenceChanged%28javax.swing.text.View,boolean,boolean%29), [setAxis](BoxView.html#setAxis%28int%29), [setSize](BoxView.html#setSize%28float,float%29), [viewToModel](BoxView.html#viewToModel%28float,float,java.awt.Shape,javax.swing.text.Position.Bias%5B%5D%29)
Methods declared in class javax.swing.text.CompositeView
[getBottomInset](CompositeView.html#getBottomInset%28%29), [getInsideAllocation](CompositeView.html#getInsideAllocation%28java.awt.Shape%29), [getLeftInset](CompositeView.html#getLeftInset%28%29), [getNextEastWestVisualPositionFrom](CompositeView.html#getNextEastWestVisualPositionFrom%28int,javax.swing.text.Position.Bias,java.awt.Shape,int,javax.swing.text.Position.Bias%5B%5D%29), [getNextNorthSouthVisualPositionFrom](CompositeView.html#getNextNorthSouthVisualPositionFrom%28int,javax.swing.text.Position.Bias,java.awt.Shape,int,javax.swing.text.Position.Bias%5B%5D%29), [getNextVisualPositionFrom](CompositeView.html#getNextVisualPositionFrom%28int,javax.swing.text.Position.Bias,java.awt.Shape,int,javax.swing.text.Position.Bias%5B%5D%29), [getRightInset](CompositeView.html#getRightInset%28%29), [getTopInset](CompositeView.html#getTopInset%28%29), [getView](CompositeView.html#getView%28int%29), [getViewCount](CompositeView.html#getViewCount%28%29), [getViewIndex](CompositeView.html#getViewIndex%28int,javax.swing.text.Position.Bias%29), [getViewIndexAtPosition](CompositeView.html#getViewIndexAtPosition%28int%29), [loadChildren](CompositeView.html#loadChildren%28javax.swing.text.ViewFactory%29), [modelToView](CompositeView.html#modelToView%28int,javax.swing.text.Position.Bias,int,javax.swing.text.Position.Bias,java.awt.Shape%29), [setInsets](CompositeView.html#setInsets%28short,short,short,short%29), [setParagraphInsets](CompositeView.html#setParagraphInsets%28javax.swing.text.AttributeSet%29), [setParent](CompositeView.html#setParent%28javax.swing.text.View%29)
Methods declared in class javax.swing.text.View
[append](View.html#append%28javax.swing.text.View%29), [breakView](View.html#breakView%28int,int,float,float%29), [changedUpdate](View.html#changedUpdate%28javax.swing.event.DocumentEvent,java.awt.Shape,javax.swing.text.ViewFactory%29), [createFragment](View.html#createFragment%28int,int%29), [forwardUpdateToView](View.html#forwardUpdateToView%28javax.swing.text.View,javax.swing.event.DocumentEvent,java.awt.Shape,javax.swing.text.ViewFactory%29), [getAttributes](View.html#getAttributes%28%29), [getBreakWeight](View.html#getBreakWeight%28int,float,float%29), [getContainer](View.html#getContainer%28%29), [getDocument](View.html#getDocument%28%29), [getElement](View.html#getElement%28%29), [getEndOffset](View.html#getEndOffset%28%29), [getGraphics](View.html#getGraphics%28%29), [getParent](View.html#getParent%28%29), [getStartOffset](View.html#getStartOffset%28%29), [getToolTipText](View.html#getToolTipText%28float,float,java.awt.Shape%29), [getViewFactory](View.html#getViewFactory%28%29), [getViewIndex](View.html#getViewIndex%28float,float,java.awt.Shape%29), [insert](View.html#insert%28int,javax.swing.text.View%29), [insertUpdate](View.html#insertUpdate%28javax.swing.event.DocumentEvent,java.awt.Shape,javax.swing.text.ViewFactory%29), [isVisible](View.html#isVisible%28%29), [modelToView](View.html#modelToView%28int,java.awt.Shape%29), [remove](View.html#remove%28int%29), [removeAll](View.html#removeAll%28%29), [removeUpdate](View.html#removeUpdate%28javax.swing.event.DocumentEvent,java.awt.Shape,javax.swing.text.ViewFactory%29), [updateChildren](View.html#updateChildren%28javax.swing.event.DocumentEvent.ElementChange,javax.swing.event.DocumentEvent,javax.swing.text.ViewFactory%29), [updateLayout](View.html#updateLayout%28javax.swing.event.DocumentEvent.ElementChange,javax.swing.event.DocumentEvent,java.awt.Shape%29), [viewToModel](View.html#viewToModel%28float,float,java.awt.Shape%29)
Methods declared in class java.lang.Object
[clone](../../../../java.base/java/lang/Object.html#clone%28%29), [equals](../../../../java.base/java/lang/Object.html#equals%28java.lang.Object%29), [finalize](../../../../java.base/java/lang/Object.html#finalize%28%29), [getClass](../../../../java.base/java/lang/Object.html#getClass%28%29), [hashCode](../../../../java.base/java/lang/Object.html#hashCode%28%29), [notify](../../../../java.base/java/lang/Object.html#notify%28%29), [notifyAll](../../../../java.base/java/lang/Object.html#notifyAll%28%29), [toString](../../../../java.base/java/lang/Object.html#toString%28%29), [wait](../../../../java.base/java/lang/Object.html#wait%28%29), [wait](../../../../java.base/java/lang/Object.html#wait%28long%29), [wait](../../../../java.base/java/lang/Object.html#wait%28long,int%29)
Constructor Details
TableView
public TableView(Element elem)
Constructs a TableView for the given element.
Parameters:
elem
- the element that this view is responsible forMethod Details
createTableRow
Creates a new table row.
Parameters:
elem
- an element
Returns:
the rowcreateTableCell
Parameters:
elem
- an element
Returns:
the cellreplace
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](BoxView.html#replace%28int,int,javax.swing.text.View%5B%5D%29)
in class[BoxView](BoxView.html "class in javax.swing.text")
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 benull
to indicate no children are being added (useful to remove)layoutColumns
protected void layoutColumns(int targetSpan, int[] offsets, int[] spans,SizeRequirements[] reqs)
Lays out the columns to fit within the given target span. Returns the results throughoffsets
andspans
.
Parameters:
targetSpan
- the given span for total of all the table columns
reqs
- the requirements desired for each column. This is the column maximum of the cells minimum, preferred, and maximum requested span
spans
- the return value of how much to allocated to each column
offsets
- the return value of the offset from the origin for each columnlayoutMinorAxis
protected void layoutMinorAxis(int targetSpan, int axis, int[] offsets, int[] spans)
Perform layout for the minor axis of the box (i.e. the axis orthogonal 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 call thelayoutColumns method, and then forward to the superclass to actually carry out the layout of the tables rows.
Overrides:
[layoutMinorAxis](BoxView.html#layoutMinorAxis%28int,int,int%5B%5D,int%5B%5D%29)
in class[BoxView](BoxView.html "class in javax.swing.text")
Parameters:
targetSpan
- the total span given to the view, which would 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.calculateMinorAxisRequirements
Calculate the requirements for the minor axis. This is called by the superclass whenever the requirements need to be updated (i.e. a preferenceChanged was messaged through this view).
This is implemented to calculate the requirements as the sum of the requirements of the columns.
Overrides:
[calculateMinorAxisRequirements](BoxView.html#calculateMinorAxisRequirements%28int,javax.swing.SizeRequirements%29)
in class[BoxView](BoxView.html "class in javax.swing.text")
Parameters:
axis
- the axis being studied
r
- theSizeRequirements
object; ifnull
one will be created
Returns:
the newly initializedSizeRequirements
object
See Also:
SizeRequirementsgetViewAtPosition
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](CompositeView.html#getViewAtPosition%28int,java.awt.Rectangle%29)
in class[CompositeView](CompositeView.html "class in javax.swing.text")
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, ornull
if there isn't one