// D3PolysAnime.java // 3次元 アニメーション double buffering // Copyright (C) 1996, 1997 Y.Nagatani // nagatani@eken.phys.nagoya-u.ac.jp import java.awt.*; import D3PolysMove; public class D3PolysAnime extends D3PolysMove implements Runnable { Thread thread = null; Image imImage; // double buffering image Graphics gImage; public int interval; // interval (m.sec.) public void init() { super.init(); try {interval = getIntHTML ("interval");} catch (NumberFormatException e) { interval = 100; } if (interval < 0) interval = 0; System.out.println ("D3Poly: interval: " + interval + "¥n"); 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(); //スレッド起動 } } public void stop() { if( thread != null ) { thread.stop(); //スレッド停止 thread = null; //スレッド消去 } } public String[][] getParameterInfo () { String info[][] = { {"background", "hexadecimal color value", "background color"}, {"interval", "integer", "flush interval (mili second)"} }; return info; } public String getAppletInfo () { return "D3PolysAnime (test applet for D3Polys class)¥n" + "Copyright(C) 1996, 1997 Y.nagatani¥n" + "nagatani@eken.phys.nagoya-u.ac.jp"; } }