edu.neu.ccs.gui
Class TablePanel

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byedu.neu.ccs.gui.DisplayPanel
                      extended byedu.neu.ccs.gui.TablePanel
All Implemented Interfaces:
Accessible, AlertListener, Displayable, EventListener, ImageObserver, JPTConstants, MalformedDataListener, MenuContainer, Serializable, SwingConstants
Direct Known Subclasses:
CheckerBoard, HTable, PathListView, SimpleArrayPanel, SwatchNamePair, VTable

public class TablePanel
extends DisplayPanel

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.

Since:
1.1
Version:
2.5.0
See Also:
Serialized Form

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 edu.neu.ccs.gui.DisplayPanel
add, add, add, add, add, addBorder, addObject, addObject, addObject, addObject, bevelBorderLowered, bevelBorderLowered, bevelBorderLowered, bevelBorderLowered, bevelBorderLowered, bevelBorderRaised, bevelBorderRaised, bevelBorderRaised, bevelBorderRaised, bevelBorderRaised, compoundBorder, compoundBorder, dataMalformed, emptyBorder, emptyBorder, emptyBorder, endAlert, etchBorderLowered, etchBorderLowered, etchBorderLowered, etchBorderRaised, etchBorderRaised, etchBorderRaised, frame, frame, frame, frame, frame, frame, generalDialog, generalDialog, generalDialog, generalDialog, getCodec, getDefaultViewState, getDefaultViewStates, getDisplayables, getViewState, getViewStates, lineBorder, lineBorder, lineBorder, lineBorder, makeComponent, matteBorder, matteBorder, matteBorder, matteBorder, matteBorder, matteBorder, OKCancelDialog, OKCancelDialog, OKDialog, OKDialog, refreshComponent, remove, remove, removeAll, removeBorder, reset, sandwichBorder, setCodec, setDeepBackground, setDeepBackground, setDefaultViewState, setDefaultViewStates, setEnabled, setViewState, setViewStates, startAlert, titleBorder, titleBorder, titleBorder, titleBorder, titleBorder, titleBorder, titleBorder, titleBorder, uniformizeHeight, uniformizeSize, uniformizeWidth, YesNoCancelDialog, YesNoCancelDialog
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getNextFocusableComponent, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_ALIGNMENT

public static final int DEFAULT_ALIGNMENT
Value of the default cell alignment.

See Also:
Constant Field Values

DEFAULT_ORIENTATION

public static final int DEFAULT_ORIENTATION
Value of the default cell alignment.

See Also:
Constant Field Values

tg

protected TableGenerator tg
Generator used to produce the content for this table.

Constructor Detail

TablePanel

public TablePanel()
Constructs a default table panel.


TablePanel

public TablePanel(int align)
Constructs a table panel with the given cell alignment.

Parameters:
align - the alignment of a component within a table cell

TablePanel

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

Parameters:
rows - the number of rows in the table
cols - the number of columns in the table

TablePanel

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

Parameters:
rows - the number of rows in the table
cols - the number of columns in the table
align - the alignment of a component within a table cell

TablePanel

public 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.

Parameters:
rows - the number of rows in the table
cols - the number of columns in the table
hgap - the horizontal gap between columns
vgap - the vertical gap between rows

TablePanel

public 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.

Parameters:
rows - the number of rows in the table
cols - the number of columns in the table
hgap - the horizontal gap between columns
vgap - the vertical gap between rows
align - the alignment of a component within a table cell

TablePanel

public 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.

Parameters:
rows - the number of rows in the table
cols - the number of columns in the table
hgap - the horizontal gap between columns
vgap - the vertical gap between rows
align - the alignment of a component within a table cell
orientation - the table layout orientation
See Also:
SwingConstants.VERTICAL, SwingConstants.HORIZONTAL

TablePanel

public TablePanel(Object[] contents,
                  int orientation)
Constructs a table panel containing the given objects in the given orientation.

Parameters:
contents - the array of contents to be used to fill the table
orientation - the table orientation
See Also:
SwingConstants.VERTICAL, SwingConstants.HORIZONTAL

TablePanel

public TablePanel(Object[] contents,
                  int orientation,
                  int align)
Constructs a table panel containing the given objects in the given orientation, with the given cell alignment.

Parameters:
contents - the array of contents to be used to fill the table
orientation - the table orientation
align - the alignment of a component within a table cell
See Also:
SwingConstants.VERTICAL, SwingConstants.HORIZONTAL

TablePanel

public 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.

Parameters:
contents - the array of contents to be used to fill the table
orientation - the table orientation
hgap - the horizontal gap between columns
vgap - the vertical gap between rows
See Also:
SwingConstants.VERTICAL, SwingConstants.HORIZONTAL

TablePanel

public 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.

Parameters:
contents - the array of contents to be used to fill the table
orientation - the table orientation
hgap - the horizontal gap between columns
vgap - the vertical gap between rows
align - the alignment of a component within a table cell
See Also:
SwingConstants.VERTICAL, SwingConstants.HORIZONTAL

TablePanel

public TablePanel(Object[][] contents)
Constructs a table panel containing the given table of objects, with the default cell alignment and a VERTICAL orientation.

Parameters:
contents - the array of contents to be used to fill the table

TablePanel

public 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.

