CPSC 170 Post Lab 2
Drawing
Due Before Lab on Tuesday, February 1st

bricks

For this assignment you will create a simple vector graphics drawing program like Adobe Illustrator or the open source Inkscape. A vector graphics program is different from a raster graphics program in that all objects that are drawn to a scene are stored parametrically instead of in a raster image, like in Adobe photoshop or Microsoft Paint. Storing objects this way allows the user of the program to zoom without losing detail and to more easily edit objects that have already been added. However, it also requires that the scene be re-rendered to a raster image for display every time a change is made.

Details

Begin by creating classes to store the objects that are drawn by the user. Create an abstract class that will be extended for each of the different shapes that can be drawn (an oval and a line are sufficient for this assignment, but you can add others if you wish). The abstract class should have instance variables that define the bounding region for an object to be drawn. Four floating point numbers representing the two points that define opposite corners of the object's bounding rectangle are sufficient. Also add a constructor that specifies the instance data and a paint method that takes a graphics object as a parameter, but does nothing. Next, define classes for the oval and the line that do define the contents of the paint method.

The last class you will need is a class that contains the main method and displays the window for the program. The window's main panel should contain two sub-panels. The Left sub-panel should contain radio buttons, aligned vertically, that represent the current tool that is selected by the user (oval, pencil, or zoom). You can use the images in the tar file DrawIcons.tar.gz for the radio buttons. The right sub-panel should be the panel that extends JPanel so that it can override paintComponent and be where the user can draw. This class should have an initially empty list of drawable objects as an instance variable. Every time the user draws something to the window the list should be updated with the new object. The paintComponent method should simply iterate over the entire list and draw every object.

Finally you will need to implement each of the different tools that the user selects.

Submission: Tar and submit your code on the course Inquire site.