1 package org.catacomb.graph.gui;
2
3
4
5
6 final class TurntableHandler extends MouseHandler {
7
8 private int xc;
9 private int yc;
10
11
12
13
14
15 final static int NORMAL = 0;
16 final static int SIMPLE = 1;
17
18 int actionMode = NORMAL;
19
20
21
22 public TurntableHandler() {
23
24 }
25
26
27 public void init(Mouse m) {
28 xc = m.getX();
29 yc = m.getY();
30
31 if (actionMode == SIMPLE) {
32 if (m.leftButton()) {
33 setClaimIn();
34
35 } else {
36 setClaimOut();
37 }
38
39
40
41 } else {
42 setClaimOut();
43
44 }
45 }
46
47
48 public void activate() {
49 actionMode = NORMAL;
50 super.activate();
51 }
52
53
54
55 public void simpleActivate() {
56 activate();
57 actionMode = SIMPLE;
58 }
59
60
61
62
63
64 public void advance(Mouse m) {
65
66 }
67
68
69
70
71 public void applyOnDown(Mouse m) {
72 m.initializeRotation(m.getX(), m.getY());
73 }
74
75
76 public void applyOnDrag(Mouse m) {
77 int x = m.getX();
78 int y = m.getY();
79
80 m.dragZRotate(x - xc, y - yc);
81 setFullRepaint();
82 }
83
84
85
86 public void applyOnRelease(Mouse m) {
87 m.restoreAA();
88
89
90
91 }
92
93 }
94
95