Reference Manual

Design Specification

This manual describes the design of the applet. The requirements for the assignment were clearly specified by the instructor’s assignment page, but it was left to the student to choose a reasonable design and implementation.

Organization of Modules

From the beginning, I wanted to create something more visually appealing than simply a text box that displayed a solution. After all, we were told to use an Applet, not to implement a text-based program, so it made sense to take this as a challenge and produce something visually appealing.

At the same time, I wanted to keep a clear distinction between the user interface elements and the algorithm to solve the graph so that I might be able to change the user interface without affecting the code for the implementation.

I further decided to separate the code to read the graph files from the code to solve them. I thought this would allow me to create several different methods to solve a graph in case one implementation worked better than another.

The result was three main categories of functionality in the applet, and this is shown below. The functionality of the files is not completely separated as they are shown in the diagram, but generally this is how the code is organized.

organization.jpg

Classes

This section describes the classes in the applet implementation and how they interact with each other. I will describe each category described above: user interface classes, graph classes, and algorithm classes.

Algorithm Classes

These classes were designed to solve graphs. The BruteForceSolver class is the main algorithm described in my paper that finds the solution for the problem posed in the assignment. The PathFinder was also described in my paper, and it is the implementation of the A* algorithm, used to find paths the robot takes to and from the solution sequence. The BooleanMatrix and Stack classes are helper classes used to improve the readability of the main algorithm classes.

algorithm.jpg

Graphs

These classes were designed to work with graphs objects but not to solve them. The Graph class is an immutable class that loads graphs from a text input stream. Like other classes in the applet, it throws a GraphException object when it detects any kind of problem with the stream. The GraphBuilder class is a mutable class, which is used to simplify the creation of a graph, and the GraphRandomizer class creates new pseudo-random graph objects. The GraphSolver is an abstract class that defines the interface that algorithms use to solve graphs. The output of a graph-solving algorithm is encapsulated in the GraphSolution class.

graphs.jpg

User Interface

These classes were designed primarily to handle user interface features of the applet. The main entry point of the applet is implemented in the RoombaApplet class. It uses two helper classes, the StatusLabel and GraphBox classes, to draw the status and graph on the display. The graph box in turn uses a helper class, the InformationFrame, to display a popup window that shows full details about the graph and solution displayed in the box. The GraphOutline class implements functionality necessary to draw the obstacle and graph borders. The AnchorLayoutManager class is used to dynamically position the components within the applet as it is resized. The BackgroundWorker class is used to keep the user interface responsive while difficult graphs are solved.

user-interface.jpg

JavaDoc

All classes, methods, and fields in the implementation are commented using JavaDoc syntax, and as a result, it is straightforward to produce HTML documentation for the code. These low-level details of the source code may be found here.

Links

Valid HTML 4.01 Valid CSS