tenua.simulator
Interface DataTable

All Known Implementing Classes:
DataTableImpl

public interface DataTable

A two-dimensional table with x values for the rows and column names for the columns, and y values as the data in the columns (i.e. a set of data series with identical x-values). Columns are allowed to have missing data; the method getY extrapolates from the values at higher and lower x's. (@link getLowestx}, getHighestX, and getNextX only return x values for which the given column has data; they can be used to implement an iterator over actual data in a column. The interface is designed to be made thread-safe with the Swing event thread; reader methods should wait for writers and writer threads should run the actual data-modifying routines on the Swing event thread.


Method Summary
 void addColumn(java.lang.String name)
          Adds a column or erases it if it already exists
 int getColumnNumber(java.lang.String name)
          Find the column index for a given column.
 double getCount(int c)
          returns the number of data points in a column
 double getHighestX(int c)
          returns the highest x value for which a column has data
 double getLowestX(int c)
          returns the lowest x value for which a column has data
 double getNextX(int c, double x)
          returns the next x value for which a column has data
 double getNthX(int c, int n)
          returns the nth x value for which data exists in a column.
 double getY(double x, int c)
          return the y value of a given x value and column.
 void setY(double x, int c, double y)
          Set the y value of a given x-value and column.
 

Method Detail

getColumnNumber

int getColumnNumber(java.lang.String name)
Find the column index for a given column.

Parameters:
name - the column name to look for
Throws:
java.lang.IllegalArgumentException - if the column does not exist

getY

double getY(double x,
            int c)
return the y value of a given x value and column. Interpolates linearly if there is no data with that x value in that column.

Parameters:
x - the X-value
c - the column number (column -1 is the X-value)
Returns:
the y value for that row
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the row or column do not exist

getLowestX

double getLowestX(int c)
returns the lowest x value for which a column has data

Parameters:
c - the column to search
Returns:
the lowest x value. If there is no data in the column, returns Double.POSITIVE_INFINITY
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the column does not exist

getHighestX

double getHighestX(int c)
returns the highest x value for which a column has data

Parameters:
c - the column to search
Returns:
the highest x value. If there is no data in the column, returns Double.NEGATIVE_INFINITY
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the column does not exist

getNextX

double getNextX(int c,
                double x)
returns the next x value for which a column has data

Parameters:
c - the column to search
x - the previous x value
Returns:
the next x value. If there is no more data in the column, returns Double.POSITIVE_INFINITY
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the column does not exist

getNthX

double getNthX(int c,
               int n)
returns the nth x value for which data exists in a column. Indexed from zero.

Parameters:
n - which x value to return
c - the column to search
Returns:
the x value
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the column does not exist
java.lang.IllegalArgumentException - if there are less than n data points

getCount

double getCount(int c)
returns the number of data points in a column

Parameters:
c - the column to search
Returns:
the number of points with data
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the column does not exist

setY

void setY(double x,
          int c,
          double y)
Set the y value of a given x-value and column. If the x-value does not exist, it is inserted at the appropriate place in the table. Specifying column -1 inserts a blank row in the table (the y value is ignored

Parameters:
x - the x value
c - the column number
y - the new value
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the row or column do not exist

addColumn

void addColumn(java.lang.String name)
Adds a column or erases it if it already exists

Parameters:
name - the name of the new column