org.simulator.math.odes
Class MultiTable

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by org.simulator.math.odes.MultiTable
All Implemented Interfaces:
Serializable, Iterable<Iterable<Double>>, TableModel

public class MultiTable
extends AbstractTableModel
implements Iterable<Iterable<Double>>

This data structure contains the an array of sorted time points and a matrix organized in one column per quantity for which data (measurement or simulation) are gathered. Each row in the matrix corresponds to one time point. Hence, the array of time points must be equal to the number of rows in the matrix. To be able to identify the content of each column, this data structure also contains an array of identifiers for each column.

To be displayed in a graphical user interface, this object extends AbstractTableModel. Note that the access to the elements in this object therefore puts both elements together, i.e., the time column is considered to be the first column in the table.

Since:
0.9
Version:
$Rev: 332 $
Author:
Andreas Dräger
See Also:
Serialized Form

Nested Class Summary
 class MultiTable.Block
          A MultiTable.Block is a data structure with a two-dimensional double array of actual data together with identifiers for each column.
 
Field Summary
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
MultiTable()
          Constructs an empty MultiTable object.
MultiTable(double[] timePoints, double[][] data, String[] identifiers)
          Constructs a data object for the given values.
MultiTable(double[] timePoints, double[][] data, String[] columnIdentifiers, String[] columnNames)
           
 
Method Summary
 void addBlock(String[] identifiers)
          Creates a new MultiTable.Block and adds it to this object.
 MultiTable filter(double[] timepoints)
          Creates a multi block table only containing the values for the given timepoints (if available)
 MultiTable.Block getBlock(int index)
           
 int getBlockCount()
           
 MultiTable.Block.Column getColumn(int column)
           
 MultiTable.Block.Column getColumn(String identifier)
          Returns the column corresponding to the given identifier.
 Class<Double> getColumnClass(int columnIndex)
           
 int getColumnCount()
           
 String getColumnIdentifier(int column)
           
 int getColumnIndex(String identifier)
          Returns the index of a column for a given identifier.
 String getColumnName(int column)
           
 String getName()
          Gives this MultiTable's name.
 int getNumBlocks()
           
 int getRowCount()
           
static long getSerialversionuid()
           
 String getTimeName()
          The column identifier for the first column, i.e., the time column.
 double getTimePoint(int rowIndex)
          Returns the time value at the given index position.
 double[] getTimePoints()
           
 Double getValueAt(int rowIndex, int columnIndex)
           
 boolean isCellEditable(int rowIndex, int columnIndex)
           
 boolean isSetTimePoints()
          Checks whether an array of time points has been set for this object.
 Iterator<Iterable<Double>> iterator()
           
 void removeBlock(int index)
          Removes the MultiTable.Block with the given index from this data structure.
 void setName(String name)
          Sets the name of this MultiTable.
 void setTimeName(String timeName)
          Set the name of the time column
 void setTimePoints(double[] timePoints)
           
 void setValueAt(Object aValue, int rowIndex, int columnIndex)
           
 String toString()
           
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MultiTable

public MultiTable()
Constructs an empty MultiTable object.


MultiTable

public MultiTable(double[] timePoints,
                  double[][] data,
                  String[] identifiers)
Constructs a data object for the given values.

Parameters:
timePoints -
data -
identifiers - The first column in identifiers may be the name for the time column.

MultiTable

public MultiTable(double[] timePoints,
                  double[][] data,
                  String[] columnIdentifiers,
                  String[] columnNames)
Parameters:
timePoints -
data -
columnIdentifiers -
columnNames -
Method Detail

getSerialversionuid

public static long getSerialversionuid()
Returns:
the serialversionuid

addBlock

public void addBlock(String[] identifiers)
Creates a new MultiTable.Block and adds it to this object. The number of rows will be equal to the number of time points of the overall data structure.

Parameters:
identifiers - The column identifiers of the new block.

filter

public MultiTable filter(double[] timepoints)
Creates a multi block table only containing the values for the given timepoints (if available)

Parameters:
timepoints -
Returns:
table the filtered table

getBlock

public MultiTable.Block getBlock(int index)
Parameters:
index -
Returns:
block the block at the given position

getBlockCount

public int getBlockCount()
Returns:
blockCount

getColumn

public MultiTable.Block.Column getColumn(int column)
Parameters:
column -
Returns:
column the column at the given position

getColumn

public MultiTable.Block.Column getColumn(String identifier)
Returns the column corresponding to the given identifier.

Parameters:
identifier - An identifier.
Returns:
A MultiTable.Block.Column object for this identifier or null if no such MultiTable.Block.Column exists.

getColumnIndex

public int getColumnIndex(String identifier)
Returns the index of a column for a given identifier.

Parameters:
identifier -
Returns:
index the index of the column

getColumnClass

public Class<Double> getColumnClass(int columnIndex)
Specified by:
getColumnClass in interface TableModel
Overrides:
getColumnClass in class AbstractTableModel

getColumnCount

public int getColumnCount()
Specified by:
getColumnCount in interface TableModel

getColumnIdentifier

public String getColumnIdentifier(int column)
Parameters:
column -
Returns:
columnIdentifier the identifier of the column at the given position

getColumnName

public String getColumnName(int column)
Specified by:
getColumnName in interface TableModel
Overrides:
getColumnName in class AbstractTableModel

getName

public String getName()
Gives this MultiTable's name.

Returns:
name the name of the table

getNumBlocks

public int getNumBlocks()
Returns:
blockCount

getRowCount

public int getRowCount()
Specified by:
getRowCount in interface TableModel

getTimeName

public String getTimeName()
The column identifier for the first column, i.e., the time column.

Returns:
the timeName

getTimePoint

public double getTimePoint(int rowIndex)
Returns the time value at the given index position.

Parameters:
rowIndex - The index of the time value of interest.
Returns:
A double number representing the time at the given index.

getTimePoints

public double[] getTimePoints()
Returns:
timePoints

getValueAt

public Double getValueAt(int rowIndex,
                         int columnIndex)
Specified by:
getValueAt in interface TableModel

isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)
Specified by:
isCellEditable in interface TableModel
Overrides:
isCellEditable in class AbstractTableModel

isSetTimePoints

public boolean isSetTimePoints()
Checks whether an array of time points has been set for this object.

Returns:
timePointsSet

iterator

public Iterator<Iterable<Double>> iterator()
Specified by:
iterator in interface Iterable<Iterable<Double>>

removeBlock

public void removeBlock(int index)
Removes the MultiTable.Block with the given index from this data structure.

Parameters:
index - The index of the block. Do not confuse with the index of the column.

setName

public void setName(String name)
Sets the name of this MultiTable.

Parameters:
name -

setTimeName

public void setTimeName(String timeName)
Set the name of the time column

Parameters:
timeName - the timeName to set

setTimePoints

public void setTimePoints(double[] timePoints)
Parameters:
timePoints - the timePoints to set

setValueAt

public void setValueAt(Object aValue,
                       int rowIndex,
                       int columnIndex)
Specified by:
setValueAt in interface TableModel
Overrides:
setValueAt in class AbstractTableModel

toString

public String toString()
Overrides:
toString in class Object

Generated December 13 2012