// EkenFire.java // Welcome to Eken Animation Applet // by nagatani@eken.phys.nagoya-u.ac.jp import java.awt.*; public class EkenFire extends EkenFireSub implements Runnable { Thread thread; Image imImage; // double buffering image Graphics gImage; int interval; // interval (m.sec.) public void init () { Color bg = getColorParameter ("bgcolor"); if (bg != null) setBackground (bg); else setBackground ( new Color (Integer.parseInt ("000080", 16))); interval = 100; String sValue = getParameter ("interval"); if (sValue != null) interval = Integer.parseInt (sValue); if (interval < 0) interval = 0; imImage = createImage (size().width, size().height); gImage = imImage.getGraphics (); super.init(); } public void paint (Graphics g) { super.paint (gImage); g.drawImage (imImage, 0, 0, this); } public void update (Graphics g) { this.paint (g); } public void run () { while (thread.isAlive ()) { repaint (); super.move (); try { Thread.sleep (interval); // Delay Time } catch (InterruptedException e) {} } } public void start () { if (thread == null) { thread = new Thread (this); thread.start(); // starting thread } } public void stop () { if (thread != null) { thread.stop (); // stop thread thread = null; // destroy thread } } public boolean mouseDown (Event e, int x, int y) { if (thread != null) this.stop(); else this.start(); return true; } public Color getColorParameter (String name) { String value = getParameter (name); int nColor; try {nColor = Integer.parseInt (value, 16);} catch (NumberFormatException e) { return null; } return new Color (nColor); } public String[][] getParameterInfo () { String info[][] = { {"Dynamical", "(existence of this)", "Dynamical Fire Image"}, {"Grid", "(existence of this)", "Grid Image"}, {"interval", "integer", "flush interval (mili second)"}, {"bgcolor", "rrggbb (HEX)", "background RGB color"} }; return info; } public String getAppletInfo () { return "EkenFire Applet\n" + "Copyright(C) 1997,1998 Y.Nagatani\n" + "nagatani@eken.phys.nagoya-u.ac.jp"; } }