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 TypeMethodDescriptionintGets the number of columns.getColumnName(int column) Gets the name of the specified column.intGets the number of rows.getValueAt(int row, int column) Gets the value at the given cell.booleanisCellEditable(int row, int col) Determines whether the given cell is editable.booleanReturns true of the table's row and column values are interchanged.voidAllows changing the array with minimal changesbooleansetColumnLock(int columnIndex, boolean locked) Sets the column's lock flag.booleansetColumnLocks(boolean[] locked) Sets the lock flag for multiple columns.booleansetColumnNames(String[] names) Sets columns names.voidsetEditable(boolean editable) Sets the editable property.voidsetFirstColIndex(int index) Sets the first column's index.voidsetFirstRowIndex(int index) Sets the first row's index.voidsetRowNumberVisible(boolean vis) Sets the display row number flag.voidsetTransposed(boolean transposed) Sets the transposed property for the array.voidsetValueAt(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:
getColumnNamein interfaceTableModel- Overrides:
getColumnNamein 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:
setValueAtin interfaceTableModel- Overrides:
setValueAtin 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:
isCellEditablein interfaceTableModel- Overrides:
isCellEditablein classAbstractTableModel- Parameters:
row- the row indexcol- the column index- Returns:
- true if editable
-