edu.neu.ccs.gui
Class TableLayout

java.lang.Object
  extended byedu.neu.ccs.gui.TableLayout
All Implemented Interfaces:
JPTConstants, LayoutManager, LayoutManager2, SwingConstants

public class TableLayout
extends Object
implements LayoutManager2, JPTConstants

Layout manager effecting a table with an arbitrary number of rows and columns, each with their own width and height. Optional gaps with a distance of an arbitrary number of pixels can be set in the horizontal and vertical directions.

The alignment of components within their respective cells can be set to any of the nine compass directions. Alignments can be set for individual cells, table rows, table columns, or the table itself.

Empty rows and columns are not included in the rendering process and do not result in the application of a gap.

As of 2.5.0, adds methods to return the component at a given row,col position or CellPosition. These methods permit one to inspect the components without the need to call the heavyweight method getComponentTable().

Corresponding methods to remove a component from a given cell position are also provided.

Since:
1.1
Version:
2.5.0

Field Summary
protected  int[][] cellAlignment
          Alignment for cells in this table layout.
protected  int[] colAlignment
          Default alignments for columns in this table layout.
protected  int cols
          Number of columns in this table layout.
static int DEFAULT_ALIGNMENT
          Value of the default alignment.
static int DEFAULT_ORIENTATION
          Value of the default orientation.
protected  int hgap
          Horizontal gap between columns in this table layout.
static int INVALID_ALIGNMENT
          Value designating an invalid alignment.
protected  int[] minColWidth
          Minimum widths for columns in this table layout.
protected  int[] minRowHeight
          Minimum heights for rows in this table layout.
static int NO_ALIGNMENT_SET
          Value designating an alignment explicitly not set.
static int NO_MINIMUM_SET
          Value designating a non-existent minimum size.
protected  int orientation
          Orientation for this table layout.
protected  int[] rowAlignment
          Default alignments for rows in this table layout.
protected  int rows
          Number of rows in this table layout.
protected  Component[][] table
          Table of components in this layout.
protected  int tableAlignment
          Default alignment for cells in this table layout.
protected  int vgap
          Vertical gap between rows in this table layout.
 
Fields inherited from interface edu.neu.ccs.util.JPTConstants
ABOVE, ALIGNMENT, BELOW, BOTTOM_LEFT, BOTTOM_RIGHT, DEFAULT, FONT, INPUT_PROPERTIES, MANDATORY, OPTIONAL, ORIENTATION, TOP_LEFT, TOP_RIGHT, VALUE
 
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
TableLayout(int rows, int cols)
          Constructs a table layout with the given number of rows and columns.
TableLayout(int rows, int cols, int align)
          Constructs a table layout with the given number of rows and columns, and the given default table cell alignment.
TableLayout(int rows, int cols, int hgap, int vgap)
          Constructs a table layout with the given number of rows and columns, and the given horizontal and vertical gaps.
TableLayout(int rows, int cols, int hgap, int vgap, int align)
          Constructs a table layout with the given number of rows and columns, the given horizontal and vertical gaps, and the given default table cell alignment,
TableLayout(int rows, int cols, int hgap, int vgap, int align, int orientation)
          Constructs a table layout with the given number of rows and columns, the given horizontal and vertical gaps, the given default table cell alignment, and the given layout orientation.
 
Method Summary
 void addLayoutComponent(Component c, Object position)
          Adds the given component to this table layout at the given table position.
 void addLayoutComponent(String name, Component c)
          Adds the given component to this layout at the next available position.
(package private)  int adjustAlignment(int align)
          Returns the alignment value corresponding to the given value, or INVALID_ALIGNMENT if the given value is invalid.
