Source code: rcsdesign/InnerAppletRepainter.java
1 package rcsdesign;
2
3 import diagapplet.utils.StandAloneApplet;
4
5
6 public class InnerAppletRepainter implements Runnable
7 {
8 StandAloneApplet innerApplet = null;
9 Thread repainter_thread = null;
10 long interval = 10;
11 long timeout = 1000;
12
13 boolean quit_flag = false;
14
15 public void start()
16 {
17 quit_flag = false;
18 repainter_thread = new Thread(this);
19 repainter_thread.start();
20 }
21
22 public void stop()
23 {
24 quit_flag = true;
25 if(null != repainter_thread)
26 {
27 repainter_thread.interrupt();
28 repainter_thread = null;
29 }
30 }
31 public void run()
32 {
33 long start_time = System.currentTimeMillis();
34 while(innerApplet.repaint_count > 0
35 && System.currentTimeMillis() -start_time < timeout
36 && !repainter_thread.isInterrupted() && !quit_flag)
37 {
38 innerApplet.repaint();
39 try
40 {
41 Thread.sleep(interval);
42 }
43 catch(InterruptedException ie)
44 {
45 break;
46 }
47 catch(Exception e)
48 {
49 e.printStackTrace();
50 }
51 }
52 }
53
54 InnerAppletRepainter(StandAloneApplet inner_applet, long _interval, long _timeout)
55 {
56 innerApplet = inner_applet;
57 interval = _interval;
58 timeout = _timeout;
59 }
60
61 }