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.HashMap;
6import java.util.List;
7import java.util.Map;
8
9import com.navigine.idl.java.DebugFlag;
10
18
19 private LocationWindow locationWindow;
20 private UserLocationLayer userLocationLayer;
21 private RouteLayer routeLayer;
22 private RouteLayerListener routeLayerListener;
23 private RouteViewListener routeViewListener;
24
28
47
51 public void demonstrateDebugFlags() {
52 System.out.println("--- Debug flags ---");
53
54 // [java_DebugFlag_enum]
55 DebugFlag[] allFlags = new DebugFlag[] {
62 };
63 System.out.println("Debug flag enum values: " + allFlags.length);
64 // [java_DebugFlag_enum]
65
66 // [java_LocationWindow_setDebugFlag]
69 System.out.println("Updated debug flags on LocationWindow");
70 // [java_LocationWindow_setDebugFlag]
71
72 // [java_LocationWindow_getDebugFlag]
73 boolean infosOn = LocationWindow.getDebugFlag(DebugFlag.INFOS);
74 System.out.println("Debug flag INFOS enabled: " + infosOn);
75 // [java_LocationWindow_getDebugFlag]
76 }
77
78
83 System.out.println("--- Operating Mode ---");
84
85 if (locationWindow == null) {
86 System.out.println("LocationWindow not available yet");
87 return;
88 }
89
90 // [java_OperatingMode_enum]
91 OperatingMode[] modes = {
95 };
96 System.out.println("Operating modes: " + modes.length);
97 // [java_OperatingMode_enum]
98
99 // [java_LocationWindow_setOperatingMode]
100 locationWindow.setOperatingMode(OperatingMode.OUTDOOR_INDOOR);
101 System.out.println("Set operating mode to OUTDOOR_INDOOR");
102 // [java_LocationWindow_setOperatingMode]
103
104 // [java_LocationWindow_getOperatingMode]
105 OperatingMode currentMode = locationWindow.getOperatingMode();
106 System.out.println("Current operating mode: " + currentMode);
107 // [java_LocationWindow_getOperatingMode]
108
109 // [java_MapTheme_enum]
110 MapTheme[] themes = { MapTheme.LIGHT, MapTheme.DARK };
111 System.out.println("Map themes: " + themes.length);
112 // [java_MapTheme_enum]
113
114 // [java_LocationWindow_setMapTheme]
115 locationWindow.setMapTheme(MapTheme.DARK);
116 System.out.println("Set map theme to DARK");
117 // [java_LocationWindow_setMapTheme]
118
119 // [java_LocationWindow_getMapTheme]
120 MapTheme currentTheme = locationWindow.getMapTheme();
121 System.out.println("Current map theme: " + currentTheme);
122 // [java_LocationWindow_getMapTheme]
123
124 // [java_TileKind_enum]
126 System.out.println("Tile kinds: " + kinds.length);
127 // [java_TileKind_enum]
128
129 // [java_TileSchema_enum]
131 System.out.println("Tile schemas: " + schemas.length);
132 // [java_TileSchema_enum]
133
134 // [java_HttpTileSource_record]
135 Map<String, String> query = new HashMap<String, String>();
136 query.put("key", "YOUR_MAPTILER_KEY");
138 "https://api.maptiler.com/tiles/v3-openmaptiles/{z}/{x}/{y}.pbf",
139 null,
140 query);
141 // [java_HttpTileSource_record]
142
143 // [java_MbtilesTileSource_record]
144 MbtilesTileSource offline = new MbtilesTileSource("/path/to/map.mbtiles");
145 // [java_MbtilesTileSource_record]
146
147 // [java_TileProvider_record]
148 TileProvider osmHttp = new TileProvider(
150 http,
151 null,
152 0,
153 14,
154 null,
156 TileProvider mbtiles = new TileProvider(
158 null,
159 offline,
160 0,
161 14,
162 null,
164 // [java_TileProvider_record]
165
166 // [java_LocationWindow_setTileProvider]
167 locationWindow.setTileProvider(osmHttp);
168 locationWindow.setTileProvider(null);
169 TileProvider imagery = new TileProvider(
171 new HttpTileSource(
172 "https://tile.openstreetmap.org/{z}/{x}/{y}.png",
173 null,
174 null),
175 null,
176 0,
177 19,
178 "© OpenStreetMap contributors",
180 locationWindow.setTileProvider(imagery);
181 // [java_LocationWindow_setTileProvider]
182
183 // [java_AttributionAlignment_record]
187 // [java_AttributionAlignment_record]
188
189 // [java_LocationWindow_setAttributionAlignment]
190 locationWindow.setAttributionAlignment(alignment);
191 // [java_LocationWindow_setAttributionAlignment]
192
193 // [java_LocationWindow_getAttribution]
194 String attribution = locationWindow.getAttribution();
195 System.out.println("Attribution: " + attribution);
196 // [java_LocationWindow_getAttribution]
197 }
198
203 System.out.println("--- setSublocationId Method ---");
204
205 if (locationWindow == null) {
206 System.out.println("LocationWindow not available yet");
207 return;
208 }
209
210 // [java_LocationWindow_setSublocationId]
211 // Set sublocation ID to switch between floors
212 locationWindow.setSublocationId(1);
213 System.out.println("Set sublocation ID to 1 (first floor)");
214 // [java_LocationWindow_setSublocationId]
215
216 // [java_LocationWindow_setSublocationId_2]
217 // Set sublocation ID to another floor
218 locationWindow.setSublocationId(2);
219 System.out.println("Set sublocation ID to 2 (second floor)");
220 // [java_LocationWindow_setSublocationId_2]
221
222 // [java_LocationWindow_setSublocationId_3]
223 // Set sublocation ID to ground floor
224 locationWindow.setSublocationId(0);
225 System.out.println("Set sublocation ID to 0 (ground floor)");
226 // [java_LocationWindow_setSublocationId_3]
227
228 // Test with different sublocation IDs
229 List<Integer> sublocationIds = Arrays.asList(1, 2, 3, 0, 5);
230 for (Integer id : sublocationIds) {
231 locationWindow.setSublocationId(id);
232 System.out.println("Switched to sublocation ID: " + id);
233 }
234 }
235
240 System.out.println("--- getSublocationId & getEnclosingCamera ---");
241
242 if (locationWindow == null) {
243 System.out.println("LocationWindow not available yet");
244 return;
245 }
246
247 // [java_LocationWindow_getSublocationId]
248 Integer currentId = locationWindow.getSublocationId();
249 if (currentId != null) {
250 System.out.println("Current sublocation id: " + currentId);
251 } else {
252 System.out.println("Current sublocation id is not set");
253 }
254 // [java_LocationWindow_getSublocationId]
255
256 // [java_LocationWindow_getEnclosingCamera]
257 BoundingBox boundingBox = new BoundingBox(new GlobalPoint(55.75, 37.61), new GlobalPoint(55.76, 37.63));
258 Camera camera = locationWindow.getEnclosingCamera(boundingBox);
259 System.out.println("Camera that fits bounding box: " + camera);
260 // [java_LocationWindow_getEnclosingCamera]
261
262 // [java_LocationWindow_setFocusRect]
263 ScreenRect focus = new ScreenRect(new ScreenPoint(0.0, 0.0), new ScreenPoint(1000.0, 1600.0));
264 locationWindow.setFocusRect(focus);
265 // [java_LocationWindow_setFocusRect]
266
267 // [java_LocationWindow_getEnclosingCameraWithFocus]
268 Camera padded = locationWindow.getEnclosingCameraWithFocus(boundingBox, focus, null, null);
269 System.out.println("Camera that fits bounding box in focus rect: " + padded);
270 // [java_LocationWindow_getEnclosingCameraWithFocus]
271 }
272
277 System.out.println("--- Sublocation Change Listener ---");
278
279 if (locationWindow == null) {
280 System.out.println("LocationWindow not available yet");
281 return;
282 }
283
284 DemoSublocationChangeListener listener = new DemoSublocationChangeListener();
285
286 // [java_LocationWindow_addSublocationChangeListener]
287 locationWindow.addSublocationChangeListener(listener);
288 System.out.println("Added sublocation change listener");
289 // [java_LocationWindow_addSublocationChangeListener]
290
291 locationWindow.setSublocationId(1);
292 locationWindow.setSublocationId(2);
293
294 // [java_LocationWindow_removeSublocationChangeListener]
295 locationWindow.removeSublocationChangeListener(listener);
296 System.out.println("Removed sublocation change listener");
297 // [java_LocationWindow_removeSublocationChangeListener]
298 }
299
304 System.out.println("--- UserLocationLayer ---");
305
306 if (userLocationLayer == null) {
307 System.out.println("UserLocationLayer not available yet");
308 return;
309 }
310
311 // [java_UserLocationLayer_setVisible]
312 userLocationLayer.setVisible(true);
313 System.out.println("User location layer set visible");
314 // [java_UserLocationLayer_setVisible]
315
316 // [java_UserLocationLayer_isVisible]
317 boolean visible = userLocationLayer.isVisible();
318 System.out.println("User location layer is visible: " + visible);
319 // [java_UserLocationLayer_isVisible]
320
321 // [java_UserLocationLayer_setAnchor]
322 ScreenPoint anchor = new ScreenPoint(100.0f, 200.0f);
323 userLocationLayer.setAnchor(anchor);
324 System.out.println("Set user location anchor to: (" + anchor.getX() + ", " + anchor.getY() + ")");
325 // [java_UserLocationLayer_setAnchor]
326
327 // [java_UserLocationLayer_anchorEnabled]
328 boolean anchorEnabled = userLocationLayer.anchorEnabled();
329 System.out.println("Anchor enabled: " + anchorEnabled);
330 // [java_UserLocationLayer_anchorEnabled]
331
332 // [java_UserLocationLayer_setHeadingModeActive]
333 userLocationLayer.setHeadingModeActive(true);
334 System.out.println("Heading-up mode enabled");
335 // [java_UserLocationLayer_setHeadingModeActive]
336
337 // [java_UserLocationLayer_headingModeActive]
338 boolean headingModeActive = userLocationLayer.headingModeActive();
339 System.out.println("Heading-up mode active: " + headingModeActive);
340 // [java_UserLocationLayer_headingModeActive]
341
342 // [java_UserLocationLayer_setFollowMode]
343 userLocationLayer.setFollowMode(UserLocationFollowMode.HEADING);
344 System.out.println("Follow mode set to heading");
345 // [java_UserLocationLayer_setFollowMode]
346
347 // [java_UserLocationLayer_followMode]
348 UserLocationFollowMode followMode = userLocationLayer.followMode();
349 System.out.println("Follow mode: " + followMode);
350 // [java_UserLocationLayer_followMode]
351
352 // [java_UserLocationLayer_setArrowBitmap]
353 userLocationLayer.setArrowBitmap(ImageProvider.fromFile("/path/to/arrow.png", true));
354 userLocationLayer.setArrowBitmap(null);
355 System.out.println("Custom arrow bitmap cleared");
356 // [java_UserLocationLayer_setArrowBitmap]
357
358 // [java_UserLocationLayer_setAccuracyColor]
359 userLocationLayer.setAccuracyColor(0x4230AAD9);
360 System.out.println("Accuracy circle color updated");
361 // [java_UserLocationLayer_setAccuracyColor]
362
363 // [java_UserLocationLayer_resetAnchor]
364 userLocationLayer.resetAnchor();
365 System.out.println("Anchor reset to default");
366 // [java_UserLocationLayer_resetAnchor]
367 }
368
372 public void demonstrateRouteLayer() {
373 System.out.println("--- RouteLayer ---");
374
375 if (routeLayer == null) {
376 System.out.println("RouteLayer not available yet");
377 return;
378 }
379
380 // [java_RouteLayer_setVisible]
381 routeLayer.setVisible(true);
382 System.out.println("Route layer set visible");
383 // [java_RouteLayer_setVisible]
384
385 // [java_RouteLayer_isVisible]
386 boolean visible = routeLayer.isVisible();
387 System.out.println("Route layer is visible: " + visible);
388 // [java_RouteLayer_isVisible]
389
390 // [java_RouteLayer_setTraveledColor]
391 routeLayer.setTraveledColor(0xB4787878);
392 System.out.println("Traveled color updated");
393 // [java_RouteLayer_setTraveledColor]
394
395 // [java_RouteLayer_setRemainingColor]
396 routeLayer.setRemainingColor(0xFF30AAD9);
397 System.out.println("Remaining color updated");
398 // [java_RouteLayer_setRemainingColor]
399
400 // [java_RouteLayer_setWidth]
401 routeLayer.setWidth(8.0f);
402 System.out.println("Route width updated");
403 // [java_RouteLayer_setWidth]
404
405 // [java_RouteLayer_setRemainingStyle]
406 routeLayer.setRemainingStyle(RouteRemainingStyle.DOTTED);
407 System.out.println("Remaining style set to DOTTED");
408 // [java_RouteLayer_setRemainingStyle]
409
410 // [java_RouteLayer_remainingStyle]
411 RouteRemainingStyle remainingStyle = routeLayer.remainingStyle();
412 System.out.println("Remaining style: " + remainingStyle);
413 // [java_RouteLayer_remainingStyle]
414
415 // [java_RouteLayer_setRemainingPointSize]
416 routeLayer.setRemainingPointSize(8.0f, 8.0f);
417 System.out.println("Remaining point size updated");
418 // [java_RouteLayer_setRemainingPointSize]
419
420 // [java_RouteLayer_setRemainingPlacement]
421 routeLayer.setRemainingPlacement(Placement.SPACED);
422 System.out.println("Remaining placement updated");
423 // [java_RouteLayer_setRemainingPlacement]
424
425 // [java_RouteLayer_setRemainingPlacementSpacing]
426 routeLayer.setRemainingPlacementSpacing(8.0f);
427 System.out.println("Remaining placement spacing updated");
428 // [java_RouteLayer_setRemainingPlacementSpacing]
429
430 // [java_RouteLayer_setRemainingPlacementMinRatio]
431 routeLayer.setRemainingPlacementMinRatio(0.0f);
432 System.out.println("Remaining placement min ratio updated");
433 // [java_RouteLayer_setRemainingPlacementMinRatio]
434
435 // [java_RouteLayer_setRemainingCollisionEnabled]
436 routeLayer.setRemainingCollisionEnabled(false);
437 System.out.println("Remaining collision disabled");
438 // [java_RouteLayer_setRemainingCollisionEnabled]
439
440 // [java_RouteLayer_setRemainingDashLength]
441 routeLayer.setRemainingDashLength(0.5f);
442 System.out.println("Remaining dash length updated");
443 // [java_RouteLayer_setRemainingDashLength]
444
445 // [java_RouteLayer_setRemainingGapLength]
446 routeLayer.setRemainingGapLength(0.4f);
447 System.out.println("Remaining gap length updated");
448 // [java_RouteLayer_setRemainingGapLength]
449
450 RouteEndpoint from = new RouteEndpoint(
451 new GlobalPoint(55.751244, 37.618423),
452 1); // null for outdoor point
454 new GlobalPoint(55.751700, 37.619000),
455 2); // null for outdoor point
456
457 // [java_RouteLayer_setRoute]
458 routeLayer.setRoute(from, to);
459 System.out.println("Static route applied");
460 // [java_RouteLayer_setRoute]
461
462 // [java_RouteLayer_setTarget]
463 routeLayer.setTarget(to);
464 System.out.println("Guidance target applied");
465 // [java_RouteLayer_setTarget]
466
467 // [java_RouteLayer_routes]
468 List<RouteView> routes = routeLayer.routes();
469 System.out.println("Visible routes: " + routes.size());
470 // [java_RouteLayer_routes]
471
472 // [java_RouteLayer_selectedRoute]
473 RouteView selectedRoute = routeLayer.selectedRoute();
474 if (selectedRoute != null) {
475 System.out.println("Selected route length: " + selectedRoute.length());
476 }
477 // [java_RouteLayer_selectedRoute]
478
479 // [java_RouteLayer_selectRoute]
480 if (!routes.isEmpty()) {
481 routeLayer.selectRoute(routes.get(0));
482 }
483 // [java_RouteLayer_selectRoute]
484
485 // [java_RouteLayer_addRouteLayerListener]
486 routeLayerListener = new RouteLayerListener() {
487 @Override
488 public void onRouteChanged(RouteLayerStatus status, RouteView route) {
489 System.out.println("Route status: " + status);
490 }
491
492 @Override
493 public void onRouteAdvanced(RouteProgress progress) {
494 System.out.println("Remaining distance: " + progress.remainingDistance
495 + ", time: " + progress.remainingTime + "s");
496 }
497
498 @Override
499 public void onRouteTargetReached() {
500 System.out.println("Route target reached");
501 }
502 };
503 routeLayer.addRouteLayerListener(routeLayerListener);
504 // [java_RouteLayer_addRouteLayerListener]
505
506 // [java_RouteLayer_addRouteViewListener]
507 routeViewListener = new RouteViewListener() {
508 @Override
509 public void onRouteViewsChanged() {
510 System.out.println("Route views changed");
511 }
512
513 @Override
514 public void onSelectedRouteChanged(RouteView route) {
515 System.out.println("Selected route changed");
516 }
517
518 @Override
519 public void onRouteViewTap(RouteView route) {
520 routeLayer.selectRoute(route);
521 }
522 };
523 routeLayer.addRouteViewListener(routeViewListener);
524 // [java_RouteLayer_addRouteViewListener]
525
526 // [java_RouteLayer_clear]
527 routeLayer.clear();
528 System.out.println("Route layer cleared");
529 // [java_RouteLayer_clear]
530 }
531
536 System.out.println("--- Coordinate Conversion Methods ---");
537
538 if (locationWindow == null) {
539 System.out.println("LocationWindow not available yet");
540 return;
541 }
542
543 // [java_LocationWindow_screenPositionToGlobal]
544 // Convert screen position to WGS84
545 ScreenPoint screenPoint = new ScreenPoint(100.0, 200.0);
546 GlobalPoint globalPoint = locationWindow.screenPositionToGlobal(screenPoint);
547 System.out.printf("Screen position (%.1f, %.1f) converted to WGS84: (%.6f, %.6f)%n",
548 screenPoint.getX(), screenPoint.getY(), globalPoint.getLatitude(), globalPoint.getLongitude());
549 // [java_LocationWindow_screenPositionToGlobal]
550
551 // [java_LocationWindow_getVisibleRegion]
552 VisibleRegion visibleRegion = locationWindow.getVisibleRegion();
553 System.out.println("Viewport top-left: " + visibleRegion.getTopLeft());
554 // [java_LocationWindow_getVisibleRegion]
555
556 // [java_LocationWindow_getFocusRegion]
557 VisibleRegion focusRegion = locationWindow.getFocusRegion();
558 System.out.println("Focus-rect top-left: " + focusRegion.getTopLeft());
559 // [java_LocationWindow_getFocusRegion]
560
561 // [java_LocationWindow_globalToScreenPosition]
562 // Convert WGS84 to screen position with clipping
563 GlobalPoint globalPoint2 = new GlobalPoint(55.7558, 37.6176);
564 ScreenPoint screenPoint2 = locationWindow.globalToScreenPosition(globalPoint2, true);
565 System.out.printf("WGS84 (%.6f, %.6f) converted to screen with clipping: (%.1f, %.1f)%n",
566 globalPoint2.getLatitude(), globalPoint2.getLongitude(), screenPoint2.getX(), screenPoint2.getY());
567 // [java_LocationWindow_globalToScreenPosition]
568
569 List<ScreenPoint> testScreenPoints = Arrays.asList(
570 new ScreenPoint(0.0, 0.0),
571 new ScreenPoint(250.0, 250.0),
572 new ScreenPoint(1000.0, 600.0)
573 );
574
575 for (int i = 0; i < testScreenPoints.size(); i++) {
576 ScreenPoint screen = testScreenPoints.get(i);
577 GlobalPoint global = locationWindow.screenPositionToGlobal(screen);
578 ScreenPoint backToScreen = locationWindow.globalToScreenPosition(global, false);
579 System.out.printf("Test %d: Screen (%.1f, %.1f) -> WGS84 (%.6f, %.6f) -> Screen (%.1f, %.1f)%n",
580 i, screen.getX(), screen.getY(),
581 global.getLatitude(), global.getLongitude(),
582 backToScreen.getX(), backToScreen.getY());
583 }
584 }
585
590 System.out.println("--- Map Feature Selection Methods ---");
591
592 if (locationWindow == null) {
593 System.out.println("LocationWindow not available yet");
594 return;
595 }
596
597 // [java_LocationWindow_selectMapFeature]
598 // Select map feature by ID
599 String featureId = "room_101";
600 boolean selected = locationWindow.selectMapFeature(featureId);
601 System.out.println("Selected map feature " + featureId + ": " + selected);
602 // [java_LocationWindow_selectMapFeature]
603
604 // [java_LocationWindow_selectMapFeature_2]
605 // Select another map feature
606 String featureId2 = "office_205";
607 boolean selected2 = locationWindow.selectMapFeature(featureId2);
608 System.out.println("Selected map feature " + featureId2 + ": " + selected2);
609 // [java_LocationWindow_selectMapFeature_2]
610
611 // [java_LocationWindow_getSelectedMapFeatures]
612 // Get list of selected map features
613 List<String> selectedFeatures = locationWindow.getSelectedMapFeatures();
614 System.out.println("Currently selected map features: " + selectedFeatures.size() + " features");
615 for (String feature : selectedFeatures) {
616 System.out.println(" - " + feature);
617 }
618 // [java_LocationWindow_getSelectedMapFeatures]
619
620 // [java_LocationWindow_deselectMapFeature]
621 // Deselect specific map feature
622 boolean deselected = locationWindow.deselectMapFeature(featureId);
623 System.out.println("Deselected map feature " + featureId + ": " + deselected);
624 // [java_LocationWindow_deselectMapFeature]
625
626 // [java_LocationWindow_deselectMapFeature_2]
627 // Deselect another map feature
628 boolean deselected2 = locationWindow.deselectMapFeature(featureId2);
629 System.out.println("Deselected map feature " + featureId2 + ": " + deselected2);
630 // [java_LocationWindow_deselectMapFeature_2]
631
632 // [java_LocationWindow_deselectAllMapFeatures]
633 // Deselect all map features
634 locationWindow.deselectAllMapFeatures();
635 System.out.println("Deselected all map features");
636 // [java_LocationWindow_deselectAllMapFeatures]
637
638 // [java_LocationWindow_getSelectedMapFeatures_2]
639 // Verify all features are deselected
640 List<String> remainingFeatures = locationWindow.getSelectedMapFeatures();
641 System.out.println("Remaining selected features after deselect all: " + remainingFeatures.size() + " features");
642 // [java_LocationWindow_getSelectedMapFeatures_2]
643
644 // Test multiple feature selection and deselection
645 List<String> testFeatureIds = Arrays.asList("room_101", "office_205", "meeting_room_301", "cafe_401");
646
647 // Select multiple features
648 for (String featureId : testFeatureIds) {
649 boolean success = locationWindow.selectMapFeature(featureId);
650 System.out.println("Selected feature " + featureId + ": " + success);
651 }
652
653 // Check selected features
654 List<String> allSelected = locationWindow.getSelectedMapFeatures();
655 System.out.println("All selected features: " + allSelected.size() + " features");
656
657 // Deselect all at once
658 locationWindow.deselectAllMapFeatures();
659 System.out.println("Deselected all features at once");
660 }
661
666 System.out.println("--- applyLayerFilter Method ---");
667
668 if (locationWindow == null) {
669 System.out.println("LocationWindow not available yet");
670 return;
671 }
672
673 // [java_MapFilterCondition_constructor]
674 // Create filter condition: show only venues with category "Toilet" or "Cafe"
675 MapFilterCondition condition = new MapFilterCondition("category", Arrays.asList("Toilet", "Cafe"));
676 // [java_MapFilterCondition_constructor]
677
678 // [java_LocationWindow_applyLayerFilter]
679 // Apply filter to venues layer
680 List<MapFilterCondition> conditions = new ArrayList<>();
681 conditions.add(new MapFilterCondition("category", Arrays.asList("Toilet", "Cafe")));
682 locationWindow.applyLayerFilter("venues", conditions);
683 System.out.println("Applied layer filter: show venues with category Toilet or Cafe");
684 // [java_LocationWindow_applyLayerFilter]
685
686 // Reset filter (show all venues)
687 locationWindow.applyLayerFilter("venues", new ArrayList<>());
688 System.out.println("Reset layer filter: show all venues");
689 }
690
695 System.out.println("--- Zoom Properties ---");
696
697 if (locationWindow == null) {
698 System.out.println("LocationWindow not available yet");
699 return;
700 }
701
702 // [java_LocationWindow_getZoomFactor]
703 // Get current zoom factor
704 double currentZoom = locationWindow.getZoomFactor();
705 System.out.println("Current zoom factor: " + currentZoom);
706 // [java_LocationWindow_getZoomFactor]
707
708 // [java_LocationWindow_setZoomFactor]
709 // Set zoom factor
710 locationWindow.setZoomFactor(150.0);
711 System.out.println("Set zoom factor to 150.0");
712 // [java_LocationWindow_setZoomFactor]
713
714 // [java_LocationWindow_getMinZoomFactor]
715 // Get minimum zoom factor
716 double minZoomFactor = locationWindow.getMinZoomFactor();
717 System.out.println("Minimum zoom factor: " + minZoomFactor);
718 // [java_LocationWindow_getMinZoomFactor]
719
720 // [java_LocationWindow_setMinZoomFactor]
721 // Set minimum zoom factor
722 locationWindow.setMinZoomFactor(50.0);
723 System.out.println("Set minimum zoom factor to 50.0");
724 // [java_LocationWindow_setMinZoomFactor]
725
726 // [java_LocationWindow_getMaxZoomFactor]
727 // Get maximum zoom factor
728 double maxZoomFactor = locationWindow.getMaxZoomFactor();
729 System.out.println("Maximum zoom factor: " + maxZoomFactor);
730 // [java_LocationWindow_getMaxZoomFactor]
731
732 // [java_LocationWindow_setMaxZoomFactor]
733 // Set maximum zoom factor
734 locationWindow.setMaxZoomFactor(300.0);
735 System.out.println("Set maximum zoom factor to 300.0");
736 // [java_LocationWindow_setMaxZoomFactor]
737
738 // Test zoom factor changes
739 List<Double> testZoomFactors = Arrays.asList(100.0, 125.0, 150.0, 200.0, 250.0);
740 for (Double zoom : testZoomFactors) {
741 locationWindow.setZoomFactor(zoom);
742 System.out.println("Changed zoom factor to: " + locationWindow.getZoomFactor());
743 }
744
745 // Test zoom limits
746 System.out.println("Testing zoom limits...");
747 locationWindow.setZoomFactor(locationWindow.getMinZoomFactor());
748 System.out.println("Set to minimum zoom: " + locationWindow.getZoomFactor());
749
750 locationWindow.setZoomFactor(locationWindow.getMaxZoomFactor());
751 System.out.println("Set to maximum zoom: " + locationWindow.getZoomFactor());
752
753 // Reset to default
754 locationWindow.setZoomFactor(100.0);
755 System.out.println("Reset zoom factor to default: " + locationWindow.getZoomFactor());
756 }
757
761 public void runExample() {
762 System.out.println("=== LocationWindowCommon Example ===");
763
764 // Simulate LocationWindow initialization
765 try {
766 Thread.sleep(500);
767 } catch (InterruptedException e) {
768 Thread.currentThread().interrupt();
769 }
770
771 // TODO: User will implement LocationWindow initialization here
772 // locationWindow = getLocationWindow();
773
774 // Run demonstrations
776
777 System.out.println("=== Example completed ===");
778 }
779
783 public static void main(String[] args) {
785 example.runExample();
786 }
787}
788
789class DemoSublocationChangeListener implements SublocationChangeListener {
790 // [java_SublocationChangeListener_onActiveSublocationChanged]
791 @Override
792 public void onActiveSublocationChanged(int sublocationId) {
793 System.out.println("Active sublocation changed to: " + sublocationId);
794 }
795 // [java_SublocationChangeListener_onActiveSublocationChanged]
796}