corina.editor
Class DecadalModel

java.lang.Object
  |
  +--javax.swing.table.AbstractTableModel
        |
        +--corina.editor.DecadalModel
All Implemented Interfaces:
Serializable, TableModel
Direct Known Subclasses:
WJTableModel

public class DecadalModel
extends AbstractTableModel

See Also:
Serialized Form

Field Summary
protected  int row_max
          The last row of the dataset.
protected  int row_min
          The first row of the dataset.
protected  Sample s
          The sample whose data is being displayed.
protected static Integer ZERO
           
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
DecadalModel()
          Default constructor.
DecadalModel(Sample s)
          Constructor, given a Sample.
 
Method Summary
protected  void countRows()
           
 Class getColumnClass(int col)
          Return the Class of the specified column.
 int getColumnCount()
          Return the column count.
 String getColumnName(int col)
          Return the column name.
protected  Integer getMean(int row)
           
 int getRowCount()
          Return the row count.
 Sample getSample()
           
 Object getValueAt(int row, int col)
           
 Year getYear(int row, int col)
          Return the Year that a (row,col) cell should display.
 boolean isCellEditable(int row, int col)
           
 void setValueAt(Object value, int row, int col)
           
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

s

protected Sample s
The sample whose data is being displayed.

row_min

protected int row_min
The first row of the dataset. Default is 0.
See Also:
row_max, Year.row()

row_max

protected int row_max
The last row of the dataset. Default is -1, so if row_min and row_max are never set, no rows are displayed.
See Also:
row_min, Year.row()

ZERO

protected static final Integer ZERO
Constructor Detail

DecadalModel

public DecadalModel()
Default constructor. Not used, but required for subclassing.

DecadalModel

public DecadalModel(Sample s)
Constructor, given a Sample.
Parameters:
s - the Sample whose data is being viewed
Method Detail

getSample

public Sample getSample()

getColumnName

public String getColumnName(int col)
Return the column name. The first column is "Year", the last column is "Nr" (number), and the 10 columns in between are 0 through 9.
Overrides:
getColumnName in class AbstractTableModel
Parameters:
col - the JTable column number to query
Returns:
the column's name

countRows

protected void countRows()

getRowCount

public int getRowCount()
Return the row count. For the Data tab of a Sample (i.e., not Weiserjahre), it adds an extra row if the last datum is a -9 year, thus ensuring that there's always one blank after the end for user editing.
Overrides:
getRowCount in class AbstractTableModel
Returns:
the number of displayable rows

getColumnCount

public int getColumnCount()
Return the column count. This is always 12: the decade, 10 columns of data, and the histogram cell
Overrides:
getColumnCount in class AbstractTableModel
Returns:
the number of columns, 12

getYear

public Year getYear(int row,
                    int col)
Return the Year that a (row,col) cell should display. This method creates a new object, and is called far, far too often. For opening one raw sample, it creates 526 Year objects, and about as many each time the window is uncovered (and there are only about 200 years of data visible!). This can't be good for performance. Make sure each call to this is really needed, or make them not require object creation each time. (Candidates for this: 2 calls in getValueAt().)
Parameters:
row - the row in question
col - the column in question
Returns:
the Year that the (row,col) cell should display

getMean

protected final Integer getMean(int row)

getValueAt

public Object getValueAt(int row,
                         int col)
Overrides:
getValueAt in class AbstractTableModel

getColumnClass

public Class getColumnClass(int col)
Return the Class of the specified column. This is Integer.class for the displayed data, else String.class
Overrides:
getColumnClass in class AbstractTableModel
Parameters:
col - the column to query
Returns:
the column's class

isCellEditable

public boolean isCellEditable(int row,
                              int col)
Overrides:
isCellEditable in class AbstractTableModel

setValueAt

public void setValueAt(Object value,
                       int row,
                       int col)
Overrides:
setValueAt in class AbstractTableModel