data
Class DataSheet

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

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

A representation of the data imported from a text file.

Everytime the user imports data from a text file the data is stored in a DataSheet. The data sheet is kind of wrapper class for the collection of all rows in the text file. Each row represents one Design.

In addition to storing the Designs and providing the possibility to display them in a JTable by implementing TableModel, the DataSheet class also keeps track of the Parameters in the data set. Each column represents one Parameter.

The third main function of this class is to actually read the data from a text file. While doing this, the DataSheet also collects some additional information, such as

Note that floating point values must be formatted in american format. (#.##) instead of (#,##)

Finally, the DataSheet also keeps track of all Clusters. However, it does not store the information to which Cluster each Design belongs. This information is stored in the Designs themselves. It is important to understand this because it means that whenever updateData(String, boolean) is called this information is lost.

See Also:
Serialized Form

Field Summary
private  ClusterSet clusterSet
          The cluster set.
private  java.util.Vector<Design> data
          The Vector containing all Designs.
private  java.lang.String delimiter
          The delimiter used for the data import.
private  java.util.Vector<javax.swing.event.TableModelListener> listeners
          Table Model Listeners to enable updating the GUI.
private  java.util.Vector<Parameter> parameters
          The parameters.
(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.
 
Constructor Summary
DataSheet(java.lang.String pathToInputFile, boolean dataHasHeaders)
          Instantiates a new data sheet and fills it with data from a given file.
 
Method Summary
 void addDesign(Design design)
          Adds a Design to the DataSheet.
 void addTableModelListener(javax.swing.event.TableModelListener l)
           
private  void checkParameters()
          Scans the whole DataSheet to determine the parameter types (numeric/discrete).
 void evaluateBoundsForAllDesigns(Chart chart)
          Evaluate each Design to check whether it is within all axis bounds.
 void fireTableChanged()
          Fire table changed.
 ClusterSet getClusterSet()
          Gets the cluster set.
 java.lang.Class<?> getColumnClass(int arg0)
           
 int getColumnCount()
           
 java.lang.String getColumnName(int columnIndex)
           
 Design getDesign(int i)
          Gets the Design with index i.
 int getDesignCount()
          Gets the design count.
 double getMaxValueOf(Parameter param)
          Gets the maximum value of a given Parameter in the DataSheet.
 double getMinValueOf(Parameter param)
          Gets the minimum value of a given Parameter.
 Parameter getParameter(int index)
          Gets the Parameter with the index index.
 Parameter getParameter(java.lang.String parameterName)
          Gets the Parameter with the name parameterName.
 int getParameterCount()
          Gets the Pparameter count.
 java.lang.String getParameterName(int index)
          Gets the Parameter name of the Parameter with index index.
 int getRowCount()
           
private  java.lang.String getUniqueParameterName(java.lang.String nameSuggestion)
          Checks whether a given String is a unique parameter name using isNameUnique(String).
 java.lang.Object getValueAt(int rowIndex, int columnIndex)
           
private  void importData(java.lang.String pathToInputFile, boolean dataHasHeaders)
          Fills the DataSheet with data from a given file and assigns Parameter names.
 boolean isCellEditable(int rowIndex, int columnIndex)
           
private  boolean isNameUnique(java.lang.String name)
          Checks if a give String is a unique Parameter name.
private  void log(java.lang.String message)
          Prints debug information to stdout when printLog is set to true.
 void removeDesign(Design design)
          Removes a Design from the DataSheets.
 void removeTableModelListener(javax.swing.event.TableModelListener l)
           
 void setClusterSet(ClusterSet clusterSet)
          Sets the cluster set.
 void setValueAt(java.lang.Object arg0, int rowIndex, int columnIndex)
           
 void updateData(java.lang.String pathToInputFile, boolean dataHasHeaders)
          Updates the DataSheet with Data from a given file and assigns Parameter names.
 
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

clusterSet

private ClusterSet clusterSet
The cluster set.


data

private java.util.Vector<Design> data
The Vector containing all Designs.


parameters

private java.util.Vector<Parameter> parameters
The parameters.


listeners

private transient java.util.Vector<javax.swing.event.TableModelListener> listeners
Table Model Listeners to enable updating the GUI.


delimiter

private java.lang.String delimiter
The delimiter used for the data import.

Constructor Detail

DataSheet

public DataSheet(java.lang.String pathToInputFile,
                 boolean dataHasHeaders)
          throws java.io.IOException
Instantiates a new data sheet and fills it with data from a given file.

Uses importData(String, boolean) for the step of reading the data.

Parameters:
pathToInputFile - the path to the input file
dataHasHeaders - specifies whether the data has headers to read the Parameter names from.
Throws:
java.io.IOException - Signals that an I/O exception has occurred.
Method Detail

checkParameters

private void checkParameters()
Scans the whole DataSheet to determine the parameter types (numeric/discrete).

See Also:
Parameter

importData

private void importData(java.lang.String pathToInputFile,
                        boolean dataHasHeaders)
                 throws java.io.IOException
Fills the DataSheet with data from a given file and assigns Parameter names.

Note that floating point values must be formatted in american format. (#.##) instead of (#,##)

If dataHasHeaders is true, the Parameter names are read from the first line. Otherwise the parameter names are created automatically.

Parameters:
pathToInputFile - the path to the input file
dataHasHeaders - specifies whether the data has headers to read the Parameter names from.
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

updateData

public void updateData(java.lang.String pathToInputFile,
                       boolean dataHasHeaders)
                throws java.io.IOException,
                       InconsistentDataException
Updates the DataSheet with Data from a given file and assigns Parameter names.

If dataHasHeaders is true, the Parameter names are read from the first line. Otherwise the parameter names are created automatically.

The difference of updating vs. importing is that all Charts are kept. This requires the new data to have the same number of parameters as the previous one. Otherwise the InconsistentDataException is thrown.

Parameters:
pathToInputFile - the path to the input file
dataHasHeaders - specifies whether the data has headers to read the Parameter names from.
Throws:
java.io.IOException - Signals that an I/O exception has occurred.
InconsistentDataException - if the user tries to import data that does not have the same number of columns as the current DataSheet.

getColumnClass

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

getColumnCount

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

getRowCount

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

getColumnName

public java.lang.String getColumnName(int columnIndex)
Specified by:
getColumnName 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

setValueAt

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

isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)
Specified by:
isCellEditable 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()
Fire table changed.


getDesign

public Design getDesign(int i)
Gets the Design with index i.

Parameters:
i - the index
Returns:
the Design

addDesign

public void addDesign(Design design)
Adds a Design to the DataSheet.

Parameters:
design - the Design

removeDesign

public void removeDesign(Design design)
Removes a Design from the DataSheets.

Parameters:
design - the Design

getParameterCount

public int getParameterCount()
Gets the Pparameter count.

Returns:
the Parameter count

getParameterName

public java.lang.String getParameterName(int index)
Gets the Parameter name of the Parameter with index index.

Parameters:
index - the index
Returns:
the parameter name

getParameter

public Parameter getParameter(int index)
Gets the Parameter with the index index.

Parameters:
index - the Parameter index
Returns:
the Parameter

getParameter

public Parameter getParameter(java.lang.String parameterName)
Gets the Parameter with the name parameterName.

Parameters:
parameterName - the Parameter name
Returns:
the Parameter

getMaxValueOf

public double getMaxValueOf(Parameter param)
Gets the maximum value of a given Parameter in the DataSheet.

Parameters:
param - the Parameter
Returns:
the maximum value of the given Parameter.

getMinValueOf

public double getMinValueOf(Parameter param)
Gets the minimum value of a given Parameter.

Parameters:
param - the parameter
Returns:
the minimum value of the given Parameter.

getDesignCount

public int getDesignCount()
Gets the design count.

Returns:
the design count

getUniqueParameterName

private java.lang.String getUniqueParameterName(java.lang.String nameSuggestion)
Checks whether a given String is a unique parameter name using isNameUnique(String). Returns a unique name if the provided string is not unique and the unchanged String otherwise.

Parameters:
nameSuggestion - the name that should be checked
Returns:
the a unique name if nameSuggestion was not a unique name and nameSuggestion otherwise

isNameUnique

private boolean isNameUnique(java.lang.String name)
Checks if a give String is a unique Parameter name.

Parameters:
name - the name to check
Returns:
true, if the name is unique

log

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

Parameters:
message - the message

getClusterSet

public ClusterSet getClusterSet()
Gets the cluster set.

Returns:
the cluster set

setClusterSet

public void setClusterSet(ClusterSet clusterSet)
Sets the cluster set.

Parameters:
clusterSet - the new cluster set

evaluateBoundsForAllDesigns

public void evaluateBoundsForAllDesigns(Chart chart)
Evaluate each Design to check whether it is within all axis bounds.

Parameters:
chart - the chart
See Also:
Design