Statement of Completion
Overview
My basic design has merit but I do see room for improvement. My event handling
became a little tiresome because I didn't know whether I was dealing with
a node or an edge and had to explicitly check by using instanceof.
Also I ended up having Edge implement Dragable, even
though it's not really, so I could get the mouse pointer to change for
free when hovering above the edge's weight. This was really just a temporary
measure (looks good though). To fix this I would create a Visual
interface to replace both Drawable and Dragable. This
interface could include a method such as isDragable. Then I would
capture the events in VisualCanvas or some superclass and forward
them on to Node and Edge (since they would both implement
Visual). I was trying to keep the interfaces small as that is
a good rule of thumb. Still, the Visual interface would not have
to be awfully large.
Also I would have liked to keep my original non graphical graph and
algorithm implementations. Then subclass them to get the graphical varieties.
However I realised too late that this might have been possible. It was
too late to go back and rework.
Note that this assignment was implemented using the 1.1 event model.
Standard Part of Assignment
I have implemented all the functionality of the standard part of the assignment:
graph editing and running of SPF algorithm.
Extra Features
Support single stepping of the SPF animation
I have not implemented this feature.
Single stepping for the SPF algorithm would not have been difficult
to implement, but this is because of the nature of the algorithm. I could
have defined a method step in ShortestPathAlgorithm and
used it. However, a more extensible way to implement this would have been
to use notification and suspend/resume on the algorithm thread. This would
also have made it easier (possible?) to implement any other graph based
algorithm. I wasn't happy to implement this feature using the first option,
and didn't believe I would have time to implement using the second option,
so I chose to concentrate on other extensions.
Support animation of a second graph based algorithm of your choice
I have not implemented this feature.
This feature would not be hard to implement and would involve creating
a class Algorithm which all supported algorithms would inherit
from. Hence, the reason I originally chose to bundle SPF in a class of
it's own.
Some other interesting extension
I have implemented a few interesting extensions:
-
Nodes can be dragged around the canvas (but not off the canvas or you couldn't
get them back!).
-
Changing of mouse cursor when it's above the hot spot for either a node
or an edge
-
Context menus for nodes and edges.
-
Selection of the start node.
-
Modification of node names and edge weights via a dialog box. Note that
the dialog boxes do not work as well under IE4.0 (must click on text before
typing takes effect).
-
Selection of example graphs
-
Output of algorithm log to a text box
I also started work on undo/redo but I didn't finish. I have included the
classes I have written in my assignment.