// // Anneal.java -- Crystalization or self-annealing 2D automaton // 2002.09.10 Steve Witham sw@tiac.net // // 2002.09.10 Started, based on LangtonsAnt.java package net.tiac.home.sw.anneal; import java.lang.Integer; import java.awt.*; import java.awt.event.*; import java.applet.*; // The applet has three main parts: // the applet itself, which is mainly a frame for the other two, // the ControlPanel, with control buttons and a step counter, and // the Board, which is where the ant runs around. public class Anneal extends Applet { Board b; ControlPanel c; public void init() { // First just create empty ControlPanel and Board objects. // Then specify their layout within ("add" them to) the applet. // Then init the ControlPanel which makes it specify its // internal layout. // Then "this.validate()" forces actual calculation of // everybody's layout, including their bounds(), based on the // height=... and width=... in the tag. // Then init the board, which needs to know its bounds() to // set its array size. // After the Board b and ControlPanel c are created, // we pass b to c.init(). c passes itself to b.init(), // so they know each other & can talk to each other. setLayout( new BorderLayout() ); c = new ControlPanel( this ); add( "North", c ); b = new Board( ); add( "Center", b ); this.validate( ); // Force calculation of bounds. c.init( b ); // The ControlPanel inits the board. } // end init() // start and stop methods. The browser calls these. Applet passes them // on to control panel, which passes them on to the board. Basically, the // board is "running" all the time, which isn't the same as having the ant // run around in there. public void start () { c.start(); } public void stop () { c.stop(); } }