Copyright RIT 2008
$Id: writeup.xml,v 1.14 2009/03/08 20:20:53 vcss232 Exp $
You will learn to use the Revision Control System (RCS) to manage versions of your Java source files. This lab will refresh your programming memory by having you fix a Java program that has syntax problems in them.
The last activities teach you about processing JPEG image files. You will manipulate a two dimensional array. You will practice processing arrays containing pixels from standard JPEG (or jpeg or jpg) pictures, accessing each pixel (processing a 2-D array) and invoking various predefined methods documented in a javadoc.
You are to work on this lab completely on your own.
Read the document An Introduction to RCS (./Auxiliary/rcs.html)
Read the UNIX manual pages for RCS (http://www.cs.rit.edu/~hpb/Man/_Man_Gnu_html/html1/rcsintro.1.html) , and the RCS ci (http://www.cs.rit.edu/~hpb/Man/_Man_Gnu_html/html1/ci.1.html) and co (http://www.cs.rit.edu/~hpb/Man/_Man_Gnu_html/html1/co.1.html) commands.
Each lab you will do is separated into a set of activities. Each activity has specific things you must hand in to get credit for it. Each activity is graded separately.
Most of the lab sections taught in the CS Department use the
try command to allow students to electronically
submit their work. In addition to managing submissions, the
try system also helps the lab instructors to keep
track of who is in their lab sections and the grades for each
student. In order for try to work correctly, you
must register for a lab section for each of the CS courses
that you are enrolled in. You only need to register once for
each course, and usually the first activity of your first lab
will step you through the registration process.
To register with try, open a terminal window
and from a Unix prompt type the following command:
|
If you type the command correctly, you will be asked to enter your lecture and lab section numbers; be sure you enter them correctly or else you will not get credit for your submitted work! If you make a mistake, tell your lab instructor right away!
When you register for labs in other courses, the
only thing that will change in the try
command is the name of the course you take.
Here the course you are taking is CS2, so the
second argument to the try command,
grd-232, identifies the
course's grader account.
First create a labs subdirectory under your CS2 course subdirectory, and make labs your current directory. Download a copy of labRCSMediaComp.jar (http://www.cs.rit.edu/~vcss232/pub/lab01/Binaries/labRCSMediaComp.jar) , which contains the files you need to complete this lab. Unpack the jar file using the command:
|
You will do all activities within the
lab1 directory.
Inside the lab1
directory created by unpacking the jar, you will find an
RCS subdirectory containing several version control files
and RCS/Hello.java.
The RCS/Hello.java file
does not belong
in the RCS directory; it was put there to make you
more familiar with RCS repository organization.
Move RCS/Hello.java
to ., the current directory
(and the parent directory of RCS.
Read the document An Introduction to RCS (./Auxiliary/rcs.html) .
The RCS directory contains what's known as the
archive
for a file named InsertSort.java.
This RCS archive file name is
InsertSort.java,v.
While in the lab1 directory,
use RCS commands to retrieve version 1.3 of this file.
Check that the file you obtained contains the correct revision.
You will submit this file at the end of this activity.
Hello.java is
a short Java file that has not yet been archived in RCS.
Treat this as your own program and
add the standard header comments to it. You must include
the RCS tag entries for the identification line and the
revision log. If you cannot remember the standard
header file block comment format, look at the
Java documentation standards
(http://www.cs.rit.edu/~fyj/java-coding-standard.html)
to learn about the expected Java code file format.
Add the appropriate comment blocks and content, check in
the file, and then check it back out again for editing.
The Hello.java program has a
minor mistake that prevents it from compiling.
Find and fix the error. After you have
corrected the mistake, check the file back into RCS.
When you check the file in, RCS asks you for a comment;
make sure the log message you type
indicates what you did to fix the program.
Your message should be brief (a one-liner in this case).
Check the file out again in 'read-only' mode, and see
what RCS did to your program.
When you are finished submit your Activity 1 work by executing the following command:
|
From now on in CS courses, you will be expected to use version control while writing programs. All the code you submit must have the appropriately tagged and completed RCS entries in it.
Emacs provides tools that makes using RCS easy. The Emacs and RCS (http://www.cs.rit.edu/~cs1/Labs/Tips/emacs-rcs.html) link will help you learn how to use RCS from emacs.
You will create Negative.java,
a program that takes an image file
and displays its negative image.
To get background on the remaining activities, please read about Image Processing with MediaComp (./Auxiliary/MediaCompInfo.html) . There are class files to download and javadocs to use for completing the rest of this lab.
The javadocs for MediaComp classes may be found at MediaComp javadocs (http://www.cs.rit.edu/~vcss232/pub/MediaComp/javadoc/index.html) .
For this activity, you will write a program that loads a JPEG picture, prints the answers to some questions, and creates a negative image of the loaded picture. When it executes, your program should print the answers to the standard output. This activity is designed to provide you with more practice at interpreting a standard javadoc.
Here is a list of the first things you should do when
you write Negative.java:
Picture()
WITHOUT the file name because we don't know whether
the file name is good; this creates a new object.
You should NOT use
the constructor Picture( aFileName )
The constructor that takes a file name
does not handle bad input; it starts to present a
window without first checking for the file's existence.
Therefore it's better to use the no-parameter constructor.
load( aFileName ) method
and pass the command line argument as the file name.
The load() method checks that the file exists, and
if the operation would fail, load() returns false.
If load() returns true, then the program knows it
can proceed to process the loaded image data.
cp ~vcss232/pub/MediaComp/pictures/* . )
You could also use a file of your own;
A digital camera photo should work fine.
show() to display
your picture in a standard Java JFrame (window).
The code should look something like this:
myPicture.show();
Below is sample output for what your program should produce. The text in braces {} contains the actual values for the swan.jpg image. Different images will have different values.
|
Note: Your program may not display completely or
hang unless unless the code pauses
a little before it explicitly exits.
Here is a code segment to put at the end of the main()
method:
|
Now we can load and display a digital picture. Knowing the height and width, we could write a nested loop to access each pixel. Let's modify each pixel and change the colors in the picture.
You may remember using a film-based camera. Film-based cameras capture images on photographic film that must be developed; the images captured are negative images of the original scene. What is returned with your developed film are the printed pictures and the negatives.
You will create a negative of the picture
identified in the command line.
For example: java Negative swan.jpg
will create the negative of the file "swan.jpg".
Your program must check whether the user provided a command line argument; if the file name is not provided or the file can't be accessed, the program must print an error message and gracefully terminate your program. The program must print the message to System.out, and the text of your error message should be:
|
Here is the rest of what to do for this activity:
show()
method to display your modified picture object.
Remember that, as you proceed, you must use RCS to manage versions of your file.
After you have your program working correctly and documented properly, use RCS to check in your files and create a version. Then submit your solution by typing the following command:
|
NOTE: You should ignore X11-related error messages presented by try; these are due to authentication issues for window display. The try system is checking your program with an invalid file name, but the MediaComp libraries try to talk to the X11 windowing system. You also must not quit out of the 'more' command during submission; press the space bar to continue so that your submission runs to the end.
For this activity, add a border around your picture. You pick the color and the width of the border. Determine the loops you will need, and find the method to set the color of a pixel. Check out the Color class in the Java API. You may use any standard color or mix your own color using a combination of RGB values.
You may start this program by copying the program from your previous activity as a starting point.
In the documentation for your program, describe what you did to create the border and how you did it. These should be in the javadoc for the method that does the work.
After you have your program working correctly and documented properly, use RCS to check in your files and create a version. Then submit your solution by typing the following command:
|
Grade Breakdown: