uk.ac.starlink.ttools.plot2.config
Class DoubleConfigKey

java.lang.Object
  extended by uk.ac.starlink.ttools.plot2.config.ConfigKey<Double>
      extended by uk.ac.starlink.ttools.plot2.config.DoubleConfigKey

public abstract class DoubleConfigKey
extends ConfigKey<Double>

Config key for double precision values. NaN and null are not distinguished.

Static methods are provided to produce config keys with a variety of GUI options for specifying values.

Since:
22 Feb 2013
Author:
Mark Taylor

Constructor Summary
protected DoubleConfigKey(ConfigMeta meta, double dflt)
          Constructor.
 
Method Summary
static DoubleConfigKey createSliderKey(ConfigMeta meta, double dflt, double lo, double hi, boolean log)
          Returns a key with a linear or logarithmic slider for a specifier.
static DoubleConfigKey createTextKey(ConfigMeta meta)
          Constructs a key with a text field specifier and default NaN.
static DoubleConfigKey createTextKey(ConfigMeta meta, double dflt)
          Constructs a key with a text field specifier and an explicit default.
static DoubleConfigKey createToggleKey(ConfigMeta meta, double fval, double tval)
          Returns a key with a specifier that only provides a toggle between two values.
 Double stringToValue(String txt)
          Decodes a string value to the value type of this key.
 String valueToString(Double value)
          Reports a value as a string.
 
Methods inherited from class uk.ac.starlink.ttools.plot2.config.ConfigKey
cast, createSpecifier, getDefaultValue, getMeta, getValueClass, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DoubleConfigKey

protected DoubleConfigKey(ConfigMeta meta,
                          double dflt)
Constructor.

Parameters:
meta - metadata
dflt - default value
Method Detail

valueToString

public String valueToString(Double value)
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<Double>
Parameters:
value - possible value associated with this key
Returns:
string representation

stringToValue

public Double 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<Double>
Parameters:
txt - string representation of value
Returns:
value
Throws:
ConfigException

createTextKey

public static DoubleConfigKey createTextKey(ConfigMeta meta)
Constructs a key with a text field specifier and default NaN.

Parameters:
meta - metadata
Returns:
key

createTextKey

public static DoubleConfigKey createTextKey(ConfigMeta meta,
                                            double dflt)
Constructs a key with a text field specifier and an explicit default.

Parameters:
meta - metadata
dflt - default value
Returns:
key

createToggleKey

public static DoubleConfigKey createToggleKey(ConfigMeta meta,
                                              double fval,
                                              double tval)
Returns a key with a specifier that only provides a toggle between two values.

Parameters:
meta - metadata
fval - value for toggle false (default)
tval - value for toggle true
Returns:
key

createSliderKey

public static DoubleConfigKey createSliderKey(ConfigMeta meta,
                                              double dflt,
                                              double lo,
                                              double hi,
                                              boolean log)
Returns a key with a linear or logarithmic slider for a specifier. Note the lower and upper bounds configure only the slider range, they do not enforce a range when the value is set from a string value.

Parameters:
meta - metadata
dflt - default value
lo - slider lower bound
hi - slider upper bound
log - true for logarithmic slider scale, false for linear
Returns:
key


Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.