Loading...
Searching...
No Matches
LocationWindowCommonExample.java
Go to the documentation of this file.
1package com.navigine.examples;
2
3import java.util.ArrayList;
4import java.util.Arrays;
5import java.util.List;
6
7import com.navigine.idl.java.DebugFlag;
8
16
17 private LocationWindow locationWindow;
18 private UserLocationLayer userLocationLayer;
19
23
41
45 public void demonstrateDebugFlags() {
46 System.out.println("--- Debug flags ---");
47
48 // [java_DebugFlag_enum]
49 DebugFlag[] allFlags = new DebugFlag[] {
56 };
57 System.out.println("Debug flag enum values: " + allFlags.length);
58 // [java_DebugFlag_enum]
59
60 // [java_LocationWindow_setDebugFlag]
63 System.out.println("Updated debug flags on LocationWindow");
64 // [java_LocationWindow_setDebugFlag]
65
66 // [java_LocationWindow_getDebugFlag]
67 boolean infosOn = LocationWindow.getDebugFlag(DebugFlag.INFOS);
68 System.out.println("Debug flag INFOS enabled: " + infosOn);
69 // [java_LocationWindow_getDebugFlag]
70 }
71
72
77 System.out.println("--- Operating Mode ---");
78
79 if (locationWindow == null) {
80 System.out.println("LocationWindow not available yet");
81 return;
82 }
83
84 // [java_OperatingMode_enum]
85 OperatingMode[] modes = {
89 };
90 System.out.println("Operating modes: " + modes.length);
91 // [java_OperatingMode_enum]
92
93 // [java_LocationWindow_setOperatingMode]
94 locationWindow.setOperatingMode(OperatingMode.OUTDOOR_INDOOR);
95 System.out.println("Set operating mode to OUTDOOR_INDOOR");
96 // [java_LocationWindow_setOperatingMode]
97
98 // [java_LocationWindow_getOperatingMode]
99 OperatingMode currentMode = locationWindow.getOperatingMode();
100 System.out.println("Current operating mode: " + currentMode);
101 // [java_LocationWindow_getOperatingMode]
102
103 // [java_AttributionAlignment_record]
107 // [java_AttributionAlignment_record]
108
109 // [java_LocationWindow_setAttributionAlignment]
110 locationWindow.setAttributionAlignment(alignment);
111 // [java_LocationWindow_setAttributionAlignment]
112
113 // [java_LocationWindow_getAttribution]
114 String attribution = locationWindow.getAttribution();
115 System.out.println("Attribution: " + attribution);
116 // [java_LocationWindow_getAttribution]
117 }
118
123 System.out.println("--- setSublocationId Method ---");
124
125 if (locationWindow == null) {
126 System.out.println("LocationWindow not available yet");
127 return;
128 }
129
130 // [java_LocationWindow_setSublocationId]
131 // Set sublocation ID to switch between floors
132 locationWindow.setSublocationId(1);
133 System.out.println("Set sublocation ID to 1 (first floor)");
134 // [java_LocationWindow_setSublocationId]
135
136 // [java_LocationWindow_setSublocationId_2]
137 // Set sublocation ID to another floor
138 locationWindow.setSublocationId(2);
139 System.out.println("Set sublocation ID to 2 (second floor)");
140 // [java_LocationWindow_setSublocationId_2]
141
142 // [java_LocationWindow_setSublocationId_3]
143 // Set sublocation ID to ground floor
144 locationWindow.setSublocationId(0);
145 System.out.println("Set sublocation ID to 0 (ground floor)");
146 // [java_LocationWindow_setSublocationId_3]
147
148 // Test with different sublocation IDs
149 List<Integer> sublocationIds = Arrays.asList(1, 2, 3, 0, 5);
150 for (Integer id : sublocationIds) {
151 locationWindow.setSublocationId(id);
152 System.out.println("Switched to sublocation ID: " + id);
153 }
154 }
155
160 System.out.println("--- getSublocationId & getEnclosingCamera ---");
161
162 if (locationWindow == null) {
163 System.out.println("LocationWindow not available yet");
164 return;
165 }
166
167 // [java_LocationWindow_getSublocationId]
168 Integer currentId = locationWindow.getSublocationId();
169 if (currentId != null) {
170 System.out.println("Current sublocation id: " + currentId);
171 } else {
172 System.out.println("Current sublocation id is not set");
173 }
174 // [java_LocationWindow_getSublocationId]
175
176 // [java_LocationWindow_getEnclosingCamera]
177 BoundingBox boundingBox = new BoundingBox(new GlobalPoint(55.75, 37.61), new GlobalPoint(55.76, 37.63));
178 Camera camera = locationWindow.getEnclosingCamera(boundingBox);
179 System.out.println("Camera that fits bounding box: " + camera);
180 // [java_LocationWindow_getEnclosingCamera]
181 }
182
187 System.out.println("--- Sublocation Change Listener ---");
188
189 if (locationWindow == null) {
190 System.out.println("LocationWindow not available yet");
191 return;
192 }
193
194 DemoSublocationChangeListener listener = new DemoSublocationChangeListener();
195
196 // [java_LocationWindow_addSublocationChangeListener]
197 locationWindow.addSublocationChangeListener(listener);
198 System.out.println("Added sublocation change listener");
199 // [java_LocationWindow_addSublocationChangeListener]
200
201 locationWindow.setSublocationId(1);
202 locationWindow.setSublocationId(2);
203
204 // [java_LocationWindow_removeSublocationChangeListener]
205 locationWindow.removeSublocationChangeListener(listener);
206 System.out.println("Removed sublocation change listener");
207 // [java_LocationWindow_removeSublocationChangeListener]
208 }
209
214 System.out.println("--- UserLocationLayer ---");
215
216 if (userLocationLayer == null) {
217 System.out.println("UserLocationLayer not available yet");
218 return;
219 }
220
221 // [java_UserLocationLayer_setVisible]
222 userLocationLayer.setVisible(true);
223 System.out.println("User location layer set visible");
224 // [java_UserLocationLayer_setVisible]
225
226 // [java_UserLocationLayer_isVisible]
227 boolean visible = userLocationLayer.isVisible();
228 System.out.println("User location layer is visible: " + visible);
229 // [java_UserLocationLayer_isVisible]
230
231 // [java_UserLocationLayer_setAnchor]
232 ScreenPoint anchor = new ScreenPoint(100.0f, 200.0f);
233 userLocationLayer.setAnchor(anchor);
234 System.out.println("Set user location anchor to: (" + anchor.getX() + ", " + anchor.getY() + ")");
235 // [java_UserLocationLayer_setAnchor]
236
237 // [java_UserLocationLayer_anchorEnabled]
238 boolean anchorEnabled = userLocationLayer.anchorEnabled();
239 System.out.println("Anchor enabled: " + anchorEnabled);
240 // [java_UserLocationLayer_anchorEnabled]
241
242 // [java_UserLocationLayer_resetAnchor]
243 userLocationLayer.resetAnchor();
244 System.out.println("Anchor reset to default");
245 // [java_UserLocationLayer_resetAnchor]
246 }
247
252 System.out.println("--- Coordinate Conversion Methods ---");
253
254 if (locationWindow == null) {
255 System.out.println("LocationWindow not available yet");
256 return;
257 }
258
259 // [java_LocationWindow_screenPositionToGlobal]
260 // Convert screen position to WGS84
261 ScreenPoint screenPoint = new ScreenPoint(100.0, 200.0);
262 GlobalPoint globalPoint = locationWindow.screenPositionToGlobal(screenPoint);
263 System.out.printf("Screen position (%.1f, %.1f) converted to WGS84: (%.6f, %.6f)%n",
264 screenPoint.getX(), screenPoint.getY(), globalPoint.getLatitude(), globalPoint.getLongitude());
265 // [java_LocationWindow_screenPositionToGlobal]
266
267 // [java_LocationWindow_globalToScreenPosition]
268 // Convert WGS84 to screen position with clipping
269 GlobalPoint globalPoint2 = new GlobalPoint(55.7558, 37.6176);
270 ScreenPoint screenPoint2 = locationWindow.globalToScreenPosition(globalPoint2, true);
271 System.out.printf("WGS84 (%.6f, %.6f) converted to screen with clipping: (%.1f, %.1f)%n",
272 globalPoint2.getLatitude(), globalPoint2.getLongitude(), screenPoint2.getX(), screenPoint2.getY());
273 // [java_LocationWindow_globalToScreenPosition]
274
275 List<ScreenPoint> testScreenPoints = Arrays.asList(
276 new ScreenPoint(0.0, 0.0),
277 new ScreenPoint(250.0, 250.0),
278 new ScreenPoint(1000.0, 600.0)
279 );
280
281 for (int i = 0; i < testScreenPoints.size(); i++) {
282 ScreenPoint screen = testScreenPoints.get(i);
283 GlobalPoint global = locationWindow.screenPositionToGlobal(screen);
284 ScreenPoint backToScreen = locationWindow.globalToScreenPosition(global, false);
285 System.out.printf("Test %d: Screen (%.1f, %.1f) -> WGS84 (%.6f, %.6f) -> Screen (%.1f, %.1f)%n",
286 i, screen.getX(), screen.getY(),
287 global.getLatitude(), global.getLongitude(),
288 backToScreen.getX(), backToScreen.getY());
289 }
290 }
291
296 System.out.println("--- Map Feature Selection Methods ---");
297
298 if (locationWindow == null) {
299 System.out.println("LocationWindow not available yet");
300 return;
301 }
302
303 // [java_LocationWindow_selectMapFeature]
304 // Select map feature by ID
305 String featureId = "room_101";
306 boolean selected = locationWindow.selectMapFeature(featureId);
307 System.out.println("Selected map feature " + featureId + ": " + selected);
308 // [java_LocationWindow_selectMapFeature]
309
310 // [java_LocationWindow_selectMapFeature_2]
311 // Select another map feature
312 String featureId2 = "office_205";
313 boolean selected2 = locationWindow.selectMapFeature(featureId2);
314 System.out.println("Selected map feature " + featureId2 + ": " + selected2);
315 // [java_LocationWindow_selectMapFeature_2]
316
317 // [java_LocationWindow_getSelectedMapFeatures]
318 // Get list of selected map features
319 List<String> selectedFeatures = locationWindow.getSelectedMapFeatures();
320 System.out.println("Currently selected map features: " + selectedFeatures.size() + " features");
321 for (String feature : selectedFeatures) {
322 System.out.println(" - " + feature);
323 }
324 // [java_LocationWindow_getSelectedMapFeatures]
325
326 // [java_LocationWindow_deselectMapFeature]
327 // Deselect specific map feature
328 boolean deselected = locationWindow.deselectMapFeature(featureId);
329 System.out.println("Deselected map feature " + featureId + ": " + deselected);
330 // [java_LocationWindow_deselectMapFeature]
331
332 // [java_LocationWindow_deselectMapFeature_2]
333 // Deselect another map feature
334 boolean deselected2 = locationWindow.deselectMapFeature(featureId2);
335 System.out.println("Deselected map feature " + featureId2 + ": " + deselected2);
336 // [java_LocationWindow_deselectMapFeature_2]
337
338 // [java_LocationWindow_deselectAllMapFeatures]
339 // Deselect all map features
340 locationWindow.deselectAllMapFeatures();
341 System.out.println("Deselected all map features");
342 // [java_LocationWindow_deselectAllMapFeatures]
343
344 // [java_LocationWindow_getSelectedMapFeatures_2]
345 // Verify all features are deselected
346 List<String> remainingFeatures = locationWindow.getSelectedMapFeatures();
347 System.out.println("Remaining selected features after deselect all: " + remainingFeatures.size() + " features");
348 // [java_LocationWindow_getSelectedMapFeatures_2]
349
350 // Test multiple feature selection and deselection
351 List<String> testFeatureIds = Arrays.asList("room_101", "office_205", "meeting_room_301", "cafe_401");
352
353 // Select multiple features
354 for (String featureId : testFeatureIds) {
355 boolean success = locationWindow.selectMapFeature(featureId);
356 System.out.println("Selected feature " + featureId + ": " + success);
357 }
358
359 // Check selected features
360 List<String> allSelected = locationWindow.getSelectedMapFeatures();
361 System.out.println("All selected features: " + allSelected.size() + " features");
362
363 // Deselect all at once
364 locationWindow.deselectAllMapFeatures();
365 System.out.println("Deselected all features at once");
366 }
367
372 System.out.println("--- applyLayerFilter Method ---");
373
374 if (locationWindow == null) {
375 System.out.println("LocationWindow not available yet");
376 return;
377 }
378
379 // [java_MapFilterCondition_constructor]
380 // Create filter condition: show only venues with category "Toilet" or "Cafe"
381 MapFilterCondition condition = new MapFilterCondition("category", Arrays.asList("Toilet", "Cafe"));
382 // [java_MapFilterCondition_constructor]
383
384 // [java_LocationWindow_applyLayerFilter]
385 // Apply filter to venues layer
386 List<MapFilterCondition> conditions = new ArrayList<>();
387 conditions.add(new MapFilterCondition("category", Arrays.asList("Toilet", "Cafe")));
388 locationWindow.applyLayerFilter("venues", conditions);
389 System.out.println("Applied layer filter: show venues with category Toilet or Cafe");
390 // [java_LocationWindow_applyLayerFilter]
391
392 // Reset filter (show all venues)
393 locationWindow.applyLayerFilter("venues", new ArrayList<>());
394 System.out.println("Reset layer filter: show all venues");
395 }
396
401 System.out.println("--- Zoom Properties ---");
402
403 if (locationWindow == null) {
404 System.out.println("LocationWindow not available yet");
405 return;
406 }
407
408 // [java_LocationWindow_getZoomFactor]
409 // Get current zoom factor
410 double currentZoom = locationWindow.getZoomFactor();
411 System.out.println("Current zoom factor: " + currentZoom);
412 // [java_LocationWindow_getZoomFactor]
413
414 // [java_LocationWindow_setZoomFactor]
415 // Set zoom factor
416 locationWindow.setZoomFactor(150.0);
417 System.out.println("Set zoom factor to 150.0");
418 // [java_LocationWindow_setZoomFactor]
419
420 // [java_LocationWindow_getMinZoomFactor]
421 // Get minimum zoom factor
422 double minZoomFactor = locationWindow.getMinZoomFactor();
423 System.out.println("Minimum zoom factor: " + minZoomFactor);
424 // [java_LocationWindow_getMinZoomFactor]
425
426 // [java_LocationWindow_setMinZoomFactor]
427 // Set minimum zoom factor
428 locationWindow.setMinZoomFactor(50.0);
429 System.out.println("Set minimum zoom factor to 50.0");
430 // [java_LocationWindow_setMinZoomFactor]
431
432 // [java_LocationWindow_getMaxZoomFactor]
433 // Get maximum zoom factor
434 double maxZoomFactor = locationWindow.getMaxZoomFactor();
435 System.out.println("Maximum zoom factor: " + maxZoomFactor);
436 // [java_LocationWindow_getMaxZoomFactor]
437
438 // [java_LocationWindow_setMaxZoomFactor]
439 // Set maximum zoom factor
440 locationWindow.setMaxZoomFactor(300.0);
441 System.out.println("Set maximum zoom factor to 300.0");
442 // [java_LocationWindow_setMaxZoomFactor]
443
444 // Test zoom factor changes
445 List<Double> testZoomFactors = Arrays.asList(100.0, 125.0, 150.0, 200.0, 250.0);
446 for (Double zoom : testZoomFactors) {
447 locationWindow.setZoomFactor(zoom);
448 System.out.println("Changed zoom factor to: " + locationWindow.getZoomFactor());
449 }
450
451 // Test zoom limits
452 System.out.println("Testing zoom limits...");
453 locationWindow.setZoomFactor(locationWindow.getMinZoomFactor());
454 System.out.println("Set to minimum zoom: " + locationWindow.getZoomFactor());
455
456 locationWindow.setZoomFactor(locationWindow.getMaxZoomFactor());
457 System.out.println("Set to maximum zoom: " + locationWindow.getZoomFactor());
458
459 // Reset to default
460 locationWindow.setZoomFactor(100.0);
461 System.out.println("Reset zoom factor to default: " + locationWindow.getZoomFactor());
462 }
463
467 public void runExample() {
468 System.out.println("=== LocationWindowCommon Example ===");
469
470 // Simulate LocationWindow initialization
471 try {
472 Thread.sleep(500);
473 } catch (InterruptedException e) {
474 Thread.currentThread().interrupt();
475 }
476
477 // TODO: User will implement LocationWindow initialization here
478 // locationWindow = getLocationWindow();
479
480 // Run demonstrations
482
483 System.out.println("=== Example completed ===");
484 }
485
489 public static void main(String[] args) {
491 example.runExample();
492 }
493}
494
495class DemoSublocationChangeListener implements SublocationChangeListener {
496 // [java_SublocationChangeListener_onActiveSublocationChanged]
497 @Override
498 public void onActiveSublocationChanged(int sublocationId) {
499 System.out.println("Active sublocation changed to: " + sublocationId);
500 }
501 // [java_SublocationChangeListener_onActiveSublocationChanged]
502}