Package org.opensourcephysics.display
Class ArrayTableModel
java.lang.Object
javax.swing.table.AbstractTableModel
org.opensourcephysics.display.ArrayTableModel
- All Implemented Interfaces:
Serializable
,TableModel
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:
-
Field Summary
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
-
Constructor Summary
ConstructorsConstructorDescriptionArrayTableModel
(boolean[] array) Constructor ArrayTableModelArrayTableModel
(boolean[][] array) Constructor ArrayTableModelArrayTableModel
(double[] array) Constructor ArrayTableModelArrayTableModel
(double[][] array) Constructor ArrayTableModelArrayTableModel
(int[] array) Constructor ArrayTableModelArrayTableModel
(int[][] array) Constructor ArrayTableModelArrayTableModel
(String[] array) Constructor ArrayTableModelArrayTableModel
(String[][] array) Constructor ArrayTableModel -
Method Summary
Modifier and TypeMethodDescriptionint
Gets the number of columns.getColumnName
(int column) Gets the name of the specified column.int
Gets the number of rows.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
Returns true of the table's row and column values are interchanged.void
Allows changing the array with minimal changesboolean
setColumnLock
(int columnIndex, boolean locked) Sets the column's lock flag.boolean
setColumnLocks
(boolean[] locked) Sets the lock flag for multiple columns.boolean
setColumnNames
(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
(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
-
Constructor Details
-
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
Constructor ArrayTableModel- Parameters:
array
-
-
ArrayTableModel
Constructor ArrayTableModel- Parameters:
array
-
-
ArrayTableModel
public ArrayTableModel(boolean[] array) Constructor ArrayTableModel- Parameters:
array
-
-
ArrayTableModel
public ArrayTableModel(boolean[][] array) Constructor ArrayTableModel- Parameters:
array
-
-
-
Method Details
-
setArray
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
- intlocked
- 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
Sets columns names. Returns true if the table has changed.- Parameters:
names
-- Returns:
- changed
-
getColumnName
Gets the name of the specified column.- Specified by:
getColumnName
in interfaceTableModel
- Overrides:
getColumnName
in classAbstractTableModel
- Parameters:
column
- the column index- Returns:
- the column name
-
getRowCount
public int getRowCount()Gets the number of rows.- Returns:
- the row count
-
getValueAt
Gets the value at the given cell.- Parameters:
row
- the row indexcolumn
- the column index- Returns:
- the value
-
setValueAt
Sets the value at the given cell.- Specified by:
setValueAt
in interfaceTableModel
- Overrides:
setValueAt
in classAbstractTableModel
- Parameters:
value
- the valuerow
- the row indexcol
- the column index
-
isCellEditable
public boolean isCellEditable(int row, int col) Determines whether the given cell is editable.- Specified by:
isCellEditable
in interfaceTableModel
- Overrides:
isCellEditable
in classAbstractTableModel
- Parameters:
row
- the row indexcol
- the column index- Returns:
- true if editable
-