Class ExtraColumn

java.lang.Object
org.ka2ddo.yaac.pluginapi.ExtraColumn

public abstract class ExtraColumn extends Object
This class defines (in a non-GUI-dependent way) an extra column of data for inclusion in the station/object list table view. This is specific to a particular GuiContentType as returned by ExtraColumnProvider so it can expect a particular class of rowData to be provided to the getValueAt(int, SupportsExtraData) method.
Author:
Andrew Pavlin, KA2DDO
  • Constructor Details

    • ExtraColumn

      protected ExtraColumn(GuiContentType guiContentType, int extraColumnIndex, ExtraColumnProvider extraColumnProvider)
      Create an ExtraColumn.
      Parameters:
      guiContentType - the GuiContentType this ExtraColumn is associated with
      extraColumnIndex - zero-based relative column index from the provider
      extraColumnProvider - ExtraColumnProvider providing this column
  • Method Details

    • getGuiContentType

      public GuiContentType getGuiContentType()
      Get the GUI content type this column is associated with.
      Returns:
      GuiContentType
    • getExtraColumnIndex

      public int getExtraColumnIndex()
      Get the provider-relative index of this extra column.
      Returns:
      zero-based index of this column from the provider
    • setExtraColumnIndex

      public void setExtraColumnIndex(int columnIndex)
      Modify the column index for the ExtraColumn. Note this should only be done if the columns are beuing reordered or the column numberwas not known at construction time.
      Parameters:
      columnIndex - zero-based ordinal of this column from its ExtraColumnProvider
    • getExtraColumnProvider

      public ExtraColumnProvider getExtraColumnProvider()
      Get the ExtraColumnProvider that defines this column.
      Returns:
      ExtraColumnProvider
    • getColumnClass

      public Class<?> getColumnClass()
      Returns the most specific superclass for all the cell values in the column. This is used by the table to set up a default renderer and editor for the column. Expected to be overridden by subclasses.
      Returns:
      the common ancestor class of the object values in the model of this column.
    • getColumnName

      public abstract String getColumnName()
      Returns the localized name of this column. This is used to initialize the table's column header name. Note: this name does not need to be unique; two columns in a table can have the same name.
      Returns:
      the name of the column
    • getValueAt

      public abstract Object getValueAt(int rowIndex, SupportsExtraData rowData)
      Returns the value for the cell at this column and rowIndex.
      Parameters:
      rowIndex - the row whose value is to be queried
      rowData - Object from the original table containing data represented by the entire row; the Object type is specific to the GuiContentType of the table
      Returns:
      the value Object at the specified cell
    • isCellEditable

      public boolean isCellEditable(int rowIndex, SupportsExtraData rowData)
      Returns true if the cell at rowIndex and this column is editable. Otherwise, setValueAt on the cell will not change the value of that cell. Expected to be overridden by editable subclasses.
      Parameters:
      rowIndex - the row whose value to be queried
      rowData - Object from the original table containing data represented by the entire row; the Object type is specific to the GuiContentType of the table
      Returns:
      true if the cell is editable
      See Also:
    • setValueAt

      public void setValueAt(Object aValue, int rowIndex, SupportsExtraData rowData)
      Sets the value in the cell at this column and rowIndex to aValue. Expected to be overridden by editable subclasses.
      Parameters:
      aValue - the new value
      rowIndex - the row whose value is to be changed
      rowData - Object from the original table containing data represented by the entire row; the Object type is specific to the GuiContentType of the table
      See Also:
    • compareRows

      public int compareRows(int rowIndex1, SupportsExtraData rowData1, int rowIndex2, SupportsExtraData rowData2)
      Compare this column of the two rows. Should be overridden in case the specified table model implements FastComparableTableModel.
      Parameters:
      rowIndex1 - zero-based model row index of first row to compare
      rowData1 - Object from the original table containing data represented by the entire first row; the Object type is specific to the GuiContentType of the table
      rowIndex2 - zero-based model row index of second row to compare
      rowData2 - Object from the original table containing data represented by the entire second row; the Object type is specific to the GuiContentType of the table
      Returns:
      +1 if the 1st row's column is after the 2nd row's column, -1 if before, or 0 if equal precedence
    • usesUnitEnum

      public boolean usesUnitEnum(Class<Enum<? extends UnitEnum>> clazz)
      Report if this column uses the specified enum class to scale its values. Expected to be overridden by subclasses.
      Parameters:
      clazz - Class of a UnitEnum
      Returns:
      boolean true if the value of this enum is used by this column
    • getContentForPopupWindow

      public ExtraContentElement[] getContentForPopupWindow(SupportsExtraData rowData)
      Get the text (if any) to be displayed on a popup for the data record being displayed in the popup. This is the same info that should be returned by the getColumnName() and the rendering of getValueAt() for the specified data object
      Parameters:
      rowData - Object to provide the data to render (same as would be passed to getValueAt(int, SupportsExtraData)
      Returns:
      array of ExtraContentElements to display on the popup, or null if nothing to display for this column of this data record