Lab 3: Image Transformer FXML
Overview
In this assignment, you will incorporate feedback from your instructor from previous assignments and develop a self-contained graphical user interface for the functionality developed in previous assignments.
Assignment
Create a JavaFX program using FXML that provides a user interface that matches the screenshot below.
Here is what each button should do:
- Open — Uses a
FileChooser
to allow the user to select an image file to be loaded and displayed. - Save — Uses a file chooser to allow the user to specified the output image location and saves the currently displayed image to the file.
- Grayscale — Converts the currently displayed image to grayscale.
- Invert — Inverts the currently displayed image.
- Brighten — Brightens the currently displayed image.
- Darken — Darkens the currently displayed image.
- Desaturate — Desaturates the currently displayed image.
- Saturate — Saturates the currently displayed image.
Details
Create a ImageTransform
class that extends the Application
class.
Handler Methods
Your controller class must have the following handler methods to respond to
the buttons on the UI: void open(ActionEvent event)
, void save(ActionEvent event)
,
void grayscale(ActionEvent event)
, void invert(ActionEvent event)
,
void brighten(ActionEvent event)
, void darken(ActionEvent event)
,
void desaturate(ActionEvent event)
, and void saturate(ActionEvent event)
.
Transformations with Color
You will use the Color
class to help implement the transformations.
Exception Handling
If any problems are encountered with reading the input files or writing the output file,
the program should display a useful error message using the
Alert
class.
Once dismissed, the user should be able to continue using the program.
The program should not crash or display any exceptions.
Just For Fun
Ambitious students may wish to:
- Add other transformations.
- Create a second FXML file that is compatible with your controller class but provides a different user interface.
Acknowledgement
This laboratory assignment, developed by Dr. Chris Taylor.