protected  Point applyAlignment(int x, int y, int cellWidth, int cellHeight, int componentWidth, int componentHeight, int align)
          Returns the point, given in terms of the parent container's coordinate space, where a component of the given size should be located given a cell with the provided bounds and the given alignment value.
 int getCellAlignment(CellPosition p)
          Returns the alignment value for the cell at the given position or the table alignment if an error occurs.
 int getCellAlignment(int row, int col)
          Returns the alignment value for the cell at the given position or the table alignment if an error occurs.
 int getColumnAlignment(int col)
          Returns the default alignment value for the given column.
 int getColumnCount()
          Returns the number of columns in this table layout.
 Component[][] getComponentTable()
          Returns a copy of the table of components in this layout.
 int getEffectiveCellAlignment(CellPosition p)
          Returns the effective alignment value for the cell at the given position, that is, either the cell's own alignment if it has been set or the alignment of the table as a whole.
 int getEffectiveCellAlignment(int row, int col)
          Returns the effective alignment value for the cell at the given position, that is, either the cell's own alignment if it has been set or the alignment of the table as a whole.
 int getHorizontalGap()
          Returns the gap, in pixels, between columns in this table layout.
 float getLayoutAlignmentX(Container target)
          Returns the alignment for this table layout along the x axis.
 float getLayoutAlignmentY(Container target)
          Returns the alignment along the y axis.
 int getMinimumColumnWidth(int col)
          Returns the minimum width set for the given column.
 int getMinimumRowHeight(int row)
          Returns the minimum height set for the given row.
protected  CellPosition getNextAvailablePosition()
          Returns the next empty position in the table layout, that is, a position that does not contain a component; if the table layout is full, returns a new position that will require either adding a column or a row to the internal component table.
 int getOrientation()
          Returns the orientation for this table layout.
 int getRowAlignment(int row)
          Returns the default alignment value for the given row.
 int getRowCount()
          Returns the number of rows in this table layout.
 int getTableAlignment()
          Returns the default alignment for cells in this table layout.
 Component getTableEntry(CellPosition position)
          Returns the component at the given CellPosition position in the table layout data structure.
 Component getTableEntry(int row, int col)
          Returns the component at the given row,col position in the table layout data structure.
 int getVerticalGap()
          Returns the gap, in pixels, between rows in this table layout.
 void invalidateLayout(Container parent)
          This method does nothing, as this layout does not cache information about its container.
 boolean isEmptyColumn(int col)
          Returns whether or not the given column is empty.
 boolean isEmptyRow(int row)
          Returns whether or not the given row is empty.
 boolean isValidColumn(int col)
          Returns whether or not the given column index is valid.
 boolean isValidRow(int row)
          Returns whether or not the given row index is valid.
 void layoutContainer(Container parent)
          Lays out the components in the given parent container.
protected  void layoutContainer(int[] widths, int[] heights, Insets insets)
          Lays out the components in the parent container using the given arrays of column widths and row heights.
 int maximumColumnWidth(int col)
          Returns the actual maximum width for the given column.
 int[] maximumColumnWidths()
          Returns the maximum widths for the columns in this table layout.
 Dimension maximumLayoutSize(Container parent)
          Returns the maximum size for this table layout.
 int maximumRowHeight(int row)
          Returns the actual maximum height for the given row.
 int[] maximumRowHeights()
          Returns the maximum heights for the rows in this table layout.
 int minimumColumnWidth(int col)
          Returns the actual minimum width for the given column.
 int[] minimumColumnWidths()
          Returns the minimum widths for the columns in this table layout.
 Dimension minimumLayoutSize(Container parent)
          Returns the minimum size for this table layout.
 int minimumRowHeight(int row)
          Returns the actual minimum height for the given row.
 int[] minimumRowHeights()
          Returns the minimum heights for the rows in this table layout.
 int preferredColumnWidth(int col)
          Returns the actual preferred width for the given column.
 int[] preferredColumnWidths()
          Returns the preferred widths for the columns in this table layout.
 Dimension preferredLayoutSize(Container parent)
          Returns the preferred size for this table layout.
 int preferredRowHeight(int row)
          Returns the actual preferred height for the given row.
 int[] preferredRowHeights()
          Returns the preferred heights for the rows in this table layout.
 void removeLayoutComponent(CellPosition position)
          Removes the component at the given CellPosition from the data structure of this layout.
 void removeLayoutComponent(Component c)
          Removes the given component from the data structure of this layout.
 void removeLayoutComponent(int row, int col)
          Removes the component at the given row,col position from the data structure of this layout.
 void setAllMinimumColumnWidths(int width)
          Sets all minimum column widths to the same value.
 void setAllMinimumRowHeights(int height)
          Sets all minimum row heights to the same value.
 void setCellAlignment(CellPosition p, int align)
          Sets the alignment for the cell at the given position to the given alignment value.
 void setCellAlignment(int row, int col, int align)
          Sets the alignment for the cell at the given position to the given alignment value.
