View Javadoc

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      // private boolean continuous;
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          // continuous = false;
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                  //  continuous = true;
34  
35              } else {
36                  setClaimOut();
37              }
38  
39  
40  
41          } else {
42  
43              if (m.leftButton()) {
44                  //	 continuous = true;
45                  setClaimOut();
46                  // used to remain undecided - could be tuyrn zoom ,oucld be pan
47                  // - reinstate??? TODO
48  
49              } else if (m.rightButton()) {
50                  // continuous = true;
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              // moved ten pixels - claim mouse for pan if we can;
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          // always pan on drag?? *** (no non-continuous mode?)
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    package void applyOnRelease() {
116 
117       } else {
118 	 boolean longClick = (ms.button == ms.RIGHTBUTTON ||
119 			      ms.tUp - ms.tDown > 500);
120 
121 	 if (dropEmptyClick) {
122 	    dropEmptyClick = false;
123 	 } else {
124 	   if (panZoomable) panZoom(longClick);
125 	 }
126 	 repaint ();
127 
128    }
129 
130 }
131 
132 */