Approach

Outline:

I want to have a nice 3d applet with toolbars and button and the like. I wanted to be able to draw other things other than just lines. I also wanted to be able to change the colours and shapes and the background. I didn't want to have code that looked like a case statement - I was trying for real OO. I also wanted to try to create some reusable classes.

Steps: (as I recall them)

  1. I started with the first Scribble applet from Java in a Nutshell. I think I upgraded this to the AWT 1.1 event model right away.
  2. I had a look at a line drawing application in Teach Yourself Java 1.1 in 21 days. I introduced line drawing and rubber banding.
  3. I wrote some 3d helper classes for buttons and panels I wanted to use for my applet. I searched the net here for code and got some ideas from someone called Sunit. However I didn't copy any code and ended up using Paintbrush (Win95) to zoom in on 3d buttons and panels. This Sunit also had a OODraw application which I looked at, however it wasn't very OO but it did give me some clues what not to do.
  4. I was interested in getting this to work as an application as well as an applet. I was using Kawa version 1.0 and it was easier to run an application from the IDE than an applet. I had installed J++ and found that a default application/applet project can be created. I got some ideas from this including the idea that both the application and applet can have the same parameters. However, I wasn't pleased with their use of a variable (f_StandAlone I think). This was a flag to indicate whether it was an applet or an application - it then did different things in the code based on this flag. I wanted a better way. I searched in the reference in Java in a Nutshell and came across some an interface called AppletStub which I implemented.
  5. I think made the classes Parameter and ColorParameter to handle reading the applet parameters for my. I integrated this with BaseApplet class.
  6. I threw some reusable class into a package called jaffasoft.cts.
  7. I knew all along that I wouldn't be happy with just simples lines, so I created a class called Shape (later renamed to Visual). I also created a few subclasses. I also created VisualTool abstract class and a "Tool" class for each shape so that the shapes could all be delivered from the same function. This made it easier (or possible) to change the shapes which are currently being drawn generically.
  8. I spent too much time trying to make it look good.
  9. Once I had created the FillRect visual I realized that I should probably use some sort of optimization on my painting (double-buffering). After some time I ended up with 2 images, one containing all current visuals and one which I draw to the screen. The idea here was never to draw a shape directly and also optimise the drawing of existing shapes be using another image (maybe this is triple-buffering). The tricky part was getting the Images to grow when the window was resized (this very definitely important for an application but I'm not sure if an applet can be resized). A interesting enhancement which I didn't implement would be generalising this "triple-buffering" into a class called, say, BufferedCanvas.
  10. I decided though, that I didn't have time to write an ImageButton class and thought it best not to use someone else's.
  11. Added menus/popup menus and shortcuts. The shortcuts don't seem to work. I think this is to do with my ScribbleCanvas being unable to get the keyboard focus. (Shortcuts don't work in IE 4.0, but look like they should in Netscape 4.04).
Tools:

I mostly using Kawa 1.0. I did install and try Microsoft J++ but it wouldn't handle the 1.1 event model so I uninstalled it. Later I downloaded SuperCede but it looked like it would take too long to get into it (and too much SuperCede code used in your applets). In the end I downloaded the latest version of Kawa which look quite nice (2.0 I think).