Lab 6
Objectives: Object I/O, handling mouse events, simple geometric algorithms
Start with the line drawing code developed in class: BasicLinePix.java, and Line.java.
- Add the following methods to the Line class.
- public int distanceFrom(int x, int y): this method returns the distance from (x,y) to the mid point of the line.
- public void rotate90(): this method rotates the line by 90 degrees around its mid point
- Make the following modifications to BasicLinePix:
- Add code so that a mouse click on the drawing panel, while the control-key is held down, causes the line whose mid point is nearest to the point where the mouse was clicked to be rotated by 90 degrees. Consult the API to see how to detect if the control-key was down when the mouse was clicked.
- Modify the saveDrawing() and loadDrawing() methods to use object I/O. Here is an example of object I/O.