Class ConfigSpecifier

  • All Implemented Interfaces:
    uk.ac.starlink.ttools.plot2.config.Specifier<uk.ac.starlink.ttools.plot2.config.ConfigMap>
    Direct Known Subclasses:
    AutoConfigSpecifier, OptionalConfigSpecifier

    public class ConfigSpecifier
    extends uk.ac.starlink.ttools.plot2.config.SpecifierPanel<uk.ac.starlink.ttools.plot2.config.ConfigMap>
    Specifier which supplies a ConfigMap. This just aggregates specifiers for a given set of ConfigKeys; the GUI component contains a specifier component for each key, and the specified value is a map containing the values for each key.

    By default the GUI component is just a stack of the constituent specifier components, but these can be decorated by supplying a suitable ConfigSpecifier.ComponentGui object.

    The checkConfig method provides a hook for additional conditions that will be applied to the ConfigMap output values from this specifier.

    Since:
    12 Mar 2013
    Author:
    Mark Taylor
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  ConfigSpecifier.ComponentGui
      GUI component policy.
    • Constructor Summary

      Constructors 
      Constructor Description
      ConfigSpecifier​(uk.ac.starlink.ttools.plot2.config.ConfigKey<?>[] keys)
      Constructs a config specifier with a default GUI.
      ConfigSpecifier​(uk.ac.starlink.ttools.plot2.config.ConfigKey<?>[] keys, ConfigSpecifier.ComponentGui gui)
      Constructs a config specifier with a custom GUI for constituent keys.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void checkConfig​(uk.ac.starlink.ttools.plot2.config.ConfigMap config)
      Performs additional checks on the result produced by this specifier prior to returning the value from getSpecifiedValue().
      static void checkRangeSense​(uk.ac.starlink.ttools.plot2.config.ConfigMap config, java.lang.String axName, uk.ac.starlink.ttools.plot2.config.ConfigKey<java.lang.Double> minKey, uk.ac.starlink.ttools.plot2.config.ConfigKey<java.lang.Double> maxKey)
      Utility method to check that min/max keys specifying a range are not the wrong way round.
      protected javax.swing.JComponent createComponent()  
      uk.ac.starlink.ttools.plot2.config.ConfigKey<?>[] getConfigKeys()
      Returns the keys for which this specifier gathers values.
      uk.ac.starlink.ttools.plot2.config.ConfigMap getSpecifiedValue()  
      <T> uk.ac.starlink.ttools.plot2.config.Specifier<T> getSpecifier​(uk.ac.starlink.ttools.plot2.config.ConfigKey<T> key)
      Returns the individual specifier used to gather values for a particular key owned by this object.
      void reportError​(uk.ac.starlink.ttools.plot2.config.ConfigException err)
      May be used by a client of this specifier to report an error associated with one of the config values obtained by this specifier.
      void setSpecifiedValue​(uk.ac.starlink.ttools.plot2.config.ConfigMap configMap)  
      void submitReport​(uk.ac.starlink.ttools.plot2.ReportMap report)  
      • Methods inherited from class uk.ac.starlink.ttools.plot2.config.SpecifierPanel

        addActionListener, fireAction, getActionForwarder, getChangeForwarder, getComponent, isXFill, removeActionListener
      • Methods inherited from class java.lang.Object

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

      • ConfigSpecifier

        public ConfigSpecifier​(uk.ac.starlink.ttools.plot2.config.ConfigKey<?>[] keys)
        Constructs a config specifier with a default GUI.
        Parameters:
        keys - config keys to gather values for
      • ConfigSpecifier

        public ConfigSpecifier​(uk.ac.starlink.ttools.plot2.config.ConfigKey<?>[] keys,
                               ConfigSpecifier.ComponentGui gui)
        Constructs a config specifier with a custom GUI for constituent keys.
        Parameters:
        keys - config keys to gather values for
        gui - specifier generation factory that can provide customised specifiers for different keys
    • Method Detail

      • createComponent

        protected javax.swing.JComponent createComponent()
        Specified by:
        createComponent in class uk.ac.starlink.ttools.plot2.config.SpecifierPanel<uk.ac.starlink.ttools.plot2.config.ConfigMap>
      • getSpecifiedValue

        public uk.ac.starlink.ttools.plot2.config.ConfigMap getSpecifiedValue()
      • checkConfig

        protected void checkConfig​(uk.ac.starlink.ttools.plot2.config.ConfigMap config)
                            throws uk.ac.starlink.ttools.plot2.config.ConfigException
        Performs additional checks on the result produced by this specifier prior to returning the value from getSpecifiedValue(). If something is wrong with the supplied config, implementations may throw a ConfigException here to indicate the problem. Per-key specifiers ought in general to police the values that they return, but this method provides a hook for checks applying to disallowed interactions between individually legal values.

        The default implementation does nothing.

        Parameters:
        config - config map to check
        Throws:
        uk.ac.starlink.ttools.plot2.config.ConfigException - if there's something wrong with the supplied map
        See Also:
        checkRangeSense
      • setSpecifiedValue

        public void setSpecifiedValue​(uk.ac.starlink.ttools.plot2.config.ConfigMap configMap)
      • submitReport

        public void submitReport​(uk.ac.starlink.ttools.plot2.ReportMap report)
      • getConfigKeys

        public uk.ac.starlink.ttools.plot2.config.ConfigKey<?>[] getConfigKeys()
        Returns the keys for which this specifier gathers values.
        Returns:
        config keys
      • getSpecifier

        public <T> uk.ac.starlink.ttools.plot2.config.Specifier<T> getSpecifier​(uk.ac.starlink.ttools.plot2.config.ConfigKey<T> key)
        Returns the individual specifier used to gather values for a particular key owned by this object.
        Parameters:
        key - config key
        Returns:
        specifier for key
      • reportError

        public void reportError​(uk.ac.starlink.ttools.plot2.config.ConfigException err)
        May be used by a client of this specifier to report an error associated with one of the config values obtained by this specifier. The error will be presented to the user somehow or other, and the state of the component will be altered so that the same error doesn't keep happening, at least not without further user activity.
        Parameters:
        err - error encountered in using a value supplied by this specifier
      • checkRangeSense

        public static void checkRangeSense​(uk.ac.starlink.ttools.plot2.config.ConfigMap config,
                                           java.lang.String axName,
                                           uk.ac.starlink.ttools.plot2.config.ConfigKey<java.lang.Double> minKey,
                                           uk.ac.starlink.ttools.plot2.config.ConfigKey<java.lang.Double> maxKey)
                                    throws uk.ac.starlink.ttools.plot2.config.ConfigException
        Utility method to check that min/max keys specifying a range are not the wrong way round. Note that indefinite values at either end are OK.
        Parameters:
        config - config map
        axName - axis name, used for error messages
        minKey - config key for minimum value
        maxKey - config key for maximum value
        Throws:
        uk.ac.starlink.ttools.plot2.config.ConfigException - if the min value is definitely greater than or equal to the max value