1 package org.catacomb.dataview.gui;
2
3 import org.catacomb.report.E;
4
5
6 public class FramePlayer implements Runnable {
7
8 FramePlayerController frameController;
9
10 boolean shouldStop;
11
12
13 public FramePlayer(FramePlayerController fc) {
14 frameController = fc;
15 shouldStop = false;
16 }
17
18
19 public void stop() {
20 shouldStop = true;
21 }
22
23
24 public void start() {
25 Thread thread = new Thread(this);
26 thread.setPriority(Thread.MIN_PRIORITY);
27 thread.start();
28 }
29
30
31
32
33 public void run() {
34 while (frameController.canAdvance()) {
35
36 double spd = frameController.getSpeed();
37
38 int msecs = (int)(100. / spd);
39
40 try {
41 Thread.sleep(msecs);
42 } catch (Exception ex) {
43
44 }
45
46 if (shouldStop) {
47 break;
48 }
49
50 if (frameController.canAdvance()) {
51 frameController.advance();
52 }
53 }
54 E.info("run finished");
55 }
56
57
58
59 }