Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / lib3DMap / src / org / gvsig / gvsig3d / navigation / NavigationMode.java @ 25722

History | View | Annotate | Download (6.51 KB)

1
package org.gvsig.gvsig3d.navigation;
2

    
3
import java.util.ArrayList;
4
import java.util.Iterator;
5
import java.util.List;
6

    
7
import org.gvsig.osgvp.planets.CustomTerrainManipulator;
8

    
9
public class NavigationMode {
10

    
11
        /**
12
         * Custom terrain manipulator
13
         */
14
        private CustomTerrainManipulator CTM;
15

    
16
        /**
17
         * List of roll manipulators
18
         */
19
        private static List manRollList;
20

    
21
        /**
22
         * List of zoom manipulator
23
         */
24
        private static List manZoomList;
25

    
26
        /**
27
         * List of azimut manipulator
28
         */
29
        private static List manAzimutList;
30

    
31
        /**
32
         * Contrustor method
33
         * 
34
         * They save the custom terrain manipulator for use in the future.
35
         * 
36
         * @param view3D
37
         *            View3D object
38
         */
39
        public NavigationMode(CustomTerrainManipulator CTM) {
40

    
41
                // Getting the custom terrain manipulator
42
                this.CTM = CTM;
43

    
44
                if (manRollList == null){
45
                        // Gettin list of roll manipulator
46
                        manRollList = new ArrayList();
47
                        for (int i = 0; i < CTM.getRollButtonMaskSize(); i++) {
48
                                // Save button and key mask
49
                                NavigationMask navMask = new NavigationMask(
50
                                                CTM.getRollMouseMask(i), CTM.getRollKeyMask(i));
51
                                // Adding to list
52
                                manRollList.add(navMask);
53
                        }
54
                }
55

    
56
                if (manZoomList == null){
57
                        // Gettin list of zoom manipulator
58
                        manZoomList = new ArrayList();
59
                        for (int i = 0; i < CTM.getZoomButtonMaskSize(); i++) {
60
                                // Save button and key mask
61
                                NavigationMask navMask = new NavigationMask(
62
                                                CTM.getZoomMouseMask(i), CTM.getZoomKeyMask(i));
63
                                // Adding to list
64
                                manZoomList.add(navMask);
65
                        }
66
                }
67

    
68
                if (manAzimutList == null){
69
                        // Gettin list of roll manipulator
70
                        manAzimutList = new ArrayList();
71
                        for (int i = 0; i < CTM.getAzimButtonMaskSize(); i++) {
72
                                // Save button and key mask
73
                                NavigationMask navMask = new NavigationMask(
74
                                                CTM.getAzimMouseMask(i), CTM.getAzimKeyMask(i));
75
                                // Adding to list
76
                                manAzimutList.add(navMask);
77
                        }
78
                }
79
        }
80

    
81
        /**
82
         * Method to restore defaul roll mode manipulator
83
         */
84
        public void RestoreRollMode() {
85

    
86
                // Setting left button for roll mode
87
                for (Iterator iter = manRollList.iterator(); iter.hasNext();) {
88
                        // Get the mask element
89
                        NavigationMask mask = (NavigationMask) iter.next();
90
                        // Settin mode
91
                        CTM.addRollButtonMask(mask.getBtnMask(), mask.getKeyMask());
92

    
93
                }
94

    
95
        }
96

    
97
        /**
98
         * Method to restore default zoom mode manipulator
99
         */
100
        public void RestoreZoomMode() {
101

    
102
                // Setting left button for roll mode
103
                for (Iterator iter = manZoomList.iterator(); iter.hasNext();) {
104
                        // Get the mask element
105
                        NavigationMask mask = (NavigationMask) iter.next();
106
                        // Settin mode
107
                        CTM.addZoomButtonMask(mask.getBtnMask(), mask.getKeyMask());
108

    
109
                }
110
        }
111

    
112
        /**
113
         * Method to restore default azimut mode manipulator
114
         */
115
        public void RestoreAzimutMode() {
116

    
117
                // Setting left button for roll mode
118
                for (Iterator iter = manAzimutList.iterator(); iter.hasNext();) {
119
                        // Get the mask element
120
                        NavigationMask mask = (NavigationMask) iter.next();
121
                        // Settin mode
122
                        CTM.addAzimButtonMask(mask.getBtnMask(), mask.getKeyMask());
123

    
124
                }
125

    
126
        }
127

    
128
        /**
129
         * Method to remove navigation altogether
130
         */
131
        public void SetStopMode() {
132
                // Removing all controls
133
                removeAllModes();
134
        }
135

    
136
        /**
137
         * Method to set up roll mode in left mouse button
138
         */
139
        public void SetRollMode() {
140
                // Relmoving all controls
141
                removeAllModes();
142

    
143
                CTM.addRollButtonMask(
144
                                CustomTerrainManipulator.MouseButtonMaskType.LEFT_MOUSE_BUTTON,
145
                                0);
146
        }
147

    
148
        /**
149
         * Method to set up zoom mode in left mouse button
150
         */
151
        public void SetZoomMode() {
152
                // Relmoving all controls
153
                removeAllModes();
154
                // Settin mode
155
                CTM.addZoomButtonMask(
156
                                CustomTerrainManipulator.MouseButtonMaskType.LEFT_MOUSE_BUTTON,
157
                                0);
158
        }
159

    
160
        /**
161
         * Method to set up azimut mode in left mouse button
162
         */
163
        public void SetAzimutMode() {
164
                // Relmoving all controls
165
                removeAllModes();
166
                CTM.addAzimButtonMask(
167
                                CustomTerrainManipulator.MouseButtonMaskType.LEFT_MOUSE_BUTTON,
168
                                0);
169
        }
170

    
171
        /**
172
         * Method to set up default mode in left mouse button
173
         */
174
        public void SetDefaultMode() {
175
                // Removing all controls
176
                removeAllModes();
177

    
178
                RestoreRollMode();
179
                RestoreZoomMode();
180
                RestoreAzimutMode();
181

    
182
        }
183
        
184
        /**
185
         * Method to set up azimut and roll mode in left mouse button
186
         */
187
        public void SetAzimutRollMode() {
188
                // Relmoving all controls
189
                removeAllModes();
190
                CTM.addAzimButtonMask(
191
                                CustomTerrainManipulator.MouseButtonMaskType.RIGHT_MOUSE_BUTTON,
192
                                0);
193
                CTM.addRollButtonMask(
194
                                CustomTerrainManipulator.MouseButtonMaskType.LEFT_MOUSE_BUTTON,
195
                                0);
196
        }
197

    
198
        /**
199
         * Method to remove all mask button manipulator
200
         */
201
        public void removeAllModes() {
202
                // For remove a button mask always remove 0 index. Why the list of
203
                // button mask auto-reorder her elements.
204

    
205
                // Removing roll modes
206
                for (int i = 0; i < manRollList.size(); i++) {
207
                        CTM.removeRollButtonMask(0);
208
                }
209

    
210
                // Removing zoom modes
211
                for (int i = 0; i < manZoomList.size(); i++) {
212
                        CTM.removeZoomButtonMask(0);
213
                }
214

    
215
                // Removing azimut modes
216
                for (int i = 0; i < manAzimutList.size(); i++) {
217
                        CTM.removeAzimButtonMask(0);
218
                }
219
        }
220

    
221
        public static void removeAllNavigationModes(CustomTerrainManipulator ctm) {
222
                // For remove a button mask always remove 0 index. Why the list of
223
                // button mask auto-reorder her elements.
224
                if (ctm != null){
225

    
226
                        // Removing roll modes
227
                        for (int i = 0; i < manRollList.size(); i++) {
228
                                ctm.removeRollButtonMask(0);
229
                        }
230
                        
231
                        // Removing zoom modes
232
                        for (int i = 0; i < manZoomList.size(); i++) {
233
                                ctm.removeZoomButtonMask(0);
234
                        }
235
                        
236
                        // Removing azimut modes
237
                        for (int i = 0; i < manAzimutList.size(); i++) {
238
                                ctm.removeAzimButtonMask(0);
239
                        }
240
                }
241
        }
242
        
243
        public static void restoreAllNavigationModes(CustomTerrainManipulator ctm) {
244
                if (ctm !=null){
245
                        
246
                        for (int i = 0; i < manRollList.size(); i++) {
247
                                // Get the mask element
248
                                NavigationMask mask = (NavigationMask) manRollList.get(i);
249
                                // Settin mode
250
                                ctm.addRollButtonMask(mask.getBtnMask(), mask.getKeyMask());
251
                        }
252
                        for (int i = 0; i < manZoomList.size(); i++) {
253
                                // Get the mask element
254
                                NavigationMask mask = (NavigationMask) manZoomList.get(i);
255
                                // Settin mode
256
                                ctm.addZoomButtonMask(mask.getBtnMask(), mask.getKeyMask());
257
                        }
258
                        for (int i = 0; i < manAzimutList.size(); i++) {
259
                                // Get the mask element
260
                                NavigationMask mask = (NavigationMask) manAzimutList.get(i);
261
                                // Settin mode
262
                                ctm.addAzimButtonMask(mask.getBtnMask(), mask.getKeyMask());
263
                        }
264
                        
265
                }
266
                
267
        }
268

    
269
}