Project Writeup
Introduction
On September 9 and 10, 1997, Eastman Kodak held its annual Software Engineering conference in Rochester, NY. The event has taken place every year, in one form or another, for the past ten years. The conference is intended as a way to get Kodak's software people together to talk about the current state-of-the-art in the computer industry and how its being applied at Kodak.
At 1996's conference four of the 29 talks had something to do with the World Wide Web. None of those four talks touched on Java. At this year's conference, there were seven Web related talks and four of those were on Java or Java related topics (two of those four were double sessions). Two keynote speakers also discussed Java topics. All sessions on the Web or Java were heavily attended by conference goers.
Ed Berard of The Object Agency, Inc gave the keynote address Wednesday morning. He told a very amusing anecdote about adopting new technologies. Paraphrased it goes something like this:
A young engineer at Boeing goes into the office of the President and says, "I've developed a new metal that has some very interesting properties. I think we should start using it instead of aluminum in all our new planes." The young engineer is laughed out of the office and is relegated to obscurity for the rest of his career.
At the same time, another young engineer at a medium-sized computer company in Silicon Valley goes into the office of the President and says, "I've developed a new Web technology that will allow us to do all kinds of cool stuff on the Internet. I think we should base all our new software on it." This young engineer is praised, patted on the back, promoted, given stock options and assigned a corner office.
In the abstract for this project I wrote, "The Internet is growing at a tremendous rate." That sentence has become a cliche, but it is also true. The previous story underlines how different the computer industry is from other traditional businesses. The environment in which the Internet continues to be forged is fast-paced and dynamic.
The Web is everywhere. Every new movie has its own web site; URLs appear on the sides of race cars and on all kinds of consumer products. Java and other Web technologies continue to receive much hype and coverage in the popular media. The Internet has become a valuable resource. One of the ways the Internet can be used is as a tool for learning. The Web's interactive and graphic nature make it a powerful medium for conveying information. With this project, it was my intention to use Java and Web technology to produce a tool to help others learn about some of the basic algorithms at the heart of computer graphics.
This document contains three major sections: Project Writeup, User's Guide, and Technical Documentation. The Project Writeup explains the evolution of the project and discusses what was learned in the process. The User's Guide explains how to use the applet and details all its functions. The Technical Documentation includes the design of the applet, explains how to extend it and outlines its limitations.
The project and associated documentation can be found on-line at:
Goals
I had four goals in mind as I started writing the project proposal for What's In A Line? I am fortunate that I was able to meet all of them with this project:
Project History and Development
The original concept for What's In A Line? was born after a short meeting with Professor Nan Schaller. I had gone to her with my project goals in mind and asked if she had any project ideas. She said she was looking for Web-based interactive tools for teaching basic computer graphics concepts. I spent a few days reviewing some topics in a computer graphics textbook. Initially I thought about leveraging a project/paper that I did when I took Computer Graphics Seminar by writing a program that would demonstrate how parallel algorithms rendered lines on multiprocessor computers. This was quickly dismissed because the topic was too advanced. Instead, I ended up heading in the other direction and settled on one of the most basic concepts of all: scan conversion of lines and circles. I threw in antialiasing as an advanced topic to round out the project . After selection of a project committee and a few revisions of the proposal, it was signed off and work began on the project itself.
The first thing I had to do was learn Java. The best book I found for this is Java in a Nutshell, by David Flanagan. The book is currently being offered in the 2nd edition, which covers Java 1.1. The first edition (which covers Java 1.0) may be even more valuable to Java newcomers because it contains more examples than the more recent version.
I started work on the program itself using a GUI builder. GUI builders are tools that allow you to rapidly create user interfaces from components on a palette. GUI builder have some drawbacks that usually show up in later cycles of the development process. So after doing some initial layout with the automated tool, I abandoned it and continued on my own.
Java is an interesting language. The syntax is similar to C++, but much simpler. There are no .h files and no pointers. All data types are passed by reference. Java is inherently object-oriented. All procedures (methods) must be part of a class. Classes are very easy to create and subclass. Java comes complete with a large collection of classes for doing GUI programming, network communication, file access, etc.
Java is also a very young language. It has all the difficulties associated with new technologies:
The development of the applet itself took place in stages. Once the GUI was in place, individual components were brought into it one at a time. First the Main Drawing Area was implemented that allows the user to define line and circle primitives. Then the Code Window was added for viewing algorithm source. Next the Zoom Canvas was added to allow closer viewing of rendered pixels. The basic algorithm control was connected to the control buttons. Finally, the scan-conversion algorithms were subclassed off of the algorithm control.
The ability to add applet components one at a time is due to the object-oriented nature of Java. A high-level design was sketched out as the project proposal was written. But the individual components were developed separately. The requirements for each component were taken from the proposal, an interface was put in place and the code was written for that component. It was then tested and debugged. As basic functionality of each component was achieved, it was integrated into the applet.
Finally, the project was documented. This included writing a User's Guide, a Technical Guide and this project Writeup. The User's Guide is intended for Internet surfers who intend to use the applet. It tells you how to get started and explains all the controls in detail. The Technical Guide is for programmers who want to dissect the applet and extend it for greater functionality. The Technical Guide explains the applet design and has a class hierarchy and class/method/field Index.
What Worked and What Didn't
Overall, the applet works well. All the applet functions specified in the proposal have been implemented. In fact, there are a few features that were extended beyond their original intention.
The Zoom Window was enhanced to include sliders so the operator can navigate to all parts of the available drawing area. The need for sliders became apparent after the first few circle primitives were drawn. As the arc of the circle changes, the pattern of rendered pixels changes too. It's important to be able to move around inside the zoom window to see these changes. Another enhancement to the Zoom Window was the addition of the resolution selector. Zoom Window pixel sizes are available from 10X to 50X.
Breakpoints were originally specified to be available at the beginning of the main loop of each algorithm. The Loop button was to work in concert with these predefined breakpoints. Breakpoints were enhanced by making them user definable. This is much more convenient and useful; the top of a loop may not always be the most desirable place for a breakpoint. It may be more interesting to set a breakpoint at, say, an else clause within a loop. And the breakpoints were expanded to work with the Jog and Run buttons to provide even more flexibility.
A cursor coordinate display was added to the lower left hand corner of the Drawing Area. This aids the user in setting endpoints with the cursor.
With all the success of the applet there are still a few things that could be improved. The method of painting pixels in the Drawing Area should probably be revisited. Pixels in the Drawing Area are painted in XOR mode. XOR mode is required because of the need to animate endpoint selection and the way Java paints and repaints the Canvas. But drawing in XOR mode causes a couple of problems. First, `holes' are produced when a primitive crosses the axes. Holes are also visible at the octant boundaries where the midpoint circle algorithm plots a pixel twice.
The second problem with drawing in XOR mode is related to the algorithm threads. If the Run button is used to re-render a primitive, the pixels are sometimes partially `inverted' and eventually flash back to the correct color. I believe this is the result of a race condition between resetting the Drawing Area and starting work on the next rendering. The work-around for this is to always press the Reset button before re-rendering.
Speed is another issue that I think could use some attention. While Java has a reputation for being slow, I think the overall efficiency of executing algorithms in Run mode could be improved. There is a lot of activity under the hood of this program during execution. Rendering to the two drawing areas and the updating of algorithm variables might be able to be streamlined quite a bit.
Finally, I think the use of color could be improved. I am not an artist. Colors were chosen more-or-less at random. I'm sure someone with artistic talent could provide some valuable tips on the use of color and maybe even suggest some improvements for the overall appearance of the project in general.
Future Development
In addition to the aesthetic improvements mentioned above (painting the Drawing Area, performance, creative presentation), there are a few areas where the project could be extended.
In keeping with the current theme, more line algorithms could be implemented. There are parallel versions (both SIMD and MIMD) of the Midpoint Line Algorithm that might be very interesting and easy to implement given Java's thread capability. See Adding An Algorithm in the Technical Documentation for more information.
In addition to an enlarged set of "stock" algorithms, the applet could be made into a tool for executing generic computer graphic algorithms. Advanced students could write algorithms in Java and present them to the applet for execution. The applet would have to be extended to include a Java bytecode interpreter. A toolkit would have to be supplied to support painting pixels, setting colors and displaying algorithm parameters.
Metrics
A few metrics on the development of the project were collected:
About The Author
David Kroth has been a software engineer with Eastman Kodak Company for nine years. He has worked in various divisions of the company including Business Imaging Systems, the Research Labs and Professional Motion Imaging. He has tackled various assignments in a range of fields including embedded systems programming, computer graphics, data communications and image processing.
David received a Bachelor of Science degree in Computer Science from Rochester Institute of Technology in 1988. This project completes his course of study for a Master of Science degree in the same field.
David can be reached via email at: kroth@kodak.com