Package com.digitizer.ui
Class AccessibilityHelper
java.lang.Object
com.digitizer.ui.AccessibilityHelper
Accessibility utility helper class for configuring JavaFX controls with
screen reader support, keyboard shortcuts, and ARIA-like descriptions.
The helper contains convenience methods to configure controls with
Tooltips, accessible labels and role
descriptions so screen reader users can discover UI semantics and
keyboard alternatives. The helper also logs "announcements" which can be
picked up by platform-specific accessibility tools.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidannounceAction(String action) Announces a dialog action (button pressed, validation error, etc.) to screen readers.static voidannounceColor(String datasetName, String colorHex, String colorName) Announces color information in accessible format.static voidannounceCoordinates(String description, double xValue, double yValue) Announces coordinate or value information to screen readers.static voidannounceHelp(String controlName, String helpText) Announces help text for the currently focused control.static voidannounceModeChange(String mode, String instructions) Creates a focused announcement for mode changes (e.g., entering calibration mode).static voidannounceProgress(String label, int current, int total) Announces numerical feedback to screen readers (e.g., point counts, calibration progress).static voidannounceStatus(String message) Announces a status change to screen readers via logging.static doubleGets the OS text scaling factor (Windows DPI scaling).static voidrequestFocusAccessible(javafx.scene.control.Control control, String announcement) Requests focus on a control and announces it to screen readers.static voidsetButtonAccessibility(javafx.scene.control.Button button, String text, String tooltip, String keyboardHint) Sets an accessible label and tooltip for a button.static voidsetCheckBoxAccessibility(javafx.scene.control.CheckBox checkBox, String label, String help) Sets an accessible label and tooltip for a checkbox.static voidsetKeyboardShortcut(javafx.scene.control.Control control, String shortcut) Configures keyboard shortcut accessibility info for a control.static voidsetLabelAccessibility(javafx.scene.control.Label label, String text, String role) Sets an accessible label for a Label control.static voidsetRequired(javafx.scene.control.Control control, boolean required) Marks a control as requiring input (validation indicator for screen readers).static voidsetTextAccessibility(javafx.scene.text.Text textNode, String text, String role) Sets accessibility metadata for a Text node.static voidsetTextFieldAccessibility(javafx.scene.control.TextField field, String label, String placeholder, String help) Sets an accessible label and tooltip for a text field.
-
Constructor Details
-
AccessibilityHelper
public AccessibilityHelper()
-
-
Method Details
-
setButtonAccessibility
public static void setButtonAccessibility(javafx.scene.control.Button button, String text, String tooltip, String keyboardHint) Sets an accessible label and tooltip for a button. Logs the action for screen reader announcement.- Parameters:
button- the button to configuretext- the button texttooltip- the tooltip text describing the button actionkeyboardHint- optional keyboard shortcut hint (e.g., "Ctrl+O")
-
setTextFieldAccessibility
public static void setTextFieldAccessibility(javafx.scene.control.TextField field, String label, String placeholder, String help) Sets an accessible label and tooltip for a text field. Provides context for screen reader users.- Parameters:
field- the text field to configurelabel- the label textplaceholder- placeholder text shown in empty fieldhelp- help text describing what the field accepts
-
setCheckBoxAccessibility
public static void setCheckBoxAccessibility(javafx.scene.control.CheckBox checkBox, String label, String help) Sets an accessible label and tooltip for a checkbox. Makes the checkbox's state clearly announceable.- Parameters:
checkBox- the checkbox to configurelabel- the label texthelp- help text describing what toggling does
-
setLabelAccessibility
public static void setLabelAccessibility(javafx.scene.control.Label label, String text, String role) Sets an accessible label for a Label control. Used for section headers and descriptive text.- Parameters:
label- the Label to configuretext- the label textrole- the semantic role (e.g., "Section heading", "Description")
-
setTextAccessibility
Sets accessibility metadata for a Text node. Useful when usingTextfor richer styling (e.g., strikethrough).- Parameters:
textNode- the Text node to configuretext- the textual contentrole- semantic role description
-
requestFocusAccessible
public static void requestFocusAccessible(javafx.scene.control.Control control, String announcement) Requests focus on a control and announces it to screen readers. Used when programmatically shifting focus (e.g., after file load).- Parameters:
control- the control to focusannouncement- optional announcement text for screen readers
-
announceStatus
Announces a status change to screen readers via logging. Screen reader applications can monitor logs or use system announcements.- Parameters:
message- the message to announce
-
announceAction
Announces a dialog action (button pressed, validation error, etc.) to screen readers.- Parameters:
action- the action that occurred (e.g., "File loaded", "Error: Invalid input")
-
announceHelp
Announces help text for the currently focused control.- Parameters:
controlName- the name of the controlhelpText- the help text to announce
-
setRequired
public static void setRequired(javafx.scene.control.Control control, boolean required) Marks a control as requiring input (validation indicator for screen readers).- Parameters:
control- the controlrequired- whether the field is required
-
setKeyboardShortcut
Configures keyboard shortcut accessibility info for a control. Helps screen reader users discover keyboard alternatives.- Parameters:
control- the controlshortcut- the keyboard shortcut (e.g., "Ctrl+S for Save")
-
announceModeChange
Creates a focused announcement for mode changes (e.g., entering calibration mode). This helps screen reader users understand the current context.- Parameters:
mode- the mode name (e.g., "Calibration Mode")instructions- the instructions for this mode
-
announceProgress
Announces numerical feedback to screen readers (e.g., point counts, calibration progress).- Parameters:
label- what is being counted (e.g., "Calibration points")current- the current counttotal- the total expected
-
announceCoordinates
Announces coordinate or value information to screen readers. Used for providing feedback on canvas interactions.- Parameters:
description- what the values representxValue- the x valueyValue- the y value
-
announceColor
Announces color information in accessible format. Screen reader users can't distinguish colors, so describe them.- Parameters:
datasetName- the name of the datasetcolorHex- the hex color code (e.g., "#0072B2")colorName- accessible description (e.g., "Blue")
-
getOSTextScaling
public static double getOSTextScaling()Gets the OS text scaling factor (Windows DPI scaling). Returns 1.0 for 100% scaling, 1.25 for 125%, 1.5 for 150%, etc.- Returns:
- the text scaling factor
-