Class BasicCoordPanel

java.lang.Object
uk.ac.starlink.topcat.plot2.BasicCoordPanel
All Implemented Interfaces:
CoordPanel
Direct Known Subclasses:
AreaCoordPanel, SimplePositionCoordPanel, XYArrayCoordPanel

public class BasicCoordPanel extends Object implements CoordPanel
Basic implementation of CoordPanel.
Since:
13 Mar 2013
Author:
Mark Taylor
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    Interface for presenting a list of coordinate selection components.
  • Constructor Summary

    Constructors
    Constructor
    Description
    BasicCoordPanel(uk.ac.starlink.ttools.plot2.data.Coord[] coords)
    Constructs a CoordPanel for selecting just Coords.
    BasicCoordPanel(uk.ac.starlink.ttools.plot2.data.Coord[] coords, uk.ac.starlink.ttools.plot2.config.ConfigKey<?>[] configKeys)
    Constructs a CoordPanel for selecting Coords and Config values.
    BasicCoordPanel(uk.ac.starlink.ttools.plot2.data.Coord[] coords, uk.ac.starlink.ttools.plot2.config.ConfigKey<?>[] configKeys, BasicCoordPanel.CoordStack stack)
    Constructs a CoordPanel for selecting Coords and Config values with a custom stack.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds a listener which will be notified when the coordinate selection changes.
    void
    Adds a row of buttons to the control panel for a given array of actions.
    void
    Makes some attempt to fill in the fields with non-blank values.
    Returns a CoordStack implementation suitable for general-purpose use.
    Returns an object which will forward actions to listeners registered with this panel.
    uk.ac.starlink.ttools.plot2.data.Coord[]
    Returns a list of coordinates which do not correspond to the selectors displayed here, but which should not be acquired by other means.
    getColumnSelector(int ic, int iu)
    Returns the selector component model for a given user coordinate.
    Returns the graphical component for this object.
    uk.ac.starlink.ttools.plot2.config.ConfigMap
    Returns the config map associated with this panel.
    Returns this panel's config specifier.
    Returns the coordinate values currently selected in this panel.
    uk.ac.starlink.ttools.plot2.data.Coord[]
    Returns the coordinates which this panel is getting values for.
    static uk.ac.starlink.table.ValueInfo[]
    Returns a list of column metadata items for the items in a list model of columns.
    Returns the component listing all the coordinates.
    Returns the currently configured topcat model.
    boolean
    isPreferredCoord(uk.ac.starlink.ttools.plot2.data.Coord coord)
    Indicates whether a coordinate is one that ought to get filled in if possible.
    static uk.ac.starlink.ttools.plot2.data.Coord[]
    multiplyCoords(uk.ac.starlink.ttools.plot2.data.Coord[] coords, int ncopy)
    Returns a list of coordinates which is like multiple copies of a supplied group.
    static boolean
    populate(ColumnDataComboBoxModel model, uk.ac.starlink.table.ValueInfo info)
    Tries to find an item of a given combo box model matching a given metadata item.
    void
    Removes a listener which was added previously.
    void
    setColumnSelector(int ic, int iu, ColumnDataComboBoxModel model)
    Resets the selector component model for a given user coordinate.
    void
    setTable(TopcatModel tcModel, boolean autoPopulate)
    Sets the table with reference to which this panel will resolve coordinate descriptions.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BasicCoordPanel

      public BasicCoordPanel(uk.ac.starlink.ttools.plot2.data.Coord[] coords)
      Constructs a CoordPanel for selecting just Coords.
      Parameters:
      coords - coordinate definitions for which values are required
    • BasicCoordPanel

      public BasicCoordPanel(uk.ac.starlink.ttools.plot2.data.Coord[] coords, uk.ac.starlink.ttools.plot2.config.ConfigKey<?>[] configKeys)
      Constructs a CoordPanel for selecting Coords and Config values.
      Parameters:
      coords - coordinate definitions for which values are required
      configKeys - config value keys
    • BasicCoordPanel

      public BasicCoordPanel(uk.ac.starlink.ttools.plot2.data.Coord[] coords, uk.ac.starlink.ttools.plot2.config.ConfigKey<?>[] configKeys, BasicCoordPanel.CoordStack stack)
      Constructs a CoordPanel for selecting Coords and Config values with a custom stack. For the stack parameter createDefaultStack() may be used if there are no special requirements.
      Parameters:
      coords - coordinate definitions for which values are required
      configKeys - config value keys
      stack - coord stack implementation
  • Method Details

    • addButtons

      public void addButtons(Action[] acts)
      Adds a row of buttons to the control panel for a given array of actions.
      Parameters:
      acts - custom actions
    • getCoords

      public uk.ac.starlink.ttools.plot2.data.Coord[] getCoords()
      Returns the coordinates which this panel is getting values for.
      Specified by:
      getCoords in interface CoordPanel
      Returns:
      coords
    • getConfigSpecifier

      public ConfigSpecifier getConfigSpecifier()
      Returns this panel's config specifier.
      Specified by:
      getConfigSpecifier in interface CoordPanel
      Returns:
      specifier for config values, if there are any
    • getConfig

      public uk.ac.starlink.ttools.plot2.config.ConfigMap getConfig()
      Returns the config map associated with this panel.
      Specified by:
      getConfig in interface CoordPanel
      Returns:
      result of getConfigSpecifier().getSpecifiedValue()
    • getComponent

      public JComponent getComponent()
      Returns the graphical component for this object.
      Specified by:
      getComponent in interface CoordPanel
      Returns:
      component
    • getStack

      public BasicCoordPanel.CoordStack getStack()
      Returns the component listing all the coordinates.
      Returns:
      coordinate stack
    • addActionListener

      public void addActionListener(ActionListener listener)
      Adds a listener which will be notified when the coordinate selection changes.
      Specified by:
      addActionListener in interface CoordPanel
      Parameters:
      listener - listener
    • removeActionListener

      public void removeActionListener(ActionListener listener)
      Removes a listener which was added previously.
      Specified by:
      removeActionListener in interface CoordPanel
      Parameters:
      listener - listener
    • getActionForwarder

      public ActionForwarder getActionForwarder()
      Returns an object which will forward actions to listeners registered with this panel.
      Returns:
      action forwarder
    • setTable

      public void setTable(TopcatModel tcModel, boolean autoPopulate)
      Sets the table with reference to which this panel will resolve coordinate descriptions.

      If the existing selected coordinate values still make sense (if the new table has sufficiently compatible column names), they are retained. If the columns cannot be retained they are cleared, and in that case if the autopopulate parameter is set, some default columns will be used.

      Specified by:
      setTable in interface CoordPanel
      Parameters:
      tcModel - table from which coordinate values will be drawn
      autoPopulate - whether to autopopulate columns when old ones can't be used or are absent
    • autoPopulate

      public void autoPopulate()
      Makes some attempt to fill in the fields with non-blank values. The default implementation fills in the first few suitable columns, but subclasses are encouraged to override this behaviour if something smarter is possible.
    • getTable

      public TopcatModel getTable()
      Returns the currently configured topcat model.
      Returns:
      table from most recent call to setTable
    • getContents

      public GuiCoordContent[] getContents()
      Returns the coordinate values currently selected in this panel. If there is insufficient information to contribute to a plot (not all of the required coord values are filled in) then null will be returned.
      Specified by:
      getContents in interface CoordPanel
      Returns:
      nCoord-element array of coord contents, or null
    • getColumnSelector

      public ColumnDataComboBoxModel getColumnSelector(int ic, int iu)
      Returns the selector component model for a given user coordinate. If no columndata-specific model has been set, null may be returned.
      Specified by:
      getColumnSelector in interface CoordPanel
      Parameters:
      ic - coord index
      iu - user info index for the given coord
      Returns:
      selector model, or null
    • setColumnSelector

      public void setColumnSelector(int ic, int iu, ColumnDataComboBoxModel model)
      Resets the selector component model for a given user coordinate.
      Parameters:
      ic - coord index
      iu - user info index for the given coord
      model - new selector model
    • isPreferredCoord

      public boolean isPreferredCoord(uk.ac.starlink.ttools.plot2.data.Coord coord)
      Indicates whether a coordinate is one that ought to get filled in if possible. The CoordPanel implementation simply returns coord.Coord.isRequired(), but subclasses can override this if more nuanced behaviour is necessary.

      In particular in order for autopopulation to work correctly, it may be necessary to return true for all members of a group of coordinates for which at least one has to be filled in for a viable plot.

      Parameters:
      coord - candidate coordinate
      Returns:
      true if we should try hard to get a value
    • getAdditionalManagedCoords

      public uk.ac.starlink.ttools.plot2.data.Coord[] getAdditionalManagedCoords()
      Returns a list of coordinates which do not correspond to the selectors displayed here, but which should not be acquired by other means.

      This is a hack to work round situations when coordinates are added into results by non-obvious means. In most cases the output result will be an empty array, which is what the implementation in this class does. But subclasses can override it for special behaviour.

      Specified by:
      getAdditionalManagedCoords in interface CoordPanel
      Returns:
      list of coords which this panel will arrange to provide values for in some non-standard way
    • getInfos

      public static uk.ac.starlink.table.ValueInfo[] getInfos(ColumnDataComboBoxModel model)
      Returns a list of column metadata items for the items in a list model of columns.
      Parameters:
      model - column list model
      Returns:
      list of valueinfos
    • populate

      public static boolean populate(ColumnDataComboBoxModel model, uk.ac.starlink.table.ValueInfo info)
      Tries to find an item of a given combo box model matching a given metadata item. If it finds it, it will set the selection and return true.
      Parameters:
      model - list model
      info - template for selection value
      Returns:
      true if selection was successfully performed
    • createDefaultStack

      public static BasicCoordPanel.CoordStack createDefaultStack()
      Returns a CoordStack implementation suitable for general-purpose use.
      Returns:
      new coord stack
    • multiplyCoords

      public static uk.ac.starlink.ttools.plot2.data.Coord[] multiplyCoords(uk.ac.starlink.ttools.plot2.data.Coord[] coords, int ncopy)
      Returns a list of coordinates which is like multiple copies of a supplied group. The returned coords have metadata which distinguish them from each other, currently an integer appended to their name. The returned coords are not totally respectable, but their metadata is OK.
      Parameters:
      coords - basic coordinates
      ncopy - number of copies to make
      Returns:
      array of ncopy copies of coords