INTRODOCTION

The pages contain the documentation for a java API designed to facilitate the rapid production of applets to be used in teaching Calculus. It consists of two packages. The classes in these were all written by Eric Carlen during 1996 and 1997, and this documentation was written during the Fall of 1997 to enable their use by others here at Georgis Tech. This documentation effort was extensive, and was made possible by generous support provided by Al West for a program to develop new ways to use computers in teaching.

I am also grateful to Tao Pan, who was the first person besides myself to use these classes to write applets in the Fall of 97. Working with him on this did a lot to clarify what would be needed in the way of documentation.

The rest of this page is an overview of the packages. The following are links to the rest of the documentation and the code itself.

  • Package Descriptions
  • Example Applets
  • Compiled Classes -- Jar Files and Class Folders.
  • A tar file containing all of the above.
  • Currently, the packages are written in java 1.02 since that runs well on all platforms and in browsers that haven't been kept absolutely current. Since there are still a lot of browsers out there that don't yet handle java 1.1 code, this seems to be the safest thing to do for now.

    Anyone who want's to use, say, the print capabilities of java 1.1 can easily add this in their applets written with these packages. also, anyone who wants to can wrap the classes into a jar file for more efficient downloading.

    The code itself is copyrighted by Eric Carlen. It may be used in any freely distributed product or project, but may not be used in or bundled with any project or product that is sold without written consent. That is, academic and personal use are fine, but no sort comercial use is without first obtaining written permission from the author.

    WHAT KIND OF APPLETS IS THIS API SUPPOSED TO BE GOOD FOR?

    The java classes in this package are designed to facilitate the construction of applet "visual laboratories" in mathematics. These should:

  • be simple dedicated programs that are optimized to do just one thing in as thorough and as simple a manner as possible, so that there is no learning curve in the way of their use.
  • be as uniform as possible in their interface, to further minimize learning curve effects.
  • be as interactive as possible -- with no "hard wired" input so that students can freely change the functions being experimented upon. Also, it should be possible to change the view in the graph -- shift the center, zoom in or out -- in a very simple way, without re-entering a complicated graph command.
  • be as graphical as possble to provide a thorough geometric insight into the problem at hand, but to also provide numerical and textual reports on the results mathematical experimants.
  • be powerful enough to permit a wide range of numerical experimentation.
  • It is because I found it difficult to provide tools with such characteristics using packages such as Maple, Matlab or Mathematica that I initially developed these classes. My difficulties may have stemmed from my limited skill in the use of those tools, but I doubt it. They are excellent all research tools, and I rely on them, especially Matlab, as such. Any single tool that is optimized for research is not going to be optimally adapted for the any particular pedagogical purpose in a Calculus class. The number of commands needed to set up any particular specialized kind of graph, and the changes in those commands needed to change the view tend to obstruct the discussion of the underlying mathematics.

    For example, one of the example applets in these pages is used to investigate the basins of attraction of Newton's method. After a function and region are entered, the press of a button runs Newton's method starting from the point uderlying each pixel in the x-axis until it converges, and then records the result by drawing a vertical line through the point with a color indicating the root to which Newton's method leads starting from that point. A table off to the right lists the roots that were found, and their corresponding colors.

    But there is more reported here than that: Notice that the lines drop different ammounts below the x-axis. The amount indicates the number of steps it took Newton's method to converge to within 8 decimal place of the root.

    The interesting discoveries to be made with this applet involve "zooming in" on the boundaires between different basins of attraction. Notice that at these boundaries, convergence is slower than elsewhere -- the lines drop down lower.

    It is also easy to shift the focus to a new region in the graph -- If one "drags the mouse" more than three pixels of distance in the graph, the place where the mouse is relased becomes the new center. Also, one can now zoom in on than point by hitting the "zoom in" button.

    In this way one quickly generates a whole range of graphs on a whole range of scales, selected by user input, and all without redoing some complicated graphics command. If you look at the text on the applet page, you will find a list of questions for investigation. With this applet, one can jump into experimantation on these questions without any barrier of programming difficulties.

    This is the type of applet for which these packages were designed. The ability to recenter and zoom in or out is a generally useful thing, and so is included in the behavior of the components defined in these packages. We next give a brief tour of the packages, first explaining the scheme behind their use.

    HOW THE CLASSES IN THESE PACKAGES ARE USED TOGETHER

    All of the example applets included with this documentation are subclasses of GraphingApplet, which is a class in the graphingApplet package. All of these are packed with various components for taking user input and displaying results. These components need to talk to one another -- values enetered in one of them, say a panel of contrals for the region to be graphed -- will have effects on several of the others.

    Also, there is often more than one way to do something. One can recenter the graph with a mouse drag as indicated above. While this is fast, it may not be accurate enough. So there is a component with a panel of TextFields in which a precise value of the new center can bt typed. These need to be coordinated.

    Now consider two ways of having five such components talk to one-another. In figure A of the diagram below,

    each component has direct connections to all the others. In figure B, another object, a MessageCenter, has been added, and each component has a singe connection with it.

    The advantages of this approach are especially clear when one consideres adding another component. Now in figure A, five new connections must be made. Generally this means adding code to the orriginal components, so each of them would probably have to be subclassed. Instead, in figure B, there is only one new connection to be made, to the MessageCenter.

    It is now easy to set things up so that theMessageCenter does not have to be subclassed to be extended. This is done by equipping it with an array of MessageSubscribers as we explain below. But the upshot is that this MessageCenter-MessageSubscriber architecture used here is easily extensible with a minimal amount of subclassing. If you write a new component that will have to be updated when the center of the graph is changed, you are unlikely to need to subclass the GrpahParamters object -- one object that manages such changes -- that is in the package. You could almost surely use it as is.

    The way the classes in these packages are ment to be put together is the following:

    The MessageCenter, and each of the Components below are owned by the parent applet as instance variables, and so it can invoke any of their methods.

    The individual components however are not directly accesible to one another. They are however passed the parent applet's MessageCenter instance on creation, so they can invoke it's public methods. They work on each other through the following mechanisms:

  • The MessageCenter contains lists of named integers, doubles and strings. By using one of the MessageCenter's writing methods, e.g., writeIntData(int value, String name), they can change the stored values of any of these -- as long as they know the name a value is stored under -- and then can call the MessageCenter's updateSubscribers() method. This in turn calls up all the regisred components, and tells them to check any data they're interested in because something was changed.
  • They can call the MessageCenter's method runNamedParentMethod(String name), which in turn calls the parent applet's method runNamedMethod(String name). This contains a list of blocks of code, and the block matching the String passed in as name is run. This code is of course suplied by the writer of the applet. The parent applet can then do pretty much anything desired with any of the other components.
  • Now, to achieve this, we would like our components to be subclasses of a class MessageSubscriber which has methods for registering named data with a MessageCenter on creation, and methods for recieving notice of changes to data that it is interested in

    However, the component will most likely also need to subclass some AWT component like Panel or Canvas -- some class with the AWT framework for input or output of informnation.

    There is no multiple inheritance in java. An interface could have been used by making MessageSubscriber's registerSubscriber() method static.

    What was done instead was simply to bundle two classes together:

    Each of the component classes used here is created with a subclass of MessageSubscriber as an instance variable. This in turn is passed the instance of its associated component through its constructor. Each object can then call the other's public methods, and the effect is the same as multiple inheritance. It could have been done more perhaps elegantly with interfaces as I've said, but this has its advantages too.

    WHAT CODE NEEDS TO BE WRITTEN TO MAKE AN APPLET USING THESE PACKAGES?

    If you look in the source code for the example applets included in this documentation, you will notice that most have just two classes written for the applet: A subclass of GraphingApplet, and a subclass of ReportingSlate. The latter is a component that handles textual reporting of results, and it differes enough from application to application that it does tend to get subclassed. The rest of the classes in the packages are used as they are.

    Let's come back to ReportingSlate later, and focus first on GraphingApplet.

    This has a number of methods, but the main work is done three of them. If you use this package, most of your work goes into writing to code to implement the following three methods:

  • handleAllData()
  • doAll Painting()
  • runNamedMethod(String name, int x, int y)
  • The first of these methods should get the strings describing the mathematical to be used in the applet from the FunctionEneringPanels and has them parsed to produce an Evaluator, which may then be used to efficiently evaluate these functions without further parsing. All of this is done by methods of FunctionParser in the functionParser package; you just have to invoke the method on the number of FunctionEnteringPanels that you want.

    Next, after this preparatory work is done, handleAllData() should do all of the calculation with these functions that need to be done before things are graphed. For instance, one might compute the values of the entered function at the points corresponding to each pixel on the visible part of the x axis, and to store these in an array to be used in graphing, which is handeled by doAll Painting().

    This method is also run every time a new function is entered in a FunctionEneteringPanel at runtime. Basically, it should be though of as the method does does all the preliminary "laboratory setup" to get ready for user input that specifies what experiment is to be done. The second of these methods, doAll Painting(), handles the application specific parts of painting grpahs in the applet. It is called by the GraphCanvas's paint() method after that has painted in a background and before drawing in axes and such on top. The third of these, runNamedMethod(String name), handles interaction with the user. For example, if one clicks the mouse in the GraphCanvas object, it invokes, through the MessageCenter as describered above, runNamedMethod("click", int x, int y). The values of x and y indicate the location of the click. You might then write code to have a tangent line drawn though the clicked point, say. If a button on some component is pushed, it genrally passes its name to runNamedMethod(String name, int x, int y), and sets x and y to zero -- thet would be ignored in the code block handling the button push. In the applet on basins of attraction for Newton's method discussed above, a start button starts the computation of the roots that the various starting points go to. This is the algorithmic heart of the applet.

    This is typical. Most of your code writing goes into writng code to handle user input through runNamedMethod(String name, int x, int y).

    After these three, there are a bunch of method that will usually be overwritten with one of two lines of code. For example, cleanInput() should be rewritten to have any boolean flags or special integer values that have been set by user interaction returned to their initialization values. This is called whenever a new function is enteredin a FunctionEneterinPanel, since that means a fresh round of experimentation.

    This resetting is not included in handleAllData() though that is invoked at that time too for the simplr reason that you may want to invoke handleAllData() in a block of code run by user input through runNamedMethod(String name, int x, int y) in the middle of an experiment.

    The various subclasses of ReportingSlate that are used in the examples included here are all invole a minimal amount of code-writing associated with handling different kinds of button actions, and drawing different strings.

    More detailed instructions on subclassing GraphingApplet and ReportingSlate are provided on another page. Also included there are template files for these subclasses, fully anotated with comments, and instructions for their use. Finally, there is the javadoc generated documentation for the two packages.

    THIS PAGE IS NOT A PUBLICATION OF THE GEORGIA
    INSTITUTE OF TECHNOLOGY AND THE GEORGIA INSTITUTE
    OF TECHNOLOGY HAS NOT HAS NOT EDITED OR EXAMINED
    THE CONTENT. THE AUTHOR OF THE PAGE IS SOLELY
    RESPONSIBLE FOR THE CONTENT.
    
    


    Return to Eric Carlen's home page

    Eric A. Carlen (send message)