-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimingTask.java
More file actions
100 lines (88 loc) · 1.98 KB
/
TimingTask.java
File metadata and controls
100 lines (88 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/**************************************************************************************
* fpstiming_tree
* Copyright (c) 2014-2017 National University of Colombia, https://github.com/remixlab
* @author Jean Pierre Charalambos, http://otrolado.info/
*
* All rights reserved. Library that eases the creation of interactive
* scenes, released under the terms of the GNU Public License v3.0
* which is available at http://www.gnu.org/licenses/gpl.html
**************************************************************************************/
package remixlab.fpstiming;
/**
* An abstract wrapper class holding a {@link #timer()} together with its call back method
* ( {@link remixlab.fpstiming.Taskable#execute()}) which derived classes should
* implement.
*/
public abstract class TimingTask implements Taskable {
protected Timer tmr;
/**
* Returns the timer instance.
*/
public Timer timer() {
return tmr;
}
/**
* Sets the timer instance.
*/
public void setTimer(Timer t) {
tmr = t;
}
// Wrappers
/**
* Timer wrapper method.
*/
public void run(long period) {
if (timer() != null) {
timer().setSingleShot(false);
timer().run(period);
}
}
/**
* Timer wrapper method.
*/
public void runOnce(long period) {
if (timer() != null) {
timer().setSingleShot(true);
timer().run(period);
}
}
/**
* Timer wrapper method.
*/
public void stop() {
if (timer() != null) {
timer().stop();
}
}
/**
* Timer wrapper method.
*/
public void cancel() {
if (timer() != null) {
timer().cancel();
}
}
/**
* Timer wrapper method.
*/
public void create() {
if (timer() != null) {
timer().create();
}
}
/**
* Timer wrapper method.
*/
public boolean isActive() {
if (timer() != null) {
return timer().isActive();
}
return false;
}
/**
* Timer wrapper method.
*/
public long period() {
return timer().period();
}
}