Introduction to Data Structures and Algorithms
Assignment 1 Part A: ArrayLists

  • Due 19 April , 7pm

What To Hand In

  • SlideShow.java

Do not rename these files.

Remember to submit all of these files. When you have submitted them, check that you can read the files listed on the submission page, and complete the submission process.

Slide show (Weight: 2/3)

Complete a program that allows a user to create and view a slide show of images. A slide show is essentially a list of names of image files. There should be a field to store this list of file names.

When creating a slideshow, the program should show thumbnails of all the images laid out in order on the window. The user should be able to edit the list of images.

When showing a slideshow, the program should cycle through the list, showing each image for one second.

The assignment directory comes with a set of images you can use to create your slideshow. You can add other images if you wish (they work best if they are square).

The program has two main modes: editing the slide show and running the slide show

Editing

When editing a slide show, the program will show thumbnails of all the images in the current list. It will also highlight the currently selected image. The user should be able to
  • Add a new image, before or after the currently selected image (using UIFileChooser to let the user select the image file).
  • Remove the currently selected image from the list, or remove all the images.
  • Move the currently selected image to the left, to the right, to the beginning, or to the end.
  • Reverse the list
  • Shuffle the list randomly

The user can use arrow keys or the home/end keys to change the current selection. The current selection should be stored as an integer in a field. The integer should be the index of an image in the list.

Running

If the user starts a slide show, the program should set the showRunning field to be true, show a large version of the currently selected image, and then loop through the list by incrementing the current selection and redisplaying once per second. When it gets to the end of the list, it should start from the beginning again. It should keep looping until the showRunning field becomes false.

The button for stopping the slide show simply changes the showRunning field back to false, which will make the loop exit.

Files

SlideShow.java contains a template for the program. It has some of the code for the user interface, and some hints about the methods, but not much more. There are hints in the setupGUI and doKey methods!

Note that you may need to comment out some bits of the template while you are getting the program to work - don't try to make everything work all at once!

The "Testing" button should make it easier to test your program by adding a set of images instantly.

Core

Implement the following in the SlideShow program:

Editing
  1. Display the list of thumbnail images. The thumbnails should be displayed left to right, in COLUMNS columns.
  2. Highlight the currently selected image (eg, by drawing a red rectangle around it).
  3. Enable the user to add a new image before the currently selected image.
  4. Enable the user to delete the currently selected image, and to remove all images.
  5. Enable the user to move the currently selected image to the left, to the right, to the beginning, or to the end of the list.
  6. Enable the user to change which image is selected (see the hints in the doKey method). Note, the mouse cursor needs to be over the graphics pane for the keys to work!

Running
  1. Complete the runShow method so that it starts a loop to repeatedly display the currently selected image then, after one second, move to the next image. The loop should stop when the showRunning field is false. Make sure that you don't have two copies of runShow running at the same time!
  2. Complete the editShow method to stop the show running, and display the list of all thumbnails again.

Completion

Add the following functionality:
  1. Enable the user to add a new image file name after the currently selected image
  2. Enable the user to reverse the order of the images in the list, and to shuffle them randomly. (Look for useful methods in the Collections class.)
  3. Make sure that the program does not break (ie, doesn't cause an Exception) if
    • there are no images in the list, or
    • the user tries to select (or move) an image beyond the ends of the list, or
    • the slideshow runs to the end of the list, or
    • the user tries to add, remove, or move images while the slide show is running

Challenge

  1. Enable the user to use the mouse to select an image or to move an image to another position in the list. (Hint: moving an image forward in the list works a little differently from moving an image backward in the list.)
  2. Enable more keys: allow the user to change the selection up or down a row, as well as left and right, and give shortcut keys for adding, removing, and moving images.
  3. Add additional functionality to make the slide show nicer or better in some way, eg, saving/loading a slide show to/from a file, making the program's parameters user adjustable (speed, size, layout, etc), scrolling through very large lists, "fisheye" effect to handle very large lists, ...