Class ThemeUpdater

java.lang.Object
com.j3d.ui.theme.updator.ThemeUpdater

public class ThemeUpdater extends Object
Manages the updating of UI component properties based on a theme. It holds a collection of Locator objects, each linking a specific theme property (represented by J3DTheme) to a method that sets a UI component's colour property. When update() is called, all registered components are updated with their respective theme colours.
Author:
Lehlogonolo Poole
See Also:
  • Field Details

    • entries

      private final ArrayList<Locator> entries
      A list of Locator objects, each representing a UI component property that needs to be updated when the theme changes.
  • Constructor Details

    • ThemeUpdater

      public ThemeUpdater()
      Constructs a new ThemeUpdater. Initializes an empty list of entries.
  • Method Details

    • remove

      public void remove(ArrayList<Locator> l2)
      Removes a collection of Locator objects from the updater.
      Parameters:
      l2 - The ArrayList of Locator objects to be removed.
    • remove

      public void remove(Locator l)
      Removes a single Locator object from the updater.
      Parameters:
      l - The Locator object to be removed.
    • add

      public Locator add(J3DTheme themeProperty, Consumer<Color> propertySetter)
      Adds a new Locator to the updater, linking a theme property to a consumer that sets a color property on a UI component.
      Parameters:
      themeProperty - The J3DTheme enum value representing the specific theme color property to track.
      propertySetter - A Consumer that accepts a Color and applies it to the corresponding UI component property.
      Returns:
      The newly created Locator object that was added to the updater.
    • update

      public void update()
      Iterates through all registered Locator objects and updates their associated UI component properties with the current color defined by their respective J3DTheme property. This method should be called whenever the theme changes or when components need to reflect the current theme.