Copyright © 2005 Scientific Applications. All Rights Reserved.

com.sciapp.table.group
Class AbstractTreeTableColumnModelAdapter

java.lang.Object
  extended by com.sciapp.table.group.AbstractTreeTableColumnModelAdapter
All Implemented Interfaces:
TreeTableColumnModelAdapter, VetoableTableColumnModel, PropertyChangeListener, Serializable, EventListener, ListSelectionListener, TableColumnModel
Direct Known Subclasses:
DefaultTreeTableColumnModelAdapter

public abstract class AbstractTreeTableColumnModelAdapter
extends Object
implements TreeTableColumnModelAdapter, VetoableTableColumnModel, PropertyChangeListener, ListSelectionListener, Serializable

AbstractTreeTableColumnModelAdapter is an implementation of a TreeTableColumnModelAdapter to serve as a basis for implementing a column model for a TreeTableHeader.

See Also:
Serialized Form

Field Summary
protected  ChangeEvent changeEvent
          Change event (only one needed)
protected  SwingPropertyChangeSupport changeSupport
          change support for the TREE_TABLE_COLUMN_MODEL_PROPERTY.
protected  int columnMargin
          Width margin between each column
protected  boolean columnSelectionAllowed
          Column selection allowed in this column model
protected  EventListenerList listenerList
          List of TableColumnModelListener
protected  ListSelectionModel selectionModel
          Model for keeping track of column selections
protected  int totalColumnWidth
          A local cache of the combined width of all columns
 
Fields inherited from interface com.sciapp.table.group.TreeTableColumnModelAdapter
TREE_PROPERTY, TREE_TABLE_COLUMN_MODEL_PROPERTY
 
Constructor Summary
AbstractTreeTableColumnModelAdapter()
          Constructs an AbstractTreeTableColumnModelAdapter.
 
Method Summary
 void addColumnModelListener(TableColumnModelListener x)
          Adds a listener for table column model events.
 void addPropertyChangeListener(PropertyChangeListener listener)
          Adds a PropertyChangeListener to the listener list to be notified when the TreeTableColumnModel changes.
 void addVetoableColumnModelListener(VetoableTableColumnModelListener l)
          Adds a listener that is notified when a table column is about to be added, moved or removed.
protected  ListSelectionModel createSelectionModel()
          Creates a new default list selection model.
protected  void fireColumnAdded(TableColumnModelEvent e)
          Notify all listeners that have registered interest for notification on this event type.
protected  void fireColumnMarginChanged()
          Notify all listeners that have registered interest for notification on this event type.
protected  void fireColumnMoved(TableColumnModelEvent e)
          Notify all listeners that have registered interest for notification on this event type.
protected  void fireColumnRemoved(TableColumnModelEvent e)
          Notify all listeners that have registered interest for notification on this event type.
protected  void fireColumnSelectionChanged(ListSelectionEvent e)
          Notify all listeners that have registered interest for notification on this event type.
protected  void fireColumnWillBeAdded(TableColumnModelEvent e)
          Notifies 'veto' listeners that a table column is about to be added.
protected  void fireColumnWillBeMoved(TableColumnModelEvent e)
          Notifies 'veto' listeners that a table column is about to be moved.
protected  void fireColumnWillBeRemoved(TableColumnModelEvent e)
          Notifies 'veto' listeners that a table column is about to be removed.
 int getColumnIndex(Object identifier)
          Returns the index of the first column in the table whose identifier is equal to identifier, when compared using equals.
 int getColumnIndexAtX(int x)
          Returns the index of the column that lies on the horizontal point, xPosition; or -1 if it lies outside the any of the column's bounds.
 int getColumnMargin()
          Returns the width between the cells in each column.
 boolean getColumnSelectionAllowed()
          Returns true if columns may be selected.
 EventListener[] getListeners(Class listenerType)
          Returns an array of all the objects currently registered as the listener type upon this model.
 int getSelectedColumnCount()
          Returns the number of selected columns.
 int[] getSelectedColumns()
          Returns an array of indicies of all selected columns.
 ListSelectionModel getSelectionModel()
          Returns the current selection model.
 int getTotalColumnWidth()
          Returns the total width of all the columns.
protected  void invalidateWidthCache()
          Invalidates the cached total column width.
 void propertyChange(PropertyChangeEvent evt)
          This method gets called when a bound property is changed.
protected  void recalcWidthCache()
          Recalculates the total combined width of all columns.
 void removeColumnModelListener(TableColumnModelListener x)
          Removes a listener for table column model events.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Removes a PropertyChangeListener from the listener list that is notified when the TreeTableColumnModel changes.
 void removeVetoableColumnModelListener(VetoableTableColumnModelListener l)
          Removes a listener that is notified when a table column is about to be added, moved or removed.
 void setColumnMargin(int newMargin)
          Sets the TableColumn's column margin to newMargin.
 void setColumnSelectionAllowed(boolean flag)
          Sets whether the columns in this model may be selected.
 void setSelectionModel(ListSelectionModel newModel)
          Sets the selection model.
 void valueChanged(ListSelectionEvent e)
          Called whenever the value of the selection changes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sciapp.table.group.TreeTableColumnModelAdapter
