Class Theme
- All Implemented Interfaces:
Serializable,Comparable<Theme>
- Direct Known Subclasses:
DarculaTheme,HighContrastDarkTheme,HighContrastLightTheme,IntelliJTheme,OneDarkTheme,SolarizedDarkTheme,SolarizedLightTheme,ThemeDelegate
Theme is responsible for providing colors and customizing properties used by the
darklaf look and feel.- See Also:
-
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) intcopy()Creates a copy of this theme.voidcustomizeGlobals(Properties properties, UIDefaults currentDefaults, com.github.weisj.darklaf.properties.icons.IconResolver iconResolver) Customize the global values.voidcustomizeIconTheme(Properties properties, UIDefaults currentDefaults, com.github.weisj.darklaf.properties.icons.IconResolver iconResolver) Customize the icon defaults.voidcustomizePlatformProperties(Properties properties, UIDefaults currentDefaults, com.github.weisj.darklaf.properties.icons.IconResolver iconResolver) Customize the platform defaults.voidcustomizeUIProperties(Properties properties, UIDefaults currentDefaults, com.github.weisj.darklaf.properties.icons.IconResolver iconResolver) Customize the ui defaults.derive(com.github.weisj.darklaf.theme.spec.FontSizeRule fontSizeRule, com.github.weisj.darklaf.theme.spec.FontPrototype fontPrototype, com.github.weisj.darklaf.theme.spec.AccentColorRule accentColorRule) Create a derived theme with the givenFontSizeRuleandAccentColorRule.booleancom.github.weisj.darklaf.theme.spec.AccentColorRuleGet the accent color rule.abstract com.github.weisj.darklaf.theme.spec.ColorToneRuleReturns the style rule for this theme.com.github.weisj.darklaf.theme.spec.ContrastRuleReturns contrast rule for the theme.Get the display name of this theme.com.github.weisj.darklaf.theme.spec.FontPrototypeGet the font prototype.com.github.weisj.darklaf.theme.spec.FontSizeRuleGet 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 final 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 final voidloadCustomProperties(String propertySuffix, Properties properties, UIDefaults currentDefaults, com.github.weisj.darklaf.properties.icons.IconResolver iconResolver) Load custom properties that are located undergetResourcePath(), with the namegetPrefix()_{propertySuffix}.propertiesvoidloadDefaults(Properties properties, UIDefaults currentDefaults, com.github.weisj.darklaf.properties.icons.IconResolver iconResolver) Load the theme defaults.voidloadIconTheme(Properties properties, UIDefaults currentDefaults, com.github.weisj.darklaf.properties.icons.IconResolver iconResolver) Load the general properties file for the icon themes.final PropertiesloadPropertyFile(String name) Load the theme property file with the specified name.final PropertiesloadPropertyFile(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 final 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.
-
Constructor Details
-
Theme
public Theme() -
Theme
public Theme(com.github.weisj.darklaf.theme.spec.FontSizeRule fontSizeRule, com.github.weisj.darklaf.theme.spec.FontPrototype fontPrototype, com.github.weisj.darklaf.theme.spec.AccentColorRule accentColorRule)
-
-
Method Details
-
baseThemeOf
-
withDisplayName
Create a derived theme with the given display name.- Parameters:
newName- the new display name.- Returns:
- the derived theme.
-
derive
public Theme derive(com.github.weisj.darklaf.theme.spec.FontSizeRule fontSizeRule, com.github.weisj.darklaf.theme.spec.FontPrototype fontPrototype, com.github.weisj.darklaf.theme.spec.AccentColorRule accentColorRule) Create a derived theme with the givenFontSizeRuleandAccentColorRule.- Parameters:
fontSizeRule- the font size rule.fontPrototype- the font prototype.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
public void loadDefaults(Properties properties, UIDefaults currentDefaults, com.github.weisj.darklaf.properties.icons.IconResolver iconResolver) 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.iconResolver- the icon resolver.
-
customizeGlobals
public void customizeGlobals(Properties properties, UIDefaults currentDefaults, com.github.weisj.darklaf.properties.icons.IconResolver iconResolver) 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
public void customizeIconTheme(Properties properties, UIDefaults currentDefaults, com.github.weisj.darklaf.properties.icons.IconResolver iconResolver) 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
public void loadIconTheme(Properties properties, UIDefaults currentDefaults, com.github.weisj.darklaf.properties.icons.IconResolver iconResolver) 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.iconResolver- the icon resolver.
-
customizePlatformProperties
public void customizePlatformProperties(Properties properties, UIDefaults currentDefaults, com.github.weisj.darklaf.properties.icons.IconResolver iconResolver) 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
public void customizeUIProperties(Properties properties, UIDefaults currentDefaults, com.github.weisj.darklaf.properties.icons.IconResolver iconResolver) 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, com.github.weisj.darklaf.properties.icons.IconResolver iconResolver) 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.iconResolver- the icon resolver.
-
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
public abstract com.github.weisj.darklaf.theme.spec.ColorToneRule getColorToneRule()Returns the style rule for this theme.- Returns:
- the style rule.
-
getContrastRule
public com.github.weisj.darklaf.theme.spec.ContrastRule getContrastRule()Returns contrast rule for the theme.- Returns:
- the contrast rule.
-
getFontSizeRule
public com.github.weisj.darklaf.theme.spec.FontSizeRule getFontSizeRule()Get the font size rule for this theme.- Returns:
- the font size rule.
-
getFontPrototype
public com.github.weisj.darklaf.theme.spec.FontPrototype getFontPrototype()Get the font prototype.- Returns:
- the font prototype
-
getAccentColorRule
public com.github.weisj.darklaf.theme.spec.AccentColorRule getAccentColorRule()Get the accent color rule.- Returns:
- the accent color rule.
-
compareTo
- Specified by:
compareToin interfaceComparable<Theme>
-
getThemeClass
-
equals
-
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.
-