org.peace_tools.data
Class ClusterTreeTableModel

java.lang.Object
  extended by org.peace_tools.data.ClusterTreeTableModel
All Implemented Interfaces:
javax.swing.tree.TreeModel, org.netbeans.swing.outline.RowModel

public class ClusterTreeTableModel
extends java.lang.Object
implements javax.swing.tree.TreeModel, org.netbeans.swing.outline.RowModel

The tree table model that provides a facade to display cluster information in a tree-table.

This class servers as a light weight wrapper to adapt the in-memory cluster representation to be displayed in a tree-table. The first column in the tree-table displays an hierarchical view of the clusters. The remaining columns display the EST sequence base pair information. This class serves as the "Model" as in a the Model-View-Controller design pattern.

The tree-table or Outline model is a generic non-standard GUI component developed by Sun Microsystems as part of the NetBeans IDE. This jar has been obtain from the NetBeans package as a part. The tree-table is a combination both a JTree and a JTable. The first column in the tree-table is a tree that provides the user with a convenient interface to access and control view of hierarchical information. The remaining columns in the tree-table display detailed information about each entry in the tree table.


Field Summary
private  int basesPerCol
          The number of base pairs per column.
private  ClusterFile clusterFile
          Reference to the cluster file that contains the cluster data to be adapted and interfaced by this model.
private  ESTList estList
          Reference to the EST file that contains the cluster data to be adapted and interfaced by this model.
private  int maxESTLen
          The maximum length of an EST sequence to be adapted by this model.
private  java.lang.Integer[] sortedSubClusterIndexs
          This array contains a sorted list of indexes of fragments if a sorting scheme has been applied to the data set.
private  java.util.ArrayList<javax.swing.event.TreeModelListener> treeModelListeners
          The list of tree mode listeners that were added to this tree model.
private  MSTClusterData wsEntry
          A handy reference to the workspace entry from which the data for this cluster table model was actually obtained.
 
Constructor Summary
ClusterTreeTableModel(ClusterFile clusters, ESTList ests, MSTClusterData wsEntry)
          The constructor.
 
Method Summary
 void addTreeModelListener(javax.swing.event.TreeModelListener tml)
          Adds a listener to be notified when the data associated with the data set changes.
protected  void fireTableStructureChanged()
          Helper method to broadcast notification to all model listeners.
 java.lang.Object getChild(java.lang.Object parent, int index)
          Returns the child cluster or EST node for a given parent node.
 int getChildCount(java.lang.Object parent)
          Return the number of child nodes for a given cluster node.
 ClusterFile getClusterFile()
          Obtain the cluster file from where cluster data was obtained.
 java.lang.Class<?> getColumnClass(int column)
          Obtain the class that describes the data type of a given column.
 int getColumnCount()
          This method overrides the interface method in RowModel to return the number of columns in the TreeTable.
 java.lang.String getColumnName(int column)
          This method overrides the interface method in RowModel to return the title for the columns.
 ESTList getESTList()
          Obtain the list of ESTs associated with this model.
 int getIndexOfChild(java.lang.Object parent, java.lang.Object child)
          Obtain the index of a given child node within its immediate parent.
 ClusterNode getRoot()
          Obtain the top-level root node.
 java.lang.Object getValueFor(java.lang.Object node, int column)
          This method returns the subset of base pairs to be displayed in a given column for a given RowModel.
 MSTClusterData getWsEntry()
          Obtain the actual workspace entry whose data is contained in this model.
 boolean isCellEditable(java.lang.Object node, int column)
          Determine if the cell in this column is editable for the passed node.
 boolean isLeaf(java.lang.Object node)
          Determine if a given node in the tree is a leaf node.
 void removeTreeModelListener(javax.swing.event.TreeModelListener tml)
          Removes a listener from the list of listeners maintained by this class.
 void setValueFor(java.lang.Object node, int column, java.lang.Object value)
          Set the value of the object in this column.
 void sort(int order)
          Method to change the order in which top-level clusters are ordered.
 void valueForPathChanged(javax.swing.tree.TreePath path, java.lang.Object newValue)
          Messaged when the user has altered the value for the item identified by path to newValue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

