Skip to content

ThemeManager Class

Natalie L edited this page Dec 5, 2024 · 1 revision

The ThemeManager class is part of the services package (package org.example.globalgoodsindex.services). It manages the application's UI themes by applying and saving user preferences. It uses AtlantFX themes (e.g., Nord, Primer) to provide a modern, visually appealing interface.

The class registers themes and allows switching between them based on the user's choice.

Methods

registerThemes

Purpose:

Registers the available themes and their associated stylesheets.

Description:

  • Maps theme names (e.g., PrimerLight, NordDark) to the corresponding stylesheets provided by AtlantFX .
  • This method is called when the ThemeManager is initialized to make sure the themes are available for application.

Example Usage:

ThemeManager themeManager = new ThemeManager(preferencesManager);

applyTheme

Purpose:

Applies the selected theme to the application interface.

Description:

  • Retrieves the stylesheet for the selected theme from the themeStylesheets map and sets it as the application's user agent stylesheet.
  • Saves the selected theme using the preferencesManager for future use.

Example Usage:

themeManager.applyTheme("NordDark");

getSavedTheme

Purpose:

Fetches the saved theme from the user's preferences.

Description:

  • Retrieves the theme previously saved by the preferencesManager.

Example Usage:

String savedTheme = themeManager.getSavedTheme();

Clone this wiki locally