(package private)  void setCellAlignmentImpl(int row, int col, int align)
          Sets the alignment for the cell at the given position to the given alignment value.
 void setColumnAlignment(int col, int align)
          Sets the alignment for cells in the given column to the given alignment value.
(package private)  void setColumns(int colCount)
          Sets the number of columns in this table layout to the given number of columns.
 void setHorizontalGap(int hgap)
          Sets the gap between columns in this table layout to the given value, in pixels.
 void setMinimumColumnWidth(int col, int width)
          Sets the minimum width for the given column to the given width in pixels.
 void setMinimumRowHeight(int row, int height)
          Sets the minimum height for the given row to the given height in pixels.
 void setOrientation(int orientation)
          Sets the orientation for this table layout to the given orientation value.
 void setRowAlignment(int row, int align)
          Sets the alignment for cells in the given row to the given alignment value.
(package private)  void setRows(int rowCount)
          Sets the number of rows in this table to the given number of rows.
 void setTableAlignment(int align)
          Sets the alignment for cells in this table layout to the given alignment value.
 void setVerticalGap(int vgap)
          Sets the gap between rows in this table layout to the given value, in pixels.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ALIGNMENT

public static final int DEFAULT_ALIGNMENT
Value of the default alignment.

See Also:
Constant Field Values

DEFAULT_ORIENTATION

public static final int DEFAULT_ORIENTATION
Value of the default orientation.

Since:
2.0
See Also:
Constant Field Values

NO_ALIGNMENT_SET

public static final int NO_ALIGNMENT_SET
Value designating an alignment explicitly not set.

See Also:
Constant Field Values

INVALID_ALIGNMENT

public static final int INVALID_ALIGNMENT
Value designating an invalid alignment.

See Also:
Constant Field Values

NO_MINIMUM_SET

public static final int NO_MINIMUM_SET
Value designating a non-existent minimum size.

See Also:
Constant Field Values

rows

protected int rows
Number of rows in this table layout.


cols

protected int cols
Number of columns in this table layout.


hgap

protected int hgap
Horizontal gap between columns in this table layout.


vgap

protected int vgap
Vertical gap between rows in this table layout.


table

protected Component[][] table
Table of components in this layout.


orientation

protected int orientation
Orientation for this table layout.

Since:
2.0

tableAlignment

protected int tableAlignment
Default alignment for cells in this table layout.


rowAlignment

protected int[] rowAlignment
Default alignments for rows in this table layout.


colAlignment

protected int[] colAlignment
Default alignments for columns in this table layout.


cellAlignment

protected int[][] cellAlignment
Alignment for cells in this table layout.


minRowHeight

protected int[] minRowHeight
Minimum heights for rows in this table layout.


minColWidth

protected int[] minColWidth
Minimum widths for columns in this table layout.

Constructor Detail

TableLayout

public TableLayout(int rows,
                   int cols)
Constructs a table layout with the given number of rows and columns.

Parameters:
rows - the number of rows in this table layout
cols - the number of columns in this table layout
See Also:
TableLayout(int, int, int), TableLayout(int, int, int, int), TableLayout(int, int, int, int, int), TableLayout(int, int, int, int, int, int)

