/* Java applet to demonstrate anchor loading in YHangs */
/* Simeon Warner - 15May96 */

/* See `Just Java' p207 for a good description of the 
   methods of the Applet body (init, start, stop etc) */

import java.awt.*;

public class YHang extends java.applet.Applet {
  ControlPanel controls;
  DiagramPanel diagram; 
  Simulation simulation;
 
  public void init() {
    float weight;

    // layout style
    setLayout(new BorderLayout(10,10));
    // the two panels
    controls = new ControlPanel();
    add("East",controls);
    diagram = new DiagramPanel();
    add("Center",diagram);

    // now add the running code
    simulation = new Simulation(controls, diagram);

    // tell the panels about the simulation
    controls.init(simulation);
    diagram.init(simulation); 

    /* Try to get input parameter */
    weight = Float.valueOf(getParameter("weight")).floatValue();
    if (weight<=(float)0.0) weight=(float)750.0;
    simulation.setDaemon(true);	// simulation thread should die with applet
    simulation.init(weight);  
  }

  public void start() {
    /* Start threads here, this gets called initially and whenever the
       applet becomes visible again in the viewer */
    simulation.start(); 	// start simulation thread
  }

  /* No need for a run() method as there is no thread in this class */

  /* No need to override paint() if we are using sub-windows */

  public void stop() {
    /* Stop threads here, this gets called when the applet is closed
       down or suspended by being moved off screen */
    simulation.stop();
  }

} /*end of YHang*/





