JCM Code Structure

Packages

The code is divided into java packages:
  • jcm/mod: the science calculation Modules
  • jcm/gui: components of the Graphical-User-Interface
  • jcm/pan: specific Panels, using both mod and gui
  • jcm/script: for scripting instructions (under development)
  • jcm/: root components (iob, mainapp, root)

    The package jcm/mod contains the science calculations, which are divided into modules. A "modlist" interface is implemented by all modules, helping them refer to each other. It also specifies the order for calculations, which are called by modloop.

    This package is entirely independent of the graphical interface, and may be compiled and run without the other packages being present (in this case, some other input/output is needed, e.g. a simple text interface or hard-coded instructions e.g. testmod.java). This independence may later be useful for batch calculations which loop through the model many times without plotting graphics at every step, for example for probability analysis or solving optimisation problems.

    The graphical interface package jcm/gui contains general components: graphs, menus, buttons, draggable controls, pop-up labels, layout manager and flowchart, event handler routines, etc. These should not refer to specific climate science modules (although they may refer to general structural elements).

    The panels in package jcm/pan combine the general graphs and adjustable controls from jcm/gui with the model data and parameters from jcm/mod. Some contain extra options to implement more flexible graphs (e.g. regionplot), or unique features (e.g. the maps).

    The package jcm/script will contain the code that records and plays back instruction sequences. This is currently intertwined with the gui, and not yet fully restored after recent restructuring (April 2002).

    The root jcm/ directory includes "iob" (see below), the applet "mainapp", which initiates and contains the other jcm/gui components, and a simple static class "root", storing the codebase for loading files etc.


    Class heirachy

    Most components descend from the same "Interaction Object", which provides the link between them, and also handles the "needed" and "changed" flags which are a key element of JCM's efficiency.

    The class heirachy is as follows:
    jcm/ interaction object (iob)
    jcm/mod jcm/gui
    module param popob jcmpanel
    (science model calculations) option control jcmchoice     simplegraph
    (params / popobs defined in
    modules or jcmpanels)
    graph
    jcm/pan/
    (custom panels -extend jcmpanel, define popobs, and refer to modules)


    See also:
  • Interaction Object
  • jcm/mod structural components
  • jcm/pan menu
  • jcm/gui components
  • How does it work so fast?
  • Links to source code
  • What is java


    Some jcm/gui components

    More documentation on the GUI structure will be added later. Meanwhile, below is some basic info:

    Jcmpanel is the basic structure for a panel. Rather than extending the java.awt panel, which is not sufficiently flexible for JCM, jcmpanel transfers coordinates, layout and events from mainapp, and extends iob.

    Simplegraph, extending jcmpanel, draws basic curves. Graph extends this, adding interactivity, legend and scales.

    Layout arranges the panels. Flowchart contains a special layout with arrows showing the interactions.

    An interface "thislayout" provides a static reference for the current layout, which contains an instance of panlist listing all the panels. Jcmpanels implement both this and the modlist interface, thus all panels can easily refer both to modules and to each other.

    Popob is the superclass of option (on/off button), jcmchoice (menu) and control (draggable arrows). Popobs all refer to, but do not own, a param (scientific params are defined in modules, layout options in panels). Popob also contains methods for event handling and making pop-up info labels (hence the name).

    The label text is stored by labinf, which loads data files for the specified language.