Statistics
| Revision:

svn-gvsig-desktop / import / ext3D / branches / ext3D_v1.1 / ext3D / src / com / iver / ai2 / gvsig3d / navigation / NavigationMode.java @ 15441

History | View | Annotate | Download (5.25 KB)

1
package com.iver.ai2.gvsig3d.navigation;
2

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

    
7
import es.upv.ai2.libjosg.planets.CustomTerrainManipulator;
8

    
9
public class NavigationMode {
10

    
11
        /**
12
         * Custom terrain manipulator
13
         */
14
        private static 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
                // Gettin list of roll manipulator
45
                manRollList = new ArrayList();
46
                for (int i = 0; i < CTM.getRollButtonMaskSize(); i++) {
47
                        // Save button and key mask
48
                        NavigationMask navMask = new NavigationMask(
49
                                        CTM.getRollMouseMask(i), CTM.getRollKeyMask(i));
50
                        // Adding to list
51
                        manRollList.add(navMask);
52
                }
53

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

    
64
                // Gettin list of roll manipulator
65
                manAzimutList = new ArrayList();
66
                for (int i = 0; i < CTM.getAzimButtonMaskSize(); i++) {
67
                        // Save button and key mask
68
                        NavigationMask navMask = new NavigationMask(
69
                                        CTM.getAzimMouseMask(i), CTM.getAzimKeyMask(i));
70
                        // Adding to list
71
                        manAzimutList.add(navMask);
72
                }
73
        }
74

    
75
        /**
76
         * Method to restore defaul roll mode manipulator
77
         */
78
        public void RestoreRollMode() {
79

    
80
                // Setting left button for roll mode
81
                for (Iterator iter = manRollList.iterator(); iter.hasNext();) {
82
                        // Get the mask element
83
                        NavigationMask mask = (NavigationMask) iter.next();
84
                        // Settin mode
85
                        CTM.addRollButtonMask(mask.getBtnMask(), mask.getKeyMask());
86

    
87
                }
88

    
89
        }
90

    
91
        /**
92
         * Method to restore default zoom mode manipulator
93
         */
94
        public void RestoreZoomMode() {
95

    
96
                // Setting left button for roll mode
97
                for (Iterator iter = manZoomList.iterator(); iter.hasNext();) {
98
                        // Get the mask element
99
                        NavigationMask mask = (NavigationMask) iter.next();
100
                        // Settin mode
101
                        CTM.addZoomButtonMask(mask.getBtnMask(), mask.getKeyMask());
102

    
103
                }
104
        }
105

    
106
        /**
107
         * Method to restore default azimut mode manipulator
108
         */
109
        public void RestoreAzimutMode() {
110

    
111
                // Setting left button for roll mode
112
                for (Iterator iter = manAzimutList.iterator(); iter.hasNext();) {
113
                        // Get the mask element
114
                        NavigationMask mask = (NavigationMask) iter.next();
115
                        // Settin mode
116
                        CTM.addAzimButtonMask(mask.getBtnMask(), mask.getKeyMask());
117

    
118
                }
119

    
120
        }
121

    
122
        /**
123
         * Method to remove navigation altogether
124
         */
125
        public void SetStopMode() {
126
                // Removing all controls
127
                removeAllModes();
128
        }
129

    
130
        /**
131
         * Method to set up roll mode in left mouse button
132
         */
133
        public void SetRollMode() {
134
                // Relmoving all controls
135
                removeAllModes();
136

    
137
                CTM.addRollButtonMask(
138
                                CustomTerrainManipulator.MouseButtonMaskType.LEFT_MOUSE_BUTTON,
139
                                0);
140
        }
141

    
142
        /**
143
         * Method to set up zoom mode in left mouse button
144
         */
145
        public void SetZoomMode() {
146
                // Relmoving all controls
147
                removeAllModes();
148
                // Settin mode
149
                CTM.addZoomButtonMask(
150
                                CustomTerrainManipulator.MouseButtonMaskType.LEFT_MOUSE_BUTTON,
151
                                0);
152
        }
153

    
154
        /**
155
         * Method to set up azimut mode in left mouse button
156
         */
157
        public void SetAzimutMode() {
158
                // Relmoving all controls
159
                removeAllModes();
160
                CTM.addAzimButtonMask(
161
                                CustomTerrainManipulator.MouseButtonMaskType.LEFT_MOUSE_BUTTON,
162
                                0);
163
        }
164

    
165
        /**
166
         * Method to set up default mode in left mouse button
167
         */
168
        public void SetDefaultMode() {
169
                // Relmoving all controls
170
                removeAllModes();
171

    
172
                RestoreRollMode();
173
                RestoreZoomMode();
174
                RestoreAzimutMode();
175

    
176
        }
177

    
178
        /**
179
         * Method to remove all mask button manipulator
180
         */
181
        public void removeAllModes() {
182
                // For remove a button mask always remove 0 index. Why the list of
183
                // button mask auto-reorder her elements.
184

    
185
                // Removing roll modes
186
                for (int i = 0; i < manRollList.size(); i++) {
187
                        CTM.removeRollButtonMask(0);
188
                }
189

    
190
                // Removing zoom modes
191
                for (int i = 0; i < manZoomList.size(); i++) {
192
                        CTM.removeZoomButtonMask(0);
193
                }
194

    
195
                // Removing azimut modes
196
                for (int i = 0; i < manAzimutList.size(); i++) {
197
                        CTM.removeAzimButtonMask(0);
198
                }
199
        }
200

    
201
        public static void removeAllNavigationModes() {
202
                // For remove a button mask always remove 0 index. Why the list of
203
                // button mask auto-reorder her elements.
204

    
205
                if (manRollList != null) {
206
                        // Removing roll modes
207
                        for (int i = 0; i < manRollList.size(); i++) {
208
                                CTM.removeRollButtonMask(0);
209
                        }
210
                }
211
                if (manZoomList != null) {
212
                        // Removing zoom modes
213
                        for (int i = 0; i < manZoomList.size(); i++) {
214
                                CTM.removeZoomButtonMask(0);
215
                        }
216
                }
217
                if (manAzimutList != null) {
218
                        // Removing azimut modes
219
                        for (int i = 0; i < manAzimutList.size(); i++) {
220
                                CTM.removeAzimButtonMask(0);
221
                        }
222
                }
223
        }
224

    
225
}