|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
edu.neu.ccs.gui.DisplayPanel
edu.neu.ccs.gui.TablePanel
A DisplayPanel designed to use a TableLayout as
its layout manager.
The method setLayout is overridden so that it is
impossible to change the layout manager to any other layout.
As of 2.5.0, the code was adjusted so that if a component is added at the same cell position as an existing component then the existing component is removed from the panel and layout.
Also in 2.5.0, the method autoEmptyBorder() was
added.
Finally, in 2.5.0, derived classes HTable and
VTable were added to simplify the creation of
horizontal and vertical tables with one row or column.
| Nested Class Summary |
| Nested classes inherited from class javax.swing.JPanel |
JPanel.AccessibleJPanel |
| Nested classes inherited from class javax.swing.JComponent |
JComponent.AccessibleJComponent |
| Nested classes inherited from class java.awt.Container |
Container.AccessibleAWTContainer |
| Nested classes inherited from class java.awt.Component |
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary | |
static int |
DEFAULT_ALIGNMENT
Value of the default cell alignment. |
static int |
DEFAULT_ORIENTATION
Value of the default cell alignment. |
protected TableGenerator |
tg
Generator used to produce the content for this table. |
| Fields inherited from class edu.neu.ccs.gui.DisplayPanel |
background, codec, CODEC |
| Fields inherited from class javax.swing.JPanel |
|
| Fields inherited from class javax.swing.JComponent |
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Container |
|
| Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface edu.neu.ccs.gui.Displayable |
DEFAULT_VIEW_STATE, VIEW_STATE |
| 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 |
| Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
TablePanel()
Constructs a default table panel. |
|
TablePanel(int align)
Constructs a table panel with the given cell alignment. |
|
TablePanel(int rows,
int cols)
Constructs a table panel with the given number of rows and columns. |
|
TablePanel(int rows,
int cols,
int align)
Constructs a table panel with the given number of rows and columns, and the given cell alignment. |
|
TablePanel(int rows,
int cols,
int hgap,
int vgap)
Constructs a table panel with the given number of rows and columns, and the given horizontal and vertical gaps between cells. |
|
TablePanel(int rows,
int cols,
int hgap,
int vgap,
int align)
Constructs a table panel with the given number of rows and columns, the given horizontal and vertical gaps between cells, and the given cell alignment. |
|
TablePanel(int rows,
int cols,
int hgap,
int vgap,
int align,
int orientation)
Constructs a table panel with the given number of rows and columns, the given horizontal and vertical gaps between cells, the given cell alignment, and the given table layout orientation. |
|
TablePanel(Object[][] contents)
Constructs a table panel containing the given table of objects, with the default cell alignment and a VERTICAL orientation. |
|
TablePanel(Object[][] contents,
int align)
Constructs a table panel containing the given table of objects and the given cell alignment, with the default cell alignment and a VERTICAL orientation. |
|
TablePanel(Object[][] contents,
int hgap,
int vgap)
Constructs a table panel containing the given table of objects, with the given horizontal and vertical gaps between cells, the default cell alignment, and a VERTICAL orientation. |
|
TablePanel(Object[][] contents,
int hgap,
int vgap,
int align)
Constructs a table panel containing the given table of objects, with the given horizontal and vertical gaps between cells, the given cell alignment, and a VERTICAL orientation. |
|
TablePanel(Object[] contents,
int orientation)
Constructs a table panel containing the given objects in the given orientation. |
|
TablePanel(Object[] contents,
int orientation,
int align)
Constructs a table panel containing the given objects in the given orientation, with the given cell alignment. |
|
TablePanel(Object[] contents,
int orientation,
int hgap,
int vgap)
Constructs a table panel containing the given objects in the given orientation, with the given horizontal and vertical gaps between cells. |
|
TablePanel(Object[] contents,
int orientation,
int hgap,
int vgap,
int align)
Constructs a table panel containing the given objects in the given orientation, with the given horizontal and vertical gaps between cells and the given cell alignment. |
|
TablePanel(TableGenerator tg,
int rows,
int cols)
Constructs a table panel constructed from the given table generator and given rows and cols. |
|
TablePanel(TableGenerator tg,
int rows,
int cols,
int align)
Constructs a table panel constructed from the given table generator, the given rows and cols, and the given cell alignment. |
|
TablePanel(TableGenerator tg,
int rows,
int cols,
int hgap,
int vgap)
Constructs a table panel constructed from the given table generator, the given rows and cols, and the given horizontal and vertical gaps between cells. |
|
TablePanel(TableGenerator tg,
int rows,
int cols,
int hgap,
int vgap,
int align)
Constructs a table panel constructed from the given table generator, the given rows and cols, the given horizontal and vertical gaps between cells, and the given cell alignment. |
|
| Method Summary | |
Component |
addObject(Object object,
CellPosition position)
Add the given object to this TablePanel
at the position specified by the CellPosition
after applying the transformation of the method
makeComponent. |
Component |
addObject(Object object,
int row,
int col)
Add the given object to this TablePanel
at the position specified by the row and column
after applying the transformation of the method
makeComponent. |
void |
autoEmptyBorder()
Adds an empty border using the current vertical and horizontal gaps. |
protected void |
createCells(int loRows,
int loCols,
int hiRows,
int hiCols)
Create the table cells at position (row, col) for loRows <= row < hiRows and loCols <= col < hiCols. |
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 panel. |
Component[][] |
getComponentTable()
Returns a copy of the table of components in this panel. |
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 panel. |
Dimension |
getMaximumSize()
Return the maximum size of the table as computed by the table layout. |
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. |
Dimension |
getMinimumSize()
Return the minimum size of the table as computed by the table layout. |
int |
getOrientation()
Returns the orientation for the layout of this table. |
Dimension |
getPreferredSize()
Return the preferred size of the table as computed by the 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 panel. |
int |
getTableAlignment()
Returns the default alignment for cells in this table panel. |
Component |
getTableEntry(CellPosition position)
Returns the component at the given CellPosition
in the table or null if no such component exists. |
Component |
getTableEntry(int row,
int col)
Returns the component at the position row,col in the table or null if no such component exists. |
TableGenerator |
getTableGenerator()
Returns the table generator used to create the components of this table or null if no generator is being used. |
TableLayout |
getTableLayout()
Returns the TableLayout managing this panel. |
int |
getVerticalGap()
Returns the gap, in pixels, between rows in this table panel. |
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. |
protected void |
removeCells(int loRows,
int loCols,
int hiRows,
int hiCols)
Remove the table cells at position (row, col) for loRows <= row < hiRows and loCols <= col < hiCols. |
protected void |
resetPreferredSize()
Sets the preferred size for this panel to its preferred size, and updates the screen UI. |
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. |
void |
setColumnAlignment(int col,
int align)
Sets the alignment for cells in the given column to the given alignment value. |
void |
setColumns(int cols)
Change the number of columns in the table to the given value but ignore invalid parameter values less than 0. |
void |
setHorizontalGap(int hgap)
Sets the gap between columns in this table panel to the given value, in pixels. |
void |
setLayout(LayoutManager manager)
Overrides the setLayout method to do nothing so that the user of TablePanel cannot change its layout. |
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 the layout of this table 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. |
void |
setRows(int rows)
Change the number of rows in the table to the given value but ignore invalid parameter values less than 0. |
void |
setTableAlignment(int align)
Sets the alignment for cells in this table panel to the given alignment value. |
void |
setVerticalGap(int vgap)
Sets the gap between rows in this table panel to the given value, in pixels. |
void |
uniformizeCellHeight()
Sets the table cell height for all cells in this panel to the same width. |
void |
uniformizeCellSize()
Sets the table cell size for all cells in this panel to the same size. |
void |
uniformizeCellWidth()
Sets the table cell width for all cells in this panel to the same width. |
| Methods inherited from class javax.swing.JPanel |
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final int DEFAULT_ALIGNMENT
public static final int DEFAULT_ORIENTATION
protected TableGenerator tg
| Constructor Detail |
public TablePanel()
public TablePanel(int align)
align - the alignment of a component within a table cell
public TablePanel(int rows,
int cols)
rows - the number of rows in the tablecols - the number of columns in the table
public TablePanel(int rows,
int cols,
int align)
rows - the number of rows in the tablecols - the number of columns in the tablealign - the alignment of a component within a table cell
public TablePanel(int rows,
int cols,
int hgap,
int vgap)
rows - the number of rows in the tablecols - the number of columns in the tablehgap - the horizontal gap between columnsvgap - the vertical gap between rows
public TablePanel(int rows,
int cols,
int hgap,
int vgap,
int align)
rows - the number of rows in the tablecols - the number of columns in the tablehgap - the horizontal gap between columnsvgap - the vertical gap between rowsalign - the alignment of a component within a table cell
public TablePanel(int rows,
int cols,
int hgap,
int vgap,
int align,
int orientation)
rows - the number of rows in the tablecols - the number of columns in the tablehgap - the horizontal gap between columnsvgap - the vertical gap between rowsalign - the alignment of a component within a table cellorientation - the table layout orientationSwingConstants.VERTICAL,
SwingConstants.HORIZONTAL
public TablePanel(Object[] contents,
int orientation)
contents - the array of contents to be used to fill the tableorientation - the table orientationSwingConstants.VERTICAL,
SwingConstants.HORIZONTAL
public TablePanel(Object[] contents,
int orientation,
int align)
contents - the array of contents to be used to fill the tableorientation - the table orientationalign - the alignment of a component within a table cellSwingConstants.VERTICAL,
SwingConstants.HORIZONTAL
public TablePanel(Object[] contents,
int orientation,
int hgap,
int vgap)
contents - the array of contents to be used to fill the tableorientation - the table orientationhgap - the horizontal gap between columnsvgap - the vertical gap between rowsSwingConstants.VERTICAL,
SwingConstants.HORIZONTAL
public TablePanel(Object[] contents,
int orientation,
int hgap,
int vgap,
int align)
contents - the array of contents to be used to fill the tableorientation - the table orientationhgap - the horizontal gap between columnsvgap - the vertical gap between rowsalign - the alignment of a component within a table cellSwingConstants.VERTICAL,
SwingConstants.HORIZONTALpublic TablePanel(Object[][] contents)
VERTICAL orientation.
contents - the array of contents to be used to fill the table
public TablePanel(Object[][] contents,
int align)
VERTICAL orientation.
contents - the array of contents to be used to fill the tablealign - the alignment of a component within a table cell
public TablePanel(Object[][] contents,
int hgap,
int vgap)
VERTICAL orientation.
contents - the array of contents to be used to fill the tablehgap - the horizontal gap between columnsvgap - the vertical gap between rows
public TablePanel(Object[][] contents,
int hgap,
int vgap,
int align)
VERTICAL orientation.
contents - the array of contents to be used to fill the tablehgap - the horizontal gap between columnsvgap - the vertical gap between rowsalign - the alignment of a component within a table cell
public TablePanel(TableGenerator tg,
int rows,
int cols)
tg - the table generator used to fill the tablerows - the number of rows in the tablecols - the number of columns in the table
public TablePanel(TableGenerator tg,
int rows,
int cols,
int align)
tg - the table generator used to fill the tablerows - the number of rows in the tablecols - the number of columns in the tablealign - the alignment of a component within a table cell
public TablePanel(TableGenerator tg,
int rows,
int cols,
int hgap,
int vgap)
tg - the table generator used to fill the tablerows - the number of rows in the tablecols - the number of columns in the tablehgap - the horizontal gap between columnsvgap - the vertical gap between rows
public TablePanel(TableGenerator tg,
int rows,
int cols,
int hgap,
int vgap,
int align)
tg - the table generator used to fill the tablerows - the number of rows in the tablecols - the number of columns in the tablehgap - the horizontal gap between columnsvgap - the vertical gap between rowsalign - the alignment of a component within a table cell| Method Detail |
public Component addObject(Object object,
int row,
int col)
Add the given object to this TablePanel
at the position specified by the row and column
after applying the transformation of the method
makeComponent.
If a component is already installed at the given position, then this component is removed.
object - the object to be transformed and added to the tablerow - the row in the tablecol - the column in the table
public Component addObject(Object object,
CellPosition position)
Add the given object to this TablePanel
at the position specified by the CellPosition
after applying the transformation of the method
makeComponent.
If a component is already installed at the given position, then this component is removed.
If the given position is null, then calls
addObject(object).
object - the object to be transformed and added to the tableposition - the position in the table
public Component[][] getComponentTable()
public Component getTableEntry(int row,
int col)
null if no such component exists.
row - the row position of the componentcol - the col position of the componentpublic Component getTableEntry(CellPosition position)
CellPosition
in the table or null if no such component exists.
position - the CellPosition of the componentpublic TableGenerator getTableGenerator()
public void autoEmptyBorder()
Adds an empty border using the current vertical and horizontal gaps.
public void setRows(int rows)
TableGenerator
then fill new cells using this table generator.
rows - the desired number of rowspublic void setColumns(int cols)
TableGenerator
then fill new cells using this table generator.
cols - the desired number of columnspublic int getRowCount()
public int getColumnCount()
public boolean isValidRow(int row)
row - the row in questionpublic boolean isValidColumn(int col)
col - the column in questionpublic boolean isEmptyRow(int row)
row - the row in questionpublic boolean isEmptyColumn(int col)
col - the column in questionpublic void setHorizontalGap(int hgap)
hgap - the desired gap, in pixelspublic int getHorizontalGap()
public void setVerticalGap(int vgap)
vgap - the desired gap, in pixelspublic int getVerticalGap()
public void setOrientation(int orientation)
orientation - the orientation for this layoutSwingConstants.HORIZONTAL,
SwingConstants.VERTICALpublic int getOrientation()
SwingConstants.HORIZONTAL,
SwingConstants.VERTICALpublic void setTableAlignment(int align)
align - the alignment value for cellspublic int getTableAlignment()
public void setRowAlignment(int row,
int align)
row - the row whose alignment is to be setalign - the alignment value for the rowpublic int getRowAlignment(int row)
row - the row whose alignment value is desired
public void setColumnAlignment(int col,
int align)
col - the column whose alignment is to be setalign - the alignment value for the columnpublic int getColumnAlignment(int col)
col - the column whose alignment value is desired
public void setCellAlignment(CellPosition p,
int align)
p - the position of the cell whose alignment is to be changedalign - the alignment value for the cell
public void setCellAlignment(int row,
int col,
int align)
row - the row for the cell whose alignment is to be changedcol - the column for the cell whose alignment is to be changedpublic int getCellAlignment(CellPosition p)
p - the position of the cell whose alignment value is desired
public int getCellAlignment(int row,
int col)
row - the row for the cell whose alignment value is desiredcol - the column for the cell whose alignment value is desiredpublic int getEffectiveCellAlignment(CellPosition p)
p - the position of the cell whose alignment value is desired
public int getEffectiveCellAlignment(int row,
int col)
row - the row for the cell whose alignment value is desiredcol - the column for the cell whose alignment value is desired
public void setMinimumRowHeight(int row,
int height)
row - the row whose minimum height is to be setheight - the height for the row in pixels
ArrayOutOfBoundsException - if the given row is invalidpublic int getMinimumRowHeight(int row)
row - the row whose minimum height is desired
ArrayOutOfBoundsException - if the given row is invalid
public void setMinimumColumnWidth(int col,
int width)
col - the column whose minimum width is to be setwidth - the width for the column in pixels
ArrayOutOfBoundsException - if the given column is invalidpublic int getMinimumColumnWidth(int col)
col - the column whose minimum width is desired
ArrayOutOfBoundsException - if the given column is invalidpublic void setAllMinimumRowHeights(int height)
public void setAllMinimumColumnWidths(int width)
public TableLayout getTableLayout()
TableLayout managing this panel.
ClassCastException - if the layout for this panel
is not an instance of TableLayoutpublic void setLayout(LayoutManager manager)
manager - parameter ignoredpublic Dimension getMinimumSize()
public Dimension getPreferredSize()
public Dimension getMaximumSize()
public void uniformizeCellSize()
Sets the table cell size for all cells in this panel to the same size.
The size that is used is created from the widest preferred width and tallest preferred height among the contained components.
public void uniformizeCellWidth()
Sets the table cell width for all cells in this panel to the same width.
The width that is used is created from the widest preferred width among the contained components.
public void uniformizeCellHeight()
Sets the table cell height for all cells in this panel to the same width.
The height that is used is created from the tallest preferred height among the contained components.
protected void createCells(int loRows,
int loCols,
int hiRows,
int hiCols)
TableGenerator.
loRows - the starting row index for generating cellsloCols - the starting column index for generating cellshiRows - the limiting row index for generating cellshiCols - the limiting column index for generating cells
protected void removeCells(int loRows,
int loCols,
int hiRows,
int hiCols)
loRows - the starting row index for generating cellsloCols - the starting column index for generating cellshiRows - the limiting row index for generating cellshiCols - the limiting column index for generating cellsprotected void resetPreferredSize()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||