getTree, getTreeTableColumnModel
 
Methods inherited from interface javax.swing.table.TableColumnModel
addColumn, getColumn, getColumnCount, getColumns, moveColumn, removeColumn
 
Methods inherited from interface javax.swing.table.TableColumnModel
addColumn, getColumn, getColumnCount, getColumns, moveColumn, removeColumn
 

Field Detail

changeSupport

protected SwingPropertyChangeSupport changeSupport
change support for the TREE_TABLE_COLUMN_MODEL_PROPERTY.


selectionModel

protected ListSelectionModel selectionModel
Model for keeping track of column selections


columnMargin

protected int columnMargin
Width margin between each column


listenerList

protected EventListenerList listenerList
List of TableColumnModelListener


changeEvent

protected transient ChangeEvent changeEvent
Change event (only one needed)


columnSelectionAllowed

protected boolean columnSelectionAllowed
Column selection allowed in this column model


totalColumnWidth

protected int totalColumnWidth
A local cache of the combined width of all columns

Constructor Detail

AbstractTreeTableColumnModelAdapter

public AbstractTreeTableColumnModelAdapter()
Constructs an AbstractTreeTableColumnModelAdapter.

Method Detail

addColumnModelListener

public void addColumnModelListener(TableColumnModelListener x)
Adds a listener for table column model events.

Specified by:
addColumnModelListener in interface TableColumnModel
Parameters:
x - a TableColumnModelListener object

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list to be notified when the TreeTableColumnModel changes. The listener should check for TREE_TABLE_COLUMN_MODEL_PROPERTY property events.

Specified by:
addPropertyChangeListener in interface TreeTableColumnModelAdapter
Parameters:
listener - the listener to add.

addVetoableColumnModelListener

public void addVetoableColumnModelListener(VetoableTableColumnModelListener l)
Adds a listener that is notified when a table column is about to be added, moved or removed.

Specified by:
addVetoableColumnModelListener in interface VetoableTableColumnModel
Parameters:
l - the listener to be added

createSelectionModel

protected ListSelectionModel createSelectionModel()
Creates a new default list selection model.

Returns:
a new instance of the list selection model used.

fireColumnAdded

protected void fireColumnAdded(TableColumnModelEvent e)
Notify all listeners that have registered interest for notification on this event type.

Parameters:
e - the event that is propagated to listeners

fireColumnMarginChanged

protected void fireColumnMarginChanged()
Notify all listeners that have registered interest for notification on this event type.


fireColumnMoved

protected void fireColumnMoved(TableColumnModelEvent e)
Notify all listeners that have registered interest for notification on this event type.

Parameters:
e - the event that is propagated to listeners

fireColumnRemoved

protected void fireColumnRemoved(TableColumnModelEvent e)
Notify all listeners that have registered interest for notification on this event type.

Parameters:
e - the event that is propagated to listeners

fireColumnSelectionChanged

protected void fireColumnSelectionChanged(ListSelectionEvent e)
Notify all listeners that have registered interest for notification on this event type.

Parameters:
e - the event that is propagated to listeners

fireColumnWillBeAdded

protected void fireColumnWillBeAdded(TableColumnModelEvent e)
                              throws ColumnModelVetoException
Notifies 'veto' listeners that a table column is about to be added.

Parameters:
e - the event identifying the addition
Throws:
ColumnModelVetoException

fireColumnWillBeMoved

protected void fireColumnWillBeMoved(TableColumnModelEvent e)
                              throws ColumnModelVetoException
Notifies 'veto' listeners that a table column is about to be moved.

Parameters:
e - the event identifying the move
Throws:
ColumnModelVetoException

fireColumnWillBeRemoved

protected void fireColumnWillBeRemoved(TableColumnModelEvent e)
                                throws ColumnModelVetoException
Notifies 'veto' listeners that a table column is about to be removed.

Parameters:
e - the event identifying the removal
Throws:
ColumnModelVetoException

getColumnIndex

public int getColumnIndex(Object identifier)
Returns the index of the first column in the table whose identifier is equal to identifier, when compared using equals.

Specified by:
getColumnIndex in interface TableColumnModel
Parameters:
identifier - the identifier object
Returns:
the index of the first table column whose identifier is equal to identifier
See Also:
TableColumnModel.getColumn(int)

getColumnIndexAtX

