The GeX Library

Overview of the qpr.math package and api

(for supporting the construction of educational math applets)

Main Idea

The code for the original GraphExplorer applet has been restructured so as to establish its various parts as mutually independent components which can be more readily mixed and matched to create a variety of alternative applets .

While this could be done with the original classes, the standardization of inter-object communication according to the jdk1.1 event model and JavaBean conventions makes the process more transparent and perhaps even accessible to non-programmers either through a gui 'builder' environment or by using relatively simple code templates.
 

Top Down

The original gex applet clearly has 4 major visible parts. In addition to the graph display area, there are controls for the graph region, the function list area, and the area for control of numerical parameters occuring in the formulae. There is also a hidden color control panel that pops up as needed.

The code for the original applet was written with a substantial number of shared variables and cross-references between internal parts of these component classes, but in the new version they are more independent, and the code (see below) is much simpler.

//////////////////////////////////////////////
// Graphit.java                            //
// Copyright © 1998-2001 Alan Cooper.     //
///////////////////////////////////////////
import qpr.util.beanstuff.*; import qpr.math.plotkit.*;
import qpr.math.alg.*; import qpr.math.d2g.*;
import qpr.math.svf.*; import qpr.math.grf.*;
import qpr.util.colorstuff.*;import qpr.util.*;
import java.awt.*;import java.beans.*;
import java.applet.Applet;

public class Graphit extends AppletAppBean
{
GraphWindow gw=new GraphWindow();
GraphSetManager gsm=new GraphSetManager();
ColorSelectPanel csp=gsm.getColorSelectPanel();
FunctionSetManager fsm=gsm.getFunctionSetManager();
ParamSetManager psm=gsm.getParamSetManager();

public Graphit(){setName("Graphit");
 setSize(800,500); setLayout(null);
 add(gw);gw.setBounds(200,0,400,480);
 add(gsm);gsm.setBounds(0,0,200,200);
 add(csp);csp.setBounds(0,200,200,200);
 add(fsm);fsm.setBounds(600,200,200,200);
 add(psm);psm.setBounds(600,0,200,200);
gw.show(gsm);
}

public void init(){setSize(800,500);}

public static void main(String[] args){
 AppletApp a=new Graphit();
 frameIt(a);      }

}//endClass(Graphit)
 

To see what it does
Run the Applet
For hints on usage
Check out the Help file
For a line-by-line explanation
View Commented Code

(Here I have put the ColorSelectPanel in a fixed position for simplicity, but - given the information that when activated it fires a 'PropertyChangeEvent' - writing the code to make it pop up as needed is not much harder. If you want you can check out the pop-up code now.)

If you want to actually experiment with modifying this code then you will need a Java development environment and might want to skip ahead to the section on compiling and running these programs.


Of course, there is much complexity hidden in the coding of the various components, but if I have designed and documented them well, it should be possible, without looking at their code, to easily rearrange and reconnect them to serve different purposes, with the functionality of the resulting applet adjusted so as to restrict or expand user options according to the paedagogical needs of the situation.

Here are two examples.

Elephant
The first is an applet (based on one of the ESCOT ePOW's for this past year) in which the user is given two views of a function graph and asked to specify the domain and range of one window to make its view match the other.
 
Run Elephant Applet View bare Code View Commented Code

 
Liner
The second is a simple version of the old 'Green Globs' game where the user has to set the coefficients of a linear function to make its graph pass through a pair of given points. (It was one of the original "Alternate Versions" I wrote in '99, but has been re-coded to take advantage of the improved modularity of the current gex library)
 
Run Liner Applet View bare Code View Commented Code

 

These examples involve some classes which correspond to sub-components or 'properties' of the five main ones used in the first example. For greater control of the design of an applet, it is of course necessary to have more information about what classes are available and what actions or 'methods' they can be asked to perform. So now we shall look at the contents of the library in more detail.



 

The various components and subcomponents and their supporting classes of the gex library have been organized into a number of 'packages'. The JAVA 'package' concept is really intended to control what features of the classes are mutually accessible, with classes that need access to one another's innards grouped together and other classes given more limited access; but such divisions also often correspond to conceptually relevant groupings and the gex library is no exception.

There are packages dealing primarily with basic algebra, geometric objects, function concepts,  and graphs&loci, with the graphical presentation tools in a separate package called the plotkit. Some frequently used tools of a general nature are also included in a 'utility' package.

The overall structure of the library is as follows:
 
qpr.util
    qpr.util.beanstuff
    qpr.util.colorstuff
    qpr.util.commstuff
qpr.math
   qpr.math.alg
    qpr.math.svf
    qpr.math.tbl
    qpr.math.d2g
    qpr.math.grf
    qpr.math.plotkit

 
 

Bottom Up

For the "bottom up" view, with complete listing of all the classes and their public properties and methods, see the gex library's JavaDoc output.

This is at present quite rudimentary, but I will add more detailed comments if anyone is actually interested in working with these classes. (So please do let me know if you might do so, and if there are additional features and or explanations that you think would be helpful.)
 
 

Compiling and Running

The entire gex  library is in the file gex.jar in the classes subdirectory of the directory containing this file. If you have the java2 sdk1.3.1 installed, that is all you need.

Otherwise, to compile and run your programs you will need a Java development environment. Sun's Java SoftwareDevelopmentKit (sdk) is available for download from their website. The package comes with an automatic installation option, and full documentation. But for just running these examples (and others built using the gex library), the process is very simple.

Once the java sdk is installed,  just copy the directory containing this file and its subdirectories to the location of your choice. If you then edit any of the .java files in the code subdirectory, change both the class name  and constructor name to (say) Classname (with the new  name also being used to call the constructor in the main method), and save the result in a file called Classname.java, then on a Windows system you should be able to compile and run your new program by using the commands jc Classname the jrun Classname in the directory containing your copy of this file. (On other systems, the commands that you will need to run should be just the contents of the files jc.bat and jrun.bat - with the expression "%1" replaced by "Classname" .)