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
Modifier and TypeFieldDescriptionprotected generic.theme.laf.UiDefaultsMapper.ColorGrouper
protected generic.theme.laf.UiDefaultsMapper.FontGrouper
protected UIDefaults
static final String
static final String
static final String
static final String
A prefix for UIManager properties that are not colors, fonts or icons (e.g., boolean)protected generic.theme.laf.UiDefaultsMapper.FontGrouper
protected generic.theme.laf.UiDefaultsMapper.ColorGrouper
protected generic.theme.laf.UiDefaultsMapper.ColorGrouper
protected generic.theme.laf.UiDefaultsMapper.FontGrouper
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
Populates the GThemeValueMap with normalized color ids.protected void
Sets the color grouper for each component groupprotected void
Sets the font grouper for each component groupprotected GThemeValueMap
Mines the UiDefaults for all color values.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 the normalized id to value map that will be installed into the theme manager to be the user changeable values for affecting the Java LookAndFeel colors, fonts, and icons.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
Defines the values to assign to all the system color ids based on the best representative value defined in theBasicLookAndFeel
protected void
Defines the font values to use for each group based upon a chosen Java representative.protected void
Registers anyLookAndFeel
ids that are not used directly (e.g.protected void
setComponentFont
(String componentName, Font font) protected void
setGroupColor
(String group, Color color) This allows clients to hard-code a chosen color for a groupprotected void
setGroupColorUsingJavaRepresentative
(String group, String javaId) Assigns the system color id to a color value from the UiDefaults map.protected void
setGroupFont
(String group, Font font) This allows clients to hard-code a chosen font for a group
-
Field Details
-
LAF_COLOR_ID_PREFIX
- See Also:
-
LAF_FONT_ID_PREFIX
- See Also:
-
LAF_ICON_ID_PREFIX
- See Also:
-
LAF_PROPERTY_PREFIX
A prefix for UIManager properties that are not colors, fonts or icons (e.g., boolean)- See Also:
-
defaults
-
ignoredJavaIds
-
viewColorGrouper
protected generic.theme.laf.UiDefaultsMapper.ColorGrouper viewColorGrouper -
tooltipColorGrouper
protected generic.theme.laf.UiDefaultsMapper.ColorGrouper tooltipColorGrouper -
defaultColorMatcher
protected generic.theme.laf.UiDefaultsMapper.ColorGrouper defaultColorMatcher -
viewFontGrouper
protected generic.theme.laf.UiDefaultsMapper.FontGrouper viewFontGrouper -
defaultFontMatcher
protected generic.theme.laf.UiDefaultsMapper.FontGrouper defaultFontMatcher
-
-
Constructor Details
-
UiDefaultsMapper
-
-
Method Details
-
getNormalizedJavaDefaults
Returns the normalized id to value map that will be installed into the theme manager to be the user changeable values for affecting the Java LookAndFeel colors, fonts, and icons.The keys in the returned map have been normalized and all start with 'laf.'
- 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.
-
registerIgnoredJavaIds
protected void registerIgnoredJavaIds()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. -
pickRepresentativeValueForColorGroups
protected void pickRepresentativeValueForColorGroups()Defines the values to assign to all the system color ids based on the best representative value defined in theBasicLookAndFeel
-
setGroupColorUsingJavaRepresentative
Assigns the system color id to a color value from the UiDefaults map.- Parameters:
group
- the system color id to get a value forjavaId
- the LaF key to use to retrieve a color from the UiDefaults
-
setGroupColor
This allows clients to hard-code a chosen color for a group- Parameters:
group
- the system color id to assign the given colorcolor
- the color to be assigned to the system color id
-
setGroupFont
This allows clients to hard-code a chosen font for a group- Parameters:
group
- the system font id to assign the given fontfont
- the font to be assigned to the system font id
-
setComponentFont
-
pickRepresentativeValueForFontGroups
protected void pickRepresentativeValueForFontGroups()Defines the font values to use for each group based upon a chosen Java representative. -
buildComponentToFontGrouperMap
protected void buildComponentToFontGrouperMap()Sets the font grouper for each component group -
buildComponentToColorGrouperMap
protected void buildComponentToColorGrouperMap()Sets the color grouper for each 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.
-