jwo.utils.gui
Class TableMap

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by jwo.utils.gui.TableMap
All Implemented Interfaces:
Serializable, EventListener, TableModelListener, TableModel
Direct Known Subclasses:
TableSorter

public class TableMap
extends AbstractTableModel
implements TableModelListener

In a chain of data manipulators some behaviour is common. TableMap provides most of this behaviour and can be subclassed by filters that only need to override a handful of specific methods. TableMap implements TableModel by routing all requests to its model, and TableModelListener by routing all events to its listeners. Inserting a TableMap which has not been subclassed into a chain of table filters should have no effect.

Version:
2.3, 17th December, 1997, last modified 12th April 2006.
Author:
Philip Milne, modifed by Jo Wood.
See Also:
Serialized Form

Field Summary
protected  TableModel model
           
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
TableMap()
           
 
Method Summary
 Class getColumnClass(int aColumn)
          Reports the class of object stored in the given column.
 int getColumnCount()
          Reports the number of columns in the table.
 String getColumnName(int aColumn)
          Reports the name of the given column.
 TableModel getModel()
          Reports the table model used by the map.
 int getRowCount()
          Reports the number of rows in the table.
 Object getValueAt(int aRow, int aColumn)
          Reports the table value at the given coordinates.
 boolean isCellEditable(int aRow, int aColumn)
          Reports whether the given cell is editable or not.
 void setModel(TableModel model)
          Sets the table model to be used by the map.
 void setValueAt(Object aValue, int aRow, int aColumn)
          Sets the table value at the given coordinates.
 void tableChanged(TableModelEvent e)
          Used to signal that there has been a change to something in the table.
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

model

protected TableModel model
Constructor Detail

TableMap

public TableMap()
Method Detail

getModel

public TableModel getModel()
Reports the table model used by the map.

Returns:
Table model used.

setModel

public void setModel(TableModel model)
Sets the table model to be used by the map.

Parameters:
model - Table model to be used.

getValueAt

public Object getValueAt(int aRow,
                         int aColumn)
Reports the table value at the given coordinates.

Specified by:
getValueAt in interface TableModel
Parameters:
aRow - Row of table cell to report.
aColumn - Column of table cell to report.
Returns:
Object at given table coordinates.

setValueAt

public void setValueAt(Object aValue,
                       int aRow,
                       int aColumn)
Sets the table value at the given coordinates.

Specified by:
setValueAt in interface TableModel
Overrides:
setValueAt in class AbstractTableModel
Parameters:
aValue - Object to place at given table coordinates.
aRow - Row of table cell to set.
aColumn - Column of table cell to set.

getRowCount

public int getRowCount()
Reports the number of rows in the table.

Specified by:
getRowCount in interface TableModel
Returns:
Number of rows in table.

getColumnCount

public int getColumnCount()
Reports the number of columns in the table.

Specified by:
getColumnCount in interface TableModel
Returns:
Number of columns in table.

getColumnName

public String getColumnName(int aColumn)
Reports the name of the given column.

Specified by:
getColumnName in interface TableModel
Overrides:
getColumnName in class AbstractTableModel
Parameters:
aColumn - Column of table to report.
Returns:
Name of column.

getColumnClass

public Class getColumnClass(int aColumn)
Reports the class of object stored in the given column.

Specified by:
getColumnClass in interface TableModel
Overrides:
getColumnClass in class AbstractTableModel
Parameters:
aColumn - Column of table to report.
Returns:
Class of objects stored in this column.

isCellEditable

public boolean isCellEditable(int aRow,
                              int aColumn)
Reports whether the given cell is editable or not.

Specified by:
isCellEditable in interface TableModel
Overrides:
isCellEditable in class AbstractTableModel
Parameters:
aRow - Row of table cell to report.
aColumn - Column of table cell to report.
Returns:
True if given cell is editable.

tableChanged

public void tableChanged(TableModelEvent e)
Used to signal that there has been a change to something in the table.

Specified by:
tableChanged in interface TableModelListener
Parameters:
e - Event encapsulating the table change.


Copyright Jo Wood, 1996-2009, last modified, 17th April, 2009