01: package tools.tracesviewer;
02:
03: import java.util.*;
04:
05: public class TracesAnimationThread implements Runnable {
06:
07: public Thread tracesThread;
08: TracesCanvas tracesCanvas;
09: Hashtable arrows;
10: int delay;
11:
12: public TracesAnimationThread(TracesCanvas tracesCanvas) {
13: tracesThread = null;
14: arrows = null;
15: delay = 2000;
16: this .tracesCanvas = tracesCanvas;
17: arrows = tracesCanvas.arrows;
18: }
19:
20: public void start() {
21: try {
22: tracesThread = new Thread(this );
23: tracesThread.setPriority(1);
24: tracesThread.start();
25: } catch (Exception exception) {
26: }
27: }
28:
29: public void stop() {
30: try {
31: tracesThread = null;
32: tracesCanvas.repaint();
33: } catch (Exception exception) {
34: }
35: }
36:
37: public void run() {
38: try {
39: arrows = tracesCanvas.arrows;
40: if (arrows.size() != 0) {
41:
42: while (tracesThread != null) {
43:
44: tracesCanvas.unvisibleAllArrows();
45: for (int i = 0; (i < arrows.size())
46: && (tracesThread != null); i++) {
47:
48: Arrow arrow = (Arrow) arrows.get("arrow"
49: + (i + 1));
50: arrow.visible = true;
51: tracesCanvas.unselectAllArrows();
52: arrow.selected = true;
53: tracesCanvas.repaint();
54:
55: if (tracesThread != null)
56: Thread.sleep(delay);
57:
58: }
59: }
60: }
61: } catch (Exception exception) {
62: }
63: }
64:
65: public void setDelay(int i) {
66: delay = i * 1000;
67: }
68:
69: public int getDelay() {
70: return delay / 1000;
71: }
72:
73: }
|