org.opensourcephysics.display
Class ArrayTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by org.opensourcephysics.display.ArrayTableModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel

public class ArrayTableModel
extends javax.swing.table.AbstractTableModel

A table model for a 1D and 2D ArrayTable. Column names, column locks, and transposed property added in version 1.1.

Version:
1.1
Author:
Douglas Brown, Wolfgang Christian
See Also:
Serialized Form

Constructor Summary
ArrayTableModel(boolean[] array)
          Constructor ArrayTableModel
ArrayTableModel(boolean[][] array)
          Constructor ArrayTableModel
ArrayTableModel(double[] array)
          Constructor ArrayTableModel
ArrayTableModel(double[][] array)
          Constructor ArrayTableModel
ArrayTableModel(int[] array)
          Constructor ArrayTableModel
ArrayTableModel(int[][] array)
          Constructor ArrayTableModel
ArrayTableModel(java.lang.String[] array)
          Constructor ArrayTableModel
ArrayTableModel(java.lang.String[][] array)
          Constructor ArrayTableModel
 
Method Summary
 int getColumnCount()
          Gets the number of columns.
 java.lang.String getColumnName(int column)
          Gets the name of the specified column.
 int getRowCount()
          Gets the number of rows.
 java.lang.Object getValueAt(int row, int column)
          Gets the value at the given cell.
 boolean isCellEditable(int row, int col)
          Determines whether the given cell is editable.
 boolean isTransposed()
          Returns true of the table's row and column values are interchanged.
 void setArray(java.lang.Object arrayObj)
          Allows changing the array with minimal changes
 boolean setColumnLock(int columnIndex, boolean locked)
          Sets the column's lock flag.
 boolean setColumnLocks(boolean[] locked)
          Sets the lock flag for multiple columns.
 boolean setColumnNames(java.lang.String[] names)
          Sets columns names.
 void setEditable(boolean editable)
          Sets the editable property.
 void setFirstColIndex(int index)
          Sets the first column's index.
 void setFirstRowIndex(int index)
          Sets the first row's index.
 void setRowNumberVisible(boolean vis)
          Sets the display row number flag.
 void setTransposed(boolean transposed)
          Sets the transposed property for the array.
 void setValueAt(java.lang.Object value, int row, int col)
          Sets the value at the given cell.
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getListeners, getTableModelListeners, removeTableModelListener
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayTableModel

public ArrayTableModel(int[] array)
Constructor ArrayTableModel

Parameters:
array -

ArrayTableModel

public ArrayTableModel(int[][] array)
Constructor ArrayTableModel

Parameters:
array -

ArrayTableModel

public ArrayTableModel(double[] array)
Constructor ArrayTableModel

Parameters:
array -

ArrayTableModel

public ArrayTableModel(double[][] array)
Constructor ArrayTableModel

Parameters:
array -

ArrayTableModel

public ArrayTableModel(java.lang.String[] array)
Constructor ArrayTableModel

Parameters:
array -

ArrayTableModel

public ArrayTableModel(java.lang.String[][] array)
Constructor ArrayTableModel

Parameters:
array -

ArrayTableModel

public ArrayTableModel(boolean[] array)
Constructor ArrayTableModel

Parameters:
array -

ArrayTableModel

public ArrayTableModel(boolean[][] array)
Constructor ArrayTableModel

Parameters:
array -
Method Detail

setArray

public void setArray(java.lang.Object arrayObj)
Allows changing the array with minimal changes

Parameters:
arrayObj -

setColumnLock

public boolean setColumnLock(int columnIndex,
                             boolean locked)
Sets the column's lock flag. Returns true if the column's lock changes.

Parameters:
column - int
locked - boolean
Returns:
true if change occurred

setColumnLocks

public boolean setColumnLocks(boolean[] locked)
Sets the lock flag for multiple columns. Previously set locks are cleared.

Parameters:
locked - boolean array
Returns:
true if change occurred

setFirstRowIndex

public void setFirstRowIndex(int index)
Sets the first row's index.

Parameters:
index -

setFirstColIndex

public void setFirstColIndex(int index)
Sets the first column's index.

Parameters:
index -

setRowNumberVisible

public void setRowNumberVisible(boolean vis)
Sets the display row number flag. Table displays row number.

Parameters:
vis - true<\code> if table display row number

setTransposed

public void setTransposed(boolean transposed)
Sets the transposed property for the array. A transposed array switches its row and column values in the display.

Parameters:
transposed -

isTransposed

public boolean isTransposed()
Returns true of the table's row and column values are interchanged.

Returns:

setEditable

public void setEditable(boolean editable)
Sets the editable property.

Parameters:
editable - true allows editing of the cell values that are not locked.

getColumnCount

public int getColumnCount()
Gets the number of columns.

Returns:
the column count

setColumnNames

public boolean setColumnNames(java.lang.String[] names)
Sets columns names. Returns true if the table has changed.

Parameters:
names -
Returns:
changed

getColumnName

public java.lang.String getColumnName(int column)
Gets the name of the specified column.

Specified by:
getColumnName in interface javax.swing.table.TableModel
Overrides:
getColumnName in class javax.swing.table.AbstractTableModel
Parameters:
column - the column index
Returns:
the column name

getRowCount

public int getRowCount()
Gets the number of rows.

Returns:
the row count

getValueAt

public java.lang.Object getValueAt(int row,
                                   int column)
Gets the value at the given cell.

Parameters:
row - the row index
column - the column index
Returns:
the value

setValueAt

public void setValueAt(java.lang.Object value,
                       int row,
                       int col)
Sets the value at the given cell.

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

isCellEditable

public boolean isCellEditable(int row,
                              int col)
Determines whether the given cell is editable.

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