Class ChartAssets
This is a small, thread-safe key/value store intended for framework-level tunables (e.g., default line widths, alpha values, thresholds). Reads are optimized via internal caches for parsed primitives.
Theme Integration: Methods prefixed with "getUI" read from UIManager,
enabling seamless integration with FlatLaf and other pluggable Look&Feel themes.
- Since:
- 2026-01-01
- Version:
- 1.0.0
- Author:
- Arber Gashi
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidClears all cached parsed values.static booleangetBoolean(String key, boolean defaultValue) Returns a boolean property.static ColorReturns a color property.static floatReturns a float property.static intReturns an integer property.static IcongetScaledIcon(String name, float scale) Returns a scaled icon by name.static StringReturns a string property.static StringgetTranslation(String key) Returns a translation for the given key.static StringgetTranslation(String key, Locale locale) Returns a translation for the given key.static booleangetUIBoolean(String key, boolean defaultValue) Returns a boolean from UIManager.static ColorgetUIColor(String key, Color defaultColor) Returns a Color from UIManager.static floatgetUIFloat(String key, float defaultValue) Returns a float value from UIManager.static intReturns an int value from UIManager.static voidremoveProperty(String key) Removes a property key.static voidsetProperty(String key, String value) Sets a property key/value pair.
-
Method Details
-
getTranslation
-
getTranslation
Returns a translation for the given key.Note: The
localeparameter is reserved for future i18n support. The current implementation ignores it and uses the same lookup asgetTranslation(String).- Parameters:
key- translation key (must not benull)locale- locale hint (currently ignored)- Returns:
- translated text, or a fallback string in the form
"!" + key + "!"
-
setProperty
Sets a property key/value pair.Changing a property invalidates any cached parsed values (float/int/boolean) for this key.
- Parameters:
key- property key (must not benullor blank)value- property value (must not benull)- Throws:
NullPointerException- ifkeyorvalueisnullIllegalArgumentException- ifkeyis empty or blank
-
removeProperty
Removes a property key.After removal, callers will observe default values again (because the property is no longer present). This method also invalidates parsed caches for the key.
Typical use cases:
- Test cleanup between runs
- Resetting user overrides back to framework defaults
- Parameters:
key- property key (must not benullor blank)
-
getScaledIcon
Returns a scaled icon by name.Framework note: This is a stub that exists for API completeness. Swing-based applications should provide their own icon loading strategy.
- Parameters:
name- icon identifierscale- scaling factor (e.g., 1.0 for 100%)- Returns:
- the icon, or
nullif not available
-
getString
-
getFloat
Returns a float property.- Parameters:
key- property keydefaultValue- value returned when the key is not present or cannot be parsed- Returns:
- parsed float value
-
getInt
Returns an integer property.- Parameters:
key- property keydefaultValue- value returned when the key is not present or cannot be parsed- Returns:
- parsed integer value
-
getBoolean
Returns a boolean property.- Parameters:
key- property keydefaultValue- value returned when the key is not present- Returns:
- parsed boolean value
-
clearCache
public static void clearCache()Clears all cached parsed values.This does not modify the underlying
Properties; it only clears the caches so subsequent reads will re-parse values. -
getColor
-
getUIFloat
Returns a float value from UIManager.- Parameters:
key- UIManager key (e.g., "Chart.analysisGrid.minorAlpha")defaultValue- fallback if key is missing or not a number- Returns:
- the float value
-
getUIInt
Returns an int value from UIManager.- Parameters:
key- UIManager keydefaultValue- fallback if key is missing or not a number- Returns:
- the int value
-
getUIColor
-
getUIBoolean
Returns a boolean from UIManager.- Parameters:
key- UIManager keydefaultValue- fallback if key is missing- Returns:
- the boolean value
-