CanScan
Loading...
Searching...
No Matches
fr.softsf.canscan.ui.UiComponentsConfiguration Enum Reference

Creating and configuring UI components. More...

+ Collaboration diagram for fr.softsf.canscan.ui.UiComponentsConfiguration:

Public Member Functions

void addRow (JPanel panel, GridBagConstraints gbc, String labelText, String tooltipText, JComponent component)
 Adds a labeled row to a panel using GridBagLayout.
 
void assignComponentNames (NativeImageUiComponents nativeImageUiComponents)
 Assigns unique names to all GUI components encapsulated in the given NativeImageUiComponents instance.
 
void attachLimitedDocumentListener (JTextField field, int maxLength, Runnable action)
 Attaches a DocumentListener to a JTextField that:
 
void configureFreeTextArea (JTextArea textArea, JScrollPane scrollPane)
 Configures a JTextArea for free text input with word wrapping and a fixed size.
 
void configureGenerateButton (JButton button, ActionListener listener)
 Configures a generate button with a standard size, attaches an action listener, and sets its initial state to disabled.
 
void configureMarginSlider (JSlider slider, int initialValue)
 Configures a JSlider with standard margin settings.
 
void configureRatioSlider (JSlider slider, double initialRatio)
 Configures a JSlider for ratio selection with standard settings and tooltip updates.
 
JPanel createColorPanel (JButton qrColorButton, JButton bgColorButton)
 Creates a panel containing buttons for selecting background and QR code colors.
 
JPanel createCoordinatesPanel (JTextField latField, JTextField longField)
 Creates a panel with latitude and longitude text fields side by side, distributed evenly with a gap.
 
JPanel createDateTimePanel (DatePicker meetDatePicker, TimePicker meetTimePicker)
 Creates a panel with date/time fields side by side, distributed evenly with a gap.
 
GridBagConstraints createDefaultConstraints ()
 Creates default GridBagConstraints for consistent layout.
 
DocumentListener createDocumentListener (Runnable action)
 Creates a simple DocumentListener that executes the given action on any change to the document.
 
JButton createIconButton (String iconCode, String text)
 Creates a JButton styled with a Material Icon and a text label.
 
JButton createIconOnlyButton (String iconCode)
 Creates a JButton styled to display a bold Material Icon only.
 
JPanel createModePanel (JRadioButton mecardRadio, JRadioButton meetRadio, JRadioButton freeRadio, JButton updateButton, ButtonGroup buttonGroup)
 Creates a mode selection panel containing radio buttons for different modes and an update button.
 
JPanel createQrCodeOverlayPanel (JProgressBar loader, JLabel qrCodeLabel)
 Creates an overlay panel containing a loader and a QR code label.
 
String getIconAfterTextHtml (String text, String iconCode)
 Generates the HTML string for a JLabel with text followed by an icon.
 
void populateFreePanel (JPanel freePanel, GridBagConstraints grid, JTextArea freeField, JScrollPane freeScrollPane)
 Creates and populates a FREE text input panel.
 
void populateMecardPanel (JPanel mecardPanel, GridBagConstraints grid, MecardJFields mecardJFields)
 Creates and populates a MECARD input panel with labeled input fields.
 
void populateMeetPanel (JPanel meetPanel, GridBagConstraints grid, MeetJFields meetJFields)
 Creates and populates a MEET input panel with labeled input fields for event details.
 

Public Attributes

 INSTANCE
 

Private Member Functions

JPanel createRadioButtonsPanel (JRadioButton mecardRadio, JRadioButton meetRadio, JRadioButton freeRadio)
 Creates a panel containing the given radio buttons arranged horizontally with spacing.
 

Static Private Attributes

static final String ADD_ROW = "addRow"
 
static final int COLOR_BUTTONS_GAP = 10
 
static final int COORDINATES_FIELDS_GAP = 5
 
static final String CREATE_MODE_PANEL = "createModePanel"
 
static final double GBC_HALF_WEIGHT_X = 0.5
 
static final int GENERATE_BUTTON_EXTRA_HEIGHT = 35
 
static final int MAJOR_TICK_SPACING = 25
 
static final int MULTILINE_TEXT_FIELDS_ROWS = 10
 
static final String POPULATE_MECARD_PANEL = "populateMecardPanel"
 
static final int RADIO_BUTTON_GAP = 10
 

Detailed Description

Creating and configuring UI components.

Member Function Documentation

◆ addRow()

void fr.softsf.canscan.ui.UiComponentsConfiguration.addRow ( JPanel panel,
GridBagConstraints gbc,
String labelText,
String tooltipText,
JComponent component )

