Service dedicated to QR code generation and saving.
More...
|
| boolean | checkNPEInputs (EncodedData qrData, CommonFields config, JProgressBar loader) |
| | Validates that all required inputs are non-null.
|
| File | chooseOutputFile (EncodedData qrData) |
| | Opens a JFileChooser to select the output PNG file and handles file name conflicts.
|
| void | executeQrGeneration (EncodedData qrData, CommonFields config, JProgressBar loader, File outputFile) |
| | Executes QR code generation asynchronously using a SwingWorker.
|
| File | getSelectedPngFile (JFileChooser chooser) |
| | Ensures the selected file has a ".png" extension.
|
| File | resolveFileNameConflict (File file) |
| | Resolves potential file name conflicts by checking if the specified file already exists.
|
Service dedicated to QR code generation and saving.
◆ GenerateAndSaveService()
| fr.softsf.canscan.service.GenerateAndSaveService.GenerateAndSaveService |
( |
EncodedImage | encodedImage | ) |
|
◆ checkNPEInputs()
| boolean fr.softsf.canscan.service.GenerateAndSaveService.checkNPEInputs |
( |
EncodedData | qrData, |
|
|
CommonFields | config, |
|
|
JProgressBar | loader ) |
|
private |
Validates that all required inputs are non-null.
- Parameters
-
| qrData | the QR code data to validate |
| config | the configuration to validate |
| loader | the progress bar to validate |
- Returns
- true if all inputs are valid, false otherwise
◆ chooseOutputFile()
| File fr.softsf.canscan.service.GenerateAndSaveService.chooseOutputFile |
( |
EncodedData | qrData | ) |
|
|
private |
Opens a JFileChooser to select the output PNG file and handles file name conflicts.
- Parameters
-
| qrData | the QR code data used to generate the default file name |
- Returns
- the selected file ready for writing, or null if the user cancels
◆ executeQrGeneration()
| void fr.softsf.canscan.service.GenerateAndSaveService.executeQrGeneration |
( |
EncodedData | qrData, |
|
|
CommonFields | config, |
|
|
JProgressBar | loader, |
|
|
File | outputFile ) |
|
private |
Executes QR code generation asynchronously using a SwingWorker.
- Parameters
-
| qrData | the QR code data |
| config | the visual configuration |
| loader | the progress bar to hide after completion |
| outputFile | the file where the QR code will be saved |
◆ generateAndSave()
| void fr.softsf.canscan.service.GenerateAndSaveService.generateAndSave |
( |
EncodedData | qrData, |
|
|
CommonFields | config, |
|
|
JProgressBar | loader ) |
Generates and saves a QR code as a PNG file using the provided data and configuration.
Validates input data, applies visual settings, generates the QR code image, and saves it to a user-selected file location. All operations are performed asynchronously to prevent UI blocking.
- Parameters
-
| qrData | the QR code data; must not be null |
| config | the visual configuration; must not be null |
| loader | the progress indicator to display during generation |
◆ getSelectedFileForTests()
| File fr.softsf.canscan.service.GenerateAndSaveService.getSelectedFileForTests |
( |
JFileChooser | chooser | ) |
|
|
package |
Returns the selected PNG file for testing.
◆ getSelectedPngFile()
| File fr.softsf.canscan.service.GenerateAndSaveService.getSelectedPngFile |
( |
JFileChooser | chooser | ) |
|
|
private |
Ensures the selected file has a ".png" extension.
- Parameters
-
- Returns
- a File guaranteed to have a ".png" extension
◆ resolveFileNameConflict()
| File fr.softsf.canscan.service.GenerateAndSaveService.resolveFileNameConflict |
( |
File | file | ) |
|
|
private |
Resolves potential file name conflicts by checking if the specified file already exists.
If the file exists, the user is prompted to overwrite it. If the user declines, the method attempts to generate a unique file name by appending a numeric suffix (e.g., "(1).png").
A safety limit of 1000 attempts is enforced to prevent infinite loops and excessive system resource consumption in directories with high file counts.
- Parameters
-
| file | the initial File to check for conflicts; must not be null |
- Returns
- a File ready for writing (original, user-approved, or auto-renamed), or null if:
-
the input file is null
-
the maximum number of naming attempts (1000) is reached
◆ resolveFileNameConflictForTests()
| File fr.softsf.canscan.service.GenerateAndSaveService.resolveFileNameConflictForTests |
( |
File | file | ) |
|
|
package |
Resolves file name conflicts for testing.
◆ encodedImage
| final EncodedImage fr.softsf.canscan.service.GenerateAndSaveService.encodedImage |
|
private |
The documentation for this class was generated from the following file: