Class ChartAssets

java.lang.Object
com.arbergashi.charts.util.ChartAssets

public final class ChartAssets extends Object
Central configuration registry for ArberCharts.

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 Details

    • getTranslation

      public static String getTranslation(String key)
      Returns a translation for the given key.
      Parameters:
      key - translation key (must not be null)
      Returns:
      translated text, or a fallback string in the form "!" + key + "!"
    • getTranslation

      public static String getTranslation(String key, Locale locale)
      Returns a translation for the given key.

      Note: The locale parameter is reserved for future i18n support. The current implementation ignores it and uses the same lookup as getTranslation(String).

      Parameters:
      key - translation key (must not be null)
      locale - locale hint (currently ignored)
      Returns:
      translated text, or a fallback string in the form "!" + key + "!"
    • setProperty

      public static void setProperty(String key, String value)
      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 be null or blank)
      value - property value (must not be null)
      Throws:
      NullPointerException - if key or value is null
      IllegalArgumentException - if key is empty or blank
    • removeProperty

      public static void removeProperty(String key)
      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 be null or blank)
    • getScaledIcon

      public static Icon getScaledIcon(String name, float scale)
      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 identifier
      scale - scaling factor (e.g., 1.0 for 100%)
      Returns:
      the icon, or null if not available
    • getString

      public static String getString(String key, String defaultValue)
      Returns a string property.
      Parameters:
      key - property key
      defaultValue - value returned when the key is not present
      Returns:
      the property value, or defaultValue
    • getFloat

      public static float getFloat(String key, float defaultValue)
      Returns a float property.
      Parameters:
      key - property key
      defaultValue - value returned when the key is not present or cannot be parsed
      Returns:
      parsed float value
    • getInt

      public static int getInt(String key, int defaultValue)
      Returns an integer property.
      Parameters:
      key - property key
      defaultValue - value returned when the key is not present or cannot be parsed
      Returns:
      parsed integer value
    • getBoolean

      public static boolean getBoolean(String key, boolean defaultValue)
      Returns a boolean property.
      Parameters:
      key - property key
      defaultValue - 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

      public static Color getColor(String key, Color defaultColor)
      Returns a color property.
      Parameters:
      key - property key
      defaultColor - value returned when the key is not present or cannot be parsed
      Returns:
      parsed color value
    • getUIFloat

      public static float getUIFloat(String key, float defaultValue)
      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

      public static int getUIInt(String key, int defaultValue)
      Returns an int value from UIManager.
      Parameters:
      key - UIManager key
      defaultValue - fallback if key is missing or not a number
      Returns:
      the int value
    • getUIColor

      public static Color getUIColor(String key, Color defaultColor)
      Returns a Color from UIManager.
      Parameters:
      key - UIManager key
      defaultColor - fallback if key is missing
      Returns:
      the Color value
    • getUIBoolean

      public static boolean getUIBoolean(String key, boolean defaultValue)
      Returns a boolean from UIManager.
      Parameters:
      key - UIManager key
      defaultValue - fallback if key is missing
      Returns:
      the boolean value