Class CombinationConfigKey

java.lang.Object
uk.ac.starlink.ttools.plot2.config.ConfigKey<boolean[]>
uk.ac.starlink.ttools.plot2.config.CombinationConfigKey

public class CombinationConfigKey extends ConfigKey<boolean[]>
Config key that can select zero or more items from a short fixed list. The string representation is an unordered list of the first letters (lowercased) of each of the given option labels. So the labels had better have different initial letters.

Typically this is used for axes.

Since:
5 Oct 2013
Author:
Mark Taylor
  • Constructor Details

    • CombinationConfigKey

      public CombinationConfigKey(ConfigMeta meta, boolean[] dflt, String[] optNames, String nullLabel)
      Constructs an instance with a specified default.
      Parameters:
      meta - metadata
      dflt - default array of selection flags
      optNames - labels for each of the options that may be selected, same length as dflt
      nullLabel - label for a specifer option indicating the null value; null is a permitted value only if this parameter is non-null
    • CombinationConfigKey

      public CombinationConfigKey(ConfigMeta meta, String[] optNames)
      Constructs an instance where all the default inclusion flags are true and a null value is not permitted.
      Parameters:
      meta - metadata
      optNames - labels for each of the options that may be selected,
  • Method Details

    • stringToValue

      public boolean[] stringToValue(String txt) throws ConfigException
      Description copied from class: ConfigKey
      Decodes a string value to the value type of this key. An empty string should be interpreted as a null value, but this may cause an exception if null is not a permissible value for this key.
      Specified by:
      stringToValue in class ConfigKey<boolean[]>
      Parameters:
      txt - string representation of value
      Returns:
      value
      Throws:
      ConfigException
    • valueToString

      public String valueToString(boolean[] opts)
      Description copied from class: ConfigKey
      Reports a value as a string. If at all possible the roundtripping should be possible, so stringToValue(valueToString(v)).equals(v). A null value, if permitted, should be represented as an empty string.
      Specified by:
      valueToString in class ConfigKey<boolean[]>
      Parameters:
      opts - possible value associated with this key
      Returns:
      string representation
    • createSpecifier

      public Specifier<boolean[]> createSpecifier()
      Description copied from class: ConfigKey
      Constructs a graphical control with which the user can specify a suitable value for association with this key.
      Specified by:
      createSpecifier in class ConfigKey<boolean[]>
      Returns:
      new specifier
    • optCharToIndex

      public int optCharToIndex(char c) throws ConfigException
      Gets the option index from an initial character.
      Parameters:
      c - label character, case unimportant
      Returns:
      option index
      Throws:
      ConfigException - if no index is indicated (unknown letter)
    • optIndexToChar

      public char optIndexToChar(int io)
      Gets the initial letter from the option index.
      Parameters:
      io - option index
      Returns:
      lowercased initial letter