Adds a labeled row to a panel using GridBagLayout.

The row consists of a JLabel on the left and the specified JComponent on the right. Optionally, a tooltip can be set for the label.

Parameters
panelthe JPanel to which the row is added; must not be null
gbcthe GridBagConstraints used for layout positioning; must not be null
labelTextthe text for the JLabel; must not be null
tooltipTextthe tooltip text for the label; may be null or blank
componentthe JComponent to add next to the label; must not be null

◆ assignComponentNames()

void fr.softsf.canscan.ui.UiComponentsConfiguration.assignComponentNames ( NativeImageUiComponents nativeImageUiComponents)

Assigns unique names to all GUI components encapsulated in the given NativeImageUiComponents instance.

This allows automated test frameworks, such as native image configuration simulators, to reliably identify each component by name.

Parameters
nativeImageUiComponentsthe NativeImageUiComponents containing the GUI elements to name; must not be null

◆ attachLimitedDocumentListener()

void fr.softsf.canscan.ui.UiComponentsConfiguration.attachLimitedDocumentListener ( JTextField field,
int maxLength,
Runnable action )

Attaches a DocumentListener to a JTextField that:

  • Executes the given action on any change to the document (insert, remove, or change), asynchronously on the Swing EDT.
  • Limits the text length to maxLength characters using a DocumentFilter.
  • Removes line breaks (
    , \r) from pasted or inserted text.

This allows dynamic updates (e.g., QR code preview) while preventing input overflow and unwanted line breaks.

Parameters
fieldthe JTextField to attach the listener to; must not be null
maxLengththe maximum number of characters allowed in the field
actionthe Runnable to execute on document changes; must not be null
+ Here is the call graph for this function:

◆ configureFreeTextArea()

void fr.softsf.canscan.ui.UiComponentsConfiguration.configureFreeTextArea ( JTextArea textArea,
JScrollPane scrollPane )

Configures a JTextArea for free text input with word wrapping and a fixed size.

Enables word wrap and line wrap for the text area, then calculates the preferred size of the enclosing JScrollPane based on character dimensions and predefined column and row counts.

Parameters
textAreathe JTextArea to configure; must not be null
scrollPanethe JScrollPane containing the text area; must not be null

◆ configureGenerateButton()

void fr.softsf.canscan.ui.UiComponentsConfiguration.configureGenerateButton ( JButton button,
ActionListener listener )

Configures a generate button with a standard size, attaches an action listener, and sets its initial state to disabled.

The button's height is increased by GENERATE_BUTTON_EXTRA_HEIGHT, and its minimum, preferred, and maximum sizes are all set to this dimension. The provided ActionListener is added to handle button actions.

Parameters
buttonthe JButton to configure; must not be null
listenerthe ActionListener to attach; must not be null

◆ configureMarginSlider()

void fr.softsf.canscan.ui.UiComponentsConfiguration.configureMarginSlider ( JSlider slider,
int initialValue )

Configures a JSlider with standard margin settings.

Sets the slider to the given initial value, enables major tick spacing of 1, and ensures that tick marks and labels are painted.

Parameters
sliderthe JSlider to configure; must not be null
initialValuethe initial value to set for the slider

◆ configureRatioSlider()

void fr.softsf.canscan.ui.UiComponentsConfiguration.configureRatioSlider ( JSlider slider,
double initialRatio )

Configures a JSlider for ratio selection with standard settings and tooltip updates.

Sets the slider's value based on initialRatio (scaled to percentage), sets the maximum value, major and minor tick spacing, enables tick marks and labels, and updates the tooltip to show the current percentage dynamically.

Parameters
sliderthe JSlider to configure; must not be null
initialRatiothe initial ratio (0.0 to 1.0) to set for the slider

◆ createColorPanel()

JPanel fr.softsf.canscan.ui.UiComponentsConfiguration.createColorPanel ( JButton qrColorButton,
JButton bgColorButton )

Creates a panel containing buttons for selecting background and QR code colors.

The panel arranges the background color button on the left and the QR color button on the right, using GridBagLayout with horizontal spacing defined by
COLOR_BUTTONS_GAP
.

Parameters
qrColorButtonthe JButton for selecting the QR code color; must not be null
bgColorButtonthe JButton for selecting the background color; must not be null
Returns
a JPanel containing the color selection buttons, or null if any button is null

◆ createCoordinatesPanel()

JPanel fr.softsf.canscan.ui.UiComponentsConfiguration.createCoordinatesPanel ( JTextField latField,
JTextField longField )

