WCM Project | WCM Project on SourceForge | JavaDoc Documentation ]

Webcompmath
Programming Information



WCM (Web Components for Mathematics) is a collection of Java classes that can be used to assemble educational mathematical applets and programs. The current version is written in Java 1.5 and covers mainly pre-calculus and calculus. The main project page has more information and links to sample applets. This page gives an overview of how the system is designed and how to program with it. This information is meant for people who understand Java.

The WCM classes are contained in several Java packages: net.sourceforge.webcompmath.applets, net.sourceforge.webcompmath.data,  net.sourceforge.webcompmath.awt,  net.sourceforge.webcompmath.draw, net.sourceforge.webcompmath.functions and several other packages ending in .beans. What follows on this page is an overview of each package with a link to a page that discusses the classes in that package in more detail.


Package net.sourceforge.webcompmath.applets

The net.sourceforge.webcompmath.applets package contains the classes for the configurable applets. In general, these are used as is and customized via various params coded into the html for a web page. However, you can use one of these applets as a starting place to make a new configurable applet. GenericGraphApplet is the base class for most of these applets and provides much of the framework, including the processing of a large number of params

For more details, click here.


Package net.sourceforge.webcompmath.data

The net.sourceforge.webcompmath.data package contains the core classes for working with mathematical objects such as variables, expressions, and functions. (This package should probably have been named net.sourceforge.webcompmath.core, but the name stuck from an earlier version.) The Value interface represents an object that has a real number value. This interface is implemented by classes such as Constant, which represents a constant value, Variable, which is a subclass of Constant that allows its value to be changed, and Expression, which represents mathematical expressions such as "x^2+3" and "sqrt(2*x)". Objects of any of these types can be used elsewhere in WCM where Value objects are required. The Function interface defines another type of mathematical object: a function that can be evaluated on an array of Values. A SimpleFunction object provides a basic way of creating a function: by considering an Expression as a function of one or more of the variables that it contains.

An object of type Parser is used to parse an expression represented as a string, such as "x^2+3", and to produce the corresponding object of type Expression. Variables can be added to a Parser, which then becomes able to understand those variables when they occur in expressions. Things that can be added to a Parser implement the MathObject interface. The ParserExtension interface is a type of MathObject that makes it possible to extend the capabilities of a parser, although doing so involves some rather tricky programming.

The classes in net.sourceforge.webcompmath.data do not depend on any of the other classes in the WCM, so they could be used independently in other software projects.

For more details, click here.


Package net.sourceforge.webcompmath.awt

The net.sourceforge.webcompmath.awt package provides classes for building the Graphical User Interface of a mathematical applet or program. Many of these classes are subclasses of Java's Swing components (I chose to keep the original .awt name for the package from JCM, instead of renaming it to .swing). Some of the classes correspond to mathematical objects. An ExpressionInput is an input box where the user can type in a mathematical expression. Similarly, a VariableInput can be used to enter the value of a variable. A VariableJSlider lets the user set the value of a variable in another way: by adjusting a slider. A DisplayLabel is a Label that can display the values of one or more Value objects, embedded in a string of text. A DataTableInput makes it possible for the user to input numbers in multiple rows and columns.

In a mathematical applet, something has to happen when the user enters a new value for a variable or expression. Other objects, such as graphs or value displays, have to be updated to reflect the change. In the WCM, the updates are done by a Controller object. A Controller works with objects of three types: InputObject, which represents objects that can change, requiring other updates; Computable which represents object that might have to be updated; and Tie, which makes it possible to synchronize two objects so that they will always have the same value. Objects of these three types must be added to a Controller if they are to function properly, and, in addition, each InputObject must be set to notify the Controller when it changes in order for the change to have any effect on other objects.