TableLayout

public TableLayout(int rows,
                   int cols,
                   int align)
Constructs a table layout with the given number of rows and columns, and the given default table cell alignment.

Parameters:
rows - the number of rows in this table layout
cols - the number of columns in this table layout
align - the default table cell alignment
See Also:
TableLayout(int, int), TableLayout(int, int, int, int), TableLayout(int, int, int, int, int), TableLayout(int, int, int, int, int, int), JPTConstants.DEFAULT

TableLayout

public TableLayout(int rows,
                   int cols,
                   int hgap,
                   int vgap)
Constructs a table layout with the given number of rows and columns, and the given horizontal and vertical gaps.

Parameters:
rows - the number of rows in this table layout
cols - the number of columns in this table layout
hgap - the gap between columns, in pixels
vgap - the gap between rows, in pixels
See Also:
TableLayout(int, int), TableLayout(int, int, int), TableLayout(int, int, int, int, int), TableLayout(int, int, int, int, int, int)

TableLayout

public TableLayout(int rows,
                   int cols,
                   int hgap,
                   int vgap,
                   int align)
Constructs a table layout with the given number of rows and columns, the given horizontal and vertical gaps, and the given default table cell alignment,

Parameters:
rows - the number of rows in this table layout
cols - the number of columns in this table layout
hgap - the gap between columns, in pixels
vgap - the gap between rows, in pixels
align - the default table cell alignment
See Also:
TableLayout(int, int), TableLayout(int, int, int), TableLayout(int, int, int, int), TableLayout(int, int, int, int, int, int), JPTConstants.DEFAULT

TableLayout

public TableLayout(int rows,
                   int cols,
                   int hgap,
                   int vgap,
                   int align,
                   int orientation)
Constructs a table layout with the given number of rows and columns, the given horizontal and vertical gaps, the given default table cell alignment, and the given layout orientation.

Parameters:
rows - the number of rows in this table layout
cols - the number of columns in this table layout
hgap - the gap between columns, in pixels
vgap - the gap between rows, in pixels
align - the default table cell alignment
orientation - the table layout orientation
Since:
2.0
See Also:
TableLayout(int, int), TableLayout(int, int, int), TableLayout(int, int, int, int), TableLayout(int, int, int, int, int), JPTConstants.DEFAULT
Method Detail

addLayoutComponent

public void addLayoutComponent(Component c,
                               Object position)
Adds the given component to this table layout at the given table position. If the given position is not a CellPosition, the given component is added at the next available position. If the given position is beyond the number of rows or columns in this table, the table is grown to accept the component at the given position.

Specified by:
addLayoutComponent in interface LayoutManager2
Parameters:
c - a component to be added
position - the cell position for the component
See Also:
addLayoutComponent(String, Component), getNextAvailablePosition()

addLayoutComponent

public void addLayoutComponent(String name,
                               Component c)
Adds the given component to this layout at the next available position.

Specified by:
addLayoutComponent in interface LayoutManager
Parameters:
name - the name for the given component (ignored)
c - a component to be added
See Also:
addLayoutComponent(Component, Object)

removeLayoutComponent

public void removeLayoutComponent(Component c)

Removes the given component from the data structure of this layout.

If the given component is not in this layout, this layout is not changed.

Specified by:
removeLayoutComponent in interface LayoutManager
Parameters:
c - a component to be removed

removeLayoutComponent

public void removeLayoutComponent(int row,
                                  int col)

Removes the component at the given row,col position from the data structure of this layout.

Does nothing if row,col is invalid.

Parameters:
row - the row position of the cell to remove
col - the col position of the cell to remove

removeLayoutComponent

public void removeLayoutComponent(CellPosition position)

Removes the component at the given CellPosition from the data structure of this layout.

Does nothing if position is null or invalid.

Parameters:
position - the CellPosition of the cell to remove

invalidateLayout

public void invalidateLayout(Container parent)
This method does nothing, as this layout does not cache information about its container.

