Package generic.theme
Class ApplicationThemeManager
java.lang.Object
generic.theme.ThemeManager
generic.theme.ApplicationThemeManager
This is the fully functional 
ThemeManager that manages themes in a application. To
 activate the theme functionality, Applications (or tests) must call
 initialize()- 
Field SummaryFieldsFields inherited from class generic.theme.ThemeManageractiveLafType, activeTheme, applicationDefaults, currentValues, INSTANCE, javaDefaults, THEME_DIR, useDarkDefaults
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidAdds the given theme to set of all themes.protected voidThis method is called to create the internal set of theme value used by the application.voiddeleteTheme(GTheme theme) Removes the theme from the set of all themes.protected voidReturns a set of all known themes.Gets a UIResource version of the GColor for the given id.Returns a set of all known themes that are supported on the current platform.Returns the known theme that has the given name.booleanReturns true if there are any unsaved changes to the current theme.booleanReturns true if any theme values have changed.static voidInitialized the Theme and its values for the application.booleanReturns true if the application should allow blinking cursors, false otherwise.booleanisChangedColor(String id) Returns true if the color associated with the given id has been changed from the current theme value for that id.booleanisChangedFont(String id) Returns true if the font associated with the given id has been changed from the current theme value for that id.booleanisChangedIcon(String id) Returns true if the Icon associated with the given id has been changed from the current theme value for that id.protected Collection<GTheme> voidvoidregisterFont(Component component, String fontId) Binds the component to the font identified by the given font id.voidregisterFont(Component component, String fontId, int fontStyle) Binds the component to the font identified by the given font id.voidrestoreColor(String id) Restores the current color value for the given color id to the value established by the current theme.voidrestoreFont(String id) Restores the current font value for the given font id to the value established by the current theme.voidrestoreIcon(String id) Restores the current icon value for the given icon id to the value established by the current theme.voidRestores all the current application back to the values as specified by the active theme.voidsetBlinkingCursors(boolean b) Sets application's blinking cursor state.voidsetColor(ColorValue newValue) Updates the current value for the color id in the newValuevoidUpdates the current value for the font id in the newValuevoidUpdates the current value for theIconid in the newValuevoidSets the map of Java default UI values.voidsetLookAndFeel(LafType lafType, boolean useDarkDefaults) Sets the currentLookAndFeel.voidSets the application's active theme to the given theme.voidunRegisterFont(JComponent component, String fontId) Removes the component and font id binding made in a previous call toThemeManager.registerFont(Component, String).Methods inherited from class generic.theme.ThemeManageraddThemeListener, adjustFonts, error, getActiveTheme, getApplicationDarkDefaults, getApplicationLightDefaults, getColor, getCurrentValues, getDefaults, getDefaultTheme, getFont, getIcon, getInstance, getJavaDefaults, getLookAndFeelType, getNonDefaultValues, getThemeValues, hasColor, hasFont, hasIcon, installInGui, isDarkTheme, isUpdatingTheme, isUsingAquaUI, isUsingAquaUI, isUsingFlatUI, isUsingNimbusUI, loadApplicationDefaults, notifyThemeChanged, removeThemeListener, setColor, setFont, setIcon, update
- 
Field Details- 
themePreferences
- 
lookAndFeelManager
 
- 
- 
Constructor Details- 
ApplicationThemeManagerprotected ApplicationThemeManager()
 
- 
- 
Method Details- 
initializepublic static void initialize()Initialized the Theme and its values for the application.
- 
doInitializeprotected void doInitialize()
- 
restoreThemeValuespublic void restoreThemeValues()Description copied from class:ThemeManagerRestores all the current application back to the values as specified by the active theme. In other words, reverts any changes to the active theme that haven't been saved.- Overrides:
- restoreThemeValuesin class- ThemeManager
 
- 
restoreColorDescription copied from class:ThemeManagerRestores the current color value for the given color id to the value established by the current theme.- Overrides:
- restoreColorin class- ThemeManager
- Parameters:
- id- the color id to restore back to the original theme value
 
