Extending the line drawing program
Document your code using javadoc
Extend the Line Pix assignment to allow users to draw lines and rectangles.
- Write a Shape class. This class can initially be empty, i.e no properties and no methods.
- Develop your own Rectangle class that extends the Shape class. Do not use the Rectangle class in the java.awt package.
- Have your Line class extend the Shape class.
- Modify the menu so that the user can indicate whether they will be drawing a line or a rectangle.
- The user interaction for drawing rectangles is similar to that for drawing lines.
- Drawing a rectangle starts with a mouse press. Call this point A.
- As the user drags the mouse, a rectangle appears whose top left corner corresponds to point A and whose bottom right corner corresponds to the current location of the mouse.
- The point where the user releases the mouse marks the final location of the bottom right corner of the rectangle.
- Create an ArrayList of Shapes. All lines and rectangles are added to this ArrayList when they are created.
- To draw all the lines and rectangles, traverse the ArrayList of Shapes and send each element in the ArrayList the draw(g) message, where g is a reference to the Graphics context of the drawing panel.
- What modifications are needed to the Shape class to enable this?