Specified by:
invalidateLayout in interface LayoutManager2
Parameters:
parent - the parent container for this layout

layoutContainer

public void layoutContainer(Container parent)
Lays out the components in the given parent container.

Specified by:
layoutContainer in interface LayoutManager
Parameters:
parent - the parent container for this layout

minimumLayoutSize

public Dimension minimumLayoutSize(Container parent)
Returns the minimum size for this table layout.

Specified by:
minimumLayoutSize in interface LayoutManager
Parameters:
parent - the parent container for this layout
See Also:
preferredLayoutSize(Container), maximumLayoutSize(Container)

preferredLayoutSize

public Dimension preferredLayoutSize(Container parent)
Returns the preferred size for this table layout.

Specified by:
preferredLayoutSize in interface LayoutManager
Parameters:
parent - the parent container for this layout
See Also:
minimumLayoutSize(Container), maximumLayoutSize(Container)

maximumLayoutSize

public Dimension maximumLayoutSize(Container parent)
Returns the maximum size for this table layout.

Specified by:
maximumLayoutSize in interface LayoutManager2
Parameters:
parent - the parent container for this layout
See Also:
minimumLayoutSize(Container), preferredLayoutSize(Container)

getLayoutAlignmentX

public float getLayoutAlignmentX(Container target)
Returns the alignment for this table layout along the x axis.

Specified by:
getLayoutAlignmentX in interface LayoutManager2
Parameters:
target - the parent container for this layout
See Also:
getLayoutAlignmentY(Container)

getLayoutAlignmentY

public float getLayoutAlignmentY(Container target)
Returns the alignment along the y axis.

Specified by:
getLayoutAlignmentY in interface LayoutManager2
Parameters:
target - the parent container for this layout
See Also:
getLayoutAlignmentX(Container)

getComponentTable

public Component[][] getComponentTable()
Returns a copy of the table of components in this layout.


getTableEntry

public Component getTableEntry(int row,
                               int col)

Returns the component at the given row,col position in the table layout data structure.

Returns null if the position is invalid or if there is no component in that cell.

Parameters:
row - the row position of the cell
col - the col position of the cell

getTableEntry

public Component getTableEntry(CellPosition position)

Returns the component at the given CellPosition position in the table layout data structure.

Returns null if position is null or invalid.

Parameters:
position - the CellPosition of the cell

getRowCount

public int getRowCount()
Returns the number of rows in this table layout.

See Also:
getColumnCount()

getColumnCount

public int getColumnCount()
Returns the number of columns in this table layout.

See Also:
getRowCount()

isValidRow

public boolean isValidRow(int row)
Returns whether or not the given row index is valid.

Parameters:
row - the row in question
See Also:
isValidColumn(int)

isValidColumn

public boolean isValidColumn(int col)
Returns whether or not the given column index is valid.

Parameters:
col - the column in question
See Also:
isValidRow(int)

isEmptyRow

public boolean isEmptyRow(int row)
Returns whether or not the given row is empty.

Parameters:
row - the row in question
See Also:
isEmptyColumn(int)

isEmptyColumn

public boolean isEmptyColumn(int col)
Returns whether or not the given column is empty.

Parameters:
col - the column in question
See Also:
isEmptyRow(int)

setHorizontalGap

public void setHorizontalGap(int hgap)
Sets the gap between columns in this table layout to the given value, in pixels.

Parameters:
hgap - the desired gap, in pixels
See Also:
getHorizontalGap()

getHorizontalGap

public int getHorizontalGap()
Returns the gap, in pixels, between columns in this table layout.

See Also:
setHorizontalGap(int)

setVerticalGap

public void setVerticalGap(int vgap)
Sets the gap between rows in this table layout to the given value, in pixels.

Parameters:
vgap - the desired gap, in pixels
See Also:
getVerticalGap()

getVerticalGap

public int getVerticalGap()
Returns the gap, in pixels, between rows in this table layout.

