Java Source code of spline applets

The class SplineApplet is the top level Applet. It creates all the other objects and deals with user input (MouseUp, MouseDrag and MouseDown events).

The class CurveCanvas controls the Canvas that is used to draw the curve. It uses an offscreen Graphics to make the curve change smoothly when control points are dragged.

The class MouseEvent is used by SplineApplet to pass ouse events to CurveCanvas. If multiple MouseDrags occur before CurveCanvas is finished drawing a curve, MouseEvent discards the extra ones. This makes the interaction more responsive.

The class ControlCurve is the superclass for each class that draws a particular sort of curve. It stores all the control points and provides methods for adding and removing them.

Each sort of curve has it's own class which is responsible for drawing the curve. The implementation of these is done in the simplest way possible - I just evaluate the polynomial that defines the curve. There are much more efficient ways of doing this, but since we are only drawing one curve, this is good enough for our purposes

Finally, Cubic just implements a cubic polynomial. It is used by the natural cubic spline classes.


Contents
lambert@cse.unsw.edu.au
Last modified: Mon Nov 4 06:34:54 MET