Creates a panel with latitude and longitude text fields side by side, distributed evenly with a gap.

Parameters
latFieldthe latitude text field
longFieldthe longitude text field
Returns
a JPanel containing the two fields

◆ createDateTimePanel()

JPanel fr.softsf.canscan.ui.UiComponentsConfiguration.createDateTimePanel ( DatePicker meetDatePicker,
TimePicker meetTimePicker )

Creates a panel with date/time fields side by side, distributed evenly with a gap.

Parameters
meetDatePickerthe date field
meetTimePickerthe time field
Returns
a JPanel containing the two fields

◆ createDefaultConstraints()

GridBagConstraints fr.softsf.canscan.ui.UiComponentsConfiguration.createDefaultConstraints ( )

Creates default GridBagConstraints for consistent layout.

The default constraints set uniform insets of 3 pixels on all sides, fill horizontally, start at gridx = 0, gridy = -1, and assign weightx = 1 for proper resizing behavior.

Returns
a new GridBagConstraints instance with default settings

◆ createDocumentListener()

DocumentListener fr.softsf.canscan.ui.UiComponentsConfiguration.createDocumentListener ( Runnable action)

Creates a simple DocumentListener that executes the given action on any change to the document.

The action is invoked asynchronously on the Swing event dispatch thread using SwingUtilities#invokeLater(Runnable) to ensure thread safety.

Parameters
actionthe Runnable to execute when the document changes; must not be null
Returns
a DocumentListener that triggers the action on insert, remove, or change events, or null if the action is null

◆ createIconButton()

JButton fr.softsf.canscan.ui.UiComponentsConfiguration.createIconButton ( String iconCode,
String text )

Creates a JButton styled with a Material Icon and a text label.

Uses an HTML table structure for consistent vertical alignment of the icon and text.

Parameters
iconCodeThe Unicode value of the Material Icon (e.g., "\uE2C7").
textThe text label to display next to the icon.
Returns
A new, styled JButton configured with the icon and text.

◆ createIconOnlyButton()

JButton fr.softsf.canscan.ui.UiComponentsConfiguration.createIconOnlyButton ( String iconCode)

Creates a JButton styled to display a bold Material Icon only.

Parameters
iconCodeThe Unicode value of the Material Icon (e.g., "\uE863").
Returns
A new JButton containing only the icon.

◆ createModePanel()

JPanel fr.softsf.canscan.ui.UiComponentsConfiguration.createModePanel ( JRadioButton mecardRadio,
JRadioButton meetRadio,
JRadioButton freeRadio,
JButton updateButton,
ButtonGroup buttonGroup )

Creates a mode selection panel containing radio buttons for different modes and an update button.

The panel arranges the radio buttons on the left and the update button on the right. The provided ButtonGroup is used to group the radio buttons, and the "mecard" radio button is selected by default.

Parameters
mecardRadiothe JRadioButton for "mecard" mode; must not be null
meetRadiothe JRadioButton for "meet" mode; must not be null
freeRadiothe JRadioButton for "free" mode; must not be null
updateButtonthe JButton used to trigger updates; must not be null
buttonGroupthe ButtonGroup to group the radio buttons; must not be null
Returns
a JPanel containing the configured mode selection UI, or null if any required component is null
+ Here is the call graph for this function:

◆ createQrCodeOverlayPanel()

JPanel fr.softsf.canscan.ui.UiComponentsConfiguration.createQrCodeOverlayPanel ( JProgressBar loader,
JLabel qrCodeLabel )

Creates an overlay panel containing a loader and a QR code label.

The loader is configured with a flat style, no border, transparent background, and set to indeterminate mode. Both the loader and the QR code label are added to a JPanel using OverlayLayout, allowing the loader to appear over the label.

Parameters
loaderthe JProgressBar used as a loader; must not be null
qrCodeLabelthe JLabel displaying the QR code; must not be null
Returns
a JPanel containing the overlay, or null if any component is null

◆ createRadioButtonsPanel()

JPanel fr.softsf.canscan.ui.UiComponentsConfiguration.createRadioButtonsPanel ( JRadioButton mecardRadio,
JRadioButton meetRadio,
JRadioButton freeRadio )
private

Creates a panel containing the given radio buttons arranged horizontally with spacing.

Uses GridBagLayout to align the radio buttons and applies horizontal gaps between them according to RADIO_BUTTON_GAP.

Parameters
mecardRadiothe JRadioButton for "mecard" mode; must not be null
meetRadiothe JRadioButton for "meet" mode; must not be null
freeRadiothe JRadioButton for "free" mode; must not be null
Returns
a JPanel containing the aligned radio buttons

