CS1331 Homework 9
Due: Monday, November 13 at 8:00 pm

Introduction

This assignment will give you some experience working with classes, subclasses, interfaces, polymorphism and dynamic binding. You will develop some classes that will be interrelated via has-a and is-a relationships. This assignment is relatively open-ended so you should be creative and have some fun with it.

Fun with Pictures

In this program you will design a simple graphical editor program that allows a user to draw different shapes in a window. While we're not quite ready to build a competitor for PhotoShop, we'll at least take a first step in that direction.

You will be creating an interactive GUI that has a main drawing area. To the side should be icons for the different graphical shapes that can be drawn: lines, circles, rectangles, text, etc. The operator of the program will click on one of these icons to select that shape's drawing mode. The operator then will go to the drawing area and create an object. Note that drawing should be done with interactive rubber-banding as you likely have seen in other, more complex systems. Also include some icons for different colors so that the user can change drawing colors as well. Note that the program should remember the shapes in case the window needs to be regenerated, eg, after minimization. The user should also be able to change drawing mode by pressing a key (l-line, r-rectangle, c-circle, t-text).

Consider the bottom-left corner of the window as the "origin." If the operator resizes the window, all objects should remain in their same position relative to that corner. If the user makes the window smaller, then some objects may disappear. But if the window is subsequently enlarged, then the objects may become visible again. And remember to have your GUI window's components do reasonable things when the window is resized as well.

Requirements

This program is intentioanlly open-ended. Feel free to elaborate and embellish as much as you would like. The following features are considered to be core "required" items to gain full credit:

Further elaborations might include fancier color capabilities, more object types, other window actions such as "raising" and "lowering" objects, and so on.

Turn-in Procedures

After you have finished your program, turn the files in via Webwork You will be submitting multiple files. Please make sure they are named as shown below:

  • Drawer.java (Main startup class, makes the JFrame)
  • Shape.java (Abstract graphical object base class)
  • Any other classes you created