Class ColorConfigKey
- java.lang.Object
-
- uk.ac.starlink.ttools.plot2.config.ConfigKey<T>
-
- uk.ac.starlink.ttools.plot2.config.ChoiceConfigKey<java.awt.Color>
-
- uk.ac.starlink.ttools.plot2.config.ColorConfigKey
-
public class ColorConfigKey extends ChoiceConfigKey<java.awt.Color>
ConfigKey for selecting colours. A null colour is optionally available, controlled by a toggle switch.Some of the colours come from Paul Tol's colour scheme notes; see Paul Tol's Notes page and SRON/EPS/TN/09-002. The version of the Tech Note used here is dated 29 December 2012.
- Since:
- 9 Sep 2014
- Author:
- Mark Taylor
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.Map<java.lang.String,java.awt.Color>CLASSIC_COLORSstatic java.lang.StringCOLORNAME_BLACKStandard colour name for black.static java.lang.StringCOLORNAME_GREYStandard colour name for grey.static java.lang.StringCOLORNAME_LIGHTGREYStandard colour name for light grey.static java.lang.StringCOLORNAME_REDStandard colour name for red.static java.util.Map<java.lang.String,java.awt.Color>SRON5_COLORSstatic java.util.Map<java.lang.String,java.awt.Color>SRON7_COLORSstatic java.util.Map<java.lang.String,java.awt.Color>SRONBRIGHT_COLORS
-
Constructor Summary
Constructors Constructor Description ColorConfigKey(ConfigMeta meta, java.lang.String dfltName, boolean allowHide)Constructs a config key using the default colour option list.ColorConfigKey(ConfigMeta meta, java.lang.String dfltName, boolean allowHide, java.util.Map<java.lang.String,java.awt.Color> colorOpts)Constructs a config key using a supplied colour option list.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.util.Map<java.lang.String,java.awt.Color>createClassicColors()Returns the default plotting colours used by TOPCAT, at least in early versions.static ConfigMetacreateColorMeta(java.lang.String shortName, java.lang.String longName, java.lang.String theItem)Returns a metadata object suitable for use with a ColorConfigKey.Specifier<java.awt.Color>createSpecifier()Constructs a graphical control with which the user can specify a suitable value for association with this key.static java.util.Map<java.lang.String,java.awt.Color>createSron5Colors()Returns a group of colours using the second (5-colour) row of figure 13 in SRON/EPS/TN/09-002.static java.util.Map<java.lang.String,java.awt.Color>createSron7Colors()Returns a group of colours using the fourth (7-colour) row of figure 13 in SRON/EPS/TN/09-002.static java.util.Map<java.lang.String,java.awt.Color>createSronBrightColors()Returns a group of colours based on the "Alternative Colour Scheme" on Paul Tol's page, but not in the TechNode.static java.awt.ColordecodeColorName(java.lang.String sval)Turns a string into a colour by looking at known colour names or using RRGGBB syntax.java.awt.ColordecodeString(java.lang.String sval)Takes a string, and attempts to turn it into an object which may be a value for this key.static java.awt.Color[]getPlottingColors()Returns an array of the colour options suitable for plotting normal markers.java.lang.StringstringifyValue(java.awt.Color color)Takes an object which may be a value of this key, and attempts to turn it into a string for reporting purposes.-
Methods inherited from class uk.ac.starlink.ttools.plot2.config.ChoiceConfigKey
addOption, getOptionMap, stringToValue, valueToString
-
Methods inherited from class uk.ac.starlink.ttools.plot2.config.ConfigKey
cast, getDefaultValue, getMeta, getValueClass, toString
-
-
-
-
Field Detail
-
SRON5_COLORS
public static final java.util.Map<java.lang.String,java.awt.Color> SRON5_COLORS
-
SRON7_COLORS
public static final java.util.Map<java.lang.String,java.awt.Color> SRON7_COLORS
-
SRONBRIGHT_COLORS
public static final java.util.Map<java.lang.String,java.awt.Color> SRONBRIGHT_COLORS
-
CLASSIC_COLORS
public static final java.util.Map<java.lang.String,java.awt.Color> CLASSIC_COLORS
-
COLORNAME_RED
public static final java.lang.String COLORNAME_RED
Standard colour name for red.- See Also:
- Constant Field Values
-
COLORNAME_BLACK
public static final java.lang.String COLORNAME_BLACK
Standard colour name for black.- See Also:
- Constant Field Values
-
COLORNAME_GREY
public static final java.lang.String COLORNAME_GREY
Standard colour name for grey.- See Also:
- Constant Field Values
-
COLORNAME_LIGHTGREY
public static final java.lang.String COLORNAME_LIGHTGREY
Standard colour name for light grey.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ColorConfigKey
public ColorConfigKey(ConfigMeta meta, java.lang.String dfltName, boolean allowHide)
Constructs a config key using the default colour option list.The supplied
dfltNamenames one of the colours in the default map. The static finalCOLORNAME_*members are guaranteed to be represented. If null is supplied, a sensible default (the first in the list) is used.- Parameters:
meta- metadatadfltName- name of default colour, or nullallowHide- true if hiding the colour, which results in a null value, is a legal option
-
ColorConfigKey
public ColorConfigKey(ConfigMeta meta, java.lang.String dfltName, boolean allowHide, java.util.Map<java.lang.String,java.awt.Color> colorOpts)
Constructs a config key using a supplied colour option list.- Parameters:
meta- metadatadfltName- name of default colour; should be one of the keys incolorOptsor nullallowHide- true if hiding the colour, which results in a null value, is a legal optioncolorOpts- name-> colour map
-
-
Method Detail
-
decodeString
public java.awt.Color decodeString(java.lang.String sval)
Description copied from class:ChoiceConfigKeyTakes a string, and attempts to turn it into an object which may be a value for this key. If the string is not of a recognised form, null is returned.This method should be the opposite of
ChoiceConfigKey.stringifyValue(T), but does not need to be consistent withstringToValueorvalueToString.- Specified by:
decodeStringin classChoiceConfigKey<java.awt.Color>- Parameters:
sval- string representation- Returns:
- typed object represented by sval, or null
-
stringifyValue
public java.lang.String stringifyValue(java.awt.Color color)
Description copied from class:ChoiceConfigKeyTakes an object which may be a value of this key, and attempts to turn it into a string for reporting purposes.This method should if possible be the opposite of
ChoiceConfigKey.decodeString(java.lang.String), but does not need to be consistent withstringToValueorvalueToString. If no round-trippable value is available, null should be returned.- Specified by:
stringifyValuein classChoiceConfigKey<java.awt.Color>- Parameters:
color- typed object- Returns:
- string representing object, or null
-
createSpecifier
public Specifier<java.awt.Color> createSpecifier()
Description copied from class:ConfigKeyConstructs a graphical control with which the user can specify a suitable value for association with this key.- Specified by:
createSpecifierin classConfigKey<java.awt.Color>- Returns:
- new specifier
-
createColorMeta
public static ConfigMeta createColorMeta(java.lang.String shortName, java.lang.String longName, java.lang.String theItem)
Returns a metadata object suitable for use with a ColorConfigKey. The standard colour set is used.- Parameters:
shortName- key name for use in command-line interfacelongName- key name for use in GUItheItem- description of the item to use in free-form text, for instance "the plot grid"- Returns:
- colour config metadata
-
decodeColorName
public static java.awt.Color decodeColorName(java.lang.String sval)
Turns a string into a colour by looking at known colour names or using RRGGBB syntax.- Parameters:
sval- string colour identifier- Returns:
- colour named by sval, or null if none is identified
-
getPlottingColors
public static java.awt.Color[] getPlottingColors()
Returns an array of the colour options suitable for plotting normal markers.- Returns:
- colour option array
-
createClassicColors
public static java.util.Map<java.lang.String,java.awt.Color> createClassicColors()
Returns the default plotting colours used by TOPCAT, at least in early versions.- Returns:
- name->colour map
-
createSron5Colors
public static java.util.Map<java.lang.String,java.awt.Color> createSron5Colors()
Returns a group of colours using the second (5-colour) row of figure 13 in SRON/EPS/TN/09-002.- Returns:
- name->colour map
-
createSron7Colors
public static java.util.Map<java.lang.String,java.awt.Color> createSron7Colors()
Returns a group of colours using the fourth (7-colour) row of figure 13 in SRON/EPS/TN/09-002.- Returns:
- name->colour map
-
createSronBrightColors
public static java.util.Map<java.lang.String,java.awt.Color> createSronBrightColors()
Returns a group of colours based on the "Alternative Colour Scheme" on Paul Tol's page, but not in the TechNode. Bright yellow is omitted on the grounds that it's too light.- Returns:
- name->colour map
-
-