// Fws3DAnime.java // Flower Works Animation Applet // Copyright (C) 1997,1998 Yukinori NAGATANI // nagatani@eken.phys.nagoya-u.ac.jp import java.awt.*; import Fws3DDrive; public class Fws3DAnime extends Fws3DDrive implements Runnable { Thread thread = null; Image imImage; Graphics gImage; public int interval = 100; // interval (m.sec.) public void init() { Color bg = getColorParameter ("bgcolor"); if (bg != null) setBackground (bg); else setBackground ( new Color (Integer.parseInt ("000000", 16))); super.init(size().width, size().height); 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 (); } 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 (); 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[][] = { {"interval", "integer", "flush interval (mili second)"}, {"bgcolor", "rrggbb", "background RGB color"} }; return info; } public String getAppletInfo () { return "Fws3DAnime Applet\n" + "Copyright(C) 1997 Y.Nagatani\n" + "nagatani@eken.phys.nagoya-u.ac.jp"; } }