data
Class ClusterSet

java.lang.Object
  extended by data.ClusterSet
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel

public class ClusterSet
extends java.lang.Object
implements java.io.Serializable, javax.swing.table.TableModel

A collection of several Clusters.

See Also:
Serialized Form

Field Summary
private  java.util.Vector<Cluster> clusters
          The clusters.
private  java.util.Vector<Cluster> clustersBuffer
          A buffer of clusters that is used while the user is editing this ClusterSet.
private  DataSheet dataSheet
          The data sheet.
private  java.util.Vector<javax.swing.event.TableModelListener> listeners
          Used for automatic update of the GUI when table contents change.
(package private) static boolean printLog
          Flag to enable debug message printing for this class.
(package private) static long serialVersionUID
          The version tracking unique identifier for Serialization.
private  int uniqueIdentificationNumberCounter
          Counter which allows to attribute a unique identifier to each Cluster.
 
Constructor Summary
ClusterSet(DataSheet dataSheet)
          Instantiates a new cluster set.
 
Method Summary
 void addClusterToBuffer()
          Adds a new cluster to the editing buffer.
 void addTableModelListener(javax.swing.event.TableModelListener l)
           
 void applyChanges()
          All changes made to the editing buffer are now applied by copying the buffer to the persistent Vector clusters.
 void createBuffer()
          Creates a buffer by copying the clusters Vector.
 void fireTableChanged()
          Called to update the display of the table
 Cluster getCluster(int i)
          Gets a cluster by index i.
 Cluster getCluster(java.lang.String clusterName)
          Gets a cluster by name.
 int getClusterCount()
          Gets the cluster count.
 java.lang.Class<?> getColumnClass(int columnIndex)
           
 int getColumnCount()
           
 java.lang.String getColumnName(int columnIndex)
           
 int getRowCount()
           
private  java.lang.String getUniqueClusterName()
          Creates a unique name for a new Cluster.
 java.lang.Object getValueAt(int rowIndex, int columnIndex)
           
 boolean isCellEditable(int rowIndex, int columnIndex)
           
private  boolean isNameUnique(java.lang.String name)
          Checks if a given name is a unique Cluster name.
private  boolean isNameUnique(java.lang.String name, int exception)
          Checks if a given name is a unique Cluster name but does check against the name of Cluster with index exception.
private  void log(java.lang.String message)
          Prints debug information to stdout when printLog is set to true.
 void removeClusterFromBuffer(Cluster cluster)
          Removes the specified Cluster from the editing buffer.
 void removeClusterFromBuffer(int i)
          Removes a cluster from the editing buffer.
 void removeClusterFromBuffer(java.lang.String clusterName)
          Removes a cluster from buffer by name.
 void removeTableModelListener(javax.swing.event.TableModelListener l)
           
 void setValueAt(java.lang.Object arg0, int rowIndex, int columnIndex)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID
The version tracking unique identifier for Serialization.

See Also:
Constant Field Values

printLog

static final boolean printLog
Flag to enable debug message printing for this class.

See Also:
Constant Field Values

dataSheet

private DataSheet dataSheet
The data sheet.


clusters

private java.util.Vector<Cluster> clusters
The clusters.


clustersBuffer

private java.util.Vector<Cluster> clustersBuffer
A buffer of clusters that is used while the user is editing this ClusterSet.

While the user edits this ClusterSet all changes are only applied to this buffer. The changes are only applied when the user confirms his actions. The method applyChanges() is used for this purpose.


listeners

private java.util.Vector<javax.swing.event.TableModelListener> listeners
Used for automatic update of the GUI when table contents change.


uniqueIdentificationNumberCounter

private int uniqueIdentificationNumberCounter
Counter which allows to attribute a unique identifier to each Cluster.

This is needed to keep the correct references between the clusters Vector and the editing buffer.

Constructor Detail

ClusterSet

public ClusterSet(DataSheet dataSheet)
Instantiates a new cluster set.

Parameters:
dataSheet - the data sheet
Method Detail

getColumnClass

public java.lang.Class<?> getColumnClass(int columnIndex)
Specified by:
getColumnClass in interface javax.swing.table.TableModel

getColumnCount

public int getColumnCount()
Specified by:
getColumnCount in interface javax.swing.table.TableModel

getColumnName

public java.lang.String getColumnName(int columnIndex)
Specified by:
getColumnName in interface javax.swing.table.TableModel

getRowCount

public int getRowCount()
Specified by:
getRowCount in interface javax.swing.table.TableModel

getValueAt

public java.lang.Object getValueAt(int rowIndex,
                                   int columnIndex)
Specified by:
getValueAt in interface javax.swing.table.TableModel

isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)
Specified by:
isCellEditable in interface javax.swing.table.TableModel

setValueAt

public void setValueAt(java.lang.Object arg0,
                       int rowIndex,
                       int columnIndex)
Specified by:
setValueAt in interface javax.swing.table.TableModel

addTableModelListener

public void addTableModelListener(javax.swing.event.TableModelListener l)
Specified by:
addTableModelListener in interface javax.swing.table.TableModel

removeTableModelListener

public void removeTableModelListener(javax.swing.event.TableModelListener l)
Specified by:
removeTableModelListener in interface javax.swing.table.TableModel

fireTableChanged

public void fireTableChanged()
Called to update the display of the table


addClusterToBuffer

public void addClusterToBuffer()
Adds a new cluster to the editing buffer.


removeClusterFromBuffer

public void removeClusterFromBuffer(int i)
Removes a cluster from the editing buffer.

Parameters:
i - the index of the Cluster to be removed.

removeClusterFromBuffer

public void removeClusterFromBuffer(Cluster cluster)
Removes the specified Cluster from the editing buffer.

Parameters:
cluster - the Cluster to be removed

getCluster

public Cluster getCluster(int i)
Gets a cluster by index i.

Parameters:
i - the index
Returns:
the cluster with index i

getCluster

public Cluster getCluster(java.lang.String clusterName)
Gets a cluster by name.

Parameters:
clusterName - the cluster name
Returns:
the cluster with name clusterName

getClusterCount

public int getClusterCount()
Gets the cluster count.

Returns:
the cluster count

removeClusterFromBuffer

public void removeClusterFromBuffer(java.lang.String clusterName)
Removes a cluster from buffer by name.

Parameters:
clusterName - the name of the Cluster to be removed.

getUniqueClusterName

private java.lang.String getUniqueClusterName()
Creates a unique name for a new Cluster.

Returns:
the unique cluster name

isNameUnique

private boolean isNameUnique(java.lang.String name)
Checks if a given name is a unique Cluster name.

Parameters:
name - the name to be checked
Returns:
true, if the name is a unique Cluster name

isNameUnique

private boolean isNameUnique(java.lang.String name,
                             int exception)
Checks if a given name is a unique Cluster name but does check against the name of Cluster with index exception.

This is needed when the user edits the Cluster name. In this case, the entered name must be checked against the names of all other Clusters, but not against the current name of this Cluster. Otherwise reentering the same name as the Cluster had before would produce an error message.

Parameters:
name - the name
exception - the exception
Returns:
true, if is name unique

applyChanges

public void applyChanges()
All changes made to the editing buffer are now applied by copying the buffer to the persistent Vector clusters.


createBuffer

public void createBuffer()
Creates a buffer by copying the clusters Vector.

This buffer is used to store modifications that the user makes until he choose to apply the changes made.


log

private void log(java.lang.String message)
Prints debug information to stdout when printLog is set to true.

Parameters:
message - the message