1 package org.catacomb.graph.gui;
2
3
4
5 final class PanHandler extends MouseHandler {
6
7 private int xc;
8 private int yc;
9
10
11
12
13
14 final static int NORMAL = 0;
15 final static int SIMPLE = 1;
16
17 int actionMode = NORMAL;
18
19
20
21 public PanHandler() {
22
23 }
24
25
26 public void init(Mouse m) {
27 xc = m.getX();
28 yc = m.getY();
29
30 if (actionMode == SIMPLE) {
31 if (m.leftButton()) {
32 setClaimIn();
33
34
35 } else {
36 setClaimOut();
37 }
38
39
40
41 } else {
42
43 if (m.leftButton()) {
44
45 setClaimOut();
46
47
48
49 } else if (m.rightButton()) {
50
51
52 } else {
53 setClaimOut();
54 }
55 }
56 }
57
58
59 public void activate() {
60 actionMode = NORMAL;
61 super.activate();
62 }
63
64
65
66 public void simpleActivate() {
67 activate();
68 actionMode = SIMPLE;
69 }
70
71
72
73
74
75 public void advance(Mouse m) {
76
77 int dx = m.getX() - xc;
78 int dy = m.getY() - yc;
79
80 if (dx * dx + dy * dy > 100) {
81
82 setClaimIn();
83 }
84
85 }
86
87
88 public void applyOnDrag(Mouse m) {
89 int x = m.getX();
90 int y = m.getY();
91
92
93 m.trialPan(xc, yc, x, y);
94 setFullRepaint();
95 }
96
97
98
99 public void applyOnRelease(Mouse m) {
100 int x = m.getX();
101 int y = m.getY();
102 m.permanentPan(xc, yc, x, y);
103 m.restoreAA();
104
105 }
106
107
108
109 }
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132