The GraphPanel class relies solely on mouse generated events to allow users to add, move and delete Edge and Vertex objects. To add a Vertex the user clicks the mouse on the drawing image anywhere not on the graph. The user can add an Edge by clicking on the origin Vertex and then clicking on the destination Vertex. Moving a Vertex is acomplished by the well known click and drag method. That is, to move a Vertex the user clicks on the Vertex and then moves the mouse while holding the mouse button down to place the Vertex in the desired location. The movement is animated as discussed above. Moving Edge objects directly is not allowed. To delete an Edge or Vertex, the user simply clicks on the Edge or Vertex and then clicks on the TrashCan. Vertices can also be deleted by dragging them to the TrashCan. The GraphPanel also allows users to select an Edge or Vertex which is then highlighted. All of this is accomplished by mouseUp(), mouseDown(), and mouseDrag() methods which handle the corresponding events. The adjInside() method is used to trap the Vertex objects inside the drawing region.
Explaining how simply the interface works is much easier than making it work. Consider what it means when the user presses the mouse button down. If nothing in the Graph has already been selected, then he must want to add a Vertex, select a Vertex, or select an Edge. Otherwise he wants to add an Edge, select an Edge, unselect the prior selection, or delete the prior selection. In either case we need to know if the mouse pointer was on the Graph, and if so on what Edge or Vertex. As you can see already, determining what the user wants to do is a complicated process.
Note that the GraphPanel class uses UNNL objects to manage vertex numbers.