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