Programming Assignment #4       Due Midnight November 29, 2004
Objective

To develop a software package that will function as a simple shape drawing tool.

User Interface

Your software will include the following user interface elements:

  1. A menu bar with the following options (and sub-options):
    1. File (New, Open, Save, Exit),
    2. Edit (Select, Cut, Eraser: small, large)
    3. Shapes (Quadrilateral, Kite, Trapezoid, Isosceles Trapezoid, Parallelogram, Rhombus, Rectangle, Square) -optionally incorporate into a JComboBox.
  2. A tool section with the following controls. These can be simple buttons with text captions or a JComboBox where appropriate.
    1. Line
    2. Circle
    3. Quadrilateral
    4. Selection tool
    5. Update Color
    6. Refresh drawing
  3. A color section with at least four colors and an indicator for current drawing color. In addition to the basic color choices presented, give the user the option of selecting a custom color using a JColorChooser.
  4. An area on which the user performs the drawing.

Desired functionality

The software will have the following functionality:

  1. (10 points) Allow user to draw quadrilaterals, circles, and lines. The user will specify location and dimensions of the shapes using mouse interaction as specified below.
     
     Lines: A left mouse press marks the start coordinate of the line. The user then indicates line direction and length by dragging the mouse. Mouse release marks the end of the line. The user interface displays the current line as the user performs the mouse drag.
     
    Quadrilaterals: Left mouse press marks the coordinates of the top left corner of the rectangle. Rectangle dimensions are indicated by mouse drag. Mouse release marks the bottom right corner of the rectangle.
     
     
    Ovals: Left mouse press marks the coordinates of the TOP LEFT CORNER of the rectangle within which the oval is inscribed. Mouse drag indicates dimensions of the oval. Mouse release marks the final size of the oval.
     
  2. (10 points) Shape selection: Allow user to select a shape that appears on the drawing. The user indicates shape to be selected by a mouse click within (or on) the shape to be selected . The software responds by rendering the selected shape in distinctive color (not one of your basic color choices.)
     
  3. (10 points) Allow user to cut the selected shape from the drawing.
     
  4. (10 points) Allow user to erase by filling in with the background color using the right mouse button..
     
  5. (10 points) Allow user to pick current drawing color from a color panel that includes at least four colors including a JColorChooser selection.
     
  6. (10 points) Control to update color: Allows user to select a previously drawn shape and change its color to the current drawing color.
     
  7. (10 points) A refresh control that allows user to refresh the drawing at any time.
     
  8. (10 points) Allow user to save a drawing to a user specified file.
     
  9. (10 points) Allow user to open, display and modify a drawing previously saved in a file.
     
  10. (10 points) Color control, allow the user to draw the object filled or just its outline. The object when applicable, can have a different fill and outline colors.

Software Design

  1. You will implement classes to represent each of the three shapes: quadrilaterals, circles, and lines. Follow the examples and techniques from Labs 13,  14a, and 14b. You may use your Lab 14b source code as a starting point.

Project Grading

Credit will given for completing the tasks identified in the section above. Each task will be scored on a Boolean basis. That is, your software either provides the desired functionality or it does not.


 

Questions answered:

 

Add g.dispose() to your open method.

The Graphics object should have the same state when you're finished painting as it had when you started.

Change drawRect to fillRect. This gives better behavior, but doesn’t solve the problem - if it is a problem. 

 Addressing this in the lab is not required. But when you resolve your persistence problem this goes away. To see the persistence problem, just minimize then maximize the frame and notice how your bottomPanel is empty. Don’t need to fix this for now. This is why I put a refresh requirement in Program 4.

This link may be beneficial:

http://java.sun.com/docs/books/tutorial/uiswing/14painting/concepts2.html

Also, look at Chapter 5 in our text.