See Also:
setVerticalGap(int)

setOrientation

public void setOrientation(int orientation)

Sets the orientation for this table layout to the given orientation value.

If the given orientation value is invalid, the orientation is not changed.

The default orientation is HORIZONTAL.

If the orientation is HORIZONTAL, then the strategy for adding components whose position is not explicitly specified is to add such components column-by-column and to add new columns if needed.

If the orientation is VERTICAL, then the strategy for adding components whose position is not explicitly specified is to add such components row-by-row and to add new rows if needed.

These policies are designed to be consistent with the situation when the table layout is initially empty and must be expanded at each step with either a new column in the case of HORIZONTAL or a new row in the case of VERTICAL.

Parameters:
orientation - the orientation for this layout
Since:
2.0
See Also:
getOrientation(), SwingConstants.HORIZONTAL, SwingConstants.VERTICAL, JPTConstants.DEFAULT

getOrientation

public int getOrientation()
Returns the orientation for this table layout.

Since:
2.0
See Also:
setOrientation(int), SwingConstants.HORIZONTAL, SwingConstants.VERTICAL

setTableAlignment

public void setTableAlignment(int align)
Sets the alignment for cells in this table layout to the given alignment value.

Parameters:
align - the alignment value for cells
See Also:
getTableAlignment(), JPTConstants.DEFAULT

getTableAlignment

public int getTableAlignment()
Returns the default alignment for cells in this table layout.

See Also:
setTableAlignment(int)

setRowAlignment

public void setRowAlignment(int row,
                            int align)
Sets the alignment for cells in the given row to the given alignment value.

Parameters:
row - the row whose alignment is to be set
align - the alignment value for the row
See Also:
getRowAlignment(int), JPTConstants.DEFAULT

getRowAlignment

public int getRowAlignment(int row)
Returns the default alignment value for the given row.

Parameters:
row - the row whose alignment value is desired
See Also:
setRowAlignment(int, int)

setColumnAlignment

public void setColumnAlignment(int col,
                               int align)
Sets the alignment for cells in the given column to the given alignment value.

Parameters:
col - the column whose alignment is to be set
align - the alignment value for the column
See Also:
getColumnAlignment(int), JPTConstants.DEFAULT

getColumnAlignment

public int getColumnAlignment(int col)
Returns the default alignment value for the given column.

Parameters:
col - the column whose alignment value is desired
See Also:
setColumnAlignment(int, int)

setCellAlignment

public void setCellAlignment(CellPosition p,
                             int align)
Sets the alignment for the cell at the given position to the given alignment value.

Parameters:
p - the position of the cell whose alignment is to be changed
align - the alignment value for the cell
See Also:
setCellAlignment(int, int, int), getCellAlignment(CellPosition), getCellAlignment(int, int), getEffectiveCellAlignment(CellPosition), getEffectiveCellAlignment(int, int), JPTConstants.DEFAULT

setCellAlignment

public void setCellAlignment(int row,
                             int col,
                             int align)
Sets the alignment for the cell at the given position to the given alignment value.

Parameters:
row - the row for the cell whose alignment is to be changed
col - the column for the cell whose alignment is to be changed
See Also:
setCellAlignment(CellPosition, int), getCellAlignment(CellPosition), getCellAlignment(int, int), getEffectiveCellAlignment(CellPosition), getEffectiveCellAlignment(int, int), JPTConstants.DEFAULT

getCellAlignment

public int getCellAlignment(CellPosition p)
Returns the alignment value for the cell at the given position or the table alignment if an error occurs.

Parameters:
p - the position of the cell whose alignment value is desired
See Also:
setCellAlignment(CellPosition, int), setCellAlignment(int, int, int), getCellAlignment(int, int), getEffectiveCellAlignment(CellPosition), getEffectiveCellAlignment(int, int), JPTConstants.DEFAULT

getCellAlignment

public int getCellAlignment(int row,
                            int col)
Returns the alignment value for the cell at the given position or the table alignment if an error occurs.

