Package generic.theme.laf
Class UiDefaultsMapper
java.lang.Object
generic.theme.laf.UiDefaultsMapper
- Direct Known Subclasses:
FlatUiDefaultsMapper
,MotifUiDefaultsMapper
,NimbusUiDefaultsMapper
The purpose of this class is to introduce multiple levels of indirection into the Java
LookAndFeel
(LaF), which allows the user to change these values. Further, when
introducing this indirection we combine the Java settings into user-friendly system ids to make
changing these values easier.
This class defines these user-friendly groups. The default system assignments are based on the
BasicLookAndFeel
values.
Subclasses can override the mapping of these standard system values for particular LaFs that have different ids or color assignments.
Some basic concepts:
- UI Defaults - key-value pairs defined by the Java LaF; there are 2 key types, widget keys and Java group/reusable keys (e.g., Button.background; control)
- UI Indirection - UI Defaults values are changed to point to custom terms we created to allow for indirection (e.g., Button.background -> laf.color.Button.background)
- Normalized Keys - keys we created to facilitate the UI Indirection, based upon the Java keys (e.g., laf.color.Button.background)
- System Color/Font Keys - user facing terms for common color or font concepts into an easy-to-change setting (e.g., system.color.fg.text)
- Palette Keys - dynamically generated color palette keys based on the LaF for any colors and fonts that were not mapped into an system color or font (e.g., laf.palette.color.01)
The mapper performs the following operations:
- Extracts all color, font, and icon values from the UI Defaults.
- Use the current LaF values to populate the pre-defined system colors and fonts.
- Any UI Defaults values not assigned in the previous step will be assigned to a dynamic shared palette color or font.
- Update Java UI Defaults to use our indirection and system values.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected generic.theme.laf.UiDefaultsMapper.ColorMatcher
protected generic.theme.laf.UiDefaultsMapper.FontMatcher
protected UIDefaults
static final String
static final String
static final String
protected generic.theme.laf.UiDefaultsMapper.FontMatcher
protected generic.theme.laf.UiDefaultsMapper.ColorMatcher
protected generic.theme.laf.UiDefaultsMapper.ColorMatcher
protected generic.theme.laf.UiDefaultsMapper.FontMatcher
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Assigns the appropriate color matcher to each component in the related component groupprotected void
Assigns the appropriate font matcher to each component in the related component groupprotected void
Populates the GThemeValueMap with normalized color ids.protected void
assignSystemColorDirect
(String systemColorId, Color color) Assigns the system color id to a directly specified color and does not use the LaF to populate the system color.protected void
assignSystemColorFromLafId
(String systemColorId, String lafId) Assigns the system color id to a color value from the UiDefaults map.protected void
Defines the values to assign to all the system color ids based on the best representative value defined in theBasicLookAndFeel
protected void
assignSystemFontDirect
(String systemFontId, Font font) Assigns the system font id a directly specified font and does not use the LaF to populate the system font.protected void
Defines the values to use for the system fonts.protected GThemeValueMap
Mines the UiDefaults for all color values.Returns the normalized id to value map that will be installed into the ApplicationThemeManager to be the user changeable values for affecting the Java LookAndFeel colors, fonts, and iconsReturns a mapping of normalized LaF Ids so that when fonts and icons get changed using the normalized ids that are presented to the user, we know which LaF ids need to be updated in the UiDefaults so that the LookAndFeel will pick up and use the changes.protected void
Replaces UiDefaults values withGColorUIResource
values the provide the theme indirection.void
installValuesIntoUIDefaults
(GThemeValueMap currentValues) Updates the UIDefaults file with indirect colors (GColors) and any overridden font or icon values as defined in theme.properites files and saved themes.protected void
overrideColor
(String lafId, String sytemId) protected void
Registers anyLookAndFeel
ids that are not used directly (e.g.
-
Field Details
-
LAF_COLOR_ID_PREFIX
- See Also:
-
LAF_FONT_ID_PREFIX
- See Also:
-
LAF_ICON_ID_PREFIX
- See Also:
-
defaults
-
ignoredLafIds
-
viewColorMatcher
protected generic.theme.laf.UiDefaultsMapper.ColorMatcher viewColorMatcher -
tooltipColorMatcher
protected generic.theme.laf.UiDefaultsMapper.ColorMatcher tooltipColorMatcher -
defaultColorMatcher
protected generic.theme.laf.UiDefaultsMapper.ColorMatcher defaultColorMatcher -
viewFontMatcher
protected generic.theme.laf.UiDefaultsMapper.FontMatcher viewFontMatcher -
defaultFontMatcher
protected generic.theme.laf.UiDefaultsMapper.FontMatcher defaultFontMatcher
-
-
Constructor Details
-
UiDefaultsMapper
-
-
Method Details
-
getJavaDefaults
Returns the normalized id to value map that will be installed into the ApplicationThemeManager to be the user changeable values for affecting the Java LookAndFeel colors, fonts, and icons- Returns:
- a map of changeable values that affect java LookAndFeel values
-
installValuesIntoUIDefaults
Updates the UIDefaults file with indirect colors (GColors) and any overridden font or icon values as defined in theme.properites files and saved themes.- Parameters:
currentValues
- a Map that contains all the values including those the may have been overridden by the theme.properties files or saved themes
-
getNormalizedIdToLafIdMap
Returns a mapping of normalized LaF Ids so that when fonts and icons get changed using the normalized ids that are presented to the user, we know which LaF ids need to be updated in the UiDefaults so that the LookAndFeel will pick up and use the changes.- Returns:
- a mapping of normalized LaF ids to original LaF ids.
-
registerIgnoredLafIds
protected void registerIgnoredLafIds()Registers anyLookAndFeel
ids that are not used directly (e.g. "control", "text", etc.) so that these values won't get mapped to any normalized id. There is no need for these values to show up in the theme values, since changing them will have no effect. They are used to seed the values for the system color and fonts. Subclasses should override this method to add additional ids so they won't show up in the theme values. -
assignSystemColorValues
protected void assignSystemColorValues()Defines the values to assign to all the system color ids based on the best representative value defined in theBasicLookAndFeel
-
assignSystemColorFromLafId
Assigns the system color id to a color value from the UiDefaults map.- Parameters:
systemColorId
- the system color id to get a value forlafId
- the LaF key to use to retrieve a color from the UiDefaults
-
assignSystemColorDirect
Assigns the system color id to a directly specified color and does not use the LaF to populate the system color.- Parameters:
systemColorId
- the system color id to assign the given colorcolor
- the color to be assigned to the system color id
-
assignSystemFontDirect
Assigns the system font id a directly specified font and does not use the LaF to populate the system font.- Parameters:
systemFontId
- the system font id to assign the given fontfont
- the font to be assigned to the system font id
-
assignSystemFontValues
protected void assignSystemFontValues()Defines the values to use for the system fonts. -
assignFontMatchersToComponentIds
protected void assignFontMatchersToComponentIds()Assigns the appropriate font matcher to each component in the related component group -
assignColorMatchersToComponentIds
protected void assignColorMatchersToComponentIds()Assigns the appropriate color matcher to each component in the related component group -
assignNormalizedColorValues
protected void assignNormalizedColorValues()Populates the GThemeValueMap with normalized color ids. For example it will assign "laf.color.Button.background" to "system.color.bg.control". -
installGColorsIntoUIDefaults
protected void installGColorsIntoUIDefaults()Replaces UiDefaults values withGColorUIResource
values the provide the theme indirection. -
overrideColor
-
extractColorFontAndIconValuesFromDefaults
Mines the UiDefaults for all color values.- Returns:
- a map of id to values for UIDefaults Colors.
-