// A real-time simulation // /** NOTE: The simulation information for this applet have been taken from ???, Hartmut Bossel, Springer-Verlag, Stuttgart, 1994*/ // (c) Tomaz Sesek, January 1996 import java.applet.Applet; import java.awt.*; public class Simulation extends Applet implements Runnable{ Thread jaz; Component board, paramCtrl; public void init() { setLayout(new GridLayout(0, 2, 5, 5)); add(board = new CurvePanel()); add(paramCtrl = new ParameterControl((CurvePanel)board)); } /** Enable as thread */ public void start() { jaz = new Thread(this); jaz.start(); } public void stop() { jaz.stop(); } public void run() { while (true) { try { Thread.currentThread().sleep(500); } catch (InterruptedException e){} } } } class CurvePanel extends Panel { Graphics backGC; Image backBuffer; int paramVal[] = new int[4]; public CurvePanel() { setBackground(Color.black); for (int i=0;i 200) | (y < -200) ) t = 300; } } public void paint(Graphics g) { if (backBuffer!=null) { drawCurve(backGC); g.drawImage(backBuffer, 0, 0, this); } /** otherwise just paint onto the screen => flashes possible */ else { drawCurve(g); } } } /** Parameter Control scrollbars determine the values of 4 parameters to curves */ class ParameterControl extends Panel { Scrollbar param[] = new Scrollbar[4]; public ParameterControl(CurvePanel graph) { setLayout(new GridLayout(1,0,0,0)); for (int i=0;i