The WcmPanel class makes it possible to avoid much of the work of setting up Controllers. WcmPanel is a subclass of Java's JPanel class, so it can contain other graphical user interface components, including other WcmPanels. If an interface is built entirely of WcmPanels, then most of the Controller setup is done automatically, and anther aspect of the setup can be accomplished simply by calling the gatherInputs() method in the main WcmPanel.

For more details, click here.


Package net.sourceforge.webcompmath.draw

The net.sourceforge.webcompmath.draw package makes it possible to display two-dimensional graphical objects such as graphs of functions, parametric curves, and vector fields. The core class in the package is DisplayCanvas, which represents an area where such objects can be displayed. A CoordinateRect is an object that lays out horizontal and vertical coordinates on a DisplayCanvas (or on a rectangular area within a DisplayCanvas). Graphical objects are actually associated with CoordinateRects. A LimitControlPanel is a graphical user interface component that can be placed elsewhere in an applet -- outside the DisplayCanvas -- to allow the user to control the range of horizontal and vertical coordinates on a CoordinateRect.

Objects that can be added to CoordinateRects are subclasses of the abstract class Drawable. These include, for example: WcmAxes, representing pair of horizontal and vertical coordinate axes, and Graph1D, representing the graph of a function of one variable. The DrawString class makes it possible to display some text, which can include the values of one or more Value objects. DrawGeometric can produce geometric objects such as lines and rectangles. A TangentLine is a type of DrawGeometric that represents the tangent line to a given function at a giveb x-coordinate (which is specified by a Value object).

Some of the things that can be added to a CoordinateRect are InputObjects, which allow user interaction. A MouseTracker is an invisible Drawable that responds when the user clicks or clicks-and-drags the mouse on the DisplayCanvas. The x- and y-coordinates of the mouse are Variables whose values can provide input to other objects. A DraggablePoint is similar, except that is visible. The user can drag a DraggablePoint around, thereby changing the values of the associated variables. A Panner is another invisible Drawable that responds when the user right-clicks-and-drags on the DisplayCanvas. It let's the user slide the coordinate rectangle around in the xy-plane.

For more details, click here.


Package net.sourceforge.webcompmath.functions

The net.sourceforge.webcompmath.functions package provides a few classes for working with functions. A Parser, by default, knows about certain standard functions such as sin(x). The class ExpressionFunction makes it possible to define other, non-standard functions, and add them to a Parser so that they can be used in expressions. An ExpressionFunction is defined by a mathematical expression. A TableFunction, on the other hand, is defined by a finite table of (x,y)-points. It is possible to use several different interpolation methods to compute the value of the function at x-coordinates that lie between points in the table. A TableFuctionGraph is a Drawable object that can be added to a DisplayCanvas. It lets the user modify a TableFunction interactively, by dragging points up and down. A TableFunctionInput is a large JPanel where the user can define a TableFunction by typing in values and by interacting with the graph of the function. (This class is not used in the current WCM version. It should be part of a more general facility for entering and editing functions. This might be added to a future version of WCM.)

The SummationParser class represents another way to add capabilities to a Parser. If a SummationParser object is added to a Parser, the parser will understand summations such as "sum(i,1,10,x/i)".

For more details, click here.


Package net.sourceforge.webcompmath.*.beans

The net.sourceforge.webcompmath.*.beans packages provide JavaBean implementations of many of the other classes in WCM. The goal is for these bean versions of the class to be used by GUI-builder tools in creating WCM applets. The Eclipse Visual Editor is one example of such a tool. These bean versions of classes usually subclass one of the WCM classes in the main packages and provide explicit set/get methods for the parameters for that class, with the intention that these parameters be set via property sheets in the GUI builder tool. In many cases the bean classes also simplify their base class, hiding some of the less-used functionality and attempting to automatically wire up controllers and error reporters. While intended for use with GUI-builders, the bean classes can also be used in hand-coded applets, just like any of the other WCM classes. 

For more details, click here.


WCM Project | WCM Project on SourceForge | JavaDoc Documentation ]