org.problets.domain.model.variable.aggregate
Class ArrayTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by org.problets.domain.model.variable.aggregate.ArrayTableModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel

public class ArrayTableModel
extends javax.swing.table.AbstractTableModel

Class: ArrayTableModel Purpose: The TableModel for class ArrayView's JTable component. It acts as an intermediate class between ArrayView's ArrayModel and JTable.

See Also:
Serialized Form

Constructor Summary
ArrayTableModel(ArrayModel inModel, boolean isEditable)
          Creates the table model
 
Method Summary
 java.lang.Class getColumnClass(int col)
          gets the class of a given column for the table.
 int getColumnCount()
          gets the number of columns in the table that this table model works for.
 java.lang.String getColumnName(int col)
          returns the name of a column in the table
 java.lang.String getNameAt(int row, int col)
          Returns the name of a variable in the ArrayModel reference
 int getRowCount()
          gets the number of rows in the table that this table model works for.
 java.lang.Object getValueAt(int row, int col)
          Gets the value for a certain cell in the table this class works for from the corresponding element in the ArrayModel reference.
 AbstractVarModel getVariableAt(int row, int col)
          Returns a variable from this class's ArrayModel reference at the given row and column.
 boolean isCellEditable(int row, int col)
          Returns true if the cell at the row and column specified is editable
static void main(java.lang.String[] args)
          For debugging
 void setValueAt(java.lang.Object inValue, int row, int col)
          Used by a table to assign a new value to one of its cell's variables at the given row and column.
 
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
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayTableModel

public ArrayTableModel(ArrayModel inModel,
                       boolean isEditable)
Creates the table model

Parameters:
inModel - The array that this TableModel gets it's values from
isEditable - true if the table that this table model works with is editable
Method Detail

getColumnName

public java.lang.String getColumnName(int col)
returns the name of a column in the table

Specified by:
getColumnName in interface javax.swing.table.TableModel
Overrides:
getColumnName in class javax.swing.table.AbstractTableModel
Parameters:
col - the column in the table to get the name for
Returns:
the name of the column

getColumnCount

public int getColumnCount()
gets the number of columns in the table that this table model works for. It accomplishes this by returning the number of columns in the ArrayModel reference of this ArrayTableModel.

Returns:
the number of columns in the table

getColumnClass

public java.lang.Class getColumnClass(int col)
gets the class of a given column for the table. In this case, all column classes are of type VarModel.

Specified by:
getColumnClass in interface javax.swing.table.TableModel
Overrides:
getColumnClass in class javax.swing.table.AbstractTableModel
Parameters:
col - the index of the column to get the class of
Returns:
the class of the column

getRowCount

public int getRowCount()
gets the number of rows in the table that this table model works for. it does this by returning the number of rows in the table model's ArrayModel reference.

Returns:
the number of rows in the ArrayModel reference

getVariableAt

public AbstractVarModel getVariableAt(int row,
                                      int col)
Returns a variable from this class's ArrayModel reference at the given row and column.

Parameters:
row - the index of the row
col - the index of the column
Returns:
the variable at row,col

getValueAt

public java.lang.Object getValueAt(int row,
                                   int col)
Gets the value for a certain cell in the table this class works for from the corresponding element in the ArrayModel reference.

Parameters:
row - the index of the row
col - the index of the column
Returns:
the value of the array's variable

getNameAt

public java.lang.String getNameAt(int row,
                                  int col)
Returns the name of a variable in the ArrayModel reference

Parameters:
row - the index of the row
col - the index of the column
Returns:
the name of the variable at row,col

isCellEditable

public boolean isCellEditable(int row,
                              int col)
Returns true if the cell at the row and column specified is editable

Specified by:
isCellEditable in interface javax.swing.table.TableModel
Overrides:
isCellEditable in class javax.swing.table.AbstractTableModel
Parameters:
row - the index of the row
col - the index of the column
Returns:
true if the cell is editable

setValueAt

public void setValueAt(java.lang.Object inValue,
                       int row,
                       int col)
Used by a table to assign a new value to one of its cell's variables at the given row and column.

Specified by:
setValueAt in interface javax.swing.table.TableModel
Overrides:
setValueAt in class javax.swing.table.AbstractTableModel
Parameters:
inValue - the new value for the variable
row - the index of the row
col - the index of the column

main

public static void main(java.lang.String[] args)
For debugging

Parameters:
args - the arguments