Loading...
Searching...
No Matches
LocationWindowMapObjectsExample.java
Go to the documentation of this file.
1package com.navigine.examples;
2
3import com.navigine.idl.java.LocationWindow;
4import com.navigine.idl.java.CircleMapObject;
5import com.navigine.idl.java.ClusterMapObject;
6import com.navigine.idl.java.ClusterMapObjectController;
7import com.navigine.idl.java.ClusterMapObjectControllerListener;
8import com.navigine.idl.java.ClusterMapObjectListener;
9import com.navigine.idl.java.IconMapObject;
10import com.navigine.idl.java.PolygonMapObject;
11import com.navigine.idl.java.PolylineMapObject;
12import com.navigine.idl.java.DottedPolylineMapObject;
13import com.navigine.idl.java.AnimationType;
14import com.navigine.idl.java.CapType;
15import com.navigine.idl.java.JoinType;
16import com.navigine.idl.java.LocationPoint;
17import com.navigine.idl.java.LocationPolygon;
18import com.navigine.idl.java.LocationPolyline;
19import com.navigine.idl.java.MapObjectType;
20import com.navigine.idl.java.Point;
21import com.navigine.idl.java.Polygon;
22import com.navigine.idl.java.Polyline;
23import com.navigine.image.ImageProvider;
24import com.navigine.idl.java.ModelMapObject;
25import com.navigine.model.ModelProvider;
26
27import java.util.ArrayList;
28import java.util.List;
29import java.util.Arrays;
30import java.util.HashMap;
31import java.util.Map;
32
41 private LocationWindow locationWindow;
42 private CircleMapObject circleMapObject;
43 private IconMapObject iconMapObject;
44 private ModelMapObject modelMapObject;
45 private PolygonMapObject polygonMapObject;
46 private PolylineMapObject polylineMapObject;
47 private DottedPolylineMapObject dottedPolylineMapObject;
48 private ClusterMapObjectController clusterMapObjectController;
49 private ClusterMapObjectControllerListener clusterMapObjectControllerListener;
50
52 demonstrateLocationWindowMapObjectsMethods();
53 }
54
58 private void demonstrateLocationWindowMapObjectsMethods() {
59 System.out.println("=== LocationWindowMapObjects Example ===");
60
61 demonstrateLocationScopedGeometryRecords();
62
63 demonstrateCircleMapObjects();
64 demonstrateIconMapObjects();
65 demonstrateClusterMapObjects();
66 demonstrateModelMapObjects();
67 demonstratePolygonMapObjects();
68 demonstratePolylineMapObjects();
69 demonstrateDottedPolylineMapObjects();
70 demonstrateRemoveAllMapObjects();
71 cleanup();
72 }
73
77 private void demonstrateLocationScopedGeometryRecords() {
78 System.out.println("--- LocationPolygon / LocationPolyline records ---");
79
80 // [java_LocationPolygon_record]
81 List<Point> ring = Arrays.asList(
82 new Point(1.0, 2.0),
83 new Point(3.0, 4.0),
84 new Point(5.0, 2.0)
85 );
86 Polygon metricPolygon = new Polygon(ring);
87 LocationPolygon locationPolygon = new LocationPolygon(metricPolygon, 42, 7);
88 Polygon polygonBack = locationPolygon.getPolygon();
89 int polygonLocationId = locationPolygon.getLocationId();
90 int polygonSublocationId = locationPolygon.getSublocationId();
91 System.out.println("LocationPolygon: location " + polygonLocationId + ", sublocation "
92 + polygonSublocationId + ", vertices " + polygonBack.getPoints().size());
93 // [java_LocationPolygon_record]
94
95 // [java_LocationPolyline_record]
96 List<Point> linePoints = Arrays.asList(new Point(0.0, 0.0), new Point(10.0, 10.0));
97 Polyline metricPolyline = new Polyline(linePoints);
98 LocationPolyline locationPolyline = new LocationPolyline(metricPolyline, 42, 7);
99 Polyline polylineBack = locationPolyline.getPolyline();
100 System.out.println("LocationPolyline: points " + polylineBack.getPoints().size());
101 // [java_LocationPolyline_record]
102 }
103
107 private void demonstrateCircleMapObjects() {
108 System.out.println("--- Circle Map Objects ---");
109
110 if (locationWindow == null) {
111 System.out.println("LocationWindow not available yet");
112 return;
113 }
114
115 // [java_CircleMapObject_constructor]
116 // Create circle map object
117 LocationPoint center = new LocationPoint(10.0, 20.0);
118 circleMapObject = locationWindow.addCircleMapObject();
119 System.out.println("Created circle map object with center (" + center.getX() + ", " + center.getY() + ") and radius 5.0");
120 // [java_CircleMapObject_constructor]
121
122 // [java_CircleMapObject_getCenter]
123 // Access circle center
124 LocationPoint circleCenter = circleMapObject.getPosition();
125 System.out.println("Circle center: (" + circleCenter.getX() + ", " + circleCenter.getY() + ")");
126 // [java_CircleMapObject_getCenter]
127
128 // [java_CircleMapObject_getRadius]
129 // Access circle radius
130 double radius = circleMapObject.getRadius();
131 System.out.println("Circle radius: " + radius);
132 // [java_CircleMapObject_getRadius]
133
134 // [java_LocationWindow_addCircleMapObject]
135 // Add circle map object
136 circleMapObject = locationWindow.addCircleMapObject();
137 System.out.println("Added circle map object");
138 // [java_LocationWindow_addCircleMapObject]
139
140 if (circleMapObject != null) {
141 // [java_CircleMapObject_setPosition]
142 // Set circle position
143 LocationPoint centerPoint = new LocationPoint(100.0, 200.0);
144 boolean success = circleMapObject.setPosition(centerPoint);
145 System.out.println("Set circle position to (" + centerPoint.getX() + ", " + centerPoint.getY() + "): " + success);
146 // [java_CircleMapObject_setPosition]
147
148 // [java_CircleMapObject_setPositionAnimated]
149 // Set circle position with animation
150 LocationPoint animatedPoint = new LocationPoint(150.0, 250.0);
151 boolean animatedSuccess = circleMapObject.setPositionAnimated(animatedPoint, 2.0, AnimationType.LINEAR);
152 System.out.println("Set circle position with animation to (" + animatedPoint.getX() + ", " + animatedPoint.getY() + "): " + animatedSuccess);
153 // [java_CircleMapObject_setPositionAnimated]
154
155 // [java_CircleMapObject_setRadius]
156 // Set circle radius
157 boolean radiusSuccess = circleMapObject.setRadius(10.0);
158 System.out.println("Set circle radius to 10.0 meters: " + radiusSuccess);
159 // [java_CircleMapObject_setRadius]
160
161 // [java_CircleMapObject_setCollisionEnabled]
162 // Enable collision detection
163 boolean collisionSuccess = circleMapObject.setCollisionEnabled(true);
164 System.out.println("Enabled collision detection for circle: " + collisionSuccess);
165 // [java_CircleMapObject_setCollisionEnabled]
166
167 // [java_CircleMapObject_setBuffer]
168 // Set collision buffer
169 boolean bufferSuccess = circleMapObject.setBuffer(5.0, 5.0);
170 System.out.println("Set collision buffer to 5x5 pixels: " + bufferSuccess);
171 // [java_CircleMapObject_setBuffer]
172
173 // [java_CircleMapObject_setOffset]
174 // Set position offset
175 boolean offsetSuccess = circleMapObject.setOffset(2.0, 3.0);
176 System.out.println("Set position offset to (2.0, 3.0) pixels: " + offsetSuccess);
177 // [java_CircleMapObject_setOffset]
178
179 // [java_CircleMapObject_setOutlineColor]
180 // Set outline color
181 boolean outlineColorSuccess = circleMapObject.setOutlineColor(0.0, 0.0, 1.0, 1.0);
182 System.out.println("Set circle outline color to blue: " + outlineColorSuccess);
183 // [java_CircleMapObject_setOutlineColor]
184
185 // [java_CircleMapObject_setOutlineAlpha]
186 // Set outline alpha
187 boolean outlineAlphaSuccess = circleMapObject.setOutlineAlpha(0.5);
188 System.out.println("Set circle outline alpha to 0.5: " + outlineAlphaSuccess);
189 // [java_CircleMapObject_setOutlineAlpha]
190
191 // [java_CircleMapObject_setOutlineRadius]
192 // Set outline radius
193 boolean outlineRadiusSuccess = circleMapObject.setOutlineRadius(2.0);
194 System.out.println("Set circle outline radius to 2.0: " + outlineRadiusSuccess);
195 // [java_CircleMapObject_setOutlineRadius]
196
197 // [java_CircleMapObject_setColor]
198 // Set circle color
199 boolean colorSuccess = circleMapObject.setColor(1.0, 0.0, 0.0, 0.8);
200 System.out.println("Set circle color to red with 80% opacity: " + colorSuccess);
201 // [java_CircleMapObject_setColor]
202
203 // [java_CircleMapObject_setPriority]
204 // Set rendering priority
205 boolean prioritySuccess = circleMapObject.setPriority(1);
206 System.out.println("Set rendering priority to 1: " + prioritySuccess);
207 // [java_CircleMapObject_setPriority]
208
209 // [java_MapObject_setVisible]
210 // Set visibility
211 boolean visibleSuccess = circleMapObject.setVisible(true);
212 System.out.println("Set circle visibility to true: " + visibleSuccess);
213 // [java_MapObject_setVisible]
214
215 // [java_CircleMapObject_getMapObjectType]
216 // Get map object type
217 MapObjectType objectType = circleMapObject.getMapObjectType();
218 System.out.println("Circle map object type: " + objectType);
219 // [java_CircleMapObject_getMapObjectType]
220
221 // [java_MapObject_setAlpha]
222 // Set alpha transparency
223 boolean alphaSuccess = circleMapObject.setAlpha(0.7);
224 System.out.println("Set circle alpha to 0.7: " + alphaSuccess);
225 // [java_MapObject_setAlpha]
226
227 // [java_MapObject_setInteractive]
228 // Set interactive mode
229 boolean interactiveSuccess = circleMapObject.setInteractive(true);
230 System.out.println("Set circle interactive to true: " + interactiveSuccess);
231 // [java_MapObject_setInteractive]
232
233 // [java_MapObject_setTitle]
234 // Set title
235 boolean titleSuccess = circleMapObject.setTitle("Circle Object");
236 System.out.println("Set circle title to 'Circle Object': " + titleSuccess);
237 // [java_MapObject_setTitle]
238
239 // [java_MapObject_setData]
240 // Set custom data
241 Map<String, String> customData = new HashMap<>();
242 customData.put("key", "value");
243 customData.put("number", "42");
244 boolean dataSuccess = circleMapObject.setData(customData);
245 System.out.println("Set circle custom data: " + dataSuccess);
246 // [java_MapObject_setData]
247
248 // [java_MapObject_getId]
249 // Get object ID
250 int objectId = circleMapObject.getId();
251 System.out.println("Circle object ID: " + objectId);
252 // [java_MapObject_getId]
253
254 // [java_MapObject_getType]
255 // Get object type
256 String objectTypeString = circleMapObject.getType();
257 System.out.println("Circle object type: " + objectTypeString);
258 // [java_MapObject_getType]
259
260 // [java_MapObject_getData]
261 // Get custom data
262 Map<String, String> retrievedData = circleMapObject.getData();
263 System.out.println("Circle custom data: " + retrievedData);
264 // [java_MapObject_getData]
265 }
266
267 // [java_LocationWindow_removeCircleMapObject]
268 // Remove circle map object
269 if (circleMapObject != null) {
270 boolean removed = locationWindow.removeCircleMapObject(circleMapObject);
271 System.out.println("Removed circle map object: " + removed);
272 circleMapObject = null;
273 }
274 // [java_LocationWindow_removeCircleMapObject]
275
276 // Test multiple circle objects
277 List<CircleMapObject> circles = new ArrayList<>();
278 for (int i = 0; i < 3; i++) {
279 CircleMapObject circle = locationWindow.addCircleMapObject();
280 if (circle != null) {
281 circle.setPosition(new LocationPoint(50.0 * i, 100.0 * i));
282 circle.setColor(0.0, 1.0, 0.0, 0.6);
283 circle.setRadius(5.0 + i * 2.0);
284 circles.add(circle);
285 System.out.println("Created circle " + i + " at (" + (50.0 * i) + ", " + (100.0 * i) + ") with radius " + (5.0 + i * 2.0));
286 }
287 }
288
289 for (int i = 0; i < circles.size(); i++) {
290 locationWindow.removeCircleMapObject(circles.get(i));
291 System.out.println("Removed circle " + i);
292 }
293 }
294
298 private void demonstrateIconMapObjects() {
299 System.out.println("--- Icon Map Objects ---");
300
301 if (locationWindow == null) {
302 System.out.println("LocationWindow not available yet");
303 return;
304 }
305
306 // [java_IconMapObject_constructor]
307 // Create icon map object
308 LocationPoint position = new LocationPoint(30.0, 40.0);
309 iconMapObject = locationWindow.addIconMapObject();
310 System.out.println("Created icon map object at (" + position.getX() + ", " + position.getY() + ")");
311 // [java_IconMapObject_constructor]
312
313 // [java_IconMapObject_getPosition]
314 // Access icon position
315 LocationPoint iconPosition = iconMapObject.getPosition();
316 System.out.println("Icon position: (" + iconPosition.getX() + ", " + iconPosition.getY() + ")");
317 // [java_IconMapObject_getPosition]
318
319 // [java_LocationWindow_addIconMapObject]
320 // Add icon map object
321 iconMapObject = locationWindow.addIconMapObject();
322 System.out.println("Added icon map object");
323 // [java_LocationWindow_addIconMapObject]
324
325 if (iconMapObject != null) {
326 // [java_IconMapObject_setPosition]
327 // Set icon position
328 LocationPoint iconPoint = new LocationPoint(200.0, 300.0);
329 boolean success = iconMapObject.setPosition(iconPoint);
330 System.out.println("Set icon position to (" + iconPoint.getX() + ", " + iconPoint.getY() + "): " + success);
331 // [java_IconMapObject_setPosition]
332
333 // [java_IconMapObject_setPositionAnimated]
334 // Set icon position with animation
335 LocationPoint animatedIconPoint = new LocationPoint(250.0, 350.0);
336 boolean animatedSuccess = iconMapObject.setPositionAnimated(animatedIconPoint, 1.5, AnimationType.CUBIC);
337 System.out.println("Set icon position with animation to (" + animatedIconPoint.getX() + ", " + animatedIconPoint.getY() + "): " + animatedSuccess);
338 // [java_IconMapObject_setPositionAnimated]
339
340 // [java_IconMapObject_setSize]
341 // Set icon size
342 boolean sizeSuccess = iconMapObject.setSize(32.0, 32.0);
343 System.out.println("Set icon size to 32x32 pixels: " + sizeSuccess);
344 // [java_IconMapObject_setSize]
345
346 // [java_IconMapObject_setAngle]
347 // Set icon rotation angle
348 boolean angleSuccess = iconMapObject.setAngle(45.0);
349 System.out.println("Set icon rotation angle to 45 degrees: " + angleSuccess);
350 // [java_IconMapObject_setAngle]
351
352 // [java_IconMapObject_setAngleAnimated]
353 // Set icon rotation with animation
354 boolean angleAnimatedSuccess = iconMapObject.setAngleAnimated(90.0, 2.0, AnimationType.SINE);
355 System.out.println("Set icon rotation with animation to 90 degrees: " + angleAnimatedSuccess);
356 // [java_IconMapObject_setAngleAnimated]
357
358 // [java_IconMapObject_setCollisionEnabled]
359 // Enable collision detection
360 boolean collisionSuccess = iconMapObject.setCollisionEnabled(true);
361 System.out.println("Enabled collision detection for icon: " + collisionSuccess);
362 // [java_IconMapObject_setCollisionEnabled]
363
364 // [java_IconMapObject_setBuffer]
365 // Set collision buffer
366 boolean bufferSuccess = iconMapObject.setBuffer(10.0, 10.0);
367 System.out.println("Set collision buffer to 10x10 pixels: " + bufferSuccess);
368 // [java_IconMapObject_setBuffer]
369
370 // [java_IconMapObject_setOffset]
371 // Set position offset
372 boolean offsetSuccess = iconMapObject.setOffset(0.0, -16.0);
373 System.out.println("Set position offset to (0.0, -16.0) pixels: " + offsetSuccess);
374 // [java_IconMapObject_setOffset]
375
376 // [java_IconMapObject_setPriority]
377 // Set rendering priority
378 boolean prioritySuccess = iconMapObject.setPriority(2);
379 System.out.println("Set rendering priority to 2: " + prioritySuccess);
380 // [java_IconMapObject_setPriority]
381
382 // [java_IconMapObject_setVisible]
383 // Set visibility
384 boolean visibleSuccess = iconMapObject.setVisible(true);
385 System.out.println("Set icon visibility to true: " + visibleSuccess);
386 // [java_IconMapObject_setVisible]
387
388 // [java_IconMapObject_getMapObjectType]
389 // Get map object type
390 MapObjectType objectType = iconMapObject.getMapObjectType();
391 System.out.println("Icon map object type: " + objectType);
392 // [java_IconMapObject_getMapObjectType]
393
394 // [java_IconMapObject_setBitmap]
395 // Icon pixels come from an ImageProvider (ARGB_8888 Bitmap on Android).
396 ImageProvider iconBitmap = ImageProvider.fromFile("/path/to/icon.png", true);
397 boolean bitmapSuccess = iconMapObject.setBitmap(iconBitmap);
398 System.out.println("Set icon from ImageProvider: " + bitmapSuccess);
399 // [java_IconMapObject_setBitmap]
400
401 // [java_IconMapObject_setFlat]
402 // Set icon flat mode
403 boolean flatSuccess = iconMapObject.setFlat(true);
404 System.out.println("Set icon flat mode to true: " + flatSuccess);
405 // [java_IconMapObject_setFlat]
406
407 // [java_MapObject_setAlpha_1]
408 // Set alpha transparency
409 boolean alphaSuccess = iconMapObject.setAlpha(0.8f);
410 System.out.println("Set icon alpha to 0.8: " + alphaSuccess);
411 // [java_MapObject_setAlpha_1]
412
413 // [java_MapObject_setInteractive_1]
414 // Set interactive mode
415 boolean interactiveSuccess = iconMapObject.setInteractive(true);
416 System.out.println("Set icon interactive to true: " + interactiveSuccess);
417 // [java_MapObject_setInteractive_1]
418
419 // [java_MapObject_setTitle_1]
420 // Set title
421 boolean titleSuccess = iconMapObject.setTitle("Icon Object");
422 System.out.println("Set icon title to 'Icon Object': " + titleSuccess);
423 // [java_MapObject_setTitle_1]
424
425 // [java_MapObject_setData_1]
426 // Set custom data
427 Map<String, Object> customData = new HashMap<>();
428 customData.put("key", "value");
429 customData.put("number", 42);
430 boolean dataSuccess = iconMapObject.setData(customData);
431 System.out.println("Set icon custom data: " + dataSuccess);
432 // [java_MapObject_setData_1]
433
434 // [java_MapObject_getId_1]
435 // Get object ID
436 int objectId = iconMapObject.getId();
437 System.out.println("Icon object ID: " + objectId);
438 // [java_MapObject_getId_1]
439
440 // [java_MapObject_getType_1]
441 // Get object type
442 String objectTypeString = iconMapObject.getType();
443 System.out.println("Icon object type: " + objectTypeString);
444 // [java_MapObject_getType_1]
445
446 // [java_MapObject_getData_1]
447 // Get custom data
448 Map<String, Object> retrievedData = iconMapObject.getData();
449 System.out.println("Icon custom data: " + retrievedData);
450 // [java_MapObject_getData_1]
451 }
452
453 // [java_LocationWindow_removeIconMapObject]
454 // Remove icon map object
455 if (iconMapObject != null) {
456 boolean removed = locationWindow.removeIconMapObject(iconMapObject);
457 System.out.println("Removed icon map object: " + removed);
458 iconMapObject = null;
459 }
460 // [java_LocationWindow_removeIconMapObject]
461
462 // Test multiple icon objects
463 List<IconMapObject> icons = new ArrayList<>();
464 for (int i = 0; i < 3; i++) {
465 IconMapObject icon = locationWindow.addIconMapObject();
466 if (icon != null) {
467 icon.setPosition(new LocationPoint(100.0 * i, 150.0 * i));
468 icon.setSize(24.0, 24.0);
469 icon.setAngle(i * 30.0);
470 icons.add(icon);
471 System.out.println("Created icon " + i + " at (" + (100.0 * i) + ", " + (150.0 * i) + ") with angle " + (i * 30.0));
472 }
473 }
474
475 for (int i = 0; i < icons.size(); i++) {
476 locationWindow.removeIconMapObject(icons.get(i));
477 System.out.println("Removed icon " + i);
478 }
479 }
480
484 private void demonstrateModelMapObjects() {
485 System.out.println("--- Model Map Objects ---");
486
487 if (locationWindow == null) {
488 System.out.println("LocationWindow not available yet");
489 return;
490 }
491
492 // [java_LocationWindow_addModelMapObject]
493 modelMapObject = locationWindow.addModelMapObject();
494 System.out.println("Added model map object: " + (modelMapObject != null));
495 // [java_LocationWindow_addModelMapObject]
496
497 if (modelMapObject == null) {
498 return;
499 }
500
501 // [java_ModelMapObject_setPosition]
502 LocationPoint modelPoint = new LocationPoint(12.0, 34.0);
503 boolean posOk = modelMapObject.setPosition(modelPoint);
504 System.out.println("Model setPosition: " + posOk);
505 // [java_ModelMapObject_setPosition]
506
507 // [java_ModelMapObject_setPositionAnimated]
508 boolean posAnimOk = modelMapObject.setPositionAnimated(
509 new LocationPoint(15.0, 40.0), 0.5f, AnimationType.SINE);
510 System.out.println("Model setPositionAnimated: " + posAnimOk);
511 // [java_ModelMapObject_setPositionAnimated]
512
513 // [java_ModelMapObject_setModel]
514 ImageProvider texture = ImageProvider.fromFile("/path/to/model_texture.png", true);
515 ModelProvider model = ModelProvider.fromFile("/path/to/model.obj", texture);
516 boolean modelOk = modelMapObject.setModel(model);
517 System.out.println("Model setModel: " + modelOk);
518 // [java_ModelMapObject_setModel]
519
520 // [java_ModelMapObject_setSize]
521 boolean sizeOk = modelMapObject.setSize(64.0f, 64.0f);
522 System.out.println("Model setSize: " + sizeOk);
523 // [java_ModelMapObject_setSize]
524
525 // [java_ModelMapObject_setCollisionEnabled]
526 boolean collOk = modelMapObject.setCollisionEnabled(true);
527 System.out.println("Model setCollisionEnabled: " + collOk);
528 // [java_ModelMapObject_setCollisionEnabled]
529
530 // [java_ModelMapObject_setAngle]
531 boolean angleOk = modelMapObject.setAngle(45.0f);
532 System.out.println("Model setAngle: " + angleOk);
533 // [java_ModelMapObject_setAngle]
534
535 // [java_ModelMapObject_setAngleAnimated]
536 boolean angleAnimOk = modelMapObject.setAngleAnimated(90.0f, 0.5f, AnimationType.QUINT);
537 System.out.println("Model setAngleAnimated: " + angleAnimOk);
538 // [java_ModelMapObject_setAngleAnimated]
539
540 // [java_ModelMapObject_setBuffer]
541 boolean bufOk = modelMapObject.setBuffer(4.0f, 4.0f);
542 System.out.println("Model setBuffer: " + bufOk);
543 // [java_ModelMapObject_setBuffer]
544
545 // [java_ModelMapObject_setPriority]
546 boolean priOk = modelMapObject.setPriority(10.0f);
547 System.out.println("Model setPriority: " + priOk);
548 // [java_ModelMapObject_setPriority]
549
550 // [java_LocationWindow_removeModelMapObject]
551 boolean removed = locationWindow.removeModelMapObject(modelMapObject);
552 System.out.println("Removed model map object: " + removed);
553 modelMapObject = null;
554 // [java_LocationWindow_removeModelMapObject]
555 }
556
560 private void demonstratePolygonMapObjects() {
561 System.out.println("--- Polygon Map Objects ---");
562
563 if (locationWindow == null) {
564 System.out.println("LocationWindow not available yet");
565 return;
566 }
567
568 // [java_LocationWindow_addPolygonMapObject]
569 // Add polygon map object
570 polygonMapObject = locationWindow.addPolygonMapObject();
571 System.out.println("Added polygon map object");
572 // [java_LocationWindow_addPolygonMapObject]
573
574 if (polygonMapObject != null) {
575 // [java_PolygonMapObject_setPolygon]
576 // Set polygon geometry
577 List<Point> points = Arrays.asList(
578 new Point(100.0, 200.0),
579 new Point(150.0, 250.0),
580 new Point(200.0, 200.0),
581 new Point(150.0, 150.0)
582 );
583 Polygon metricPolygon = new Polygon(points);
584 LocationPolygon polygon = new LocationPolygon(metricPolygon, 1, 0);
585 boolean success = polygonMapObject.setPolygon(polygon);
586 System.out.println("Set polygon with " + points.size() + " points: " + success);
587 // [java_PolygonMapObject_setPolygon]
588
589 // [java_PolygonMapObject_setColor]
590 // Set polygon color
591 boolean colorSuccess = polygonMapObject.setColor(0.0, 1.0, 0.0, 0.7);
592 System.out.println("Set polygon color to green with 70% opacity: " + colorSuccess);
593 // [java_PolygonMapObject_setColor]
594
595 // [java_PolygonMapObject_setVisible]
596 // Set visibility
597 boolean visibleSuccess = polygonMapObject.setVisible(true);
598 System.out.println("Set polygon visibility to true: " + visibleSuccess);
599 // [java_PolygonMapObject_setVisible]
600
601 // [java_PolygonMapObject_getMapObjectType]
602 // Get map object type
603 MapObjectType objectType = polygonMapObject.getMapObjectType();
604 System.out.println("Polygon map object type: " + objectType);
605 // [java_PolygonMapObject_getMapObjectType]
606
607 // [java_PolygonMapObject_setOrder]
608 // Set polygon rendering order
609 boolean orderSuccess = polygonMapObject.setOrder(2);
610 System.out.println("Set polygon rendering order to 2: " + orderSuccess);
611 // [java_PolygonMapObject_setOrder]
612
613 // [java_PolygonMapObject_setOutlineColor]
614 // Set polygon outline color
615 boolean outlineColorSuccess = polygonMapObject.setOutlineColor(0.0, 0.0, 1.0, 1.0);
616 System.out.println("Set polygon outline color to blue: " + outlineColorSuccess);
617 // [java_PolygonMapObject_setOutlineColor]
618
619 // [java_PolygonMapObject_setOutlineWidth]
620 // Set polygon outline width
621 boolean outlineWidthSuccess = polygonMapObject.setOutlineWidth(2.0);
622 System.out.println("Set polygon outline width to 2.0 pixels: " + outlineWidthSuccess);
623 // [java_PolygonMapObject_setOutlineWidth]
624
625 // [java_PolygonMapObject_setOutlineAlpha]
626 // Set polygon outline alpha
627 boolean outlineAlphaSuccess = polygonMapObject.setOutlineAlpha(0.8);
628 System.out.println("Set polygon outline alpha to 0.8: " + outlineAlphaSuccess);
629 // [java_PolygonMapObject_setOutlineAlpha]
630
631 // [java_PolygonMapObject_setOutlineOrder]
632 // Set polygon outline order
633 boolean outlineOrderSuccess = polygonMapObject.setOutlineOrder(1);
634 System.out.println("Set polygon outline order to 1: " + outlineOrderSuccess);
635 // [java_PolygonMapObject_setOutlineOrder]
636
637 // [java_MapObject_setAlpha_2]
638 // Set alpha transparency
639 boolean alphaSuccess = polygonMapObject.setAlpha(0.7);
640 System.out.println("Set polygon alpha to 0.7: " + alphaSuccess);
641 // [java_MapObject_setAlpha_2]
642
643 // [java_MapObject_setInteractive_2]
644 // Set interactive mode
645 boolean interactiveSuccess = polygonMapObject.setInteractive(true);
646 System.out.println("Set polygon interactive to true: " + interactiveSuccess);
647 // [java_MapObject_setInteractive_2]
648
649 // [java_MapObject_setTitle_2]
650 // Set title
651 boolean titleSuccess = polygonMapObject.setTitle("Polygon Object");
652 System.out.println("Set polygon title to 'Polygon Object': " + titleSuccess);
653 // [java_MapObject_setTitle_2]
654
655 // [java_MapObject_setData_2]
656 // Set custom data
657 Map<String, Object> customData = new HashMap<>();
658 customData.put("key", "value");
659 customData.put("number", 42);
660 boolean dataSuccess = polygonMapObject.setData(customData);
661 System.out.println("Set polygon custom data: " + dataSuccess);
662 // [java_MapObject_setData_2]
663
664 // [java_MapObject_getId_2]
665 // Get object ID
666 int objectId = polygonMapObject.getId();
667 System.out.println("Polygon object ID: " + objectId);
668 // [java_MapObject_getId_2]
669
670 // [java_MapObject_getType_2]
671 // Get object type
672 String objectTypeString = polygonMapObject.getType();
673 System.out.println("Polygon object type: " + objectTypeString);
674 // [java_MapObject_getType_2]
675
676 // [java_MapObject_getData_2]
677 // Get custom data
678 Map<String, Object> retrievedData = polygonMapObject.getData();
679 System.out.println("Polygon custom data: " + retrievedData);
680 // [java_MapObject_getData_2]
681 }
682
683 // [java_LocationWindow_removePolygonMapObject]
684 // Remove polygon map object
685 if (polygonMapObject != null) {
686 boolean removed = locationWindow.removePolygonMapObject(polygonMapObject);
687 System.out.println("Removed polygon map object: " + removed);
688 polygonMapObject = null;
689 }
690 // [java_LocationWindow_removePolygonMapObject]
691
692 // Test multiple polygon objects
693 List<PolygonMapObject> polygons = new ArrayList<>();
694 for (int i = 0; i < 3; i++) {
695 PolygonMapObject polygon = locationWindow.addPolygonMapObject();
696 if (polygon != null) {
697 List<Point> points = Arrays.asList(
698 new Point(300.0 + i * 50, 400.0 + i * 50),
699 new Point(350.0 + i * 50, 450.0 + i * 50),
700 new Point(400.0 + i * 50, 400.0 + i * 50),
701 new Point(350.0 + i * 50, 350.0 + i * 50)
702 );
703 Polygon metricPoly = new Polygon(points);
704 LocationPolygon polygonGeometry = new LocationPolygon(metricPoly, 1, 0);
705 polygon.setPolygon(polygonGeometry);
706 polygon.setColor(0.0, 0.0, 1.0, 0.5);
707 polygons.add(polygon);
708 System.out.println("Created polygon " + i + " with " + points.size() + " points");
709 }
710 }
711
712 for (int i = 0; i < polygons.size(); i++) {
713 locationWindow.removePolygonMapObject(polygons.get(i));
714 System.out.println("Removed polygon " + i);
715 }
716 }
717
721 private void demonstratePolylineMapObjects() {
722 System.out.println("--- Polyline Map Objects ---");
723
724 if (locationWindow == null) {
725 System.out.println("LocationWindow not available yet");
726 return;
727 }
728
729 // [java_PolylineMapObject_constructor]
730 // Create polyline map object
731 List<Point> points = new ArrayList<>();
732 points.add(new Point(100.0, 110.0));
733 points.add(new Point(105.0, 115.0));
734 points.add(new Point(110.0, 120.0));
735 points.add(new Point(115.0, 125.0));
736 Polyline polyline = new Polyline(points);
737 LocationPolyline locationPolyline = new LocationPolyline(polyline, 1, 0);
738 polylineMapObject = locationWindow.addPolylineMapObject();
739 System.out.println("Created polyline map object with " + points.size() + " points");
740 // [java_PolylineMapObject_constructor]
741
742 // [java_PolylineMapObject_getPolyline]
743 // Access polyline
744 LocationPolyline polylineShape = polylineMapObject.getPolyLine();
745 System.out.println("Polyline has " + polylineShape.getPolyline().getPoints().size() + " points");
746 // [java_PolylineMapObject_getPolyline]
747
748 // [java_LocationWindow_addPolylineMapObject]
749 // Add polyline map object
750 polylineMapObject = locationWindow.addPolylineMapObject();
751 System.out.println("Added polyline map object");
752 // [java_LocationWindow_addPolylineMapObject]
753
754 if (polylineMapObject != null) {
755 // [java_PolylineMapObject_setPolyLine]
756 // Set polyline geometry
757 List<Point> polylinePoints = new ArrayList<>();
758 polylinePoints.add(new Point(0.0, 0.0));
759 polylinePoints.add(new Point(50.0, 50.0));
760 polylinePoints.add(new Point(100.0, 0.0));
761 polylinePoints.add(new Point(150.0, 50.0));
762 Polyline polyline = new Polyline(polylinePoints);
763 LocationPolyline locationPolyline = new LocationPolyline(polyline, 1, 0);
764 boolean success = polylineMapObject.setPolyLine(locationPolyline);
765 System.out.println("Set polyline geometry: " + success);
766 // [java_PolylineMapObject_setPolyLine]
767
768 // [java_PolylineMapObject_setWidth]
769 // Set polyline width
770 boolean widthSuccess = polylineMapObject.setWidth(3.0);
771 System.out.println("Set polyline width to 3.0 pixels: " + widthSuccess);
772 // [java_PolylineMapObject_setWidth]
773
774 // [java_PolylineMapObject_setColor]
775 // Set polyline color
776 boolean colorSuccess = polylineMapObject.setColor(1.0, 0.5, 0.0, 0.9);
777 System.out.println("Set polyline color to orange with 90% opacity: " + colorSuccess);
778 // [java_PolylineMapObject_setColor]
779
780 // [java_PolylineMapObject_setOrder]
781 // Set rendering order
782 boolean orderSuccess = polylineMapObject.setOrder(2);
783 System.out.println("Set rendering order to 2: " + orderSuccess);
784 // [java_PolylineMapObject_setOrder]
785
786 // [java_PolylineMapObject_setCapType]
787 // Set cap type
788 boolean capSuccess = polylineMapObject.setCapType(CapType.ROUND);
789 System.out.println("Set cap type to ROUND: " + capSuccess);
790 // [java_PolylineMapObject_setCapType]
791
792 // [java_PolylineMapObject_setJoinType]
793 // Set join type
794 boolean joinSuccess = polylineMapObject.setJoinType(JoinType.ROUND);
795 System.out.println("Set join type to ROUND: " + joinSuccess);
796 // [java_PolylineMapObject_setJoinType]
797
798 // [java_PolylineMapObject_setMiterLimit]
799 // Set miter limit
800 boolean miterSuccess = polylineMapObject.setMiterLimit(5.0);
801 System.out.println("Set miter limit to 5.0: " + miterSuccess);
802 // [java_PolylineMapObject_setMiterLimit]
803
804 // [java_PolylineMapObject_setVisible]
805 // Set visibility
806 boolean visibleSuccess = polylineMapObject.setVisible(true);
807 System.out.println("Set polyline visibility to true: " + visibleSuccess);
808 // [java_PolylineMapObject_setVisible]
809
810 // [java_PolylineMapObject_getMapObjectType]
811 // Get map object type
812 MapObjectType objectType = polylineMapObject.getMapObjectType();
813 System.out.println("Polyline map object type: " + objectType);
814 // [java_PolylineMapObject_getMapObjectType]
815
816 // [java_MapObject_setAlpha_3]
817 // Set alpha transparency
818 boolean alphaSuccess = polylineMapObject.setAlpha(0.7);
819 System.out.println("Set polyline alpha to 0.7: " + alphaSuccess);
820 // [java_MapObject_setAlpha_3]
821
822 // [java_MapObject_setInteractive_3]
823 // Set interactive mode
824 boolean interactiveSuccess = polylineMapObject.setInteractive(true);
825 System.out.println("Set polyline interactive to true: " + interactiveSuccess);
826 // [java_MapObject_setInteractive_3]
827
828 // [java_MapObject_setTitle_3]
829 // Set title
830 boolean titleSuccess = polylineMapObject.setTitle("Polyline Object");
831 System.out.println("Set polyline title to 'Polyline Object': " + titleSuccess);
832 // [java_MapObject_setTitle_3]
833
834 // [java_MapObject_setData_3]
835 // Set custom data
836 Map<String, Object> customData = new HashMap<>();
837 customData.put("key", "value");
838 customData.put("number", 42);
839 boolean dataSuccess = polylineMapObject.setData(customData);
840 System.out.println("Set polyline custom data: " + dataSuccess);
841 // [java_MapObject_setData_3]
842
843 // [java_MapObject_getId_3]
844 // Get object ID
845 int objectId = polylineMapObject.getId();
846 System.out.println("Polyline object ID: " + objectId);
847 // [java_MapObject_getId_3]
848
849 // [java_MapObject_getType_3]
850 // Get object type
851 String objectTypeString = polylineMapObject.getType();
852 System.out.println("Polyline object type: " + objectTypeString);
853 // [java_MapObject_getType_3]
854
855 // [java_MapObject_getData_3]
856 // Get custom data
857 Map<String, Object> retrievedData = polylineMapObject.getData();
858 System.out.println("Polyline custom data: " + retrievedData);
859 // [java_MapObject_getData_3]
860
861 // [java_PolylineMapObject_setOutlineWidth]
862 // Set polyline outline width
863 boolean outlineWidthSuccess2 = polylineMapObject.setOutlineWidth(1.0);
864 System.out.println("Set polyline outline width to 1.0 pixels: " + outlineWidthSuccess2);
865 // [java_PolylineMapObject_setOutlineWidth]
866
867 // [java_PolylineMapObject_setOutlineColor]
868 // Set polyline outline color
869 boolean outlineColorSuccess2 = polylineMapObject.setOutlineColor(0.0, 0.0, 0.0, 1.0);
870 System.out.println("Set polyline outline color to black: " + outlineColorSuccess2);
871 // [java_PolylineMapObject_setOutlineColor]
872
873 // [java_PolylineMapObject_setOutlineAlpha]
874 // Set polyline outline alpha
875 boolean outlineAlphaSuccess2 = polylineMapObject.setOutlineAlpha(0.5);
876 System.out.println("Set polyline outline alpha to 0.5: " + outlineAlphaSuccess2);
877 // [java_PolylineMapObject_setOutlineAlpha]
878
879 // [java_PolylineMapObject_setOutlineOrder]
880 // Set polyline outline rendering order
881 boolean outlineOrderSuccess2 = polylineMapObject.setOutlineOrder(0);
882 System.out.println("Set polyline outline rendering order to 0: " + outlineOrderSuccess2);
883 // [java_PolylineMapObject_setOutlineOrder]
884
885 // [java_PolylineMapObject_setOutlineCapType]
886 // Set polyline outline cap type
887 boolean outlineCapTypeSuccess2 = polylineMapObject.setOutlineCapType(CapType.SQUARE);
888 System.out.println("Set polyline outline cap type to SQUARE: " + outlineCapTypeSuccess2);
889 // [java_PolylineMapObject_setOutlineCapType]
890
891 // [java_PolylineMapObject_setOutlineJoinType]
892 // Set polyline outline join type
893 boolean outlineJoinTypeSuccess2 = polylineMapObject.setOutlineJoinType(JoinType.MITER);
894 System.out.println("Set polyline outline join type to MITER: " + outlineJoinTypeSuccess2);
895 // [java_PolylineMapObject_setOutlineJoinType]
896
897 // [java_PolylineMapObject_setOutlineMiterLimit]
898 // Set polyline outline miter limit
899 boolean outlineMiterLimitSuccess2 = polylineMapObject.setOutlineMiterLimit(3.0);
900 System.out.println("Set polyline outline miter limit to 3.0: " + outlineMiterLimitSuccess2);
901 // [java_PolylineMapObject_setOutlineMiterLimit]
902 }
903
904 // [java_LocationWindow_removePolylineMapObject]
905 // Remove polyline map object
906 if (polylineMapObject != null) {
907 boolean removed = locationWindow.removePolylineMapObject(polylineMapObject);
908 System.out.println("Removed polyline map object: " + removed);
909 polylineMapObject = null;
910 }
911 // [java_LocationWindow_removePolylineMapObject]
912
913 // Test multiple polyline objects
914 List<PolylineMapObject> polylines = new ArrayList<>();
915 for (int i = 0; i < 3; i++) {
916 PolylineMapObject polyline = locationWindow.addPolylineMapObject();
917 if (polyline != null) {
918 List<Point> points = new ArrayList<>();
919 points.add(new Point(i * 30.0, i * 30.0));
920 points.add(new Point((i + 1) * 30.0, (i + 1) * 30.0));
921 Polyline poly = new Polyline(points);
922 LocationPolyline locPoly = new LocationPolyline(poly, 1, 0);
923 polyline.setPolyLine(locPoly);
924 polyline.setWidth(2.0 + i);
925 polyline.setColor(0.0, 1.0, 1.0, 0.8);
926 polylines.add(polyline);
927 System.out.println("Created polyline " + i + " with width " + (2.0 + i));
928 }
929 }
930
931 for (int i = 0; i < polylines.size(); i++) {
932 locationWindow.removePolylineMapObject(polylines.get(i));
933 System.out.println("Removed polyline " + i);
934 }
935 }
936
940 private void demonstrateDottedPolylineMapObjects() {
941 System.out.println("--- Dotted Polyline Map Objects ---");
942
943 if (locationWindow == null) {
944 System.out.println("LocationWindow not available yet");
945 return;
946 }
947
948 // [java_DottedPolylineMapObject_constructor]
949 // Create dotted polyline map object
950 List<Point> points = new ArrayList<>();
951 points.add(new Point(160.0, 170.0));
952 points.add(new Point(165.0, 175.0));
953 points.add(new Point(170.0, 180.0));
954 points.add(new Point(175.0, 185.0));
955 Polyline polyline = new Polyline(points);
956 LocationPolyline locationPolyline = new LocationPolyline(polyline, 1, 0);
957 dottedPolylineMapObject = locationWindow.addDottedPolylineMapObject();
958 System.out.println("Created dotted polyline map object with " + points.size() + " points");
959 // [java_DottedPolylineMapObject_constructor]
960
961 // [java_DottedPolylineMapObject_getPolyline]
962 // Access dotted polyline
963 LocationPolyline dottedPolylineShape = dottedPolylineMapObject.getPolyLine();
964 System.out.println("Dotted polyline has " + dottedPolylineShape.getPolyline().getPoints().size() + " points");
965 // [java_DottedPolylineMapObject_getPolyline]
966
967 // [java_LocationWindow_addDottedPolylineMapObject]
968 // Add dotted polyline map object
969 dottedPolylineMapObject = locationWindow.addDottedPolylineMapObject();
970 System.out.println("Added dotted polyline map object");
971 // [java_LocationWindow_addDottedPolylineMapObject]
972
973 if (dottedPolylineMapObject != null) {
974 // [java_DottedPolylineMapObject_setPolyline]
975 // Set dotted polyline geometry
976 List<Point> dottedPoints = new ArrayList<>();
977 dottedPoints.add(new Point(0.0, 100.0));
978 dottedPoints.add(new Point(50.0, 150.0));
979 dottedPoints.add(new Point(100.0, 100.0));
980 dottedPoints.add(new Point(150.0, 150.0));
981 Polyline dottedPolyline = new Polyline(dottedPoints);
982 LocationPolyline locationDottedPolyline = new LocationPolyline(dottedPolyline, 1, 0);
983 boolean success = dottedPolylineMapObject.setPolyLine(locationDottedPolyline);
984 System.out.println("Set dotted polyline geometry: " + success);
985 // [java_DottedPolylineMapObject_setPolyline]
986
987 // [java_DottedPolylineMapObject_setWidth]
988 // Set dotted polyline width
989 boolean widthSuccess = dottedPolylineMapObject.setWidth(2.0);
990 System.out.println("Set dotted polyline width to 2.0 pixels: " + widthSuccess);
991 // [java_DottedPolylineMapObject_setWidth]
992
993 // [java_DottedPolylineMapObject_setColor]
994 // Set dotted polyline color
995 boolean colorSuccess = dottedPolylineMapObject.setColor(0.5, 0.0, 1.0, 0.8);
996 System.out.println("Set dotted polyline color to purple with 80% opacity: " + colorSuccess);
997 // [java_DottedPolylineMapObject_setColor]
998
999 // [java_DottedPolylineMapObject_setOrder]
1000 // Set rendering order
1001 boolean orderSuccess = dottedPolylineMapObject.setOrder(3);
1002 System.out.println("Set rendering order to 3: " + orderSuccess);
1003 // [java_DottedPolylineMapObject_setOrder]
1004
1005 // [java_DottedPolylineMapObject_setVisible]
1006 // Set visibility
1007 boolean visibleSuccess = dottedPolylineMapObject.setVisible(true);
1008 System.out.println("Set dotted polyline visibility to true: " + visibleSuccess);
1009 // [java_DottedPolylineMapObject_setVisible]
1010
1011 // [java_DottedPolylineMapObject_getMapObjectType]
1012 // Get map object type
1013 MapObjectType objectType = dottedPolylineMapObject.getMapObjectType();
1014 System.out.println("Dotted polyline map object type: " + objectType);
1015 // [java_DottedPolylineMapObject_getMapObjectType]
1016
1017 // [java_MapObject_setAlpha_4]
1018 // Set alpha transparency
1019 boolean alphaSuccess = dottedPolylineMapObject.setAlpha(0.8);
1020 System.out.println("Set dotted polyline alpha to 0.8: " + alphaSuccess);
1021 // [java_MapObject_setAlpha_4]
1022
1023 // [java_MapObject_setInteractive_4]
1024 // Set interactive mode
1025 boolean interactiveSuccess = dottedPolylineMapObject.setInteractive(true);
1026 System.out.println("Set dotted polyline interactive to true: " + interactiveSuccess);
1027 // [java_MapObject_setInteractive_4]
1028
1029 // [java_MapObject_setTitle_4]
1030 // Set title
1031 boolean titleSuccess = dottedPolylineMapObject.setTitle("Dotted Polyline Object");
1032 System.out.println("Set dotted polyline title to 'Dotted Polyline Object': " + titleSuccess);
1033 // [java_MapObject_setTitle_4]
1034
1035 // [java_MapObject_setData_4]
1036 // Set custom data
1037 Map<String, Object> customData = new HashMap<>();
1038 customData.put("key", "value");
1039 customData.put("number", 42);
1040 boolean dataSuccess = dottedPolylineMapObject.setData(customData);
1041 System.out.println("Set dotted polyline custom data: " + dataSuccess);
1042 // [java_MapObject_setData_4]
1043
1044 // [java_MapObject_getId_4]
1045 // Get object ID
1046 int objectId = dottedPolylineMapObject.getId();
1047 System.out.println("Dotted polyline object ID: " + objectId);
1048 // [java_MapObject_getId_4]
1049
1050 // [java_MapObject_getType_4]
1051 // Get object type
1052 String objectTypeString = dottedPolylineMapObject.getType();
1053 System.out.println("Dotted polyline object type: " + objectTypeString);
1054 // [java_MapObject_getType_4]
1055
1056 // [java_MapObject_getData_4]
1057 // Get custom data
1058 Map<String, Object> retrievedData = dottedPolylineMapObject.getData();
1059 System.out.println("Dotted polyline custom data: " + retrievedData);
1060 // [java_MapObject_getData_4]
1061
1062 // [java_DottedPolylineMapObject_setCollisionEnabled]
1063 // Enable collision detection
1064 boolean dottedCollisionSuccess = dottedPolylineMapObject.setCollisionEnabled(true);
1065 System.out.println("Enabled collision detection for dotted polyline: " + dottedCollisionSuccess);
1066 // [java_DottedPolylineMapObject_setCollisionEnabled]
1067
1068 // [java_DottedPolylineMapObject_setPlacement]
1069 // Set placement type
1070 boolean dottedPlacementSuccess = dottedPolylineMapObject.setPlacement(Placement.CENTER);
1071 System.out.println("Set dotted polyline placement to CENTER: " + dottedPlacementSuccess);
1072 // [java_DottedPolylineMapObject_setPlacement]
1073
1074 // [java_DottedPolylineMapObject_setPlacementMinRatio]
1075 // Set placement min ratio
1076 boolean dottedMinRatioSuccess = dottedPolylineMapObject.setPlacementMinRatio(0.5);
1077 System.out.println("Set dotted polyline placement min ratio to 0.5: " + dottedMinRatioSuccess);
1078 // [java_DottedPolylineMapObject_setPlacementMinRatio]
1079
1080 // [java_DottedPolylineMapObject_setPlacementSpacing]
1081 // Set placement spacing
1082 boolean dottedSpacingSuccess = dottedPolylineMapObject.setPlacementSpacing(10.0);
1083 System.out.println("Set dotted polyline placement spacing to 10.0: " + dottedSpacingSuccess);
1084 // [java_DottedPolylineMapObject_setPlacementSpacing]
1085
1086 // [java_DottedPolylineMapObject_setPriority]
1087 // Set rendering priority
1088 boolean dottedPrioritySuccess = dottedPolylineMapObject.setPriority(1);
1089 System.out.println("Set dotted polyline rendering priority to 1: " + dottedPrioritySuccess);
1090 // [java_DottedPolylineMapObject_setPriority]
1091
1092 // [java_DottedPolylineMapObject_setRepeatDistance]
1093 // Set repeat distance
1094 boolean dottedRepeatDistanceSuccess = dottedPolylineMapObject.setRepeatDistance(20.0);
1095 System.out.println("Set dotted polyline repeat distance to 20.0: " + dottedRepeatDistanceSuccess);
1096 // [java_DottedPolylineMapObject_setRepeatDistance]
1097
1098 // [java_DottedPolylineMapObject_setRepeatGroup]
1099 // Set repeat group
1100 boolean dottedRepeatGroupSuccess = dottedPolylineMapObject.setRepeatGroup(1);
1101 System.out.println("Set dotted polyline repeat group to 1: " + dottedRepeatGroupSuccess);
1102 // [java_DottedPolylineMapObject_setRepeatGroup]
1103
1104 // [java_DottedPolylineMapObject_setSize]
1105 // Set size
1106 Size dottedSize = new Size(16.0, 16.0);
1107 boolean dottedSizeSuccess = dottedPolylineMapObject.setSize(dottedSize);
1108 System.out.println("Set dotted polyline size to (" + dottedSize.getWidth() + ", " + dottedSize.getHeight() + "): " + dottedSizeSuccess);
1109 // [java_DottedPolylineMapObject_setSize]
1110 }
1111
1112 // [java_LocationWindow_removeDottedPolylineMapObject]
1113 // Remove dotted polyline map object
1114 if (dottedPolylineMapObject != null) {
1115 boolean removed = locationWindow.removeDottedPolylineMapObject(dottedPolylineMapObject);
1116 System.out.println("Removed dotted polyline map object: " + removed);
1117 dottedPolylineMapObject = null;
1118 }
1119 // [java_LocationWindow_removeDottedPolylineMapObject]
1120
1121 // Test multiple dotted polyline objects
1122 List<DottedPolylineMapObject> dottedPolylines = new ArrayList<>();
1123 for (int i = 0; i < 2; i++) {
1124 DottedPolylineMapObject dottedPolyline = locationWindow.addDottedPolylineMapObject();
1125 if (dottedPolyline != null) {
1126 List<Point> points = new ArrayList<>();
1127 points.add(new Point(i * 40.0, i * 40.0 + 100.0));
1128 points.add(new Point((i + 1) * 40.0, (i + 1) * 40.0 + 100.0));
1129 Polyline poly = new Polyline(points);
1130 LocationPolyline locPoly = new LocationPolyline(poly, 1, 0);
1131 dottedPolyline.setPolyLine(locPoly);
1132 dottedPolyline.setWidth(1.5);
1133 dottedPolyline.setColor(1.0, 0.0, 1.0, 0.6);
1134 dottedPolylines.add(dottedPolyline);
1135 System.out.println("Created dotted polyline " + i);
1136 }
1137 }
1138
1139 for (int i = 0; i < dottedPolylines.size(); i++) {
1140 locationWindow.removeDottedPolylineMapObject(dottedPolylines.get(i));
1141 System.out.println("Removed dotted polyline " + i);
1142 }
1143 }
1144
1148 private void demonstrateRemoveAllMapObjects() {
1149 System.out.println("--- Remove All Map Objects ---");
1150
1151 if (locationWindow == null) {
1152 System.out.println("LocationWindow not available yet");
1153 return;
1154 }
1155
1156 // Create various map objects
1157 CircleMapObject circle = locationWindow.addCircleMapObject();
1158 IconMapObject icon = locationWindow.addIconMapObject();
1159 PolygonMapObject polygon = locationWindow.addPolygonMapObject();
1160 PolylineMapObject polyline = locationWindow.addPolylineMapObject();
1161 DottedPolylineMapObject dottedPolyline = locationWindow.addDottedPolylineMapObject();
1162
1163 System.out.println("Created 5 map objects");
1164
1165 // [java_LocationWindow_removeAllMapObjects]
1166 // Remove all map objects
1167 locationWindow.removeAllMapObjects();
1168 System.out.println("Removed all map objects");
1169 // [java_LocationWindow_removeAllMapObjects]
1170 }
1171
1175 private void demonstrateClusterMapObjects() {
1176 System.out.println("--- Cluster map objects ---");
1177
1178 if (locationWindow == null) {
1179 System.out.println("LocationWindow not available");
1180 return;
1181 }
1182
1183 // [java_LocationWindow_addClusterMapObjectController]
1184 clusterMapObjectController = locationWindow.addClusterMapObjectController();
1185 System.out.println("Added cluster map object controller");
1186 // [java_LocationWindow_addClusterMapObjectController]
1187
1188 if (clusterMapObjectController == null) {
1189 return;
1190 }
1191
1192 IconMapObject clusterIcon1 = locationWindow.addIconMapObject();
1193 IconMapObject clusterIcon2 = locationWindow.addIconMapObject();
1194 if (clusterIcon1 != null) {
1195 clusterIcon1.setPosition(new LocationPoint(100.0, 100.0));
1196 }
1197 if (clusterIcon2 != null) {
1198 clusterIcon2.setPosition(new LocationPoint(105.0, 102.0));
1199 }
1200
1201 // [java_ClusterMapObjectController_addIconMapObject]
1202 boolean added1 = clusterMapObjectController.addIconMapObject(clusterIcon1);
1203 boolean added2 = clusterMapObjectController.addIconMapObject(clusterIcon2);
1204 System.out.println("Registered icons for clustering: " + added1 + ", " + added2);
1205 // [java_ClusterMapObjectController_addIconMapObject]
1206
1207 // [java_ClusterMapObjectController_setEnabled]
1208 clusterMapObjectController.setEnabled(true);
1209 System.out.println("Clustering enabled");
1210 // [java_ClusterMapObjectController_setEnabled]
1211
1212 // [java_ClusterMapObjectController_isEnabled]
1213 boolean clusteringEnabled = clusterMapObjectController.isEnabled();
1214 System.out.println("Clustering is enabled: " + clusteringEnabled);
1215 // [java_ClusterMapObjectController_isEnabled]
1216
1217 // [java_ClusterMapObjectController_setRadius]
1218 clusterMapObjectController.setRadius(40.0f);
1219 System.out.println("Set cluster radius to 40 px");
1220 // [java_ClusterMapObjectController_setRadius]
1221
1222 // [java_ClusterMapObjectController_getRadius]
1223 float clusterRadius = clusterMapObjectController.getRadius();
1224 System.out.println("Cluster radius: " + clusterRadius);
1225 // [java_ClusterMapObjectController_getRadius]
1226
1227 // [java_ClusterMapObjectController_setInteractive]
1228 boolean interactiveSuccess = clusterMapObjectController.setInteractive(true);
1229 System.out.println("Set cluster markers interactive: " + interactiveSuccess);
1230 // [java_ClusterMapObjectController_setInteractive]
1231
1232 // [java_ClusterMapObjectController_setClusterSize]
1233 boolean sizeSuccess = clusterMapObjectController.setClusterSize(32.0f, 32.0f);
1234 System.out.println("Set default cluster icon size: " + sizeSuccess);
1235 // [java_ClusterMapObjectController_setClusterSize]
1236
1237 clusterMapObjectControllerListener = new DemoClusterMapObjectControllerListener();
1238
1239 // [java_ClusterMapObjectController_addListener]
1240 clusterMapObjectController.addListener(clusterMapObjectControllerListener);
1241 System.out.println("Added cluster map object controller listener");
1242 // [java_ClusterMapObjectController_addListener]
1243
1244 // [java_ClusterMapObjectController_getClusters]
1245 List<ClusterMapObject> clusters = clusterMapObjectController.getClusters();
1246 System.out.println("Visible clusters: " + clusters.size());
1247 // [java_ClusterMapObjectController_getClusters]
1248
1249 if (!clusters.isEmpty()) {
1250 ClusterMapObject cluster = clusters.get(0);
1251 // [java_ClusterMapObject_setBitmap]
1252 ImageProvider clusterBitmap = ImageProvider.fromFile("/path/to/cluster.png", true);
1253 boolean bitmapSuccess = cluster.setBitmap(clusterBitmap);
1254 System.out.println("Set cluster bitmap from ImageProvider: " + bitmapSuccess);
1255 // [java_ClusterMapObject_setBitmap]
1256 }
1257
1258 // [java_ClusterMapObjectController_removeListener]
1259 clusterMapObjectController.removeListener(clusterMapObjectControllerListener);
1260 System.out.println("Removed cluster map object controller listener");
1261 // [java_ClusterMapObjectController_removeListener]
1262
1263 if (clusterIcon1 != null) {
1264 // [java_ClusterMapObjectController_removeIconMapObject]
1265 boolean removed = clusterMapObjectController.removeIconMapObject(clusterIcon1);
1266 System.out.println("Removed icon from cluster controller: " + removed);
1267 // [java_ClusterMapObjectController_removeIconMapObject]
1268 locationWindow.removeIconMapObject(clusterIcon1);
1269 }
1270 if (clusterIcon2 != null) {
1271 locationWindow.removeIconMapObject(clusterIcon2);
1272 }
1273
1274 // [java_ClusterMapObjectController_clear]
1275 clusterMapObjectController.clear();
1276 System.out.println("Cleared cluster controller");
1277 // [java_ClusterMapObjectController_clear]
1278
1279 // [java_LocationWindow_removeClusterMapObjectController]
1280 boolean controllerRemoved =
1281 locationWindow.removeClusterMapObjectController(clusterMapObjectController);
1282 System.out.println("Removed cluster map object controller: " + controllerRemoved);
1283 // [java_LocationWindow_removeClusterMapObjectController]
1284
1285 clusterMapObjectController = null;
1286 clusterMapObjectControllerListener = null;
1287 }
1288
1292 public void cleanup() {
1293 if (circleMapObject != null) {
1294 locationWindow.removeCircleMapObject(circleMapObject);
1295 circleMapObject = null;
1296 }
1297 if (iconMapObject != null) {
1298 locationWindow.removeIconMapObject(iconMapObject);
1299 iconMapObject = null;
1300 }
1301 if (polygonMapObject != null) {
1302 // Polygon objects are removed automatically when LocationWindow is destroyed
1303 polygonMapObject = null;
1304 }
1305 if (polylineMapObject != null) {
1306 locationWindow.removePolylineMapObject(polylineMapObject);
1307 polylineMapObject = null;
1308 }
1309 if (dottedPolylineMapObject != null) {
1310 locationWindow.removeDottedPolylineMapObject(dottedPolylineMapObject);
1311 dottedPolylineMapObject = null;
1312 }
1313 if (modelMapObject != null) {
1314 locationWindow.removeModelMapObject(modelMapObject);
1315 modelMapObject = null;
1316 }
1317 System.out.println("LocationWindowMapObjects example cleanup completed");
1318 }
1319}
1320
1321class DemoClusterMapObjectControllerListener implements ClusterMapObjectControllerListener {
1322 private final ClusterMapObjectListener clusterChangeListener = new DemoClusterMapObjectListener();
1323 private ClusterMapObject activeCluster;
1324
1325 // [java_ClusterMapObjectControllerListener_onClusterCreated]
1326 @Override
1327 public void onClusterCreated(ClusterMapObjectController controller, ClusterMapObject cluster) {
1328 // [java_ClusterMapObject_addListener]
1329 cluster.addListener(clusterChangeListener);
1330 System.out.println("Added cluster change listener, initial count: " + cluster.getCount());
1331 // [java_ClusterMapObject_addListener]
1332 activeCluster = cluster;
1333 }
1334 // [java_ClusterMapObjectControllerListener_onClusterCreated]
1335
1336 // [java_ClusterMapObjectControllerListener_onClusterDestroyed]
1337 @Override
1338 public void onClusterDestroyed(ClusterMapObjectController controller, int clusterId) {
1339 if (activeCluster != null && activeCluster.getId() == clusterId) {
1340 // [java_ClusterMapObject_removeListener]
1341 activeCluster.removeListener(clusterChangeListener);
1342 System.out.println("Removed cluster change listener");
1343 // [java_ClusterMapObject_removeListener]
1344 activeCluster = null;
1345 }
1346 System.out.println("Cluster destroyed, id: " + clusterId);
1347 }
1348 // [java_ClusterMapObjectControllerListener_onClusterDestroyed]
1349}
1350
1351class DemoClusterMapObjectListener implements ClusterMapObjectListener {
1352
1353 // [java_ClusterMapObjectListener_onClusterChanged]
1354 @Override
1355 public void onClusterChanged(ClusterMapObject cluster) {
1356 int memberCount = cluster.getCount();
1357 System.out.println("Cluster changed, member count: " + memberCount);
1358 }
1359 // [java_ClusterMapObjectListener_onClusterChanged]
1360}
1361
1362// Main class
1363class Main {
1364 public static void main(String[] args) {
1365 LocationWindowMapObjectsExample example = new LocationWindowMapObjectsExample();
1366 }
1367}