1 package org.catacomb.graph.gui;
2
3
4 public class HoverTimer implements Runnable {
5
6
7 PickHandler pickHandler;
8
9 boolean active;
10 Thread thread;
11
12 int ntick = 0;
13
14
15 public HoverTimer(PickHandler ph) {
16 pickHandler = ph;
17 active = false;
18
19 thread = new Thread(this);
20 thread.setDaemon(true);
21 thread.start();
22 }
23
24
25 public void clear() {
26 active = false;
27 ntick = 0;
28 }
29
30 public void start() {
31 active = true;
32 ntick = 0;
33 }
34
35
36
37 public void run() {
38 while (true) {
39 if (active) {
40 ntick += 1;
41 }
42
43 if (ntick == 3) {
44 pickHandler.hovered();
45 }
46
47 try {
48 Thread.sleep(500);
49
50 } catch (Exception ex) {
51
52 }
53 }
54
55 }
56
57
58 }