Loading...
Searching...
No Matches
LocationWindowCommonExample.java
Go to the documentation of this file.
1package com.navigine.examples;
2
3import java.util.Arrays;
4import java.util.List;
5
13
14 private LocationWindow locationWindow;
15
19
24 System.out.println("=== LocationWindowCommon Methods ===");
25
30 }
31
36 System.out.println("--- setSublocationId Method ---");
37
38 if (locationWindow == null) {
39 System.out.println("LocationWindow not available yet");
40 return;
41 }
42
43 // [java_LocationWindow_setSublocationId]
44 // Set sublocation ID to switch between floors
45 locationWindow.setSublocationId(1);
46 System.out.println("Set sublocation ID to 1 (first floor)");
47 // [java_LocationWindow_setSublocationId]
48
49 // [java_LocationWindow_setSublocationId_2]
50 // Set sublocation ID to another floor
51 locationWindow.setSublocationId(2);
52 System.out.println("Set sublocation ID to 2 (second floor)");
53 // [java_LocationWindow_setSublocationId_2]
54
55 // [java_LocationWindow_setSublocationId_3]
56 // Set sublocation ID to ground floor
57 locationWindow.setSublocationId(0);
58 System.out.println("Set sublocation ID to 0 (ground floor)");
59 // [java_LocationWindow_setSublocationId_3]
60
61 // Test with different sublocation IDs
62 List<Integer> sublocationIds = Arrays.asList(1, 2, 3, 0, 5);
63 for (Integer id : sublocationIds) {
64 locationWindow.setSublocationId(id);
65 System.out.println("Switched to sublocation ID: " + id);
66 }
67 }
68
73 System.out.println("--- Coordinate Conversion Methods ---");
74
75 if (locationWindow == null) {
76 System.out.println("LocationWindow not available yet");
77 return;
78 }
79
80 // [java_LocationWindow_screenPositionToMeters]
81 // Convert screen position to meters
82 Point screenPoint = new Point(100.0, 200.0);
83 Point metersPoint = locationWindow.screenPositionToMeters(screenPoint);
84 System.out.printf("Screen position (%.1f, %.1f) converted to meters: (%.1f, %.1f)%n",
85 screenPoint.getX(), screenPoint.getY(), metersPoint.getX(), metersPoint.getY());
86 // [java_LocationWindow_screenPositionToMeters]
87
88 // [java_LocationWindow_screenPositionToMeters_2]
89 // Convert another screen position to meters
90 Point screenPoint2 = new Point(500.0, 300.0);
91 Point metersPoint2 = locationWindow.screenPositionToMeters(screenPoint2);
92 System.out.printf("Screen position (%.1f, %.1f) converted to meters: (%.1f, %.1f)%n",
93 screenPoint2.getX(), screenPoint2.getY(), metersPoint2.getX(), metersPoint2.getY());
94 // [java_LocationWindow_screenPositionToMeters_2]
95
96 // [java_LocationWindow_metersToScreenPosition]
97 // Convert meters to screen position with clipping
98 Point metersPoint3 = new Point(50.0, 75.0);
99 Point screenPoint3 = locationWindow.metersToScreenPosition(metersPoint3, true);
100 System.out.printf("Meters position (%.1f, %.1f) converted to screen with clipping: (%.1f, %.1f)%n",
101 metersPoint3.getX(), metersPoint3.getY(), screenPoint3.getX(), screenPoint3.getY());
102 // [java_LocationWindow_metersToScreenPosition]
103
104 // [java_LocationWindow_metersToScreenPosition_2]
105 // Convert meters to screen position without clipping
106 Point metersPoint4 = new Point(150.0, 200.0);
107 Point screenPoint4 = locationWindow.metersToScreenPosition(metersPoint4, false);
108 System.out.printf("Meters position (%.1f, %.1f) converted to screen without clipping: (%.1f, %.1f)%n",
109 metersPoint4.getX(), metersPoint4.getY(), screenPoint4.getX(), screenPoint4.getY());
110 // [java_LocationWindow_metersToScreenPosition_2]
111
112 // Test coordinate conversion with different values
113 List<Point> testScreenPoints = Arrays.asList(
114 new Point(0.0, 0.0),
115 new Point(250.0, 250.0),
116 new Point(1000.0, 600.0)
117 );
118
119 for (int i = 0; i < testScreenPoints.size(); i++) {
120 Point screenPoint = testScreenPoints.get(i);
121 Point metersPoint = locationWindow.screenPositionToMeters(screenPoint);
122 Point backToScreen = locationWindow.metersToScreenPosition(metersPoint, false);
123 System.out.printf("Test %d: Screen (%.1f, %.1f) -> Meters (%.1f, %.1f) -> Screen (%.1f, %.1f)%n",
124 i, screenPoint.getX(), screenPoint.getY(),
125 metersPoint.getX(), metersPoint.getY(),
126 backToScreen.getX(), backToScreen.getY());
127 }
128 }
129
134 System.out.println("--- Map Feature Selection Methods ---");
135
136 if (locationWindow == null) {
137 System.out.println("LocationWindow not available yet");
138 return;
139 }
140
141 // [java_LocationWindow_selectMapFeature]
142 // Select map feature by ID
143 String featureId = "room_101";
144 boolean selected = locationWindow.selectMapFeature(featureId);
145 System.out.println("Selected map feature " + featureId + ": " + selected);
146 // [java_LocationWindow_selectMapFeature]
147
148 // [java_LocationWindow_selectMapFeature_2]
149 // Select another map feature
150 String featureId2 = "office_205";
151 boolean selected2 = locationWindow.selectMapFeature(featureId2);
152 System.out.println("Selected map feature " + featureId2 + ": " + selected2);
153 // [java_LocationWindow_selectMapFeature_2]
154
155 // [java_LocationWindow_getSelectedMapFeatures]
156 // Get list of selected map features
157 List<String> selectedFeatures = locationWindow.getSelectedMapFeatures();
158 System.out.println("Currently selected map features: " + selectedFeatures.size() + " features");
159 for (String feature : selectedFeatures) {
160 System.out.println(" - " + feature);
161 }
162 // [java_LocationWindow_getSelectedMapFeatures]
163
164 // [java_LocationWindow_deselectMapFeature]
165 // Deselect specific map feature
166 boolean deselected = locationWindow.deselectMapFeature(featureId);
167 System.out.println("Deselected map feature " + featureId + ": " + deselected);
168 // [java_LocationWindow_deselectMapFeature]
169
170 // [java_LocationWindow_deselectMapFeature_2]
171 // Deselect another map feature
172 boolean deselected2 = locationWindow.deselectMapFeature(featureId2);
173 System.out.println("Deselected map feature " + featureId2 + ": " + deselected2);
174 // [java_LocationWindow_deselectMapFeature_2]
175
176 // [java_LocationWindow_deselectAllMapFeatures]
177 // Deselect all map features
178 locationWindow.deselectAllMapFeatures();
179 System.out.println("Deselected all map features");
180 // [java_LocationWindow_deselectAllMapFeatures]
181
182 // [java_LocationWindow_getSelectedMapFeatures_2]
183 // Verify all features are deselected
184 List<String> remainingFeatures = locationWindow.getSelectedMapFeatures();
185 System.out.println("Remaining selected features after deselect all: " + remainingFeatures.size() + " features");
186 // [java_LocationWindow_getSelectedMapFeatures_2]
187
188 // Test multiple feature selection and deselection
189 List<String> testFeatureIds = Arrays.asList("room_101", "office_205", "meeting_room_301", "cafe_401");
190
191 // Select multiple features
192 for (String featureId : testFeatureIds) {
193 boolean success = locationWindow.selectMapFeature(featureId);
194 System.out.println("Selected feature " + featureId + ": " + success);
195 }
196
197 // Check selected features
198 List<String> allSelected = locationWindow.getSelectedMapFeatures();
199 System.out.println("All selected features: " + allSelected.size() + " features");
200
201 // Deselect all at once
202 locationWindow.deselectAllMapFeatures();
203 System.out.println("Deselected all features at once");
204 }
205
210 System.out.println("--- Zoom Properties ---");
211
212 if (locationWindow == null) {
213 System.out.println("LocationWindow not available yet");
214 return;
215 }
216
217 // [java_LocationWindow_getZoomFactor]
218 // Get current zoom factor
219 double currentZoom = locationWindow.getZoomFactor();
220 System.out.println("Current zoom factor: " + currentZoom);
221 // [java_LocationWindow_getZoomFactor]
222
223 // [java_LocationWindow_setZoomFactor]
224 // Set zoom factor
225 locationWindow.setZoomFactor(150.0);
226 System.out.println("Set zoom factor to 150.0");
227 // [java_LocationWindow_setZoomFactor]
228
229 // [java_LocationWindow_getMinZoomFactor]
230 // Get minimum zoom factor
231 double minZoomFactor = locationWindow.getMinZoomFactor();
232 System.out.println("Minimum zoom factor: " + minZoomFactor);
233 // [java_LocationWindow_getMinZoomFactor]
234
235 // [java_LocationWindow_setMinZoomFactor]
236 // Set minimum zoom factor
237 locationWindow.setMinZoomFactor(50.0);
238 System.out.println("Set minimum zoom factor to 50.0");
239 // [java_LocationWindow_setMinZoomFactor]
240
241 // [java_LocationWindow_getMaxZoomFactor]
242 // Get maximum zoom factor
243 double maxZoomFactor = locationWindow.getMaxZoomFactor();
244 System.out.println("Maximum zoom factor: " + maxZoomFactor);
245 // [java_LocationWindow_getMaxZoomFactor]
246
247 // [java_LocationWindow_setMaxZoomFactor]
248 // Set maximum zoom factor
249 locationWindow.setMaxZoomFactor(300.0);
250 System.out.println("Set maximum zoom factor to 300.0");
251 // [java_LocationWindow_setMaxZoomFactor]
252
253 // Test zoom factor changes
254 List<Double> testZoomFactors = Arrays.asList(100.0, 125.0, 150.0, 200.0, 250.0);
255 for (Double zoom : testZoomFactors) {
256 locationWindow.setZoomFactor(zoom);
257 System.out.println("Changed zoom factor to: " + locationWindow.getZoomFactor());
258 }
259
260 // Test zoom limits
261 System.out.println("Testing zoom limits...");
262 locationWindow.setZoomFactor(locationWindow.getMinZoomFactor());
263 System.out.println("Set to minimum zoom: " + locationWindow.getZoomFactor());
264
265 locationWindow.setZoomFactor(locationWindow.getMaxZoomFactor());
266 System.out.println("Set to maximum zoom: " + locationWindow.getZoomFactor());
267
268 // Reset to default
269 locationWindow.setZoomFactor(100.0);
270 System.out.println("Reset zoom factor to default: " + locationWindow.getZoomFactor());
271 }
272
276 public void runExample() {
277 System.out.println("=== LocationWindowCommon Example ===");
278
279 // Simulate LocationWindow initialization
280 try {
281 Thread.sleep(500);
282 } catch (InterruptedException e) {
283 Thread.currentThread().interrupt();
284 }
285
286 // TODO: User will implement LocationWindow initialization here
287 // locationWindow = getLocationWindow();
288
289 // Run demonstrations
291
292 System.out.println("=== Example completed ===");
293 }
294
298 public static void main(String[] args) {
300 example.runExample();
301 }
302}