SudokuFX
Loading...
Searching...
No Matches
fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel Class Reference

ViewModel managing menu options UI state and accessibility strings. More...

+ Collaboration diagram for fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel:

Public Member Functions

 MenuBackgroundViewModel ()
 
StringBinding backgroundAccessibleTextProperty ()
 
StringBinding backgroundColorAccessibleTextProperty ()
 
StringBinding backgroundColorRoleDescriptionProperty ()
 
StringBinding backgroundColorTooltipProperty ()
 
StringBinding backgroundImageAccessibleTextProperty ()
 
StringBinding backgroundImageRoleDescriptionProperty ()
 
StringBinding backgroundImageTextProperty ()
 
StringBinding backgroundImageTooltipProperty ()
 
StringBinding backgroundMenuMaxiAccessibleTextProperty ()
 
StringBinding backgroundMenuMaxiRoleDescriptionProperty ()
 
StringBinding backgroundMenuMaxiTextProperty ()
 
StringBinding backgroundMenuMaxiTooltipProperty ()
 
StringBinding backgroundOpacityAccessibleTextProperty ()
 
StringBinding backgroundOpacityRoleDescriptionProperty ()
 
StringBinding backgroundOpacityTextProperty ()
 
StringBinding backgroundOpacityTooltipProperty ()
 
StringBinding backgroundReduceAccessibleTextProperty ()
 
StringBinding backgroundReduceTextProperty ()
 
StringBinding backgroundReduceTooltipProperty ()
 
StringBinding backgroundRoleDescriptionProperty ()
 
StringBinding backgroundTextProperty ()
 
StringBinding backgroundTooltipProperty ()
 
File chooseBackgroundImage (Stage primaryStage)
 Opens file chooser dialog for options image selection.
 
boolean getOpaqueMode ()
 Gets the grid opacity mode.
 
void handleFileImageChooser (File selectedFile, ToasterVBox toaster, SpinnerGridPane spinner, GridPane sudokuFX)
 Handles image file selection by validating the file format and starting the image loading process.
 
void init (GridPane sudokuFX, ColorPicker menuBackgroundButtonColor, ToasterVBox toaster, SpinnerGridPane spinner)
 Initializes the GridPane options with settings from database.
 
boolean toggleGridOpacity ()
 Toggles grid opacity mode and returns the new state.
 
void updateBackgroundColorAndApply (GridPane sudokuFX, Color color)
 Sets the options color of the given GridPane.
 

Package Functions

void onImageTaskError (WorkerStateEvent e, ToasterVBox toaster, SpinnerGridPane spinner)
 Called when the image loading task fails.
 

Private Member Functions

StringBinding createFormattedBinding (String key, String suffixKey)
 Creates a StringBinding that returns the concatenation of two localized strings (main key and suffix key), updating automatically when the locale changes.
 
FileChooser createImageFileChooser ()
 Creates configured FileChooser for image files.
 
StringBinding createStringBinding (String key)
 Creates a StringBinding that returns the localized string for the given key, updating automatically when the locale changes.
 
void loadImage (File selectedFile, ToasterVBox toaster, SpinnerGridPane spinner, GridPane sudokuFX)
 Starts the asynchronous image loading and resizing task.
 
void onImageTaskComplete (Task< BackgroundImage > backgroundTask, ToasterVBox toaster, SpinnerGridPane spinner, GridPane sudokuFX)
 Called upon successful completion of the image loading task.
 
void setColorFromModel (GridPane sudokuFX, ColorPicker menuBackgroundButtonColor, String colorValueFromModel)
 Applies a options color to the GridPane and sets it in the ColorPicker.
 
void setOpaqueMode (boolean opaque)
 Sets the grid opacity mode.
 

Private Attributes

final StringBinding backgroundAccessibleText
 
final StringBinding backgroundColorAccessibleText
 
final StringBinding backgroundColorRoleDescription
 
final StringBinding backgroundColorTooltip
 
final StringBinding backgroundImageAccessibleText
 
final StringBinding backgroundImageRoleDescription
 
final StringBinding backgroundImageText
 
final StringBinding backgroundImageTooltip
 
final StringBinding backgroundMenuMaxiAccessibleText
 
final StringBinding backgroundMenuMaxiRoleDescription
 
final StringBinding backgroundMenuMaxiText
 
final StringBinding backgroundMenuMaxiTooltip
 
final StringBinding backgroundOpacityAccessibleText
 
final StringBinding backgroundOpacityRoleDescription
 
final StringBinding backgroundOpacityText
 
final StringBinding backgroundOpacityTooltip
 
final StringBinding backgroundReduceAccessibleText
 
final StringBinding backgroundReduceText
 
final StringBinding backgroundReduceTooltip
 
final StringBinding backgroundRoleDescription
 
final StringBinding backgroundText
 
final StringBinding backgroundTooltip
 
final ImageUtils imageUtils
 
boolean isOpaqueMode = false
 

Static Private Attributes

static final int HEX_RADIX = 16
 
static final Logger LOG = LoggerFactory.getLogger(MenuBackgroundViewModel.class)
 