Parameters:
row - the row for the cell whose alignment value is desired
col - the column for the cell whose alignment value is desired
See Also:
setCellAlignment(CellPosition, int), setCellAlignment(int, int, int), getCellAlignment(CellPosition), getEffectiveCellAlignment(CellPosition), getEffectiveCellAlignment(int, int), JPTConstants.DEFAULT

getEffectiveCellAlignment

public int getEffectiveCellAlignment(CellPosition p)
Returns the effective alignment value for the cell at the given position, that is, either the cell's own alignment if it has been set or the alignment of the table as a whole.

Parameters:
p - the position of the cell whose alignment value is desired
See Also:
setCellAlignment(CellPosition, int), setCellAlignment(int, int, int), getCellAlignment(CellPosition), getCellAlignment(int, int), getEffectiveCellAlignment(int, int), JPTConstants.DEFAULT

getEffectiveCellAlignment

public int getEffectiveCellAlignment(int row,
                                     int col)
Returns the effective alignment value for the cell at the given position, that is, either the cell's own alignment if it has been set or the alignment of the table as a whole.

Parameters:
row - the row for the cell whose alignment value is desired
col - the column for the cell whose alignment value is desired
See Also:
setCellAlignment(CellPosition, int), setCellAlignment(int, int, int), getCellAlignment(CellPosition), getCellAlignment(int, int), getEffectiveCellAlignment(CellPosition), JPTConstants.DEFAULT

setMinimumRowHeight

public void setMinimumRowHeight(int row,
                                int height)
Sets the minimum height for the given row to the given height in pixels.

Parameters:
row - the row whose minimum height is to be set
height - the height for the row in pixels
Throws:
ArrayOutOfBoundsException - if the given row is invalid
See Also:
getMinimumRowHeight(int)

getMinimumRowHeight

public int getMinimumRowHeight(int row)
Returns the minimum height set for the given row.

Parameters:
row - the row whose minimum height is desired
Throws:
ArrayOutOfBoundsException - if the given row is invalid
See Also:
setMinimumRowHeight(int, int)

setAllMinimumRowHeights

public void setAllMinimumRowHeights(int height)
Sets all minimum row heights to the same value.

See Also:
setMinimumRowHeight(int, int), setAllMinimumColumnWidths(int)

setMinimumColumnWidth

public void setMinimumColumnWidth(int col,
                                  int width)
Sets the minimum width for the given column to the given width in pixels.

Parameters:
col - the column whose minimum width is to be set
width - the width for the column in pixels
Throws:
ArrayOutOfBoundsException - if the given column is invalid
See Also:
getMinimumColumnWidth(int)

getMinimumColumnWidth

public int getMinimumColumnWidth(int col)
Returns the minimum width set for the given column.

Parameters:
col - the column whose minimum width is desired
Throws:
ArrayOutOfBoundsException - if the given column is invalid
See Also:
setMinimumColumnWidth(int, int)

setAllMinimumColumnWidths

public void setAllMinimumColumnWidths(int width)
Sets all minimum column widths to the same value.

See Also:
setMinimumColumnWidth(int, int), setAllMinimumRowHeights(int)

minimumRowHeight

public int minimumRowHeight(int row)
Returns the actual minimum height for the given row.

Parameters:
row - the row whose minimum height is desired
See Also:
preferredRowHeight(int), maximumRowHeight(int)

minimumColumnWidth

public int minimumColumnWidth(int col)
Returns the actual minimum width for the given column.

Parameters:
col - the column whose minimum width is desired
See Also:
preferredColumnWidth(int), maximumColumnWidth(int)

preferredRowHeight

public int preferredRowHeight(int row)
Returns the actual preferred height for the given row.

Parameters:
row - the row whose preferred height is desired
See Also:
minimumRowHeight(int), maximumRowHeight(int)

preferredColumnWidth

public int preferredColumnWidth(int col)
Returns the actual preferred width for the given column.

