Class ArrayTableModel

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

public class ArrayTableModel extends 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:
  • 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

      public ArrayTableModel(String[] array)
      Constructor ArrayTableModel
      Parameters:
      array -
    • ArrayTableModel

      public ArrayTableModel(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 Details

    • setArray

      public void setArray(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(String[] names)
      Sets columns names. Returns true if the table has changed.
      Parameters:
      names -
      Returns:
      changed
    • getColumnName

      public String getColumnName(int column)
      Gets the name of the specified column.
      Specified by:
      getColumnName in interface TableModel
      Overrides:
      getColumnName in class 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 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(Object value, int row, int col)
      Sets the value at the given cell.
      Specified by:
      setValueAt in interface TableModel
      Overrides:
      setValueAt in class 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 TableModel
      Overrides:
      isCellEditable in class AbstractTableModel
      Parameters:
      row - the row index
      col - the column index
      Returns:
      true if editable