clusterFile

private final ClusterFile clusterFile
Reference to the cluster file that contains the cluster data to be adapted and interfaced by this model. This value is set in the constructor and is never changed during the life time of this class.


wsEntry

private final MSTClusterData wsEntry
A handy reference to the workspace entry from which the data for this cluster table model was actually obtained. This information can be used by "view" classes to create additional views as needed.


estList

private final ESTList estList
Reference to the EST file that contains the cluster data to be adapted and interfaced by this model. This value is set in the constructor and is never changed during the life time of this class.


maxESTLen

private final int maxESTLen
The maximum length of an EST sequence to be adapted by this model. This value along with the basesPerCol determines the total number of columns that are logically represented by this model.


basesPerCol

private int basesPerCol
The number of base pairs per column. This value along with the maxESTLen determines the total number of columns that are logically represented by this model.


sortedSubClusterIndexs

private java.lang.Integer[] sortedSubClusterIndexs
This array contains a sorted list of indexes of fragments if a sorting scheme has been applied to the data set. If this array is not null then this table model returns entries using the order specified in this array. The entries in this array are indexes into the original set of clusters in the root. This list changes depending on the order of sorting requested by the user.


treeModelListeners

private java.util.ArrayList<javax.swing.event.TreeModelListener> treeModelListeners
The list of tree mode listeners that were added to this tree model. This list is used to notify listeners that the tree has changed.

Constructor Detail

ClusterTreeTableModel

public ClusterTreeTableModel(ClusterFile clusters,
                             ESTList ests,
                             MSTClusterData wsEntry)
The constructor. The constructor merely initializes the necessary data members in the cluster tree (and its base class).

Parameters:
clusters - The set of clusters to be displayed by this class.
ests - The set of ESTs that contain information about each EST in the clusters.
wsEntry - The workspace entry corresponding to the clusters being adapted by this object.
Method Detail

getColumnClass

public java.lang.Class<?> getColumnClass(int column)
Obtain the class that describes the data type of a given column. This method overrides the API method in RowModel.

Specified by:
getColumnClass in interface org.netbeans.swing.outline.RowModel
Parameters:
column - The zero-based index of the column whose Class type is to be returned.

getColumnCount

public int getColumnCount()
This method overrides the interface method in RowModel to return the number of columns in the TreeTable. This value is determined using a combination of maxLen and basesPerCol values. This method overrides the API method in RowModel.

Specified by:
getColumnCount in interface org.netbeans.swing.outline.RowModel
Returns:
The number of columns to be displayed in this table. There are always a minimum of 1 column.

getColumnName

public java.lang.String getColumnName(int column)
This method overrides the interface method in RowModel to return the title for the columns. The column titles are dynamically determined depending on the number of columns displayed in the table.

Specified by:
getColumnName in interface org.netbeans.swing.outline.RowModel
Returns:
The title for the columns. The title for the first column that contains the tree display is fixed.

getValueFor

public java.lang.Object getValueFor(java.lang.Object node,
                                    int column)
This method returns the subset of base pairs to be displayed in a given column for a given RowModel. This method overrides the interface method in TreeTableModel to return the data to be displayed in a given row. The return value is computed as follows:
  1. If the node is an EST node and column * basesPerCol is less than EST length, then the bases logically associated with the column are returned.
  2. Otherwise this method returns an empty string.

Specified by:
getValueFor in interface org.netbeans.swing.outline.RowModel
Returns:
The data to be displayed for a given node (or row) and a given column.

isCellEditable

public boolean isCellEditable(java.lang.Object node,
                              int column)
Determine if the cell in this column is editable for the passed node. This method implements the corresponding method in the RowTable interface.

Specified by:
isCellEditable in interface org.netbeans.swing.outline.RowModel
Parameters:
node - The node corresponding to the entry in the tree.
column - The zero-based index of the column to be edited.
Returns:
This method always returns false to indicate that the data is not editable.

setValueFor

public void setValueFor(java.lang.Object node,
                        int column,
                        java.lang.Object value)