static final String ROLE_CLOSED = "menu.accessibility.role.description.closed"
 
static final String ROLE_OPENED = "menu.accessibility.role.description.opened"
 
static final String ROLE_SUBMENU_OPTION
 

Detailed Description

ViewModel managing menu options UI state and accessibility strings.

Provides localized StringBindings for button labels, tooltips, and roles, updating automatically on locale changes. Supports options color and image initialization and updates, including asynchronous image loading with user feedback.

Constructor & Destructor Documentation

◆ MenuBackgroundViewModel()

fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.MenuBackgroundViewModel ( )
+ Here is the call graph for this function:

Member Function Documentation

◆ backgroundAccessibleTextProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundAccessibleTextProperty ( )

◆ backgroundColorAccessibleTextProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundColorAccessibleTextProperty ( )

◆ backgroundColorRoleDescriptionProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundColorRoleDescriptionProperty ( )

◆ backgroundColorTooltipProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundColorTooltipProperty ( )

◆ backgroundImageAccessibleTextProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundImageAccessibleTextProperty ( )

◆ backgroundImageRoleDescriptionProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundImageRoleDescriptionProperty ( )

◆ backgroundImageTextProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundImageTextProperty ( )

◆ backgroundImageTooltipProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundImageTooltipProperty ( )

◆ backgroundMenuMaxiAccessibleTextProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundMenuMaxiAccessibleTextProperty ( )

◆ backgroundMenuMaxiRoleDescriptionProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundMenuMaxiRoleDescriptionProperty ( )

◆ backgroundMenuMaxiTextProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundMenuMaxiTextProperty ( )

◆ backgroundMenuMaxiTooltipProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundMenuMaxiTooltipProperty ( )

◆ backgroundOpacityAccessibleTextProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundOpacityAccessibleTextProperty ( )

◆ backgroundOpacityRoleDescriptionProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundOpacityRoleDescriptionProperty ( )

◆ backgroundOpacityTextProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundOpacityTextProperty ( )

◆ backgroundOpacityTooltipProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundOpacityTooltipProperty ( )

◆ backgroundReduceAccessibleTextProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundReduceAccessibleTextProperty ( )

◆ backgroundReduceTextProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundReduceTextProperty ( )

◆ backgroundReduceTooltipProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundReduceTooltipProperty ( )

◆ backgroundRoleDescriptionProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundRoleDescriptionProperty ( )

◆ backgroundTextProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundTextProperty ( )

◆ backgroundTooltipProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundTooltipProperty ( )

◆ chooseBackgroundImage()

File fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.chooseBackgroundImage ( Stage primaryStage)

Opens file chooser dialog for options image selection.

Parameters
primaryStageparent stage for the dialog
Returns
selected image file or null if cancelled/error
+ Here is the call graph for this function:

◆ createFormattedBinding()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.createFormattedBinding ( String key,
String suffixKey )
private

Creates a StringBinding that returns the concatenation of two localized strings (main key and suffix key), updating automatically when the locale changes.

Parameters
keythe main i18n translation key
suffixKeythe suffix i18n translation key to append
Returns
a StringBinding with the concatenated localized string value

◆ createImageFileChooser()

FileChooser fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.createImageFileChooser ( )
private

Creates configured FileChooser for image files.

Returns
FileChooser with image filters and home directory set

◆ createStringBinding()

StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.createStringBinding ( String key)
private

Creates a StringBinding that returns the localized string for the given key, updating automatically when the locale changes.

Parameters
keythe i18n translation key
Returns
a StringBinding with the localized string value

◆ getOpaqueMode()

boolean fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.getOpaqueMode ( )

Gets the grid opacity mode.

◆ handleFileImageChooser()

void fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.handleFileImageChooser ( File selectedFile,
ToasterVBox toaster,
SpinnerGridPane spinner,
GridPane sudokuFX )

Handles image file selection by validating the file format and starting the image loading process.

Parameters
selectedFileThe selected image file.
toasterThe toaster component for user notifications.
spinnerThe spinner component to indicate loading.
sudokuFXThe GridPane where the options image will be applied.
+ Here is the call graph for this function:

◆ init()

void fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.init ( GridPane sudokuFX,
ColorPicker menuBackgroundButtonColor,
ToasterVBox toaster,
SpinnerGridPane spinner )

Initializes the GridPane options with settings from database.

Loads and applies saved options configuration including color, image, and grid transparency.

This method performs the following initialization steps:

  • Retrieves and applies saved options color from database
  • Loads and applies saved options image if configured
  • Sets grid transparency mode based on user preferences
  • Updates UI components (ColorPicker, etc.) with current values
Parameters
sudokuFXThe GridPane to initialize with options settings
menuBackgroundButtonColorThe ColorPicker to sync with current color value
toasterThe toaster component for user notifications during image loading
spinnerThe spinner component to indicate loading state during operations
See also
setColorFromModel(GridPane, ColorPicker, String)
handleFileImageChooser(File, ToasterVBox, SpinnerGridPane, GridPane)
setOpaqueMode(boolean)
+ Here is the call graph for this function:

◆ loadImage()

void fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.loadImage ( File selectedFile,
ToasterVBox toaster,
SpinnerGridPane spinner,
GridPane sudokuFX )
private

Starts the asynchronous image loading and resizing task.

The task runs on a separate daemon thread, so it does not block application shutdown.

Parameters
selectedFileThe selected image file.
toasterThe toaster component for user notifications.
spinnerThe spinner component to indicate loading.
sudokuFXThe GridPane where the options image will be applied.
+ Here is the call graph for this function:

◆ onImageTaskComplete()

void fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.onImageTaskComplete ( Task< BackgroundImage > backgroundTask,
ToasterVBox toaster,
SpinnerGridPane spinner,
GridPane sudokuFX )
private

Called upon successful completion of the image loading task.

Applies the loaded options image or shows an error toast if loading failed.

Parameters
backgroundTaskThe completed options task.
toasterThe toaster component for user notifications.
spinnerThe spinner component to hide loading state.
sudokuFXThe GridPane where the options image will be applied.
+ Here is the call graph for this function:

◆ onImageTaskError()

void fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.onImageTaskError ( WorkerStateEvent e,
ToasterVBox toaster,
SpinnerGridPane spinner )
package

Called when the image loading task fails.

Logs the error and shows an error toast to the user.

Parameters
eThe failure event.
toasterThe toaster component for user notifications.
spinnerThe spinner component to hide loading state.
+ Here is the call graph for this function:

◆ setColorFromModel()

void fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.setColorFromModel ( GridPane sudokuFX,
ColorPicker menuBackgroundButtonColor,
String colorValueFromModel )
private

Applies a options color to the GridPane and sets it in the ColorPicker.

Parameters
sudokuFXThe GridPane to update.
menuBackgroundButtonColorThe ColorPicker to update.
colorValueFromModelThe hex color string (e.g., "99b3ffcd").

◆ setOpaqueMode()

void fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.setOpaqueMode ( boolean opaque)
private

Sets the grid opacity mode.

Parameters
opaquetrue for opaque mode, false for transparent

◆ toggleGridOpacity()

boolean fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.toggleGridOpacity ( )

Toggles grid opacity mode and returns the new state.

Returns
true if opaque mode is now active, false if transparent

◆ updateBackgroundColorAndApply()

void fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.updateBackgroundColorAndApply ( GridPane sudokuFX,
Color color )

Sets the options color of the given GridPane.

Parameters
sudokuFXThe GridPane to update.
colorThe color to apply as the options.

Member Data Documentation

◆ backgroundAccessibleText

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundAccessibleText
private

◆ backgroundColorAccessibleText

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundColorAccessibleText
private

◆ backgroundColorRoleDescription

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundColorRoleDescription
private

◆ backgroundColorTooltip

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundColorTooltip
private

◆ backgroundImageAccessibleText

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundImageAccessibleText
private

◆ backgroundImageRoleDescription

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundImageRoleDescription
private

◆ backgroundImageText

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundImageText
private

◆ backgroundImageTooltip

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundImageTooltip
private

◆ backgroundMenuMaxiAccessibleText

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundMenuMaxiAccessibleText
private

◆ backgroundMenuMaxiRoleDescription

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundMenuMaxiRoleDescription
private

◆ backgroundMenuMaxiText

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundMenuMaxiText
private

◆ backgroundMenuMaxiTooltip

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundMenuMaxiTooltip
private

◆ backgroundOpacityAccessibleText

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundOpacityAccessibleText
private

◆ backgroundOpacityRoleDescription

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundOpacityRoleDescription
private

◆ backgroundOpacityText

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundOpacityText
private

◆ backgroundOpacityTooltip

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundOpacityTooltip
private

◆ backgroundReduceAccessibleText

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundReduceAccessibleText
private

◆ backgroundReduceText

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundReduceText
private

◆ backgroundReduceTooltip

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundReduceTooltip
private

◆ backgroundRoleDescription

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundRoleDescription
private

◆ backgroundText

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundText
private

◆ backgroundTooltip

final StringBinding fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.backgroundTooltip
private

◆ HEX_RADIX

final int fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.HEX_RADIX = 16
staticprivate

◆ imageUtils

final ImageUtils fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.imageUtils
private

◆ isOpaqueMode

boolean fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.isOpaqueMode = false
private

◆ LOG

final Logger fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.LOG = LoggerFactory.getLogger(MenuBackgroundViewModel.class)
staticprivate

◆ ROLE_CLOSED

final String fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.ROLE_CLOSED = "menu.accessibility.role.description.closed"
staticprivate

◆ ROLE_OPENED

final String fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.ROLE_OPENED = "menu.accessibility.role.description.opened"
staticprivate

◆ ROLE_SUBMENU_OPTION

final String fr.softsf.sudokufx.viewmodel.MenuOptionsViewModel.ROLE_SUBMENU_OPTION
staticprivate
Initial value:
=
"menu.accessibility.role.description.submenu.option"

The documentation for this class was generated from the following file: