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