infovis.table
Class DefaultTable

java.lang.Object
  extended by infovis.utils.ChangeManager
      extended by infovis.column.AbstractColumn
          extended by infovis.column.BasicColumn
              extended by infovis.column.BasicObjectColumn
                  extended by infovis.column.ColumnColumn
                      extended by infovis.table.DefaultTable
All Implemented Interfaces:
IntComparator, Column, Metadata, Constants, Table, RowComparator, Serializable, EventListener, ChangeListener, TableModel
Direct Known Subclasses:
DefaultDynamicTable, RulerTable

public class DefaultTable
extends ColumnColumn
implements Table, ChangeListener, Serializable

Concrete Table. Implements all the methods of Table managing a Column of Columns

Version:
$Revision: 1.34 $
Author:
Jean-Daniel Fekete
See Also:
Serialized Form

Field Summary
 
Fields inherited from class infovis.column.AbstractColumn
MODIFIED_ALL, MODIFIED_NONE
 
Fields inherited from interface infovis.Table
FILTER_COLUMN, INTERNAL_PREFIX, NIL, SELECTION_COLUMN
 
Fields inherited from interface infovis.metadata.Constants
CONTRIBUTOR, COVERAGE, CREATOR, DATE, DESCRITION, FORMAT, IDENTIFIER, LANGUAGE, PUBLISHER, RELATION, RIGHTS, SOURCE, SUBJECT, TITLE, TYPE
 
Constructor Summary
DefaultTable()
          Creates a new DefaultTable object.
 
Method Summary
 void addColumn(Column c)
          Adds a column.
 void addTableModelListener(TableModelListener l)
          
 void clear()
          Removes all of the elements from this column. The Column will be empty after this call returns. WARNING: if there is an associated format that maintains a status, such as a CategoricalFormat, it is not cleared so results may not be what you expected. The CategoricalFormat can be cleared explicitely if needed.
 void disableNotify()
          Disables notification until enableNotify has been called.
 void enableNotify()
          Re enable notifications, triggering eventListeners if modifications occur.
 void fireTableChanged(TableModelEvent e)
          Forwards the given notification event to all TableModelListeners that registered themselves as listeners for this table model.
 void fireTableDataChanged()
          Notifies all listeners that all the table has changed.
 void fireTableDataChanged(int firstRow, int lastRow, int type)
          Notifies all listeners that all cell values in the table's rows may have changed.
 void fireTableStructureChanged()
          Notifies all listeners that the table's structure has changed.
 Column getColumn(String name)
          Returns the column of a specified name.
 Column getColumnAt(int index)
          Returns the column at a specified index.
 Class getColumnClass(int columnIndex)
          
 int getColumnCount()
          Returns the number of columns of the table.
 String getColumnName(int columnIndex)
          
 int getLastRow()
          Returns the index of the last row in the table.
 Object getObjectFromRow(int row)
          Returns an object from a row.
 int getRowCount()
          Returns the number of rows in the table.
 int getRowFromObject(Object obj)
          Returns a row from an object returned by getObjectFromRow.
 Table getTable()
          Returns the real table for Proxies and this for a concrete table.
 Object getValueAt(int rowIndex, int columnIndex)
          
 boolean hasTableModelListener()
          Returns true if the table has any registered TableModelListeners.
 int indexOf(Column column)
          Returns the index of a specified column.
 int indexOf(String name)
          Returns the index of a column of a specified name.
 boolean isCellEditable(int rowIndex, int columnIndex)
          
static boolean isColumnInternal(Column col)
          Test if the column is internal, i˙e˙ the first character of its name is a '#'.
 boolean isRowValid(int row)
          Checks whether a specified row is valid.
 RowIterator iterator()
          Returns a RowIterator over all the valid rows of this column.
 boolean removeColumn(Column c)
          Removes a column from the table.
 void removeTableModelListener(TableModelListener l)
          
 RowIterator reverseIterator()
          Returns an iterator over the columns of this table in reverse order.
 void setColumnAt(int i, Column c)
          Replaces the column at a specified index.
 void setValueAt(Object aValue, int rowIndex, int columnIndex)
          TableModel method for editable tables.
 void stateChanged(ChangeEvent e)
          Called when one of the column has changed to propagate the TableChanged notification.
 