- 
restoreFontDescription copied from class:ThemeManagerRestores the current font value for the given font id to the value established by the current theme.- Overrides:
- restoreFontin class- ThemeManager
- Parameters:
- id- the font id to restore back to the original theme value
 
- 
restoreIconDescription copied from class:ThemeManagerRestores the current icon value for the given icon id to the value established by the current theme.- Overrides:
- restoreIconin class- ThemeManager
- Parameters:
- id- the icon id to restore back to the original theme value
 
- 
isChangedColorDescription copied from class:ThemeManagerReturns true if the color associated with the given id has been changed from the current theme value for that id.- Overrides:
- isChangedColorin class- ThemeManager
- Parameters:
- id- the color id to check if it has been changed
- Returns:
- true if the color associated with the given id has been changed from the current theme value for that id.
 
- 
isChangedFontDescription copied from class:ThemeManagerReturns true if the font associated with the given id has been changed from the current theme value for that id.- Overrides:
- isChangedFontin class- ThemeManager
- Parameters:
- id- the font id to check if it has been changed
- Returns:
- true if the font associated with the given id has been changed from the current theme value for that id.
 
- 
isChangedIconDescription copied from class:ThemeManagerReturns true if the Icon associated with the given id has been changed from the current theme value for that id.- Overrides:
- isChangedIconin class- ThemeManager
- Parameters:
- id- the Icon id to check if it has been changed
- Returns:
- true if the Icon associated with the given id has been changed from the current theme value for that id.
 
- 
setThemeDescription copied from class:ThemeManagerSets the application's active theme to the given theme.- Overrides:
- setThemein class- ThemeManager
- Parameters:
- theme- the theme to make active
 
- 
setLookAndFeelDescription copied from class:ThemeManagerSets the currentLookAndFeel. This is used by theme editors to allow users to see the effects of changing LookAndFeels when configuring a theme. Setting this different from the activeTheme's LookAndFeel setting means that the current theme is in an unsaved state and causes theThemeManager.hasThemeChanges()method to return true.- Overrides:
- setLookAndFeelin class- ThemeManager
- Parameters:
- lafType- the- LafTypeto set the LookAndFeel to
- useDarkDefaults- true if the application should used dark defaults with this LookAndFeel
 
- 
setBlinkingCursorspublic void setBlinkingCursors(boolean b) Description copied from class:ThemeManagerSets application's blinking cursor state. This will affect all JTextFields, JTextAreas, JTextPanes viaUIDefaults. Custom components can also respect this setting by either adding aThemeListeneror overridingJComponent.updateUI()NOTE: This method is a bit odd here as it doesn't really apply to a theme. But it requires manipulation of the look and feel which is managed by the theme. If other application level properties come along and also require changing the UIDefaults, perhaps a more general solution might be to add a way for clients to register a callback so that they get a chance to change the UIDefaults map as the look and feel is loaded. - Overrides:
- setBlinkingCursorsin class- ThemeManager
- Parameters:
- b- true for blinking text cursors, false for non-blinking text cursors
 
- 
isBlinkingCursorspublic boolean isBlinkingCursors()Description copied from class:ThemeManagerReturns true if the application should allow blinking cursors, false otherwise. Custom components can use this method to determine if they should have a blinking cursor or not.- Overrides:
- isBlinkingCursorsin class- ThemeManager
- Returns:
- true if the application should allow blinking cursors, false otherwise.
 
- 
addThemeDescription copied from class:ThemeManagerAdds the given theme to set of all themes.- Overrides:
- addThemein class- ThemeManager
- Parameters:
- newTheme- the theme to add
 
- 
deleteThemeDescription copied from class:ThemeManagerRemoves the theme from the set of all themes. Also, if the theme has an associated file, the file will be deleted.- Overrides:
- deleteThemein class- ThemeManager
- Parameters:
- theme- the theme to delete
 
- 
getAllThemesDescription copied from class:ThemeManagerReturns a set of all known themes.- Overrides:
- getAllThemesin class- ThemeManager
- Returns:
- a set of all known themes.
 
- 
getSupportedThemesDescription copied from class:ThemeManagerReturns a set of all known themes that are supported on the current platform.- Overrides:
- getSupportedThemesin class- ThemeManager
- Returns:
- a set of all known themes that are supported on the current platform.
 
- 
getThemeDescription copied from class:ThemeManagerReturns the known theme that has the given name.- Overrides:
- getThemein class- ThemeManager
- Parameters:
- themeName- the name of the theme to retrieve
- Returns:
- the known theme that has the given name
 
- 
setFontDescription copied from class:ThemeManagerUpdates the current value for the font id in the newValue- Overrides:
- setFontin class- ThemeManager
- Parameters:
- newValue- the new- FontValueto install in the current values.
 
- 
setColorDescription copied from class:ThemeManagerUpdates the current value for the color id in the newValue- Overrides:
- setColorin class- ThemeManager
- Parameters:
- newValue- the new- ColorValueto install in the current values.
 
- 
setIconDescription copied from class:ThemeManagerUpdates the current value for theIconid in the newValue- Overrides:
- setIconin class- ThemeManager
- Parameters:
- newValue- the new- IconValueto install in the current values.
 
- 
getGColorUiResourceGets a UIResource version of the GColor for the given id. Using this method ensures that the same instance is used for a given id. This fixes an issue with someLookAndFeels that internally use '==' comparisons.- Parameters:
- id- the id to get a GColorUIResource for
- Returns:
- a GColorUIResource for the given id
 
- 
setJavaDefaultsSets the map of Java default UI values. These are the UI values defined by the current Java Look and Feel.- Parameters:
- map- the default theme values defined by the- LookAndFeel
 
- 
hasThemeChangespublic boolean hasThemeChanges()Description copied from class:ThemeManagerReturns true if there are any unsaved changes to the current theme.- Overrides:
- hasThemeChangesin class- ThemeManager
- Returns:
- true if there are any unsaved changes to the current theme.
 
- 
hasThemeValueChangespublic boolean hasThemeValueChanges()Description copied from class:ThemeManagerReturns true if any theme values have changed. This does not take into account the current Look and Feel. UseThemeManager.hasThemeChanges()to also account for changes to the Look and Feel.- Overrides:
- hasThemeValueChangesin class- ThemeManager
- Returns:
- true if any theme values have changed
 
- 
registerFontDescription copied from class:ThemeManagerBinds the component to the font identified by the given font id. Whenever the font for the font id changes, the component will updated with the new font.- Overrides:
- registerFontin class- ThemeManager
- Parameters:
- component- the component to set/update the font
- fontId- the id of the font to register with the given component
 
- 
registerFontDescription copied from class:ThemeManagerBinds the component to the font identified by the given font id. Whenever the font for the font id changes, the component will updated with the new font.This method is fairly niche and should not be called by most clients. Instead, call ThemeManager.registerFont(Component, String).- Overrides:
- registerFontin class- ThemeManager
- Parameters:
- component- the component to set/update the font
- fontId- the id of the font to register with the given component
- fontStyle- the font style
 
- 
unRegisterFontDescription copied from class:ThemeManagerRemoves the component and font id binding made in a previous call toThemeManager.registerFont(Component, String).- Overrides:
- unRegisterFontin class- ThemeManager
- Parameters:
- component- the component to remove
- fontId- the id of the font previously registered
 
- 
buildCurrentValuesprotected void buildCurrentValues()Description copied from class:ThemeManagerThis method is called to create the internal set of theme value used by the application. To do this, we use a layered approach to install values, with the last values added overwriting any pre-existing values with the same key. The values are added in the following order:java defaults -> light values -> dark values -> look and feel values -> property file values -> theme values At the point this method is called, this is the state of these various values: - The 'javaValues' are normalized in the form of 'laf.font.TextArea'
- The 'applicationDefaults' contains values loaded from the theme.propertiesfiles:font.listing.base font.monospaced [color]Viewport.background = color.bg [laf.font]TextArea.font = font.monospaced [laf.boolean]Button.rollover = true
- The 'activeTheme' values are those loaded by the current theme, which has any changes made to the default values
 - Overrides:
- buildCurrentValuesin class- ThemeManager
 
- 
loadThemeFiles
- 
refreshGThemeValuespublic void refreshGThemeValues()
 
-