[ JCM Project | JavaDoc Documentation ]

JCM Version 1.0
Programming Information



JCM (Java 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.1 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 JCM classes are contained in four Java packages: edu.hws.jcm.data, edu.hws.jcm.awt, edu.hws.jcm.draw, and edu.hws.jcm.functions. 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 edu.hws.jcm.data

The edu.hws.jcm.data package contains the core classes for working with mathematical objects such as variables, expressions, and functions. (This package should probably have been named edu.hws.jcm.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 JCM 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 edu.hws.jcm.data do not depend on any of the other classes in the JCM, so they could be used independently in other software projects.

For more details, click here.


Package edu.hws.jcm.awt

The edu.hws.edu.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 AWT (Abstract Windowing Toolkit) components. 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 VariableSlider lets the user set the value of a variable in another way: by adjusting a slider (actually, an object belonging to the AWT's Scrollbar class). 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 JCM, 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 JCMPanel class makes it possible to avoid much of the work of setting up Controllers. JCMPanel is a subclass of Java's Panel class, so it can contain other graphical user interface components, including other JCMPanels. If an interface is built entirely of JCMPanels, 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 JCMPanel.

For more details, click here.


Package edu.hws.jcm.draw

The edu.hws.jcm.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: Axes, 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 edu.hws.jcm.functions

The edu.hws.jcm.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 Panel 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 JCM version. It should be part of a more general facility for entering and editing functions. This might be added to a future version of JCM.)

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.


[ JCM Project | JavaDoc Documentation ]