Set the value of the object in this column. This method implements the corresponding method in the RowTable interface. Currently this method does nothing as the data is not really editable.

Specified by:
setValueFor in interface org.netbeans.swing.outline.RowModel
Parameters:
node - The node corresponding to the entry in the tree.
column - The zero-based index of the column to be edited.
value - The new value to be set for the given column and node (row).

sort

public void sort(int order)
Method to change the order in which top-level clusters are ordered. This method resets the order in which top-level clusters (that is, clusters that are directly the children of the root) are displayed.

Parameters:
order - The order in which the clusters are to be sorted. The following values are valid for this parameter: 0: no sorting, 1: smaller clusters first, 2: smaller clusters last.

fireTableStructureChanged

protected void fireTableStructureChanged()
Helper method to broadcast notification to all model listeners. This method is a helper method that is used to broadcast notification that the tree model has changed to all interested listeners. Typically, the listeners are views that refresh their display when the data changes.


addTreeModelListener

public void addTreeModelListener(javax.swing.event.TreeModelListener tml)
Adds a listener to be notified when the data associated with the data set changes. This method implements the API method in TreeModel.

Specified by:
addTreeModelListener in interface javax.swing.tree.TreeModel
Parameters:
tml - The listener to be added to the list of listeners to be notified when the data associated with the workspace changes.

getChild

public java.lang.Object getChild(java.lang.Object parent,
                                 int index)
Returns the child cluster or EST node for a given parent node. This method overrides the interface method in the base class to return the tree node corresponding to the given child. This method implements the API method in TreeModel.

Specified by:
getChild in interface javax.swing.tree.TreeModel
Returns:
The child cluster or EST node in the given cluster.

getChildCount

public int getChildCount(java.lang.Object parent)
Return the number of child nodes for a given cluster node. This method overrides the interface method in the TreeModel to return the number of child nodes for a given node.

Specified by:
getChildCount in interface javax.swing.tree.TreeModel
Returns:
The number of child nodes for a given node.

getIndexOfChild

public int getIndexOfChild(java.lang.Object parent,
                           java.lang.Object child)
Obtain the index of a given child node within its immediate parent. This method overrides the interface method in TreeModel to return the index of a child node for a given parent node.

Specified by:
getIndexOfChild in interface javax.swing.tree.TreeModel
Returns:
The index of the child node within the parent node.

getRoot

public ClusterNode getRoot()
Obtain the top-level root node. This method implements the corresponding API method in the TreeModel.

Specified by:
getRoot in interface javax.swing.tree.TreeModel
Returns:
The top-level root cluster node.

isLeaf

public boolean isLeaf(java.lang.Object node)
Determine if a given node in the tree is a leaf node.

Specified by:
isLeaf in interface javax.swing.tree.TreeModel
Parameters:
node - The node must be a valid node obtained via an earlier call to the getChild.
Returns:
Returns true if the given node is a leaf node in the tree.

removeTreeModelListener

public void removeTreeModelListener(javax.swing.event.TreeModelListener tml)
Removes a listener from the list of listeners maintained by this class.

Specified by:
removeTreeModelListener in interface javax.swing.tree.TreeModel
Parameters:
tml - The listener to be removed from the list of listeners to receive updates.

valueForPathChanged

public void valueForPathChanged(javax.swing.tree.TreePath path,
                                java.lang.Object newValue)
Messaged when the user has altered the value for the item identified by path to newValue. This method is currently not implemented because the cluster data cannot be edited.

Specified by:
valueForPathChanged in interface javax.swing.tree.TreeModel

getESTList

public ESTList getESTList()
Obtain the list of ESTs associated with this model.

Returns:
The EST list set for use by this model.

getClusterFile

public ClusterFile getClusterFile()
Obtain the cluster file from where cluster data was obtained.

Returns:
The cluster file from where the clustering information was obtained.

getWsEntry

public MSTClusterData getWsEntry()
Obtain the actual workspace entry whose data is contained in this model. A handy reference to the workspace entry from which the data for this cluster table model was actually obtained. This information can be used by "view" classes to create additional views as needed.

Returns:
The reference to the MSTClusterData workspace entry whose data is "modeled" by this class.