Class ToggleNullConfigKey<T>
java.lang.Object
uk.ac.starlink.ttools.plot2.config.ConfigKey<T>
uk.ac.starlink.ttools.plot2.config.ToggleNullConfigKey<T>
Wraps a supplied ConfigKey to provide one that will also allow
selection of the null value.
In the GUI, this is represented with a toggle button
that when selected indicates null, and when not defers to the
usual specifier GUI.
This is intended for use with config keys that do not normally accept null values. If used with config keys that do permit null values, confusion may result.
- Since:
- 29 Jun 2016
- Author:
- Mark Taylor
-
Constructor Summary
ConstructorsConstructorDescriptionToggleNullConfigKey
(ConfigKey<T> baseKey, String toggleLabel, boolean toggleDflt) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionConstructs a graphical control with which the user can specify a suitable value for association with this key.stringToValue
(String txt) Decodes a string value to the value type of this key.valueToString
(T value) Reports a value as a string.Methods inherited from class uk.ac.starlink.ttools.plot2.config.ConfigKey
cast, getDefaultValue, getMeta, getValueClass, toString
-
Constructor Details
-
ToggleNullConfigKey
Constructor.- Parameters:
baseKey
- config key providing non-null-valued behaviourtoggleLabel
- GUI label for the toggle button selecting nulltoggleDflt
- true if the default is null, false if the default is that of the base key
-
-
Method Details
-
valueToString
Description copied from class:ConfigKey
Reports a value as a string. If at all possible the roundtripping should be possible, sostringToValue(valueToString(v)).equals(v)
. A null value, if permitted, should be represented as an empty string.- Specified by:
valueToString
in classConfigKey<T>
- Parameters:
value
- possible value associated with this key- Returns:
- string representation
-
stringToValue
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 classConfigKey<T>
- Parameters:
txt
- string representation of value- Returns:
- value
- Throws:
ConfigException
-
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 classConfigKey<T>
- Returns:
- new specifier
-