Package generic.theme
Class ColorValue
- All Implemented Interfaces:
Comparable<ThemeValue<Color>>
A class for storing
Color
values that have a String id (e.g. color.bg.foo) and either
a concrete color or a reference id which is the String id of another ColorValue that it
will inherit its color from. So if this class's color value is non-null, the refId will be null
and if the class's refId is non-null, then the color value will be null.-
Field Summary
Fields inherited from class generic.theme.ThemeValue
id, referenceId, value
-
Constructor Summary
ConstructorDescriptionColorValue
(String id, Color value) Constructor used when the ColorValue will have a directColor
value.ColorValue
(String id, String refId) Constructor used when the ColorValue will inherit its color from another ColorValue. -
Method Summary
Modifier and TypeMethodDescriptionprotected ColorValue
getReferredValue
(GThemeValueMap values, String refId) Returns the ThemeValue referred to by this ThemeValue.Returns the "key = value" String for writing this ThemeValue to a fileprotected Color
getUnresolvedReferenceValue
(String primaryId, String unresolvedId) Returns the T to be used if the indirect reference couldn't be resolved.void
installValue
(ThemeManager themeManager) Install this value as the current value for the applicationstatic boolean
isColorKey
(String key) Returns true if the given key string is a valid external key for a color valueboolean
True if this value is one that is one that is defined outside of the application, such as a Java Look and Feel key.static ColorValue
Parses the value string into a color or reference and creates a new ColorValue using the given key and the parse results.Methods inherited from class generic.theme.ThemeValue
compareTo, equals, get, getId, getRawValue, getReferenceId, hashCode, hasResolvableValue, inheritsFrom, isIndirect, toString
-
Field Details
-
LAF_ID_PREFIX
- See Also:
-
EXTERNAL_LAF_ID_PREFIX
- See Also:
-
LAST_RESORT_DEFAULT
-
-
Constructor Details
-
ColorValue
Constructor used when the ColorValue will have a directColor
value. The refId will be null. Note: if aGColor
is passed in as the value, then this will be an indirect ColorValue that inherits its color from the id stored in the GColor.- Parameters:
id
- the id for this ColorValuevalue
- theColor
to associate with the given id
-
ColorValue
Constructor used when the ColorValue will inherit its color from another ColorValue. The color value field will be null.- Parameters:
id
- the id for this ColorValuerefId
- the id of another ColorValue that this ColorValue will inherit from
-
-
Method Details
-
getSerializationString
Description copied from class:ThemeValue
Returns the "key = value" String for writing this ThemeValue to a file- Specified by:
getSerializationString
in classThemeValue<Color>
- Returns:
- the "key = value" String for writing this ThemeValue to a file
-
isExternal
public boolean isExternal()Description copied from class:ThemeValue
True if this value is one that is one that is defined outside of the application, such as a Java Look and Feel key.- Specified by:
isExternal
in classThemeValue<Color>
- Returns:
- true if external
-
isColorKey
Returns true if the given key string is a valid external key for a color value- Parameters:
key
- the key string to test- Returns:
- true if the given key string is a valid external key for a color value
-
parse
Parses the value string into a color or reference and creates a new ColorValue using the given key and the parse results.- Parameters:
key
- the key to associate the parsed value withvalue
- the color value to parse- Returns:
- a ColorValue with the given key and the parsed value
-
getReferredValue
Description copied from class:ThemeValue
Returns the ThemeValue referred to by this ThemeValue. Needs to be overridden by concrete classes as they know the correct method to call on the preferredValues map.- Specified by:
getReferredValue
in classThemeValue<Color>
- Parameters:
values
- theGThemeValueMap
to be used to resolve the reference idrefId
- the id of the reference ThemeValue- Returns:
- the ThemeValue referred to by this ThemeValue.
-
getUnresolvedReferenceValue
Description copied from class:ThemeValue
Returns the T to be used if the indirect reference couldn't be resolved.- Specified by:
getUnresolvedReferenceValue
in classThemeValue<Color>
- Parameters:
primaryId
- the id we are trying to get a value forunresolvedId
- the reference id that couldn't be resolved- Returns:
- the default value to be used if the indirect reference couldn't be resolved.
-
installValue
Description copied from class:ThemeValue
Install this value as the current value for the application- Specified by:
installValue
in classThemeValue<Color>
- Parameters:
themeManager
- the application ThemeManager
-