Parameters:
contents - the array of contents to be used to fill the table
align - the alignment of a component within a table cell

TablePanel

public 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.

Parameters:
contents - the array of contents to be used to fill the table
hgap - the horizontal gap between columns
vgap - the vertical gap between rows

TablePanel

public 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.

Parameters:
contents - the array of contents to be used to fill the table
hgap - the horizontal gap between columns
vgap - the vertical gap between rows
align - the alignment of a component within a table cell

TablePanel

public TablePanel(TableGenerator tg,
                  int rows,
                  int cols)
Constructs a table panel constructed from the given table generator and given rows and cols.

Parameters:
tg - the table generator used to fill the table
rows - the number of rows in the table
cols - the number of columns in the table

TablePanel

public 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.

Parameters:
tg - the table generator used to fill the table
rows - the number of rows in the table
cols - the number of columns in the table
align - the alignment of a component within a table cell

TablePanel

public 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.

Parameters:
tg - the table generator used to fill the table
rows - the number of rows in the table
cols - the number of columns in the table
hgap - the horizontal gap between columns
vgap - the vertical gap between rows

TablePanel

public 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.

Parameters:
tg - the table generator used to fill the table
rows - the number of rows in the table
cols - the number of columns in the table
hgap - the horizontal gap between columns
vgap - the vertical gap between rows
align - the alignment of a component within a table cell
Method Detail

addObject

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.

Parameters:
object - the object to be transformed and added to the table
row - the row in the table
col - the column in the table
Returns:
the component obtained by transforming the object

addObject

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).

Parameters:
object - the object to be transformed and added to the table
position - the position in the table
Returns:
the component obtained by transforming the object

getComponentTable

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


getTableEntry

public Component getTableEntry(int row,
                               int col)
Returns the component at the position row,col in the table or null if no such component exists.

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

getTableEntry

public Component getTableEntry(CellPosition position)
Returns the component at the given CellPosition in the table or null if no such component exists.

Parameters:
position - the CellPosition of the component

getTableGenerator

public TableGenerator getTableGenerator()
Returns the table generator used to create the components of this table or null if no generator is being used.


autoEmptyBorder

public void autoEmptyBorder()

Adds an empty border using the current vertical and horizontal gaps.


setRows

public void setRows(int rows)
Change the number of rows in the table to the given value but ignore invalid parameter values less than 0. If the table was created using a TableGenerator then fill new cells using this table generator.

Parameters:
rows - the desired number of rows

setColumns

public void setColumns(int cols)
Change the number of columns in the table to the given value but ignore invalid parameter values less than 0. If the table was created using a TableGenerator then fill new cells using this table generator.

Parameters:
cols - the desired number of columns

getRowCount

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


getColumnCount

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


isValidRow

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

Parameters:
row - the row in question

isValidColumn

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

Parameters:
col - the column in question

isEmptyRow

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

Parameters:
row - the row in question

isEmptyColumn

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

Parameters:
col - the column in question

setHorizontalGap

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

Parameters:
hgap - the desired gap, in pixels

getHorizontalGap

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


setVerticalGap

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

Parameters:
vgap - the desired gap, in pixels

getVerticalGap

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


setOrientation

public void setOrientation(int orientation)
Sets the orientation for the layout of this table to the given orientation value. If the given orientation value is invalid, the orientation is not changed.

Parameters:
orientation - the orientation for this layout
See Also:
SwingConstants.HORIZONTAL, SwingConstants.VERTICAL

getOrientation

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

See Also:
SwingConstants.HORIZONTAL, SwingConstants.VERTICAL

setTableAlignment

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

Parameters:
align - the alignment value for cells

getTableAlignment

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


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

getRowAlignment

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

Parameters:
row - the row whose alignment value is desired

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

getColumnAlignment

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

Parameters:
col - the column whose alignment value is desired

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

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

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

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

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

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

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

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

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

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

setAllMinimumRowHeights

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


setAllMinimumColumnWidths

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


getTableLayout

public TableLayout getTableLayout()
Returns the TableLayout managing this panel.

Throws:
ClassCastException - if the layout for this panel is not an instance of TableLayout

setLayout

public void setLayout(LayoutManager manager)
Overrides the setLayout method to do nothing so that the user of TablePanel cannot change its layout.

Parameters:
manager - parameter ignored

getMinimumSize

public Dimension getMinimumSize()
Return the minimum size of the table as computed by the table layout.


getPreferredSize

public Dimension getPreferredSize()
Return the preferred size of the table as computed by the table layout.


getMaximumSize

public Dimension getMaximumSize()
Return the maximum size of the table as computed by the table layout.


uniformizeCellSize

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.


uniformizeCellWidth

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.


uniformizeCellHeight

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.


createCells

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. This method does nothing if the table was not created with a TableGenerator.

Parameters:
loRows - the starting row index for generating cells
loCols - the starting column index for generating cells
hiRows - the limiting row index for generating cells
hiCols - the limiting column index for generating cells

removeCells

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.

Parameters:
loRows - the starting row index for generating cells
loCols - the starting column index for generating cells
hiRows - the limiting row index for generating cells
hiCols - the limiting column index for generating cells

resetPreferredSize

protected void resetPreferredSize()
Sets the preferred size for this panel to its preferred size, and updates the screen UI.