Class ColumnSelector

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable

public class ColumnSelector extends JComponent
Allows selection of a column from a table which represents a requested kind of value. The column may not actually exist in the table, but may be based on one that does, modified by a ColumnConverter.
Since:
6 Oct 2004
Author:
Mark Taylor (Starlink)
See Also:
  • Constructor Details

    • ColumnSelector

      public ColumnSelector(uk.ac.starlink.table.ValueInfo info, boolean showLabel)
      Constructs a new selector ready to select columns corresponding to a given ValueInfo. It is initialised with no data model.
      Parameters:
      info - describes the columns to be selected by this component
      showLabel - true iff you want the axis label to be displayed with the selectors
    • ColumnSelector

      public ColumnSelector(ColumnSelectorModel model, boolean showLabel)
      Constructs a new selector with a given data model.
      Parameters:
      model - data model
      showLabel - true iff you want the axis label to be displayed with the selectors
  • Method Details

    • setModel

      public void setModel(ColumnSelectorModel model)
      Sets the model for this selector. model must have the same ValueInfo as the one this component was set up with.
      Parameters:
      model - new data model
    • setTable

      public void setTable(TopcatModel tcModel)
      Convenience method which sets this selector's model to the one appropriate for its ValueInfo and the given TopcatModel.
      Parameters:
      tcModel - table model
    • getColumnData

      public uk.ac.starlink.table.ColumnData getColumnData()
      Returns the (effective) column currently selected by the user. It takes into account the column and (if any) conversion selected by the user.
      Returns:
      ColumnData representing the currently-selected column, or null if none is selected
    • setColumnData

      public void setColumnData(uk.ac.starlink.table.ColumnData colData)
      Sets the currently selected column data value. Does not have to be to one of the values in the selection model.
      Parameters:
      colData - new column data selection
    • setStringValue

      public void setStringValue(String txt)
      Sets the value of the selector progrmmatically as a string. This should be a legal JEL expression in the context of the selector's table.
      Parameters:
      txt - text value
    • getStringValue

      public String getStringValue()
      Returns the value of the selector as a string.
      Returns:
      text value
    • getModel

      public ColumnSelectorModel getModel()
      Returns the model for this selector.
      Returns:
      data model
    • getLabel

      public JLabel getLabel()
      Returns the label which annotates this selector (though it may or may not be displayed in this component according to how the constructor was called).
      Returns:
      label annotating label
    • getColumnComponent

      public JComboBox<uk.ac.starlink.table.ColumnData> getColumnComponent()
      Returns the component displaying selection of the actual column or expression.
      Returns:
      column selection component
    • getUnitComponent

      public JComboBox<ColumnConverter> getUnitComponent()
      Returns the component displaying selection of the unit, if any.
      Returns:
      converter selection component
    • addActionListener

      public void addActionListener(ActionListener listener)
      Adds a listener for changes on the state of this component.
      Parameters:
      listener - listener to add
    • removeActionListener

      public void removeActionListener(ActionListener listener)
      Removes a listener for changes on the state of this component.
      Parameters:
      listener - listener to remove
    • setEnabled

      public void setEnabled(boolean enabled)
      Overrides:
      setEnabled in class JComponent