// PolysMove2.java // A Test Animation for Polys with Double Buffering // Copyright (C) 1996, 1997 Y.Nagatani // nagatani@eken.phys.nagoya-u.ac.jp import java.awt.*; import Polys; public class PolysMove2 extends Polys implements Runnable { Thread thread = null; Image imImage; // for double buffering Graphics gImage; public int interval; // interval (mili sec) public void init() { super.init(); try {interval = getIntParameter ("interval");} catch (NumberFormatException e) { interval = 500; } 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, null); } 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 (); // start thread } } public void stop () { if (thread != null) { thread.stop (); // stop thread thread = null; // delete thread } } public String[][] getParameterInfo () { String info[][] = { {"interval", "integer", "flush interval (milisecond)"} }; return info; } public String getAppletInfo () { return "PolysMove2 (test for Polys with double buffering)\n" + "Copyright(C) 1996, 1997 Y.nagatani\n" + "nagatani@eken.phys.nagoya-u.ac.jp"; } }