◆ getIconAfterTextHtml()

String fr.softsf.canscan.ui.UiComponentsConfiguration.getIconAfterTextHtml ( String text,
String iconCode )

Generates the HTML string for a JLabel with text followed by an icon.

Parameters
textThe text label to display first.
iconCodeThe Unicode value of the Material Icon (e.g., "\uE161").
Returns
The formatted HTML string.

◆ populateFreePanel()

void fr.softsf.canscan.ui.UiComponentsConfiguration.populateFreePanel ( JPanel freePanel,
GridBagConstraints grid,
JTextArea freeField,
JScrollPane freeScrollPane )

Creates and populates a FREE text input panel.

Configures the text area with wrapping and size using configureFreeTextArea(JTextArea, JScrollPane), then adds it to the panel with a label and tooltip. Uses GridBagLayout for layout.

Parameters
freePanelthe JPanel to populate; must not be null
gridthe GridBagConstraints used for layout positioning; must not be null
freeFieldthe JTextArea for free text input; must not be null
freeScrollPanethe JScrollPane containing the text area; must not be null
+ Here is the call graph for this function:

◆ populateMecardPanel()

void fr.softsf.canscan.ui.UiComponentsConfiguration.populateMecardPanel ( JPanel mecardPanel,
GridBagConstraints grid,
MecardJFields mecardJFields )

Creates and populates a MECARD input panel with labeled input fields.

Configures the JPanel using GridBagLayout and adds rows for name, organization, phone, email, address, and URL fields. Tooltips provide guidance for each input field.

Parameters
mecardPanelthe JPanel to populate; must not be null
gridthe GridBagConstraints used for layout positioning; must not be null
mecardJFieldsthe MecardJFields containing the input fields; must not be null
+ Here is the call graph for this function:

◆ populateMeetPanel()

void fr.softsf.canscan.ui.UiComponentsConfiguration.populateMeetPanel ( JPanel meetPanel,
GridBagConstraints grid,
MeetJFields meetJFields )

Creates and populates a MEET input panel with labeled input fields for event details.

Configures the JPanel using GridBagLayout and adds rows for the event title, unique identifier, start and end date/time, organizer name, and location coordinates. Tooltips provide guidance for each input field.

Parameters
meetPanelthe JPanel to populate; must not be null
gridthe GridBagConstraints used for layout positioning; must not be null
meetJFieldsthe MeetJFields containing the input fields; must not be null
+ Here is the call graph for this function:

Member Data Documentation

◆ ADD_ROW

final String fr.softsf.canscan.ui.UiComponentsConfiguration.ADD_ROW = "addRow"
staticprivate

◆ COLOR_BUTTONS_GAP

final int fr.softsf.canscan.ui.UiComponentsConfiguration.COLOR_BUTTONS_GAP = 10
staticprivate

◆ COORDINATES_FIELDS_GAP

final int fr.softsf.canscan.ui.UiComponentsConfiguration.COORDINATES_FIELDS_GAP = 5
staticprivate

◆ CREATE_MODE_PANEL

final String fr.softsf.canscan.ui.UiComponentsConfiguration.CREATE_MODE_PANEL = "createModePanel"
staticprivate

◆ GBC_HALF_WEIGHT_X

final double fr.softsf.canscan.ui.UiComponentsConfiguration.GBC_HALF_WEIGHT_X = 0.5
staticprivate

◆ GENERATE_BUTTON_EXTRA_HEIGHT

final int fr.softsf.canscan.ui.UiComponentsConfiguration.GENERATE_BUTTON_EXTRA_HEIGHT = 35
staticprivate

◆ INSTANCE

fr.softsf.canscan.ui.UiComponentsConfiguration.INSTANCE

◆ MAJOR_TICK_SPACING

final int fr.softsf.canscan.ui.UiComponentsConfiguration.MAJOR_TICK_SPACING = 25
staticprivate

◆ MULTILINE_TEXT_FIELDS_ROWS

final int fr.softsf.canscan.ui.UiComponentsConfiguration.MULTILINE_TEXT_FIELDS_ROWS = 10
staticprivate

◆ POPULATE_MECARD_PANEL

final String fr.softsf.canscan.ui.UiComponentsConfiguration.POPULATE_MECARD_PANEL = "populateMecardPanel"
staticprivate

◆ RADIO_BUTTON_GAP

final int fr.softsf.canscan.ui.UiComponentsConfiguration.RADIO_BUTTON_GAP = 10
staticprivate

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