Class UIDefaultsLoader
java.lang.Object
com.formdev.flatlaf.UIDefaultsLoader
Load UI defaults from properties files associated to Flat LaF classes and add to UI defaults.
Each class that extend the LaF class may have its own .properties file
in the same package as the class. Properties from superclasses are loaded
first to give subclasses a chance to override defaults.
E.g. if running FlatDarkLaf, then the FlatLaf.properties is loaded first
and FlatDarkLaf.properties loaded second.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static Map<Class<?>, UIDefaultsLoader.ValueType> (package private) static final String(package private) static final Stringprivate static Map<String, UIDefaultsLoader.ValueType> private static final Stringprivate static intprivate static final Stringprivate static Map<String, ColorUIResource> private static final UIDefaultsLoader.ValueType[]private static final Stringprivate static final Stringprivate static final Stringprivate static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static Class<?> findClass(String className, List<ClassLoader> addonClassLoaders) getLafClassesForDefaultsLoading(Class<?> lookAndFeelClass) private static ColorUIResourcegetSystemColor(String name) private static ObjectinvokeConstructorOrStaticMethod(Executable[] constructorsOrMethods, List<String> parts, Function<String, String> resolver) (package private) static ObjectlazyUIManagerGet(String uiKey) For use in LazyValue to get value for given key from UIManager and report error if not found.(package private) static voidloadDefaultsFromProperties(List<Class<?>> lafClasses, List<FlatDefaultsAddon> addons, Consumer<Properties> intellijThemesHook, Properties additionalDefaults, boolean dark, UIDefaults defaults) (package private) static voidlogParseError(String key, String value, RuntimeException ex, boolean severe) private static IllegalArgumentExceptionnewInvalidColorException(String value) private static UIDefaults.LazyValuenewLazyColorFunction(String uiKey, ColorFunctions.ColorFunction function) private static IllegalArgumentException(package private) static PropertiesnewUIProperties(boolean dark) private static BooleanparseBoolean(String value) private static ObjectparseBorder(String value, Function<String, String> resolver, List<ClassLoader> addonClassLoaders) private static CharacterparseCharacter(String value) private static ObjectparseClass(String value, List<ClassLoader> addonClassLoaders) (package private) static ColorUIResourceparseColor(String value) Parses a hex color in#RGB,#RGBA,#RRGGBBor#RRGGBBAAformat and returns it as color object.private static ObjectSyntax: changeHue(color,value[,options]) or changeSaturation(color,value[,options]) or changeLightness(color,value[,options]) or changeAlpha(color,value[,options]) - color: a color (e.g.private static ObjectSyntax: contrast(color,dark,light[,threshold]) - color: a color to compare against - dark: a designated dark color (e.g.private static ObjectSyntax: fade(color,amount[,options]) - color: a color (e.g.private static ObjectparseColorFunctions(String value, Function<String, String> resolver) private static ObjectparseColorHSLIncreaseDecrease(int hslIndex, boolean increase, List<String> params, Function<String, String> resolver) Syntax: lighten(color,amount[,options]) or darken(color,amount[,options]) or saturate(color,amount[,options]) or desaturate(color,amount[,options]) or fadein(color,amount[,options]) or fadeout(color,amount[,options]) - color: a color (e.g.private static ColorUIResourceparseColorHslOrHsla(boolean hasAlpha, List<String> params) Syntax: hsl(hue,saturation,lightness) or hsla(hue,saturation,lightness,alpha) - hue: an integer 0-360 representing degrees - saturation: a percentage 0-100% - lightness: a percentage 0-100% - alpha: a percentage 0-100%private static ObjectSyntax: if(condition,trueValue,falseValue)private static ObjectSyntax: lazy(uiKey)private static ObjectSyntax: mix(color1,color2[,weight][,options]) or tint(color[,weight][,options]) or shade(color[,weight][,options]) - color1: a color (e.g.private static ObjectparseColorOrFunction(String value, Function<String, String> resolver) private static ColorUIResourceSyntax: over(foreground,background) - foreground: a foreground color (e.g.(package private) static intparseColorRGBA(String value) Parses a hex color in#RGB,#RGBA,#RRGGBBor#RRGGBBAAformat and returns it asrgbainteger suitable forColor, which includes alpha component in bits 24-31.private static ColorUIResourceSyntax: rgb(red,green,blue) or rgba(red,green,blue,alpha) - red: an integer 0-255 or a percentage 0-100% - green: an integer 0-255 or a percentage 0-100% - blue: an integer 0-255 or a percentage 0-100% - alpha: an integer 0-255 or a percentage 0-100%private static ObjectSyntax: spin(color,angle[,options]) - color: a color (e.g.private static ObjectSyntax: systemColor(name[,defaultValue]) - name: system color name - defaultValue: default color value used if system color is not availableprivate static booleanparseCondition(String condition, Function<String, String> resolver, List<ClassLoader> addonClassLoaders) private static DimensionparseDimension(String value) private static FloatparseFloat(String value) private static ObjectSyntax: [normal] [bold|+bold|-bold] [italic|+italic|-italic] [|+ |- | %] [family[, family]] [$baseFontKey] private static ObjectparseFunctionBaseColor(String colorStr, ColorFunctions.ColorFunction function, boolean derived, Function<String, String> resolver) private static ObjectparseGrayFilter(String value) private static InsetsparseInsets(String value) private static ObjectparseInstance(String value, Function<String, String> resolver, List<ClassLoader> addonClassLoaders) private static IntegerparseInteger(String value) private static IntegerparseInteger(String value, int min, int max, boolean allowPercentage) private static NumberparseIntegerOrFloat(String value) private static Object[]private static intparsePercentage(String value) private static UIDefaults.ActiveValueparseScaledDimension(String value) private static UIDefaults.ActiveValueparseScaledFloat(String value) private static UIDefaults.ActiveValueparseScaledInsets(String value) private static UIDefaults.ActiveValueparseScaledInteger(String value) (package private) static ObjectparseValue(String key, String value, Class<?> valueType) (package private) static ObjectparseValue(String key, String value, Class<?> javaValueType, UIDefaultsLoader.ValueType[] resultValueType, Function<String, String> resolver, List<ClassLoader> addonClassLoaders) (package private) static StringresolveValue(String value, Function<String, String> propertiesGetter) (package private) static StringresolveValueFromUIManager(String value) (package private) static StringsimpleClassName(Class<?> cls) Similar to Class.getSimpleName(), but includes enclosing class for nested classes.splitFunctionParams(String str, char delim) Splits function parameters and allows using functions as parameters.
-
Field Details
-
TYPE_PREFIX
- See Also:
-
TYPE_PREFIX_END
- See Also:
-
VARIABLE_PREFIX
- See Also:
-
PROPERTY_PREFIX
- See Also:
-
OPTIONAL_PREFIX
- See Also:
-
WILDCARD_PREFIX
- See Also:
-
KEY_VARIABLES
- See Also:
-
KEY_PROPERTIES
- See Also:
-
parseColorDepth
private static int parseColorDepth -
systemColorCache
-
fontCache
-
tempResultValueType
-
javaValueTypes
-
knownValueTypes
-
-
Constructor Details
-
UIDefaultsLoader
UIDefaultsLoader()
-
-
Method Details
-
getLafClassesForDefaultsLoading
-
newUIProperties
-
loadDefaultsFromProperties
static void loadDefaultsFromProperties(List<Class<?>> lafClasses, List<FlatDefaultsAddon> addons, Consumer<Properties> intellijThemesHook, Properties additionalDefaults, boolean dark, UIDefaults defaults) -
simpleClassName
-
logParseError
-
resolveValue
static String resolveValue(String value, Function<String, String> propertiesGetter) throws IllegalArgumentException- Throws:
IllegalArgumentException
-
resolveValueFromUIManager
- Throws:
IllegalArgumentException
-
parseValue
static Object parseValue(String key, String value, Class<?> valueType) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
parseValue
static Object parseValue(String key, String value, Class<?> javaValueType, UIDefaultsLoader.ValueType[] resultValueType, Function<String, String> resolver, List<ClassLoader> addonClassLoaders) throws IllegalArgumentException- Throws:
IllegalArgumentException
-
parseCondition
-
parseBorder
private static Object parseBorder(String value, Function<String, String> resolver, List<ClassLoader> addonClassLoaders) throws IllegalArgumentException- Throws:
IllegalArgumentException
-
parseInstance
-
parseClass
-
findClass
private static Class<?> findClass(String className, List<ClassLoader> addonClassLoaders) throws ClassNotFoundException - Throws:
ClassNotFoundException
-
parseInsets
- Throws:
IllegalArgumentException
-
parseDimension
- Throws:
IllegalArgumentException
-
parseColorOrFunction
private static Object parseColorOrFunction(String value, Function<String, String> resolver) throws IllegalArgumentException- Throws:
IllegalArgumentException
-
parseColor
Parses a hex color in#RGB,#RGBA,#RRGGBBor#RRGGBBAAformat and returns it as color object.- Throws:
IllegalArgumentException
-
parseColorRGBA
Parses a hex color in#RGB,#RGBA,#RRGGBBor#RRGGBBAAformat and returns it asrgbainteger suitable forColor, which includes alpha component in bits 24-31.- Throws:
IllegalArgumentException
-
newInvalidColorException
-
parseColorFunctions
private static Object parseColorFunctions(String value, Function<String, String> resolver) throws IllegalArgumentException- Throws:
IllegalArgumentException
-
parseColorIf
private static Object parseColorIf(String value, List<String> params, Function<String, String> resolver) throws IllegalArgumentExceptionSyntax: if(condition,trueValue,falseValue)This "if" function is only used if the "if" is passed as parameter to another color function. Otherwise, the general "if" function is used.
- Throws:
IllegalArgumentException
-
parseColorLazy
private static Object parseColorLazy(String value, List<String> params, Function<String, String> resolver) throws IllegalArgumentExceptionSyntax: lazy(uiKey)This "lazy" function is only used if the "lazy" is passed as parameter to another color function. Otherwise, the general "lazy" function is used.
Note: The color is resolved immediately, not lazy, because it is passed as parameter to another color function. So e.g.
darken(lazy(List.background), 10%)is the same asdarken($List.background, 10%).Only useful if a property is defined as lazy and that property is used in another property's color function. E.g.
someProperty = lazy(List.background) anotherProperty = darken($someProperty, 10%)- Throws:
IllegalArgumentException
-
parseColorSystemColor
private static Object parseColorSystemColor(String value, List<String> params, Function<String, String> resolver) throws IllegalArgumentExceptionSyntax: systemColor(name[,defaultValue]) - name: system color name - defaultValue: default color value used if system color is not available- Throws:
IllegalArgumentException
-
getSystemColor
-
parseColorRgbOrRgba
private static ColorUIResource parseColorRgbOrRgba(boolean hasAlpha, List<String> params, Function<String, String> resolver) throws IllegalArgumentExceptionSyntax: rgb(red,green,blue) or rgba(red,green,blue,alpha) - red: an integer 0-255 or a percentage 0-100% - green: an integer 0-255 or a percentage 0-100% - blue: an integer 0-255 or a percentage 0-100% - alpha: an integer 0-255 or a percentage 0-100%- Throws:
IllegalArgumentException
-
parseColorHslOrHsla
private static ColorUIResource parseColorHslOrHsla(boolean hasAlpha, List<String> params) throws IllegalArgumentException Syntax: hsl(hue,saturation,lightness) or hsla(hue,saturation,lightness,alpha) - hue: an integer 0-360 representing degrees - saturation: a percentage 0-100% - lightness: a percentage 0-100% - alpha: a percentage 0-100%- Throws:
IllegalArgumentException
-
parseColorHSLIncreaseDecrease
private static Object parseColorHSLIncreaseDecrease(int hslIndex, boolean increase, List<String> params, Function<String, String> resolver) throws IllegalArgumentExceptionSyntax: lighten(color,amount[,options]) or darken(color,amount[,options]) or saturate(color,amount[,options]) or desaturate(color,amount[,options]) or fadein(color,amount[,options]) or fadeout(color,amount[,options]) - color: a color (e.g. #f00) or a color function - amount: percentage 0-100% - options: [relative] [autoInverse] [noAutoInverse] [derived] [lazy]- Throws:
IllegalArgumentException
-
parseColorFade
private static Object parseColorFade(List<String> params, Function<String, String> resolver) throws IllegalArgumentExceptionSyntax: fade(color,amount[,options]) - color: a color (e.g. #f00) or a color function - amount: percentage 0-100% - options: [derived] [lazy]- Throws:
IllegalArgumentException
-
parseColorSpin
private static Object parseColorSpin(List<String> params, Function<String, String> resolver) throws IllegalArgumentExceptionSyntax: spin(color,angle[,options]) - color: a color (e.g. #f00) or a color function - angle: number of degrees to rotate - options: [derived] [lazy]- Throws:
IllegalArgumentException
-
parseColorChange
private static Object parseColorChange(int hslIndex, List<String> params, Function<String, String> resolver) throws IllegalArgumentExceptionSyntax: changeHue(color,value[,options]) or changeSaturation(color,value[,options]) or changeLightness(color,value[,options]) or changeAlpha(color,value[,options]) - color: a color (e.g. #f00) or a color function - value: for hue: number of degrees; otherwise: percentage 0-100% - options: [derived] [lazy]- Throws:
IllegalArgumentException
-
parseColorMix
private static Object parseColorMix(String color1Str, List<String> params, Function<String, String> resolver) throws IllegalArgumentExceptionSyntax: mix(color1,color2[,weight][,options]) or tint(color[,weight][,options]) or shade(color[,weight][,options]) - color1: a color (e.g. #f00) or a color function - color2: a color (e.g. #f00) or a color function - weight: the weight (in range 0-100%) to mix the two colors larger weight uses more of first color, smaller weight more of second color - options: [derived] [lazy]- Throws:
IllegalArgumentException
-
parseColorContrast
private static Object parseColorContrast(List<String> params, Function<String, String> resolver) throws IllegalArgumentExceptionSyntax: contrast(color,dark,light[,threshold]) - color: a color to compare against - dark: a designated dark color (e.g. #000) or a color function - light: a designated light color (e.g. #fff) or a color function - threshold: the threshold (in range 0-100%) to specify where the transition from "dark" to "light" is (default is 43%)- Throws:
IllegalArgumentException
-
parseColorOver
private static ColorUIResource parseColorOver(List<String> params, Function<String, String> resolver) throws IllegalArgumentExceptionSyntax: over(foreground,background) - foreground: a foreground color (e.g. #f00) or a color function; the alpha of this color is used as weight to mix the two colors - background: a background color (e.g. #f00) or a color function- Throws:
IllegalArgumentException
-
parseFunctionBaseColor
private static Object parseFunctionBaseColor(String colorStr, ColorFunctions.ColorFunction function, boolean derived, Function<String, String> resolver) throws IllegalArgumentException- Throws:
IllegalArgumentException
-
newLazyColorFunction
private static UIDefaults.LazyValue newLazyColorFunction(String uiKey, ColorFunctions.ColorFunction function) -
parseFont
Syntax: [normal] [bold|+bold|-bold] [italic|+italic|-italic] [|+ |- | %] [family[, family]] [$baseFontKey] - Throws:
IllegalArgumentException
-
parsePercentage
private static int parsePercentage(String value) throws IllegalArgumentException, NumberFormatException -
parseBoolean
- Throws:
IllegalArgumentException
-
parseCharacter
- Throws:
IllegalArgumentException
-
parseInteger
private static Integer parseInteger(String value, int min, int max, boolean allowPercentage) throws IllegalArgumentException, NumberFormatException -
parseInteger
- Throws:
NumberFormatException
-
parseIntegerOrFloat
- Throws:
NumberFormatException
-
parseFloat
- Throws:
NumberFormatException
-
parseScaledInteger
- Throws:
NumberFormatException
-
parseScaledFloat
- Throws:
NumberFormatException
-
parseScaledInsets
private static UIDefaults.ActiveValue parseScaledInsets(String value) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
parseScaledDimension
private static UIDefaults.ActiveValue parseScaledDimension(String value) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
parseGrayFilter
- Throws:
IllegalArgumentException
-
splitFunctionParams
-
invokeConstructorOrStaticMethod
-
parseMethodParams
-
lazyUIManagerGet
-
newMissingParametersException
-