public int getColumnIndexAtX(int x)
Returns the index of the column that lies on the horizontal point, xPosition; or -1 if it lies outside the any of the column's bounds. In keeping with Swing's separable model architecture, a TableColumnModel does not know how the table columns actually appear on screen. The visual presentation of the columns is the responsibility of the view/controller object using this model (typically JTable). The view/controller need not display the columns sequentially from left to right. For example, columns could be displayed from right to left to accomodate a locale preference or some columns might be hidden at the request of the user. Because the model does not know how the columns are laid out on screen, the given xPosition should not be considered to be a coordinate in 2D graphics space. Instead, it should be considered to be a width from the start of the first column in the model. If the column index for a given X coordinate in 2D space is required, JTable.columnAtPoint can be used instead.

Specified by:
getColumnIndexAtX in interface TableColumnModel
Returns:
the index of the column; or -1 if no column is found
See Also:
JTable.columnAtPoint(java.awt.Point)

getColumnMargin

public int getColumnMargin()
Returns the width between the cells in each column.

Specified by:
getColumnMargin in interface TableColumnModel
Returns:
the margin, in pixels, between the cells

getColumnSelectionAllowed

public boolean getColumnSelectionAllowed()
Returns true if columns may be selected.

Specified by:
getColumnSelectionAllowed in interface TableColumnModel
Returns:
true if columns may be selected
See Also:
TableColumnModel.setColumnSelectionAllowed(boolean)

getListeners

public EventListener[] getListeners(Class listenerType)
Returns an array of all the objects currently registered as the listener type upon this model.

Parameters:
listenerType - the type of listeners requested; this parameter should specify an interface that descends from java.util.EventListener
Returns:
an array of all objects registered as the listener type on this model, or an empty array if no such listeners have been added

getSelectedColumnCount

public int getSelectedColumnCount()
Returns the number of selected columns.

Specified by:
getSelectedColumnCount in interface TableColumnModel
Returns:
the number of selected columns; or 0 if no columns are selected

getSelectedColumns

public int[] getSelectedColumns()
Returns an array of indicies of all selected columns.

Specified by:
getSelectedColumns in interface TableColumnModel
Returns:
an array of integers containing the indicies of all selected columns; or an empty array if nothing is selected

getSelectionModel

public ListSelectionModel getSelectionModel()
Returns the current selection model.

Specified by:
getSelectionModel in interface TableColumnModel
Returns:
a ListSelectionModel object
See Also:
TableColumnModel.setSelectionModel(javax.swing.ListSelectionModel)

getTotalColumnWidth

public int getTotalColumnWidth()
Returns the total width of all the columns.

Specified by:
getTotalColumnWidth in interface TableColumnModel
Returns:
the total computed width of all columns

invalidateWidthCache

protected void invalidateWidthCache()
Invalidates the cached total column width.


propertyChange

public void propertyChange(PropertyChangeEvent evt)
This method gets called when a bound property is changed.

Specified by:
propertyChange in interface PropertyChangeListener
Parameters:
evt - A PropertyChangeEvent object describing the event source and the property that has changed.

recalcWidthCache

protected void recalcWidthCache()
Recalculates the total combined width of all columns. Updates the totalColumnWidth property.


removeColumnModelListener

public void removeColumnModelListener(TableColumnModelListener x)
Removes a listener for table column model events.

Specified by:
removeColumnModelListener in interface TableColumnModel
Parameters:
x - a TableColumnModelListener object

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Removes a PropertyChangeListener from the listener list that is notified when the TreeTableColumnModel changes. The listener should check for TREE_TABLE_COLUMN_MODEL_PROPERTY property events.

Specified by:
removePropertyChangeListener in interface TreeTableColumnModelAdapter
Parameters:
listener - the listener to remove.

removeVetoableColumnModelListener

public void removeVetoableColumnModelListener(VetoableTableColumnModelListener l)
Removes a listener that is notified when a table column is about to be added, moved or removed.

Specified by:
removeVetoableColumnModelListener in interface VetoableTableColumnModel
Parameters:
l - the listener to be removed

setColumnMargin

public void setColumnMargin(int newMargin)
Sets the TableColumn's column margin to newMargin. This method posts a columnMarginChanged event to its listeners.

Specified by:
setColumnMargin in interface TableColumnModel
Parameters:
newMargin - the width, in pixels, of the new column margins
See Also:
TableColumnModel.getColumnMargin()

setColumnSelectionAllowed

public void setColumnSelectionAllowed(boolean flag)
Sets whether the columns in this model may be selected.

Specified by:
setColumnSelectionAllowed in interface TableColumnModel
Parameters:
flag - true if columns may be selected; otherwise false
See Also:
TableColumnModel.getColumnSelectionAllowed()

setSelectionModel

public void setSelectionModel(ListSelectionModel newModel)
Sets the selection model.

Specified by:
setSelectionModel in interface TableColumnModel
Parameters:
newModel - a ListSelectionModel object
See Also:
TableColumnModel.getSelectionModel()

valueChanged

public void valueChanged(ListSelectionEvent e)
Called whenever the value of the selection changes.

Specified by:
valueChanged in interface ListSelectionListener
Parameters:
e - the event that characterizes the change.

Copyright © 2005 Scientific Applications. All Rights Reserved.