Developing User Interfaces
CMSC 498B
Spring 2002
Prof. Ben Bederson
Project #1
Due February 21, 2001
The purpose of this program is to gain familiarity with Java's and C#'s drawing facilities. This is also an exercise in using the I/O and string facilities that you will need in later programs.
You must display all GIF and JPEG images found in a directory along with their names. The file name is to be displayed immediately below each image. The images and titles should be laid out in a grid that reacts to the current window size. As many images should be laid out horizontally as will fit completely in the window, and as many rows should be created as needed to display all the images. A vertical scroll bar should allow you to scroll to see the images that are off the screen. If the window is resized, the images should be relayed out to accommodate the change. You must write the program once in Java and once in C#. Each program should look and behave identically (or as close as possible given the differences in some widgets). Your program should put up a window that displays the graphics with a scrollbar. There should be no other interactivity. The program should be launched by specifying a required directory name that it should load the images from.
The requirements of the project are:
- Write your code using emacs, and build and run your code using the command-line compiler and run-time. Do not use an IDE.
- Read directory name of images from the first (required) command-line argument. Note that you should only read the images of the specified directory - do not search subdirectories.
- Render images scaled to fit in a 150x150 box
- Render a 3 pixel thick light gray border around that 150x150 box
- Render the image file name (excluding directory information) centered, immediately below the images
- Lay out the images in a grid with a 15 pixel padding around each image and label pair
- No image should ever be clipped horizontally (unless the width of the window is less than 150 pixels in which case only one image should be placed on each row, and it can be clipped. A horizontal scrollbar in this case is not necessary.
- If the images don't all fit in the window, they should fall off the bottom, and the scrollbar should scroll vertically.
- You must implement scrolling by having a fixed size component, and altering how you render within that component. It is not ok to make a huge component and just scroll the component.
- Relayout the image grid when the window is resized
- The background of the window should be white
- Recognize GIF and JPEG images by their filename extensions. GIF images are assumed to have an extension of any combination of upper and lower case letters of ".gif" JPEG images are assumed to have an extension of any combination of upper and lower case letters of ".jpg" or ".jpeg"
- If there is a second command-line argument, then assume this is a valid number which should specify the size that the images should be rendered at. If this argument is not specified, it should default to 150.
- If there is a third command-line argument, then assume this is a valid number which should specify the amount of padding between images. If it is not specified, it should default to 15.
- If no command-line arguments are given, then print the usage of your program to stdout
- Follow good coding standards (well structured and documented code), and follow the naming conventions described in class.
For the Java version, the only widget classes that you are allowed to use are the JComponent, JFrame and JScrollBar. You must build this assignment from scratch using the Graphics/Graphics2D object to draw and by implementing your own subclass of JComponent.
For the C# version, the only widget classes that you are allowed to use are the Control, Form and VScrollBar. You must build this assignment from scratch using the Graphics object to draw and by implementing your own subclass of Control.
You can test your program with the images in /users/bederson/pub/images on WAM, accessible on the PCs in t:\wam\home\wam\b\e\bederson\pub\images
The files are also available zipped if you want to download them to your local machine in
images.zip
form.Resize += new EventHandler(resizeEventHandler)
...
public void resizeEventHandler(object sender, EventArgs e) { Size size = form.ClientSize; ... }
Submit your program by creating a zip file of all the source code files related to your project, login to a unix WAM computer, and run the WAM submit program. This is cource CMSC 498B, Section 0101, Project #1.