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
FieldsChangeModifier and TypeFieldDescriptionMODIFIEDprotected generic.theme.laf.UiDefaultsMapper.ColorGrouperMODIFIEDprotected generic.theme.laf.UiDefaultsMapper.FontGrouperprotected UIDefaultsNEWstatic final Stringstatic final Stringstatic final StringNEWstatic final StringA prefix for UIManager properties that are not colors, fonts or icons (e.g., boolean)NEWprotected generic.theme.laf.UiDefaultsMapper.FontGrouperNEWprotected generic.theme.laf.UiDefaultsMapper.ColorGrouperNEWprotected generic.theme.laf.UiDefaultsMapper.ColorGrouperNEWprotected generic.theme.laf.UiDefaultsMapper.FontGrouperREMOVEDRemovedREMOVEDRemovedREMOVEDRemovedREMOVEDRemovedREMOVEDRemoved -
Constructor Summary
Constructors -
Method Summary
ChangeModifier and TypeMethodDescriptionprotected voidPopulates the GThemeValueMap with normalized color ids.NEWprotected voidSets the color grouper for each component groupNEWprotected voidSets the font grouper for each component groupprotected GThemeValueMapMines 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.NEWReturns 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 voidReplaces UiDefaults values withGColorUIResourcevalues the provide the theme indirection.voidinstallValuesIntoUIDefaults(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 voidoverrideColor(String lafId, String sytemId) NEWprotected voidDefines the values to assign to all the system color ids based on the best representative value defined in theBasicLookAndFeelNEWprotected voidDefines the font values to use for each group based upon a chosen Java representative.NEWprotected voidRegisters anyLookAndFeelids that are not used directly (e.g.NEWprotected voidsetComponentFont(String componentName, Font font) NEWprotected voidsetGroupColor(String group, Color color) This allows clients to hard-code a chosen color for a groupNEWprotected voidsetGroupColorUsingJavaRepresentative(String group, String javaId) Assigns the system color id to a color value from the UiDefaults map.NEWprotected voidsetGroupFont(String group, Font font) This allows clients to hard-code a chosen font for a groupREMOVEDGThemeValueMapRemovedREMOVEDvoidRemovedREMOVEDvoidRemovedREMOVEDvoidassignSystemColorFromLafId(String systemColorId, String lafId) RemovedREMOVEDvoidassignSystemColorDirect(String systemColorId, Color color) RemovedREMOVEDvoidassignSystemFontDirect(String systemFontId, Font font) RemovedREMOVEDvoidRemovedREMOVEDvoidRemovedREMOVEDvoidRemoved
-
Field Details
-
LAF_COLOR_ID_PREFIX
- See Also:
-
- Constant Field Values
-
ignoredLafIds REMOVED
Set<String> ignoredLafIds
-
LAF_FONT_ID_PREFIX
- See Also:
-
LAF_ICON_ID_PREFIX
- See Also:
-
LAF_PROPERTY_PREFIX NEW
A prefix for UIManager properties that are not colors, fonts or icons (e.g., boolean)- See Also:
-
defaults
-
ignoredJavaIds NEW
-
viewColorGrouper NEW
protected generic.theme.laf.UiDefaultsMapper.ColorGrouper viewColorGrouper -
tooltipColorGrouper NEW
protected generic.theme.laf.UiDefaultsMapper.ColorGrouper tooltipColorGrouper -
defaultColorMatcher MODIFIED
protected generic.theme.laf.UiDefaultsMapper.ColorGrouper defaultColorMatchertype: ColorMatcher → ColorGrouper-generic.theme.laf.UiDefaultsMapper.ColorMatcher defaultColorMatcher+generic.theme.laf.UiDefaultsMapper.ColorGrouper defaultColorMatcher -
viewFontGrouper NEW
protected generic.theme.laf.UiDefaultsMapper.FontGrouper viewFontGrouper -
defaultFontMatcher MODIFIED
protected generic.theme.laf.UiDefaultsMapper.FontGrouper defaultFontMatchertype: FontMatcher → FontGrouper-generic.theme.laf.UiDefaultsMapper.FontMatcher defaultFontMatcher+generic.theme.laf.UiDefaultsMapper.FontGrouper defaultFontMatcher
-
-
Constructor Details
-
UiDefaultsMapper
-
-
Method Details
-
getNormalizedJavaDefaults NEW
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 NEW
protected void registerIgnoredJavaIds()Registers anyLookAndFeelids 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 NEW
protected void pickRepresentativeValueForColorGroups()Defines the values to assign to all the system color ids based on the best representative value defined in theBasicLookAndFeel -
setGroupColorUsingJavaRepresentative NEW
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 NEW
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 NEW
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 NEW
-
pickRepresentativeValueForFontGroups NEW
protected void pickRepresentativeValueForFontGroups()Defines the font values to use for each group based upon a chosen Java representative. -
buildComponentToFontGrouperMap NEW
protected void buildComponentToFontGrouperMap()Sets the font grouper for each component group -
buildComponentToColorGrouperMap NEW
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 withGColorUIResourcevalues the provide the theme indirection. -
overrideColor
-
extractColorFontAndIconValuesFromDefaults
Mines the UiDefaults for all color values.- Returns:
- a map of id to values for UIDefaults Colors.
-