Problem:
1. Add a method
public GeometryDescriptor pointGeometry(Point mouseLoc)
{
}
to your PedigreeView class. This method will take a mouse location in component coordinates and will return a descriptor that indicates the person ID, surname or given name and character index of what was selected. Your GeometryDescriptor should have a field for the person ID. If the mouseLoc is not over the name or icon of any person then your person ID should be -1. If the mouseLoc is over a person then you need a flag to indicate whether it was over the surname, given name or icon of that person. If the mouse is over anything but the surname or given name, then report it as an icon. You also need a field in GeometryDescriptor to give the index of the character in the surname or given name that was selected if a name was selected. You can implement GeometryDescriptor as an inner class inside of your pedigree view or as a class of its own. Your code does not need to report anything about the children of the Root node. We will not be doing anything with those in later programs.
When reporting the index of the character selected by the mouse, this should not include the ID numbers and it should not treat the surname and given name as one string. If you look at your model those items are separate and to edit those names you will need to get separate selections.
Your mouse location may be over a Nobody icon. If that occurs you will want to return the fact that this is a Nobody. who is the father or mother of some other personID. You will need this information in later programs so that you know where in the pedigree a new person should be added.
2. Add an event handler to your PedigreeView class that can handle mouseReleased events. On every mouseReleased event you should call your pointGeometry() method and write out a line to System.out indicating what was selected by the mouse location. This should be one line that indicates the ID, name and character index that was selected or that nothing was selected. In the case of Nobody selections, the child's PersonID should be displayed along with whether the Nobody is the father or the mother.
|