Chaos in AFM Trajectories Applet structure and programming information. (Last update 02/06/06; r32) TO DO: 1) Add functionality to the 'measure' window and to the 'calculator' 2) Ability to zoom out in all windows so that multiple surface periods are visible 3) Add mouse listener / scale to all windows, maybe. 4) Fix 'probe' tool 5) To conserve memory: animation, trajectory, and measure windows can take data from the same pool? This will be troublesome...might need to store data points in an array. leave for later. I. Structure of the applet: Classes 1. Base classes (i) Surface.java : Models the surface (ii) AFM.java : AFM model, contains free-motion and reflection behavior. 2. Simulator (i) AFMSimulator.java : Brings the AFM and the Surface togeter to create the impact oscillator system. All the real computations are done here. 3. Applet (i) AFMApplet.java : Contains all display information. Menus, windows, buttons, frames, colors, etc. This class also contains some 'control' variables and functions that are used by the four windows on screen. 4. Output classes The following classes extend the Java graphical class "Canvas". These are the four graphical windows that are seen on screen when the applet is run. (i) Animation.java : The actual AFM bouncing on the surface in real time. (ii) Trajectory.java : The AFM trajectory over time. (iii) Measure.java : Numerics and plots. Displays calculated magnitude, average,... of force and other measurables. (iv) Map.java : Stroboscopic map of canonical pairs (x, px) or (y, py) 5. Utility classes (i) AFMConstants.java : Contains some constants. Currently only #samples. (ii) AFMMath.java : Some customized STATIC math functions that are useful -- defined a "modulo division" for double values; method for calculating log2, which is used to find number of appropriate significant figures while zooming into and out of the map. (iii) Calculate.java : Contains many STATIC methods that calculate average, max, min, etc. of an input array (for example, array of calculated force values) 5. Other classes (i) ControlPanel : This class extends the java class 'JFrame'. It's the control panel that you see when you start the applet. The code for this class is contained in AFMApplet.java (ii) ProbeData : This class contains information about the region on the map that is being probed (for the [Probe] function). Code is located in Map.java Hierarchy: |---------| | Surface | \ /> |Animation| \ |---------| \ / \ \ / /> |Trajectory| \ \ > |------------|/ / \ \ |-----------| |AFMSimulator|\ \ >>/>/>- - -> | AFMApplet | /> |------------| \ \> |Measure| - -/ / |-----------| / \ / | |---------| / \> |Map|- - - - -/ |ControlPanel| | AFM |/ | |---------| |ProbeData| |------------| |---------| |-----------| |AFMConstants| | AFMMath | | Calculate | |------------| |---------| |-----------| > Note: Names changed from previous versions. > "AFMControl" --> "AFMApplet" > "Animate" --> "Animation" > "Modular" --> "Trajectory" > "Trajectory" --> "Accumulated" --> combined with "Trajectory" and window replaced with "Measure" > "XVsPX" --> "Map" II. Working of the applet The applet runs 4 threads (one for each window on screen) and these are independently controlled by the user. Each window class does its own calculations. Each class requires a different amount of data, so independence can be maintained easily if they do separate calculations. II. Applet Tutorial Standard methods in a typical applet: (These methods are called by the browser or appletviewer) (1) init() : This is called when the applet is first initialized. Used to set up variables, classes, GUI, etc. (2) start() : This is called immediately after init(). Used to assign initial values to variables and create object instances of classes. (3) paint() : This method draws things on screen. (4) stop() : Called when applet minimized or iconified, or when the window is closed. (5) destroy() : Called after stop() to "clean up" and release resources currently held by the applet. In this applet: (1) init() sets up the entire GUI and initializes all threads (2) The start() method is not used, since starting/stopping simulation should be under the user's control (and not the browser's). (3) paint() is used for individual canvases. (Using paint() in the main applet causes all kinds of problems -- browser constantly refreshes page and makes random calls to paint()). (4) stop() stops all threads (5) destroy() sets all threads to null