Program 3 - Simple Interaction

Goal Description Hints Passoff

Due Date - Oct 21

Goal

 
Learn to handle various kinds of input events. Learn to correctly update the model and the view when interactive changes are made.
 CS 456
Description
 

1. Modify your model so that it implements a listener mechanism that your view can use. Modify your view so that any model changes are correctly reflected in the view using damages so that redrawing will handle the update correctly.

2. Modify your program so that if a mouse-up occurs on the ID or icon of any individual on the screen, that person becomes the new root person for the model. Use your essential geometry code to make this work.

3. Modify your program so that when mouse-up occurs on the surname or given name of a person,  an insertion  bar is displayed showing where text insertion will occur. If an icon or ID was selected then no insertion bar should appear. You may need to modify your essential geometry code to make certain that selection is accurate and that you can select the beginning of a name as well as the end.

Then add event handling for key events so that typing characters will add characters at the insertion point. Also implement backspace so that characters can be deleted. Use your model update and listener mechanism to correctly update the display.

4. If the user does a mouse-down on an ID or icon and then begins to move the mouse, display an icon under the cursor and drag it around the screen following the mouse. If the mouse is released over empty space, then unlink that individual from that location in your model. If the mouse is released over a nobody icon, then move that individual to the new location in the family tree by adjusting the father/mother links.  This individual now exists at two places in the pedigree (as frequently happens). The individual is not unlinked from the original location in the tree until a drag for unlink is perform.

Do not worry about creating cycles in the ancestry. If your paint and selection code correctly terminates when there is no more room to draw then there will be no infinite loop. In this project we are concerned with user interface techniques, not actual genealogy.

When a person is unlinked from a location in the tree he/she is NOT unlinked from any other location in the tree where he/she appears. Unlinking a person from a location is NOT the same as calling delete() on your model. An easy way to handle this would be to add an unlink() method to your model that unlinks a person from a location in the tree.

When you unlink an individual from a location in the tree they should be removed as the parent of the child shown in the tree. This does not mean that they are deleted from all of their children

Be careful with your mouse movement. Movement of less than 4 pixels followed by a mouse-up should not count as a drag. That should count as a click as in item 2. If the mouse moves more than that then the action is to drag as in item 4.

DO NOT HACK THIS PROGRAM

Your code will be inspected to see if you correctly implemented listeners and correctly used your essential geometry code. Learn the architecture. That is more important than hacking together something that works.

Hints
 
There is a sample program where the mouse chases a cat around the screen. This implements event handlers and model notification in ways similar to what you will need. Carefully read and understand this code.
Passoff
 
__ 1) Click on icon changes root person
__ 1) Click on ID changes root person
__ 3) Click on a name accurately places a text insertion bar
__ 1) Click not on a name correctly removes insertion bar
__ 3) Typing and backspacing correctly edits a name including correct placement of the new insertion bar position
__ 1) Dragging will move an icon around the screen under the mouse.
__ 1) Dragging to empty space unlinks an individual
__ 2) Dragging to a nobody icon correctly modifies the family tree.
__ 5) Correct architecture for communication between model, view and controller