stella.jview
Class ParameterTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by stella.jview.ParameterTableModel
All Implemented Interfaces:
Serializable, TableModel, Initializable

public class ParameterTableModel
extends AbstractTableModel
implements Initializable

A class that represents a table model for parameters. Each entry in the table is a parameter, thus its values may change. User edits are not allowed. Value changes are only intended by changing parameter values. As parameter do not notify if their value changes, a timer task is scheduled to update the parameters. Displayed are the formatted strings, if the parameter is a value, we justify to the right, triggers are displayed as check boxes. All other parameters are using left-justified labels, as is appropriate for text.
Each row has an TargetDefinition assigned to it, the number of available (thus observable) targets determine the number of rows. The column headers are the names of the parameters. Note that the jtable associated with this table model must override the getCellRenderer method

See Also:
Serialized Form

Field Summary
private  List columns
          The list of parameters.
private  Object[][] data
          The displayable data, a rowxcolumns array.
private  int observable
          The number of currently observable targets.
private  Collection rows
          The targets available.
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
ParameterTableModel(Collection targets, List parameters)
          Constructs a new table model.
 
Method Summary
 Class getColumnClass(int col)
          Returns the class object of the given column.
 int getColumnCount()
          Returns the number of columns or the number of parameters.
 String getColumnName(int col)
          Returns the name of the parameter constituing the given row.
 int getRowCount()
          Returns the number of currently available targets.
 Object getValueAt(int row, int col)
          Returns the value to display on the given row number.
 void init()
          Init simply assigns the data array.
 void setObservable(int valid)
          Sets the refresh interval.
 void setValueAt(Object val, int row, int col)
          Sets the table value at the given index.
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rows

private Collection rows
The targets available. Only observables are displayed.


columns

private List columns
The list of parameters. Their name builds table columns.


data

private Object[][] data
The displayable data, a rowxcolumns array.


observable

private int observable
The number of currently observable targets. Calculated during update.

Constructor Detail

ParameterTableModel

public ParameterTableModel(Collection targets,
                           List parameters)
Constructs a new table model. Two lists are supplied, the list of all targets known and the list of the parameters to be displayed. The collection of global constraints may be null.

Method Detail

init

public void init()
Init simply assigns the data array. The number of parameters is the number of columns minus one.

Specified by:
init in interface Initializable

getColumnCount

public int getColumnCount()
Returns the number of columns or the number of parameters.

Specified by:
getColumnCount in interface TableModel

getRowCount

public int getRowCount()
Returns the number of currently available targets. Relies on the value calculated during the most recent call to setObservable(int).

Specified by:
getRowCount in interface TableModel

getColumnName

public String getColumnName(int col)
Returns the name of the parameter constituing the given row.

Specified by:
getColumnName in interface TableModel
Overrides:
getColumnName in class AbstractTableModel

getColumnClass

public Class getColumnClass(int col)
Returns the class object of the given column. We are not sur on how JTable treats this, so we make sure that the internal data model always has the right run-time assignment.

Specified by:
getColumnClass in interface TableModel
Overrides:
getColumnClass in class AbstractTableModel

getValueAt

public Object getValueAt(int row,
                         int col)
Returns the value to display on the given row number.

Specified by:
getValueAt in interface TableModel

setValueAt

public void setValueAt(Object val,
                       int row,
                       int col)
Sets the table value at the given index.

Specified by:
setValueAt in interface TableModel
Overrides:
setValueAt in class AbstractTableModel

setObservable

public void setObservable(int valid)
Sets the refresh interval. This means that any timer task already present is canceled and a new timer task is constructed and scheduled. The first update occurs after the refresh interval.