Package generic.theme
Class IconValue
- All Implemented Interfaces:
Comparable<ThemeValue<Icon>>
A class for storing
Icon
values that have a String id (e.g. icon.bg.foo) and either
a concrete icon or a reference id which is the String id of another IconValue that it
will inherit its icon from. So if this class's icon value is non-null, the refId will be null
and if the class's refId is non-null, then the icon value will be null.-
Field Summary
Fields inherited from class generic.theme.ThemeValue
id, referenceId, value
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionget
(GThemeValueMap values) Returns the T value for this instance, following references as needed.protected IconValue
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 Icon
getUnresolvedReferenceValue
(String primaryId, String unresolvedId) Returns the T to be used if the indirect reference couldn't be resolved.static String
iconToString
(Icon icon) Converts an icon to a string.void
installValue
(ThemeManager themeManager) Install this value as the current value for the applicationboolean
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 boolean
Returns true if the given key string is a valid external key for an icon valuestatic IconValue
Parses the value string into an icon or reference and creates a new IconValue using the given key and the parse results.Methods inherited from class generic.theme.ThemeValue
compareTo, equals, 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
-
IconValue
Constructor used when the ColorValue will have a directIcon
value. The refId will be null. Note: if aGIcon
is passed in as the value, then this will be an indirect IconValue that inherits its icon from the id stored in the GIcon.- Parameters:
id
- the id for this IconValueicon
- theIcon
to associate with the given id
-
IconValue
Constructor used when the IconValue will inherit itsIcon
from another IconValue. The icon value field will be null.- Parameters:
id
- the id for this IconValuerefId
- the id of another IconValue that this IconValue 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<Icon>
- 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<Icon>
- Returns:
- true if external
-
get
Description copied from class:ThemeValue
Returns the T value for this instance, following references as needed. Uses the given preferredValues map to resolve references. If the value can't be resolved by following reference chains, an error stack trace will be generated and the default T value will be returned. In rare situations where it is acceptable for the value to not be resolvable, use theThemeValue.hasResolvableValue(GThemeValueMap)
method first.- Overrides:
get
in classThemeValue<Icon>
- Parameters:
values
- theGThemeValueMap
used to resolve references if this instance doesn't have an actual value.- Returns:
- the T value for this instance, following references as needed.
-
isIconKey
Returns true if the given key string is a valid external key for an icon value- Parameters:
key
- the key string to test- Returns:
- true if the given key string is a valid external key for an icon value
-
iconToString
Converts an icon to a string.- Parameters:
icon
- the icon to convert to a String- Returns:
- a String that represents the icon
-
parse
Parses the value string into an icon or reference and creates a new IconValue using the given key and the parse results.- Parameters:
key
- the key to associate the parsed value withvalue
- the color value to parse- Returns:
- an IconValue with the given key and the parsed value
- Throws:
ParseException
- if the value can't be parsed
-
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<Icon>
- 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<Icon>
- 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<Icon>
- Parameters:
themeManager
- the application ThemeManager
-