Parameters:
col - the column whose preferred width is desired
See Also:
minimumColumnWidth(int), maximumColumnWidth(int)

maximumRowHeight

public int maximumRowHeight(int row)
Returns the actual maximum height for the given row.

Parameters:
row - the row whose maximum height is desired
See Also:
minimumRowHeight(int), preferredRowHeight(int)

maximumColumnWidth

public int maximumColumnWidth(int col)
Returns the actual maximum width for the given column.

Parameters:
col - the column whose maximum width is desired
See Also:
minimumColumnWidth(int), preferredColumnWidth(int)

minimumRowHeights

public int[] minimumRowHeights()
Returns the minimum heights for the rows in this table layout.


minimumColumnWidths

public int[] minimumColumnWidths()
Returns the minimum widths for the columns in this table layout.


preferredRowHeights

public int[] preferredRowHeights()
Returns the preferred heights for the rows in this table layout.


preferredColumnWidths

public int[] preferredColumnWidths()
Returns the preferred widths for the columns in this table layout.


maximumRowHeights

public int[] maximumRowHeights()
Returns the maximum heights for the rows in this table layout.


maximumColumnWidths

public int[] maximumColumnWidths()
Returns the maximum widths for the columns in this table layout.


layoutContainer

protected void layoutContainer(int[] widths,
                               int[] heights,
                               Insets insets)
Lays out the components in the parent container using the given arrays of column widths and row heights.

Parameters:
widths - the column widths for this layout
heights - the row heights for this layout
insets - the insets of the parent

getNextAvailablePosition

protected CellPosition getNextAvailablePosition()

Returns the next empty position in the table layout, that is, a position that does not contain a component; if the table layout is full, returns a new position that will require either adding a column or a row to the internal component table.

If the table orientation is HORIZONTAL, then the strategy for adding components is to fill the table column-by-column and to add new columns if needed. Thus, for example, the cell position (1, 0) will be returned before the cell position (0, 1) if both cell positions are empty. If the table layout is full, this method returns the cell position (0, cols) that will require horizontal expansion of the internal component table by the layout manager.

If the table orientation is VERTICAL, then the strategy for adding components is to fill the table row-by-row and to add new rows if needed. Thus, for example, the cell position (0, 1) will be returned before the cell position (1, 0) if both cell positions are empty. If the table layout is full, this method returns the cell position (rows, 0) that will require vertical expansion of the internal component table by the layout manager.

These policies are designed to be consistent with the situation when the table layout is initially empty and must be expanded at each step with either a new column in the case of HORIZONTAL or a new row in the case of VERTICAL.

Returns null if the orientation is set improperly.


applyAlignment

protected Point applyAlignment(int x,
                               int y,
                               int cellWidth,
                               int cellHeight,
                               int componentWidth,
                               int componentHeight,
                               int align)
Returns the point, given in terms of the parent container's coordinate space, where a component of the given size should be located given a cell with the provided bounds and the given alignment value.

Parameters:
x - the x-coordinate of the cell
y - the y-coordinate of the cell
cellWidth - the width of the cell
cellHeight - the height of the cell
componentWidth - the width of the component
componentHeight - the height of the component
align - the alignment value for the component

setRows

void setRows(int rowCount)
Sets the number of rows in this table to the given number of rows.

Parameters:
rowCount - the number of rows for this table layout

setColumns

void setColumns(int colCount)
Sets the number of columns in this table layout to the given number of columns.

Parameters:
colCount - the number of columns for this table layout

setCellAlignmentImpl

void setCellAlignmentImpl(int row,
                          int col,
                          int align)
Sets the alignment for the cell at the given position to the given alignment value.

Parameters:
row - the row for the cell
col - the column for the cell
align - the alignment value for the given cell

adjustAlignment

int adjustAlignment(int align)
Returns the alignment value corresponding to the given value, or INVALID_ALIGNMENT if the given value is invalid.

Parameters:
align - the alignment value to adjust