1 package fi.jyu.mit.graphics;
2 import java.util.Timer;
3 import java.util.TimerTask;
4
5
9 public class BasicTransformer extends TimerTask implements Transformer {
10
11 private final Transformable object;
12 private Matrix tra;
13 private final Timer timer;
14
15
21 public BasicTransformer(Transformable object,Matrix tra,long dt) {
22 super();
23 this.object = object;
24 this.tra = tra;
25 timer = new Timer();
26 timer.schedule(this,dt,dt);
27 }
28
29
30
33 @Override
34 public void run() {
35 object.transform(tra);
36 }
37
38
39
43 public void setTransform(Matrix rot) {
44 this.tra = rot;
45 }
46
47
48
51 public Matrix getTransform() {
52 return tra;
53 }
54
55
56
59 @Override
60 public void remove() {
61 this.cancel();
62 timer.cancel();
63 }
64
65
66
69 public Transformable getObject() {
70 return object;
71 }
72
73 }
74