Technical Guide

This guide is intended for programmers who wish to understand the internal workings of the What's In A Line? applet. It contains three sections. The first is a general description of the applet design. The second section is a class hierarchy in javadoc format. The last section is an index of all classes, fields and methods, also in javadoc format.


Applet Design:

The What's In A Line? applet consists of two parts; a GUI part and an Algorithm part. The GUI part represents the larger portion of the applet code and consists of 13 java files. The GUI is responsible for presenting graphics to the user, processing input and displaying algorithm output in graphical form. The GUI source files are in the ./classes directory:

The Algorithm part is responsible for controlling and executing the various algorithm and providing data for display by the GUI. The Algorithm part consists of five files, also in the ./classes directory:

In Java, each class is contained in its own source file which is named after the class. You can find complete definitions of each of these classes in the Class Hierarchy.

The What's In A Line? applet consists of five threads; the main program thread and one thread for each of the four scan conversion algorithms. The algorithm threads are created by the main thread when the applet is launched. All algorithm threads are initially suspended. When an algorithm is selected on the main panel of the applet, that algorithm thread is resumed and the current algorithm thread is suspended. When the applet is first launched, the Midpoint Line algorithm thread is resumed automatically by default. Pressing the control buttons on the applet (Run, Jog, etc.) causes methods to be invoked in the current algorithm thread that change an internal state variable within the algorithm. This variable is used to regulate execution of the algorithm. Here is the applet thread diagram:


Adding An Algorithm:

The following steps can be used to add a scan conversion algorithm to the applet:


Limitations:

The Algorithm class has a rigid format that must be adhered to. The algorithm must be instrumented manually. The text of the algorithm must be entered into the getText() function manually. Output is limited to individual pixels. These restrictions are not a problem in the current configuration but do limit the potential for further development. A tool could be developed to automate this process. But a more exciting solution would involve writing a Java bytecode interpreter and executing .class files directly. This would provide greater flexibility and would open the door for students who want to write their own graphics algorithms and test them using What's In A Line?

There are only two inputs to an algorithm: the two endpoints of a line or the center and a point on the radius of a circle. A generic mechanism for entering algorithm parameters would increase the flexibility of the applet. This should include text input through the feedback panel as well as cursor input through the Drawing Area.


Class Hierarchy


Index