Class StarTableModel

java.lang.Object
javax.swing.table.AbstractTableModel
uk.ac.starlink.table.gui.StarTableModel
All Implemented Interfaces:
Serializable, TableModel

public class StarTableModel extends AbstractTableModel
Adapts a StarTable into a TableModel. The base StarTable must provide random access (its isRandom method must return true); to make a StarTableModel if your StarTable is not random you will have to make a random one using for instance Tables.randomTable(uk.ac.starlink.table.StarTable).

One extra bit of functionality is enabled, namely that an extra column containing row indices may be provided.

As well as providing the data model for a JTable, this class can be used as a general wrapper for StarTable objects when the event handling mechanism it supplies is required.

Author:
Mark Taylor (Starlink)
See Also:
  • Field Details

  • Constructor Details

    • StarTableModel

      public StarTableModel(StarTable startable)
      Constructs a StarTableModel from a StarTable, without row index column. The supplied StarTable must provide random access.
      Parameters:
      startable - the StarTable object
      Throws:
      IllegalArgumentException - if startable.isRandom returns false
      See Also:
    • StarTableModel

      public StarTableModel(StarTable startable, boolean rowHeader)
      Constructs a StarTableModel from a StarTable, optionally with a row index column. The supplied StarTable must provide random access.
      Parameters:
      startable - the StarTable object
      rowHeader - whether to add an extra column at the start containing the row index
      Throws:
      IllegalArgumentException - if startable.isRandom returns false
      See Also:
  • Method Details

    • hasRowHeader

      public boolean hasRowHeader()
      Indicates whether the first column in this table is an artificial one containing just the index of the row.
      Returns:
      true iff column 0 is a row index
    • getStarTable

      public StarTable getStarTable()
      Gets the StarTable underlying this model.
      Returns:
      the StarTable object
    • getRowCount

      public int getRowCount()
    • getColumnCount

      public int getColumnCount()
    • getValueAt

      public Object getValueAt(int irow, int icol)
    • getColumnName

      public String getColumnName(int icol)
      Specified by:
      getColumnName in interface TableModel
      Overrides:
      getColumnName in class AbstractTableModel
    • getColumnClass

      public Class<?> getColumnClass(int icol)
      Specified by:
      getColumnClass in interface TableModel
      Overrides:
      getColumnClass in class AbstractTableModel