Methods inherited from class infovis.column.ColumnColumn
add, compare, compare, definedValue, fill, findColumn, get, getColumn, getColumn, getValueClass, set, setExtend
 
Methods inherited from class infovis.column.BasicObjectColumn
add, capacity, compare, compareValues, ensureCapacity, fill, format, getObjectAt, getOrder, getValueAt, getValueReference, hasUndefinedValue, indexOf, isValueUndefined, parse, remove, remove, setExtend, setObjectAt, setOrder, setSize, setValueAt, setValueUndefined, size
 
Methods inherited from class infovis.column.BasicColumn
addValue, addValueOrNull, firstValidRow, getClientProperty, getFormat, getMaxIndex, getMetadata, getMinIndex, getName, isEmpty, isInternal, lastValidRow, setFormat, setName, setValueOrNullAt, toString
 
Methods inherited from class infovis.column.AbstractColumn
addChangeListener, computeValueMap, computeValueMap, equalObj, equals, getLastModifiedRow
 
Methods inherited from class infovis.utils.ChangeManager
getModCount, removeChangeListener
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface infovis.Column
addChangeListener, addValue, addValueOrNull, capacity, ensureCapacity, getFormat, getMaxIndex, getMinIndex, getName, getValueAt, getValueClass, hasUndefinedValue, isEmpty, isInternal, isValueUndefined, removeChangeListener, setFormat, setName, setSize, setValueAt, setValueOrNullAt, setValueUndefined, size
 
Methods inherited from interface infovis.Metadata
getClientProperty, getMetadata
 
Methods inherited from interface cern.colt.function.IntComparator
compare, equals
 

Constructor Detail

DefaultTable

public DefaultTable()
Creates a new DefaultTable object.

Method Detail

getColumnCount

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

Specified by:
getColumnCount in interface Table
Specified by:
getColumnCount in interface TableModel
Returns:
the number of columns of the table.

clear

public void clear()
Removes all of the elements from this column. The Column will be empty after this call returns. WARNING: if there is an associated format that maintains a status, such as a CategoricalFormat, it is not cleared so results may not be what you expected. The CategoricalFormat can be cleared explicitely if needed.

Specified by:
clear in interface Column
Specified by:
clear in interface Table
Overrides:
clear in class BasicObjectColumn

addColumn

public void addColumn(Column c)
Adds a column.

Specified by:
addColumn in interface Table
Parameters:
c - the column.

getColumnAt

public Column getColumnAt(int index)
Returns the column at a specified index.

Specified by:
getColumnAt in interface Table
Parameters:
index - the index.
Returns:
the column at a specified index or null if the index is out of range.

setColumnAt

public void setColumnAt(int i,
                        Column c)
Replaces the column at a specified index.

Specified by:
setColumnAt in interface Table
Parameters:
i - the index.
c - the column.

indexOf

public int indexOf(String name)
Returns the index of a column of a specified name.

Specified by:
indexOf in interface Table
Parameters:
name - the name.
Returns:
the index of a column of a specified name or -1 if no such column exist.

indexOf

public int indexOf(Column column)
Returns the index of a specified column.

Specified by:
indexOf in interface Table
Parameters:
column - the column
Returns:
the index of a specified column or -1 if the column is not in the table.

disableNotify

public void disableNotify()
Disables notification until enableNotify has been called.

This method is useful if a large number of modifications is going to happen on the column and notifying each time would be too time consuming. The notification will be deferred until enableNotify is called.

Calls to disableNotify can be nested

Specified by:
disableNotify in interface Column
Overrides:
disableNotify in class ChangeManager
See Also:
ChangeManager.enableNotify()

enableNotify

public void enableNotify()
Re enable notifications, triggering eventListeners if modifications occur.

Specified by:
enableNotify in interface Column
Overrides:
enableNotify in class ChangeManager
See Also:
ChangeManager.disableNotify()

getColumn

public Column getColumn(String name)
Returns the column of a specified name.

Specified by:
getColumn in interface Table
Parameters:
name - the name.
Returns:
the column of a specified name.

removeColumn

public boolean removeColumn(Column c)
Removes a column from the table.

Specified by:
removeColumn in interface Table
Parameters:
c - the column.
Returns:
true if the column has been removed.

iterator

public RowIterator iterator()
Returns a RowIterator over all the valid rows of this column.

