In this lab assignment you will:
- Create your own Java source code file that manipulates a picture.
Lab Tasks
More detailed information about some of these tasks is available in Chapters 3 & 4 of the text. This set of tasks is not necessarily linear. You may have to go back and forth between editing and testing several times before moving on to the next step on the list.
- Create a file named
PictureManipulator.java
using the DrJava editor.
- In this file, create a class definition for a class named
PictureManipulator
.
- Inside the class, create a constructor that brings up a
FileChooser
and when the user selects a file, creates a Picture
object from the file selected.
- Display the picture using the explore method.
- Save the file and test out what you have done by creating a
PictureManipulator
and seeing the results.
- You will then write the code to manipulate the picture object as described in steps 7 - 14. Insert the code for these steps in between the lines that create the picture and the line that brings up the picture explorer. This way, the picture explorer comes up with the results of the manipulation of the picture you have done.
- Get the pixel that is at 25, 25 and make its red component have the value 49.
- Save the file and test out what you have done by creating a
PictureManipulator
and seeing the results.
- Get the pixel that is at 3,3 and make its green component have the value 150.
- Save the file and test out what you have done by creating a
PictureManipulator
and seeing the results.
- Get the pixel that is at the bottom right corner of the image and double its green and blue component.
- Save the file and test out what you have done by creating a
PictureManipulator
and seeing the results.
- Get the pixel that is 10 pixels to the left and 15 pixels above the bottom right corner of the image and change its color to
java.awt.Color.CYAN
.
- Save the file and test out what you have done by creating a
PictureManipulator
and seeing the results.
Save Your File
You should save the file you created, named PictureManipulator.java
into your own module4
directory.
Submission
You should make sure to name your class and save your file with the name PictureManipulator.java
. Submit this file by going back out to the Unix prompt and typing:
submit_cse113 PictureManipulator.java
Due date
Your lab submission is due no later than
11:59:59 pm on February 29th. Remember,
no late labs will be accepted.
Lab authored by Adrienne Decker