Class Theme
- All Implemented Interfaces:
Serializable,Comparable<Theme>,Comparator<Theme>
- Direct Known Subclasses:
DarculaTheme,HighContrastDarkTheme,HighContrastLightTheme,IntelliJTheme,OneDarkTheme,SolarizedDarkTheme,SolarizedLightTheme,ThemeDelegate
- See Also:
- Serialized Form
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanappearsEqualTo(Theme theme)Returns whether the appearance of the given theme is equal to the appearance if [this].static ThemebaseThemeOf(Theme theme)intintcopy()Creates a copy of this theme.voidcustomizeGlobals(Properties properties, UIDefaults currentDefaults)Customize the global values.voidcustomizeIconTheme(Properties properties, UIDefaults currentDefaults)Customize the icon defaults.voidcustomizePlatformProperties(Properties properties, UIDefaults currentDefaults)Customize the platform defaults.voidcustomizeUIProperties(Properties properties, UIDefaults currentDefaults)Customize the ui defaults.derive(FontSizeRule fontSizeRule, AccentColorRule accentColorRule)Create a derived theme with the givenFontSizeRuleandAccentColorRule.booleanGet the accent color rule.abstract ColorToneRuleReturns the style rule for this theme.Returns contrast rule for the theme.Get the display name of this theme.Get the font size rule for this theme.The class used to determine the runtime location of resources.abstract StringgetName()Get the name of this theme.abstract StringGet the prefix for resource loading.protected abstract PresetIconRuleThe preset icon theme.protected StringgetPropertyFilePath(String name)Get the path for the file [prefix]_[name].properties in the themes resource location.protected StringThe path to the resource location relative to the classpath ofgetLoaderClass().inthashCode()static booleanReturns whether the theme is a dark theme.static booleanisHighContrast(Theme theme)Returns whether the theme is a high contrast theme.protected PropertiesLoad a .properties file usinggetLoaderClass()} to resolve the file path.Load the properties specifying how to map the colors from theAccentColorRuleare mapped to the properties.protected voidloadCustomProperties(String propertySuffix, Properties properties, UIDefaults currentDefaults)Load custom properties that are located undergetResourcePath(), with the namegetPrefix()_{propertySuffix}.propertiesvoidloadDefaults(Properties properties, UIDefaults currentDefaults)Load the theme defaults.voidloadIconTheme(Properties properties, UIDefaults currentDefaults)Load the general properties file for the icon themes.loadPropertyFile(String name)Load the theme property file with the specified name.loadPropertyFile(String name, boolean silent)Load the theme property file with the specified name.Load the css style sheet used for html display in text components with aHTMLEditorKit.protected PropertiesloadWithClass(String name, Class<?> loaderClass)Load a .properties file.booleanReturns whether this theme supports custom accent colors.booleanReturns whether this theme supports custom selection colors.toString()booleanReturns whether this theme should use custom decorations if available.withDisplayName(String newName)Create a derived theme with the given display name.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Constructor Details
-
Theme
public Theme() -
Theme
-
-
Method Details
-
baseThemeOf
-
withDisplayName
Create a derived theme with the given display name.- Parameters:
newName- the new display name.- Returns:
- the derived theme.
-
derive
Create a derived theme with the givenFontSizeRuleandAccentColorRule.- Parameters:
fontSizeRule- the font size rule.accentColorRule- the accent color rule.- Returns:
- the derived theme.
-
copy
Creates a copy of this theme. This is not equivalent toObject.clone()in the sense thatclone().getClass() == this.getClass()andcopy().getClass() != this.getClass(). Nonetheless the copy theme behaves exactly the same as the original.- Returns:
- a copy of the theme.
-
isDark
Returns whether the theme is a dark theme. This is used to determine the default mode for [aware] icons.- Parameters:
theme- the theme.- Returns:
- true if dark.
-
isHighContrast
Returns whether the theme is a high contrast theme.- Parameters:
theme- the theme.- Returns:
- true if the theme is a high contrast theme.
-
loadDefaults
Load the theme defaults.Note: When overwriting a theme you also have overwrite
getLoaderClass()to return the class of the theme you are overwriting. In this case you should useloadWithClass(String, Class)instead ofload(String).- Parameters:
properties- the properties to load the values into.currentDefaults- the current ui defaults.
-
customizeGlobals
Customize the global values.Note: When overwriting a theme you also have overwrite
getLoaderClass()to return the class of the theme you are overwriting. In this case you should useloadWithClass(String, Class)instead ofload(String).- Parameters:
properties- the properties to load the values into.currentDefaults- the current ui defaults.
-
customizeIconTheme
Customize the icon defaults.Note: When overwriting a theme you also have overwrite
getLoaderClass()to return the class of the theme you are overwriting. In this case you should useloadWithClass(String, Class)instead ofload(String).- Parameters:
properties- the properties to load the value into.currentDefaults- the current ui defaults.
-
loadIconTheme
Load the general properties file for the icon themes.Note: When overwriting a theme you also have overwrite
getLoaderClass()to return the class of the theme you are overwriting. In this case you should useloadWithClass(String, Class)instead ofload(String).- Parameters:
properties- the properties to load the value into.currentDefaults- the current ui defaults.
-
customizePlatformProperties
Customize the platform defaults.Note: When overwriting a theme you should use
loadWithClass(String, Class)instead ofload(String).- Parameters:
properties- the properties to load the values into.currentDefaults- the current ui defaults.
-
customizeUIProperties
Customize the ui defaults.Note: When overwriting a theme you should use
loadWithClass(String, Class)instead ofload(String).- Parameters:
properties- the properties to load the values into.currentDefaults- the current ui defaults.
-
getPresetIconRule
The preset icon theme.- Returns:
- the icon theme.
-
loadCustomProperties
protected final void loadCustomProperties(String propertySuffix, Properties properties, UIDefaults currentDefaults)Load custom properties that are located undergetResourcePath(), with the namegetPrefix()_{propertySuffix}.propertiesNote: When overwriting a theme you should use
loadWithClass(String, Class)instead ofload(String).- Parameters:
propertySuffix- the property suffix.properties- the properties to load into.currentDefaults- the current ui defaults.
-
loadAccentProperties
Load the properties specifying how to map the colors from theAccentColorRuleare mapped to the properties.- Returns:
- the properties providing the mapping rules.
-
load
Load a .properties file usinggetLoaderClass()} to resolve the file path.Note: When overwriting a theme you should use
loadWithClass(String, Class)instead.- Parameters:
name- the properties file to load.- Returns:
- the properties.
-
loadWithClass
Load a .properties file.- Parameters:
name- the properties file to load.loaderClass- the class to resolve the file location from.- Returns:
- the properties.
-
loadStyleSheet
Load the css style sheet used for html display in text components with aHTMLEditorKit.- Returns:
- the
StyleSheet.
-
toString
-
getResourcePath
The path to the resource location relative to the classpath ofgetLoaderClass().- Returns:
- the relative resource path
-
getPrefix
Get the prefix for resource loading.- Returns:
- the prefix for loading resources.
-
getName
Get the name of this theme.- Returns:
- the name of the theme.
-
getDisplayName
Get the display name of this theme.- Returns:
- the display name of the theme.
-
getLoaderClass
The class used to determine the runtime location of resources. It is advised to explicitly return the class instead of usingObject.getClass()to protect against extending the theme.- Returns:
- the loader class.
-
getPropertyFilePath
Get the path for the file [prefix]_[name].properties in the themes resource location.- Parameters:
name- the of the file.- Returns:
- the path relative to the location of
getLoaderClass().
-
loadPropertyFile
Load the theme property file with the specified name. The name gets resolved to the resource location of the theme adds the theme property prefix and appends ".properties" e.g. "test" -> [resource_location]/[prefix_of_theme]_test.properties.- Parameters:
name- the properties name.- Returns:
- the properties.
-
loadPropertyFile
Load the theme property file with the specified name. The name gets resolved to the resource location of the theme adds the theme property prefix and appends ".properties" e.g. "test" -> [resource_location]/[prefix_of_theme]_test.properties.- Parameters:
name- the properties name.silent- if true no warnings are issues if the file is not present. Instead, an empty property instance is returned.- Returns:
- the properties.
-
useCustomDecorations
public boolean useCustomDecorations()Returns whether this theme should use custom decorations if available.- Returns:
- true if decoration should be used.
-
supportsCustomAccentColor
public boolean supportsCustomAccentColor()Returns whether this theme supports custom accent colors.- Returns:
- true if supported.
-
supportsCustomSelectionColor
public boolean supportsCustomSelectionColor()Returns whether this theme supports custom selection colors.- Returns:
- true if supported.
-
getColorToneRule
Returns the style rule for this theme.- Returns:
- the style rule.
-
getContrastRule
Returns contrast rule for the theme.- Returns:
- the contrast rule.
-
getFontSizeRule
Get the font size rule for this theme.- Returns:
- the font size rule.
-
getAccentColorRule
Get the accent color rule.- Returns:
- the accent color rule.
-
compareTo
- Specified by:
compareToin interfaceComparable<Theme>
-
compare
- Specified by:
comparein interfaceComparator<Theme>
-
getThemeClass
-
equals
- Specified by:
equalsin interfaceComparator<Theme>- Overrides:
equalsin classObject
-
hashCode
public int hashCode() -
appearsEqualTo
Returns whether the appearance of the given theme is equal to the appearance if [this].- Parameters:
theme- the other theme.- Returns:
- true if they appear equal.
-