Specified by:
iterator in interface Column
Overrides:
iterator in class BasicColumn
Returns:
a RowIterator over all the valid rows of this column.

reverseIterator

public RowIterator reverseIterator()
Returns an iterator over the columns of this table in reverse order.

Specified by:
reverseIterator in interface Table
Returns:
an iterator over the columns of this table in reverse order.

getTable

public Table getTable()
Returns the real table for Proxies and this for a concrete table.

Specified by:
getTable in interface Table
Returns:
the real table for Proxies and this for a concrete table.

isRowValid

public boolean isRowValid(int row)
Checks whether a specified row is valid.

Specified by:
isRowValid in interface Table
Parameters:
row - the row.
Returns:
true if it is.

getColumnName

public String getColumnName(int columnIndex)

Specified by:
getColumnName in interface TableModel

getRowCount

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

Specified by:
getRowCount in interface Table
Specified by:
getRowCount in interface TableModel
Returns:
the number of rows in the table.

getLastRow

public int getLastRow()
Returns the index of the last row in the table.

Specified by:
getLastRow in interface Table
Returns:
the index of the last row in the table

getValueAt

public Object getValueAt(int rowIndex,
                         int columnIndex)

Specified by:
getValueAt in interface TableModel

setValueAt

public void setValueAt(Object aValue,
                       int rowIndex,
                       int columnIndex)
TableModel method for editable tables.

Specified by:
setValueAt in interface TableModel
Parameters:
aValue - value to assign to cell
rowIndex - row of cell
columnIndex - column of cell
See Also:
TableModel.setValueAt(Object, int, int)

getColumnClass

public Class getColumnClass(int columnIndex)

Specified by:
getColumnClass in interface TableModel

isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)

Specified by:
isCellEditable in interface TableModel

isColumnInternal

public static boolean isColumnInternal(Column col)
Test if the column is internal, i˙e˙ the first character of its name is a '#'.

Parameters:
col - the column.
Returns:
true if the column is internal, i.e. the first character of its name is a '#'.

hasTableModelListener

public boolean hasTableModelListener()
Returns true if the table has any registered TableModelListeners.

Returns:
true if the table has any registered TableModelListeners.

getObjectFromRow

public Object getObjectFromRow(int row)
Returns an object from a row.

Parameters:
row - the row
Returns:
an object

getRowFromObject

public int getRowFromObject(Object obj)
Returns a row from an object returned by getObjectFromRow.

Parameters:
obj - the object
Returns:
the row

addTableModelListener

public void addTableModelListener(TableModelListener l)

Specified by:
addTableModelListener in interface TableModel

removeTableModelListener

public void removeTableModelListener(TableModelListener l)

Specified by:
removeTableModelListener in interface TableModel

fireTableDataChanged

public void fireTableDataChanged(int firstRow,
                                 int lastRow,
                                 int type)
Notifies all listeners that all cell values in the table's rows may have changed. The number of rows may also have changed and the JTable should redraw the table from scratch. The structure of the table (as in the order of the columns) is assumed to be the same.

Parameters:
firstRow - the first row modified or NIL
lastRow - the last row modified or NIL
type - the event type
See Also:
TableModelEvent, EventListenerList, JTable.tableChanged(TableModelEvent)

fireTableDataChanged

public void fireTableDataChanged()
Notifies all listeners that all the table has changed.


fireTableStructureChanged

public void fireTableStructureChanged()
Notifies all listeners that the table's structure has changed. The number of columns in the table, and the names and types of the new columns may be different from the previous state. If the JTable receives this event and its autoCreateColumnsFromModel flag is set it discards any table columns that it had and reallocates default columns in the order they appear in the model. This is the same as calling setModel(TableModel) on the JTable.

See Also:
TableModelEvent, EventListenerList

fireTableChanged

public void fireTableChanged(TableModelEvent e)
Forwards the given notification event to all TableModelListeners that registered themselves as listeners for this table model.

Parameters:
e - the event to be forwarded
See Also:
addTableModelListener(javax.swing.event.TableModelListener), TableModelEvent, EventListenerList

stateChanged

public void stateChanged(ChangeEvent e)
Called when one of the column has changed to propagate the TableChanged notification.

Specified by:
stateChanged in interface ChangeListener
Parameters:
e - the change event.


Copyright 2005 by Jean-Daniel Fekete and INRIA, France All rights reserved.