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.IconMapObject;
6import com.navigine.idl.java.PolygonMapObject;
7import com.navigine.idl.java.PolylineMapObject;
8import com.navigine.idl.java.DottedPolylineMapObject;
9import com.navigine.idl.java.AnimationType;
10import com.navigine.idl.java.CapType;
11import com.navigine.idl.java.JoinType;
12import com.navigine.idl.java.LocationPoint;
13import com.navigine.idl.java.LocationPolygon;
14import com.navigine.idl.java.LocationPolyline;
15import com.navigine.idl.java.MapObjectType;
16import com.navigine.idl.java.Point;
17import com.navigine.idl.java.Polygon;
18import com.navigine.idl.java.Polyline;
19import com.navigine.idl.java.ImageWrapper;
20
21import java.util.ArrayList;
22import java.util.List;
23import java.util.Arrays;
24import java.util.HashMap;
25import java.util.Map;
26
34 private LocationWindow locationWindow;
35 private CircleMapObject circleMapObject;
36 private IconMapObject iconMapObject;
37 private PolygonMapObject polygonMapObject;
38 private PolylineMapObject polylineMapObject;
39 private DottedPolylineMapObject dottedPolylineMapObject;
40
42 demonstrateLocationWindowMapObjectsMethods();
43 }
44
48 private void demonstrateLocationWindowMapObjectsMethods() {
49 System.out.println("=== LocationWindowMapObjects Example ===");
50
51 demonstrateCircleMapObjects();
52 demonstrateIconMapObjects();
53 demonstratePolygonMapObjects();
54 demonstratePolylineMapObjects();
55 demonstrateDottedPolylineMapObjects();
56 demonstrateRemoveAllMapObjects();
57 cleanup();
58 }
59
63 private void demonstrateCircleMapObjects() {
64 System.out.println("--- Circle Map Objects ---");
65
66 if (locationWindow == null) {
67 System.out.println("LocationWindow not available yet");
68 return;
69 }
70
71 // [java_CircleMapObject_constructor]
72 // Create circle map object
73 LocationPoint center = new LocationPoint(10.0, 20.0);
74 circleMapObject = locationWindow.addCircleMapObject();
75 System.out.println("Created circle map object with center (" + center.getX() + ", " + center.getY() + ") and radius 5.0");
76 // [java_CircleMapObject_constructor]
77
78 // [java_CircleMapObject_getCenter]
79 // Access circle center
80 LocationPoint circleCenter = circleMapObject.getPosition();
81 System.out.println("Circle center: (" + circleCenter.getX() + ", " + circleCenter.getY() + ")");
82 // [java_CircleMapObject_getCenter]
83
84 // [java_CircleMapObject_getRadius]
85 // Access circle radius
86 double radius = circleMapObject.getRadius();
87 System.out.println("Circle radius: " + radius);
88 // [java_CircleMapObject_getRadius]
89
90 // [java_LocationWindow_addCircleMapObject]
91 // Add circle map object
92 circleMapObject = locationWindow.addCircleMapObject();
93 System.out.println("Added circle map object");
94 // [java_LocationWindow_addCircleMapObject]
95
96 if (circleMapObject != null) {
97 // [java_CircleMapObject_setPosition]
98 // Set circle position
99 LocationPoint centerPoint = new LocationPoint(100.0, 200.0);
100 boolean success = circleMapObject.setPosition(centerPoint);
101 System.out.println("Set circle position to (" + centerPoint.getX() + ", " + centerPoint.getY() + "): " + success);
102 // [java_CircleMapObject_setPosition]
103
104 // [java_CircleMapObject_setPositionAnimated]
105 // Set circle position with animation
106 LocationPoint animatedPoint = new LocationPoint(150.0, 250.0);
107 boolean animatedSuccess = circleMapObject.setPositionAnimated(animatedPoint, 2.0, AnimationType.LINEAR);
108 System.out.println("Set circle position with animation to (" + animatedPoint.getX() + ", " + animatedPoint.getY() + "): " + animatedSuccess);
109 // [java_CircleMapObject_setPositionAnimated]
110
111 // [java_CircleMapObject_setRadius]
112 // Set circle radius
113 boolean radiusSuccess = circleMapObject.setRadius(10.0);
114 System.out.println("Set circle radius to 10.0 meters: " + radiusSuccess);
115 // [java_CircleMapObject_setRadius]
116
117 // [java_CircleMapObject_setCollisionEnabled]
118 // Enable collision detection
119 boolean collisionSuccess = circleMapObject.setCollisionEnabled(true);
120 System.out.println("Enabled collision detection for circle: " + collisionSuccess);
121 // [java_CircleMapObject_setCollisionEnabled]
122
123 // [java_CircleMapObject_setBuffer]
124 // Set collision buffer
125 boolean bufferSuccess = circleMapObject.setBuffer(5.0, 5.0);
126 System.out.println("Set collision buffer to 5x5 pixels: " + bufferSuccess);
127 // [java_CircleMapObject_setBuffer]
128
129 // [java_CircleMapObject_setOffset]
130 // Set position offset
131 boolean offsetSuccess = circleMapObject.setOffset(2.0, 3.0);
132 System.out.println("Set position offset to (2.0, 3.0) pixels: " + offsetSuccess);
133 // [java_CircleMapObject_setOffset]
134
135 // [java_CircleMapObject_setOutlineColor]
136 // Set outline color
137 boolean outlineColorSuccess = circleMapObject.setOutlineColor(0.0, 0.0, 1.0, 1.0);
138 System.out.println("Set circle outline color to blue: " + outlineColorSuccess);
139 // [java_CircleMapObject_setOutlineColor]
140
141 // [java_CircleMapObject_setOutlineAlpha]
142 // Set outline alpha
143 boolean outlineAlphaSuccess = circleMapObject.setOutlineAlpha(0.5);
144 System.out.println("Set circle outline alpha to 0.5: " + outlineAlphaSuccess);
145 // [java_CircleMapObject_setOutlineAlpha]
146
147 // [java_CircleMapObject_setOutlineRadius]
148 // Set outline radius
149 boolean outlineRadiusSuccess = circleMapObject.setOutlineRadius(2.0);
150 System.out.println("Set circle outline radius to 2.0: " + outlineRadiusSuccess);
151 // [java_CircleMapObject_setOutlineRadius]
152
153 // [java_CircleMapObject_setColor]
154 // Set circle color
155 boolean colorSuccess = circleMapObject.setColor(1.0, 0.0, 0.0, 0.8);
156 System.out.println("Set circle color to red with 80% opacity: " + colorSuccess);
157 // [java_CircleMapObject_setColor]
158
159 // [java_CircleMapObject_setPriority]
160 // Set rendering priority
161 boolean prioritySuccess = circleMapObject.setPriority(1);
162 System.out.println("Set rendering priority to 1: " + prioritySuccess);
163 // [java_CircleMapObject_setPriority]
164
165 // [java_MapObject_setVisible]
166 // Set visibility
167 boolean visibleSuccess = circleMapObject.setVisible(true);
168 System.out.println("Set circle visibility to true: " + visibleSuccess);
169 // [java_MapObject_setVisible]
170
171 // [java_CircleMapObject_getMapObjectType]
172 // Get map object type
173 MapObjectType objectType = circleMapObject.getMapObjectType();
174 System.out.println("Circle map object type: " + objectType);
175 // [java_CircleMapObject_getMapObjectType]
176
177 // [java_MapObject_setAlpha]
178 // Set alpha transparency
179 boolean alphaSuccess = circleMapObject.setAlpha(0.7);
180 System.out.println("Set circle alpha to 0.7: " + alphaSuccess);
181 // [java_MapObject_setAlpha]
182
183 // [java_MapObject_setInteractive]
184 // Set interactive mode
185 boolean interactiveSuccess = circleMapObject.setInteractive(true);
186 System.out.println("Set circle interactive to true: " + interactiveSuccess);
187 // [java_MapObject_setInteractive]
188
189 // [java_MapObject_setTitle]
190 // Set title
191 boolean titleSuccess = circleMapObject.setTitle("Circle Object");
192 System.out.println("Set circle title to 'Circle Object': " + titleSuccess);
193 // [java_MapObject_setTitle]
194
195 // [java_MapObject_setData]
196 // Set custom data
197 Map<String, String> customData = new HashMap<>();
198 customData.put("key", "value");
199 customData.put("number", "42");
200 boolean dataSuccess = circleMapObject.setData(customData);
201 System.out.println("Set circle custom data: " + dataSuccess);
202 // [java_MapObject_setData]
203
204 // [java_MapObject_getId]
205 // Get object ID
206 int objectId = circleMapObject.getId();
207 System.out.println("Circle object ID: " + objectId);
208 // [java_MapObject_getId]
209
210 // [java_MapObject_getType]
211 // Get object type
212 String objectTypeString = circleMapObject.getType();
213 System.out.println("Circle object type: " + objectTypeString);
214 // [java_MapObject_getType]
215
216 // [java_MapObject_getData]
217 // Get custom data
218 Map<String, String> retrievedData = circleMapObject.getData();
219 System.out.println("Circle custom data: " + retrievedData);
220 // [java_MapObject_getData]
221 }
222
223 // [java_LocationWindow_removeCircleMapObject]
224 // Remove circle map object
225 if (circleMapObject != null) {
226 boolean removed = locationWindow.removeCircleMapObject(circleMapObject);
227 System.out.println("Removed circle map object: " + removed);
228 circleMapObject = null;
229 }
230 // [java_LocationWindow_removeCircleMapObject]
231
232 // Test multiple circle objects
233 List<CircleMapObject> circles = new ArrayList<>();
234 for (int i = 0; i < 3; i++) {
235 CircleMapObject circle = locationWindow.addCircleMapObject();
236 if (circle != null) {
237 circle.setPosition(new LocationPoint(50.0 * i, 100.0 * i));
238 circle.setColor(0.0, 1.0, 0.0, 0.6);
239 circle.setRadius(5.0 + i * 2.0);
240 circles.add(circle);
241 System.out.println("Created circle " + i + " at (" + (50.0 * i) + ", " + (100.0 * i) + ") with radius " + (5.0 + i * 2.0));
242 }
243 }
244
245 for (int i = 0; i < circles.size(); i++) {
246 locationWindow.removeCircleMapObject(circles.get(i));
247 System.out.println("Removed circle " + i);
248 }
249 }
250
254 private void demonstrateIconMapObjects() {
255 System.out.println("--- Icon Map Objects ---");
256
257 if (locationWindow == null) {
258 System.out.println("LocationWindow not available yet");
259 return;
260 }
261
262 // [java_IconMapObject_constructor]
263 // Create icon map object
264 LocationPoint position = new LocationPoint(30.0, 40.0);
265 iconMapObject = locationWindow.addIconMapObject();
266 System.out.println("Created icon map object at (" + position.getX() + ", " + position.getY() + ")");
267 // [java_IconMapObject_constructor]
268
269 // [java_IconMapObject_getPosition]
270 // Access icon position
271 LocationPoint iconPosition = iconMapObject.getPosition();
272 System.out.println("Icon position: (" + iconPosition.getX() + ", " + iconPosition.getY() + ")");
273 // [java_IconMapObject_getPosition]
274
275 // [java_LocationWindow_addIconMapObject]
276 // Add icon map object
277 iconMapObject = locationWindow.addIconMapObject();
278 System.out.println("Added icon map object");
279 // [java_LocationWindow_addIconMapObject]
280
281 if (iconMapObject != null) {
282 // [java_IconMapObject_setPosition]
283 // Set icon position
284 LocationPoint iconPoint = new LocationPoint(200.0, 300.0);
285 boolean success = iconMapObject.setPosition(iconPoint);
286 System.out.println("Set icon position to (" + iconPoint.getX() + ", " + iconPoint.getY() + "): " + success);
287 // [java_IconMapObject_setPosition]
288
289 // [java_IconMapObject_setPositionAnimated]
290 // Set icon position with animation
291 LocationPoint animatedIconPoint = new LocationPoint(250.0, 350.0);
292 boolean animatedSuccess = iconMapObject.setPositionAnimated(animatedIconPoint, 1.5, AnimationType.CUBIC);
293 System.out.println("Set icon position with animation to (" + animatedIconPoint.getX() + ", " + animatedIconPoint.getY() + "): " + animatedSuccess);
294 // [java_IconMapObject_setPositionAnimated]
295
296 // [java_IconMapObject_setSize]
297 // Set icon size
298 boolean sizeSuccess = iconMapObject.setSize(32.0, 32.0);
299 System.out.println("Set icon size to 32x32 pixels: " + sizeSuccess);
300 // [java_IconMapObject_setSize]
301
302 // [java_IconMapObject_setAngle]
303 // Set icon rotation angle
304 boolean angleSuccess = iconMapObject.setAngle(45.0);
305 System.out.println("Set icon rotation angle to 45 degrees: " + angleSuccess);
306 // [java_IconMapObject_setAngle]
307
308 // [java_IconMapObject_setAngleAnimated]
309 // Set icon rotation with animation
310 boolean angleAnimatedSuccess = iconMapObject.setAngleAnimated(90.0, 2.0, AnimationType.SINE);
311 System.out.println("Set icon rotation with animation to 90 degrees: " + angleAnimatedSuccess);
312 // [java_IconMapObject_setAngleAnimated]
313
314 // [java_IconMapObject_setCollisionEnabled]
315 // Enable collision detection
316 boolean collisionSuccess = iconMapObject.setCollisionEnabled(true);
317 System.out.println("Enabled collision detection for icon: " + collisionSuccess);
318 // [java_IconMapObject_setCollisionEnabled]
319
320 // [java_IconMapObject_setBuffer]
321 // Set collision buffer
322 boolean bufferSuccess = iconMapObject.setBuffer(10.0, 10.0);
323 System.out.println("Set collision buffer to 10x10 pixels: " + bufferSuccess);
324 // [java_IconMapObject_setBuffer]
325
326 // [java_IconMapObject_setOffset]
327 // Set position offset
328 boolean offsetSuccess = iconMapObject.setOffset(0.0, -16.0);
329 System.out.println("Set position offset to (0.0, -16.0) pixels: " + offsetSuccess);
330 // [java_IconMapObject_setOffset]
331
332 // [java_IconMapObject_setPriority]
333 // Set rendering priority
334 boolean prioritySuccess = iconMapObject.setPriority(2);
335 System.out.println("Set rendering priority to 2: " + prioritySuccess);
336 // [java_IconMapObject_setPriority]
337
338 // [java_IconMapObject_setVisible]
339 // Set visibility
340 boolean visibleSuccess = iconMapObject.setVisible(true);
341 System.out.println("Set icon visibility to true: " + visibleSuccess);
342 // [java_IconMapObject_setVisible]
343
344 // [java_IconMapObject_getMapObjectType]
345 // Get map object type
346 MapObjectType objectType = iconMapObject.getMapObjectType();
347 System.out.println("Icon map object type: " + objectType);
348 // [java_IconMapObject_getMapObjectType]
349
350 // [java_IconMapObject_setIcon]
351 // Set icon image
352 boolean iconSuccess = iconMapObject.setIcon("path/to/icon.png");
353 System.out.println("Set icon image: " + iconSuccess);
354 // [java_IconMapObject_setIcon]
355
356 // [java_IconMapObject_setBitmap]
357 // Set icon bitmap
358 boolean bitmapSuccess = iconMapObject.setBitmap("path/to/bitmap.png");
359 System.out.println("Set icon bitmap: " + bitmapSuccess);
360 // [java_IconMapObject_setBitmap]
361
362 // [java_IconMapObject_setFlat]
363 // Set icon flat mode
364 boolean flatSuccess = iconMapObject.setFlat(true);
365 System.out.println("Set icon flat mode to true: " + flatSuccess);
366 // [java_IconMapObject_setFlat]
367
368 // [java_IconMapObject_setPlacement]
369 // Set icon placement
370 boolean placementSuccess = iconMapObject.setPlacement(Placement.CENTER);
371 System.out.println("Set icon placement to CENTER: " + placementSuccess);
372 // [java_IconMapObject_setPlacement]
373
374 // [java_MapObject_setAlpha_1]
375 // Set alpha transparency
376 boolean alphaSuccess = iconMapObject.setAlpha(0.8);
377 System.out.println("Set icon alpha to 0.8: " + alphaSuccess);
378 // [java_MapObject_setAlpha_1]
379
380 // [java_MapObject_setInteractive_1]
381 // Set interactive mode
382 boolean interactiveSuccess = iconMapObject.setInteractive(true);
383 System.out.println("Set icon interactive to true: " + interactiveSuccess);
384 // [java_MapObject_setInteractive_1]
385
386 // [java_MapObject_setTitle_1]
387 // Set title
388 boolean titleSuccess = iconMapObject.setTitle("Icon Object");
389 System.out.println("Set icon title to 'Icon Object': " + titleSuccess);
390 // [java_MapObject_setTitle_1]
391
392 // [java_MapObject_setData_1]
393 // Set custom data
394 Map<String, Object> customData = new HashMap<>();
395 customData.put("key", "value");
396 customData.put("number", 42);
397 boolean dataSuccess = iconMapObject.setData(customData);
398 System.out.println("Set icon custom data: " + dataSuccess);
399 // [java_MapObject_setData_1]
400
401 // [java_MapObject_getId_1]
402 // Get object ID
403 int objectId = iconMapObject.getId();
404 System.out.println("Icon object ID: " + objectId);
405 // [java_MapObject_getId_1]
406
407 // [java_MapObject_getType_1]
408 // Get object type
409 String objectTypeString = iconMapObject.getType();
410 System.out.println("Icon object type: " + objectTypeString);
411 // [java_MapObject_getType_1]
412
413 // [java_MapObject_getData_1]
414 // Get custom data
415 Map<String, Object> retrievedData = iconMapObject.getData();
416 System.out.println("Icon custom data: " + retrievedData);
417 // [java_MapObject_getData_1]
418 }
419
420 // [java_LocationWindow_removeIconMapObject]
421 // Remove icon map object
422 if (iconMapObject != null) {
423 boolean removed = locationWindow.removeIconMapObject(iconMapObject);
424 System.out.println("Removed icon map object: " + removed);
425 iconMapObject = null;
426 }
427 // [java_LocationWindow_removeIconMapObject]
428
429 // Test multiple icon objects
430 List<IconMapObject> icons = new ArrayList<>();
431 for (int i = 0; i < 3; i++) {
432 IconMapObject icon = locationWindow.addIconMapObject();
433 if (icon != null) {
434 icon.setPosition(new LocationPoint(100.0 * i, 150.0 * i));
435 icon.setSize(24.0, 24.0);
436 icon.setAngle(i * 30.0);
437 icons.add(icon);
438 System.out.println("Created icon " + i + " at (" + (100.0 * i) + ", " + (150.0 * i) + ") with angle " + (i * 30.0));
439 }
440 }
441
442 for (int i = 0; i < icons.size(); i++) {
443 locationWindow.removeIconMapObject(icons.get(i));
444 System.out.println("Removed icon " + i);
445 }
446 }
447
451 private void demonstratePolygonMapObjects() {
452 System.out.println("--- Polygon Map Objects ---");
453
454 if (locationWindow == null) {
455 System.out.println("LocationWindow not available yet");
456 return;
457 }
458
459 // [java_LocationWindow_addPolygonMapObject]
460 // Add polygon map object
461 polygonMapObject = locationWindow.addPolygonMapObject();
462 System.out.println("Added polygon map object");
463 // [java_LocationWindow_addPolygonMapObject]
464
465 if (polygonMapObject != null) {
466 // [java_PolygonMapObject_setPolygon]
467 // Set polygon geometry
468 List<LocationPoint> points = Arrays.asList(
469 new LocationPoint(100.0, 200.0),
470 new LocationPoint(150.0, 250.0),
471 new LocationPoint(200.0, 200.0),
472 new LocationPoint(150.0, 150.0)
473 );
474 LocationPolygon polygon = new LocationPolygon(points);
475 boolean success = polygonMapObject.setPolygon(polygon);
476 System.out.println("Set polygon with " + points.size() + " points: " + success);
477 // [java_PolygonMapObject_setPolygon]
478
479 // [java_PolygonMapObject_setColor]
480 // Set polygon color
481 boolean colorSuccess = polygonMapObject.setColor(0.0, 1.0, 0.0, 0.7);
482 System.out.println("Set polygon color to green with 70% opacity: " + colorSuccess);
483 // [java_PolygonMapObject_setColor]
484
485 // [java_PolygonMapObject_setVisible]
486 // Set visibility
487 boolean visibleSuccess = polygonMapObject.setVisible(true);
488 System.out.println("Set polygon visibility to true: " + visibleSuccess);
489 // [java_PolygonMapObject_setVisible]
490
491 // [java_PolygonMapObject_getMapObjectType]
492 // Get map object type
493 MapObjectType objectType = polygonMapObject.getMapObjectType();
494 System.out.println("Polygon map object type: " + objectType);
495 // [java_PolygonMapObject_getMapObjectType]
496
497 // [java_PolygonMapObject_setOrder]
498 // Set polygon rendering order
499 boolean orderSuccess = polygonMapObject.setOrder(2);
500 System.out.println("Set polygon rendering order to 2: " + orderSuccess);
501 // [java_PolygonMapObject_setOrder]
502
503 // [java_PolygonMapObject_setOutlineColor]
504 // Set polygon outline color
505 boolean outlineColorSuccess = polygonMapObject.setOutlineColor(0.0, 0.0, 1.0, 1.0);
506 System.out.println("Set polygon outline color to blue: " + outlineColorSuccess);
507 // [java_PolygonMapObject_setOutlineColor]
508
509 // [java_PolygonMapObject_setOutlineWidth]
510 // Set polygon outline width
511 boolean outlineWidthSuccess = polygonMapObject.setOutlineWidth(2.0);
512 System.out.println("Set polygon outline width to 2.0 pixels: " + outlineWidthSuccess);
513 // [java_PolygonMapObject_setOutlineWidth]
514
515 // [java_PolygonMapObject_setOutlineAlpha]
516 // Set polygon outline alpha
517 boolean outlineAlphaSuccess = polygonMapObject.setOutlineAlpha(0.8);
518 System.out.println("Set polygon outline alpha to 0.8: " + outlineAlphaSuccess);
519 // [java_PolygonMapObject_setOutlineAlpha]
520
521 // [java_PolygonMapObject_setOutlineOrder]
522 // Set polygon outline order
523 boolean outlineOrderSuccess = polygonMapObject.setOutlineOrder(1);
524 System.out.println("Set polygon outline order to 1: " + outlineOrderSuccess);
525 // [java_PolygonMapObject_setOutlineOrder]
526
527 // [java_MapObject_setAlpha_2]
528 // Set alpha transparency
529 boolean alphaSuccess = polygonMapObject.setAlpha(0.7);
530 System.out.println("Set polygon alpha to 0.7: " + alphaSuccess);
531 // [java_MapObject_setAlpha_2]
532
533 // [java_MapObject_setInteractive_2]
534 // Set interactive mode
535 boolean interactiveSuccess = polygonMapObject.setInteractive(true);
536 System.out.println("Set polygon interactive to true: " + interactiveSuccess);
537 // [java_MapObject_setInteractive_2]
538
539 // [java_MapObject_setTitle_2]
540 // Set title
541 boolean titleSuccess = polygonMapObject.setTitle("Polygon Object");
542 System.out.println("Set polygon title to 'Polygon Object': " + titleSuccess);
543 // [java_MapObject_setTitle_2]
544
545 // [java_MapObject_setData_2]
546 // Set custom data
547 Map<String, Object> customData = new HashMap<>();
548 customData.put("key", "value");
549 customData.put("number", 42);
550 boolean dataSuccess = polygonMapObject.setData(customData);
551 System.out.println("Set polygon custom data: " + dataSuccess);
552 // [java_MapObject_setData_2]
553
554 // [java_MapObject_getId_2]
555 // Get object ID
556 int objectId = polygonMapObject.getId();
557 System.out.println("Polygon object ID: " + objectId);
558 // [java_MapObject_getId_2]
559
560 // [java_MapObject_getType_2]
561 // Get object type
562 String objectTypeString = polygonMapObject.getType();
563 System.out.println("Polygon object type: " + objectTypeString);
564 // [java_MapObject_getType_2]
565
566 // [java_MapObject_getData_2]
567 // Get custom data
568 Map<String, Object> retrievedData = polygonMapObject.getData();
569 System.out.println("Polygon custom data: " + retrievedData);
570 // [java_MapObject_getData_2]
571 }
572
573 // [java_LocationWindow_removePolygonMapObject]
574 // Remove polygon map object
575 if (polygonMapObject != null) {
576 boolean removed = locationWindow.removePolygonMapObject(polygonMapObject);
577 System.out.println("Removed polygon map object: " + removed);
578 polygonMapObject = null;
579 }
580 // [java_LocationWindow_removePolygonMapObject]
581
582 // Test multiple polygon objects
583 List<PolygonMapObject> polygons = new ArrayList<>();
584 for (int i = 0; i < 3; i++) {
585 PolygonMapObject polygon = locationWindow.addPolygonMapObject();
586 if (polygon != null) {
587 List<LocationPoint> points = Arrays.asList(
588 new LocationPoint(300.0 + i * 50, 400.0 + i * 50),
589 new LocationPoint(350.0 + i * 50, 450.0 + i * 50),
590 new LocationPoint(400.0 + i * 50, 400.0 + i * 50),
591 new LocationPoint(350.0 + i * 50, 350.0 + i * 50)
592 );
593 LocationPolygon polygonGeometry = new LocationPolygon(points);
594 polygon.setPolygon(polygonGeometry);
595 polygon.setColor(0.0, 0.0, 1.0, 0.5);
596 polygons.add(polygon);
597 System.out.println("Created polygon " + i + " with " + points.size() + " points");
598 }
599 }
600
601 for (int i = 0; i < polygons.size(); i++) {
602 locationWindow.removePolygonMapObject(polygons.get(i));
603 System.out.println("Removed polygon " + i);
604 }
605 }
606
610 private void demonstratePolylineMapObjects() {
611 System.out.println("--- Polyline Map Objects ---");
612
613 if (locationWindow == null) {
614 System.out.println("LocationWindow not available yet");
615 return;
616 }
617
618 // [java_PolylineMapObject_constructor]
619 // Create polyline map object
620 List<Point> points = new ArrayList<>();
621 points.add(new Point(100.0, 110.0));
622 points.add(new Point(105.0, 115.0));
623 points.add(new Point(110.0, 120.0));
624 points.add(new Point(115.0, 125.0));
625 Polyline polyline = new Polyline(points);
626 LocationPolyline locationPolyline = new LocationPolyline(polyline);
627 polylineMapObject = locationWindow.addPolylineMapObject();
628 System.out.println("Created polyline map object with " + points.size() + " points");
629 // [java_PolylineMapObject_constructor]
630
631 // [java_PolylineMapObject_getPolyline]
632 // Access polyline
633 LocationPolyline polylineShape = polylineMapObject.getPolyLine();
634 System.out.println("Polyline has " + polylineShape.getPoints().size() + " points");
635 // [java_PolylineMapObject_getPolyline]
636
637 // [java_LocationWindow_addPolylineMapObject]
638 // Add polyline map object
639 polylineMapObject = locationWindow.addPolylineMapObject();
640 System.out.println("Added polyline map object");
641 // [java_LocationWindow_addPolylineMapObject]
642
643 if (polylineMapObject != null) {
644 // [java_PolylineMapObject_setPolyLine]
645 // Set polyline geometry
646 List<Point> polylinePoints = new ArrayList<>();
647 polylinePoints.add(new Point(0.0, 0.0));
648 polylinePoints.add(new Point(50.0, 50.0));
649 polylinePoints.add(new Point(100.0, 0.0));
650 polylinePoints.add(new Point(150.0, 50.0));
651 Polyline polyline = new Polyline(polylinePoints);
652 LocationPolyline locationPolyline = new LocationPolyline(polyline);
653 boolean success = polylineMapObject.setPolyLine(locationPolyline);
654 System.out.println("Set polyline geometry: " + success);
655 // [java_PolylineMapObject_setPolyLine]
656
657 // [java_PolylineMapObject_setWidth]
658 // Set polyline width
659 boolean widthSuccess = polylineMapObject.setWidth(3.0);
660 System.out.println("Set polyline width to 3.0 pixels: " + widthSuccess);
661 // [java_PolylineMapObject_setWidth]
662
663 // [java_PolylineMapObject_setColor]
664 // Set polyline color
665 boolean colorSuccess = polylineMapObject.setColor(1.0, 0.5, 0.0, 0.9);
666 System.out.println("Set polyline color to orange with 90% opacity: " + colorSuccess);
667 // [java_PolylineMapObject_setColor]
668
669 // [java_PolylineMapObject_setOrder]
670 // Set rendering order
671 boolean orderSuccess = polylineMapObject.setOrder(2);
672 System.out.println("Set rendering order to 2: " + orderSuccess);
673 // [java_PolylineMapObject_setOrder]
674
675 // [java_PolylineMapObject_setCapType]
676 // Set cap type
677 boolean capSuccess = polylineMapObject.setCapType(CapType.ROUND);
678 System.out.println("Set cap type to ROUND: " + capSuccess);
679 // [java_PolylineMapObject_setCapType]
680
681 // [java_PolylineMapObject_setJoinType]
682 // Set join type
683 boolean joinSuccess = polylineMapObject.setJoinType(JoinType.ROUND);
684 System.out.println("Set join type to ROUND: " + joinSuccess);
685 // [java_PolylineMapObject_setJoinType]
686
687 // [java_PolylineMapObject_setMiterLimit]
688 // Set miter limit
689 boolean miterSuccess = polylineMapObject.setMiterLimit(5.0);
690 System.out.println("Set miter limit to 5.0: " + miterSuccess);
691 // [java_PolylineMapObject_setMiterLimit]
692
693 // [java_PolylineMapObject_setVisible]
694 // Set visibility
695 boolean visibleSuccess = polylineMapObject.setVisible(true);
696 System.out.println("Set polyline visibility to true: " + visibleSuccess);
697 // [java_PolylineMapObject_setVisible]
698
699 // [java_PolylineMapObject_getMapObjectType]
700 // Get map object type
701 MapObjectType objectType = polylineMapObject.getMapObjectType();
702 System.out.println("Polyline map object type: " + objectType);
703 // [java_PolylineMapObject_getMapObjectType]
704
705 // [java_MapObject_setAlpha_3]
706 // Set alpha transparency
707 boolean alphaSuccess = polylineMapObject.setAlpha(0.7);
708 System.out.println("Set polyline alpha to 0.7: " + alphaSuccess);
709 // [java_MapObject_setAlpha_3]
710
711 // [java_MapObject_setInteractive_3]
712 // Set interactive mode
713 boolean interactiveSuccess = polylineMapObject.setInteractive(true);
714 System.out.println("Set polyline interactive to true: " + interactiveSuccess);
715 // [java_MapObject_setInteractive_3]
716
717 // [java_MapObject_setTitle_3]
718 // Set title
719 boolean titleSuccess = polylineMapObject.setTitle("Polyline Object");
720 System.out.println("Set polyline title to 'Polyline Object': " + titleSuccess);
721 // [java_MapObject_setTitle_3]
722
723 // [java_MapObject_setData_3]
724 // Set custom data
725 Map<String, Object> customData = new HashMap<>();
726 customData.put("key", "value");
727 customData.put("number", 42);
728 boolean dataSuccess = polylineMapObject.setData(customData);
729 System.out.println("Set polyline custom data: " + dataSuccess);
730 // [java_MapObject_setData_3]
731
732 // [java_MapObject_getId_3]
733 // Get object ID
734 int objectId = polylineMapObject.getId();
735 System.out.println("Polyline object ID: " + objectId);
736 // [java_MapObject_getId_3]
737
738 // [java_MapObject_getType_3]
739 // Get object type
740 String objectTypeString = polylineMapObject.getType();
741 System.out.println("Polyline object type: " + objectTypeString);
742 // [java_MapObject_getType_3]
743
744 // [java_MapObject_getData_3]
745 // Get custom data
746 Map<String, Object> retrievedData = polylineMapObject.getData();
747 System.out.println("Polyline custom data: " + retrievedData);
748 // [java_MapObject_getData_3]
749
750 // [java_PolylineMapObject_setOutlineWidth]
751 // Set polyline outline width
752 boolean outlineWidthSuccess2 = polylineMapObject.setOutlineWidth(1.0);
753 System.out.println("Set polyline outline width to 1.0 pixels: " + outlineWidthSuccess2);
754 // [java_PolylineMapObject_setOutlineWidth]
755
756 // [java_PolylineMapObject_setOutlineColor]
757 // Set polyline outline color
758 boolean outlineColorSuccess2 = polylineMapObject.setOutlineColor(0.0, 0.0, 0.0, 1.0);
759 System.out.println("Set polyline outline color to black: " + outlineColorSuccess2);
760 // [java_PolylineMapObject_setOutlineColor]
761
762 // [java_PolylineMapObject_setOutlineAlpha]
763 // Set polyline outline alpha
764 boolean outlineAlphaSuccess2 = polylineMapObject.setOutlineAlpha(0.5);
765 System.out.println("Set polyline outline alpha to 0.5: " + outlineAlphaSuccess2);
766 // [java_PolylineMapObject_setOutlineAlpha]
767
768 // [java_PolylineMapObject_setOutlineOrder]
769 // Set polyline outline rendering order
770 boolean outlineOrderSuccess2 = polylineMapObject.setOutlineOrder(0);
771 System.out.println("Set polyline outline rendering order to 0: " + outlineOrderSuccess2);
772 // [java_PolylineMapObject_setOutlineOrder]
773
774 // [java_PolylineMapObject_setOutlineCapType]
775 // Set polyline outline cap type
776 boolean outlineCapTypeSuccess2 = polylineMapObject.setOutlineCapType(CapType.SQUARE);
777 System.out.println("Set polyline outline cap type to SQUARE: " + outlineCapTypeSuccess2);
778 // [java_PolylineMapObject_setOutlineCapType]
779
780 // [java_PolylineMapObject_setOutlineJoinType]
781 // Set polyline outline join type
782 boolean outlineJoinTypeSuccess2 = polylineMapObject.setOutlineJoinType(JoinType.MITER);
783 System.out.println("Set polyline outline join type to MITER: " + outlineJoinTypeSuccess2);
784 // [java_PolylineMapObject_setOutlineJoinType]
785
786 // [java_PolylineMapObject_setOutlineMiterLimit]
787 // Set polyline outline miter limit
788 boolean outlineMiterLimitSuccess2 = polylineMapObject.setOutlineMiterLimit(3.0);
789 System.out.println("Set polyline outline miter limit to 3.0: " + outlineMiterLimitSuccess2);
790 // [java_PolylineMapObject_setOutlineMiterLimit]
791 }
792
793 // [java_LocationWindow_removePolylineMapObject]
794 // Remove polyline map object
795 if (polylineMapObject != null) {
796 boolean removed = locationWindow.removePolylineMapObject(polylineMapObject);
797 System.out.println("Removed polyline map object: " + removed);
798 polylineMapObject = null;
799 }
800 // [java_LocationWindow_removePolylineMapObject]
801
802 // Test multiple polyline objects
803 List<PolylineMapObject> polylines = new ArrayList<>();
804 for (int i = 0; i < 3; i++) {
805 PolylineMapObject polyline = locationWindow.addPolylineMapObject();
806 if (polyline != null) {
807 List<Point> points = new ArrayList<>();
808 points.add(new Point(i * 30.0, i * 30.0));
809 points.add(new Point((i + 1) * 30.0, (i + 1) * 30.0));
810 Polyline poly = new Polyline(points);
811 LocationPolyline locPoly = new LocationPolyline(poly);
812 polyline.setPolyLine(locPoly);
813 polyline.setWidth(2.0 + i);
814 polyline.setColor(0.0, 1.0, 1.0, 0.8);
815 polylines.add(polyline);
816 System.out.println("Created polyline " + i + " with width " + (2.0 + i));
817 }
818 }
819
820 for (int i = 0; i < polylines.size(); i++) {
821 locationWindow.removePolylineMapObject(polylines.get(i));
822 System.out.println("Removed polyline " + i);
823 }
824 }
825
829 private void demonstrateDottedPolylineMapObjects() {
830 System.out.println("--- Dotted Polyline Map Objects ---");
831
832 if (locationWindow == null) {
833 System.out.println("LocationWindow not available yet");
834 return;
835 }
836
837 // [java_DottedPolylineMapObject_constructor]
838 // Create dotted polyline map object
839 List<Point> points = new ArrayList<>();
840 points.add(new Point(160.0, 170.0));
841 points.add(new Point(165.0, 175.0));
842 points.add(new Point(170.0, 180.0));
843 points.add(new Point(175.0, 185.0));
844 Polyline polyline = new Polyline(points);
845 LocationPolyline locationPolyline = new LocationPolyline(polyline);
846 dottedPolylineMapObject = locationWindow.addDottedPolylineMapObject();
847 System.out.println("Created dotted polyline map object with " + points.size() + " points");
848 // [java_DottedPolylineMapObject_constructor]
849
850 // [java_DottedPolylineMapObject_getPolyline]
851 // Access dotted polyline
852 LocationPolyline dottedPolylineShape = dottedPolylineMapObject.getPolyLine();
853 System.out.println("Dotted polyline has " + dottedPolylineShape.getPoints().size() + " points");
854 // [java_DottedPolylineMapObject_getPolyline]
855
856 // [java_LocationWindow_addDottedPolylineMapObject]
857 // Add dotted polyline map object
858 dottedPolylineMapObject = locationWindow.addDottedPolylineMapObject();
859 System.out.println("Added dotted polyline map object");
860 // [java_LocationWindow_addDottedPolylineMapObject]
861
862 if (dottedPolylineMapObject != null) {
863 // [java_DottedPolylineMapObject_setPolyline]
864 // Set dotted polyline geometry
865 List<Point> dottedPoints = new ArrayList<>();
866 dottedPoints.add(new Point(0.0, 100.0));
867 dottedPoints.add(new Point(50.0, 150.0));
868 dottedPoints.add(new Point(100.0, 100.0));
869 dottedPoints.add(new Point(150.0, 150.0));
870 Polyline dottedPolyline = new Polyline(dottedPoints);
871 LocationPolyline locationDottedPolyline = new LocationPolyline(dottedPolyline);
872 boolean success = dottedPolylineMapObject.setPolyLine(locationDottedPolyline);
873 System.out.println("Set dotted polyline geometry: " + success);
874 // [java_DottedPolylineMapObject_setPolyline]
875
876 // [java_DottedPolylineMapObject_setWidth]
877 // Set dotted polyline width
878 boolean widthSuccess = dottedPolylineMapObject.setWidth(2.0);
879 System.out.println("Set dotted polyline width to 2.0 pixels: " + widthSuccess);
880 // [java_DottedPolylineMapObject_setWidth]
881
882 // [java_DottedPolylineMapObject_setColor]
883 // Set dotted polyline color
884 boolean colorSuccess = dottedPolylineMapObject.setColor(0.5, 0.0, 1.0, 0.8);
885 System.out.println("Set dotted polyline color to purple with 80% opacity: " + colorSuccess);
886 // [java_DottedPolylineMapObject_setColor]
887
888 // [java_DottedPolylineMapObject_setOrder]
889 // Set rendering order
890 boolean orderSuccess = dottedPolylineMapObject.setOrder(3);
891 System.out.println("Set rendering order to 3: " + orderSuccess);
892 // [java_DottedPolylineMapObject_setOrder]
893
894 // [java_DottedPolylineMapObject_setVisible]
895 // Set visibility
896 boolean visibleSuccess = dottedPolylineMapObject.setVisible(true);
897 System.out.println("Set dotted polyline visibility to true: " + visibleSuccess);
898 // [java_DottedPolylineMapObject_setVisible]
899
900 // [java_DottedPolylineMapObject_getMapObjectType]
901 // Get map object type
902 MapObjectType objectType = dottedPolylineMapObject.getMapObjectType();
903 System.out.println("Dotted polyline map object type: " + objectType);
904 // [java_DottedPolylineMapObject_getMapObjectType]
905
906 // [java_MapObject_setAlpha_4]
907 // Set alpha transparency
908 boolean alphaSuccess = dottedPolylineMapObject.setAlpha(0.8);
909 System.out.println("Set dotted polyline alpha to 0.8: " + alphaSuccess);
910 // [java_MapObject_setAlpha_4]
911
912 // [java_MapObject_setInteractive_4]
913 // Set interactive mode
914 boolean interactiveSuccess = dottedPolylineMapObject.setInteractive(true);
915 System.out.println("Set dotted polyline interactive to true: " + interactiveSuccess);
916 // [java_MapObject_setInteractive_4]
917
918 // [java_MapObject_setTitle_4]
919 // Set title
920 boolean titleSuccess = dottedPolylineMapObject.setTitle("Dotted Polyline Object");
921 System.out.println("Set dotted polyline title to 'Dotted Polyline Object': " + titleSuccess);
922 // [java_MapObject_setTitle_4]
923
924 // [java_MapObject_setData_4]
925 // Set custom data
926 Map<String, Object> customData = new HashMap<>();
927 customData.put("key", "value");
928 customData.put("number", 42);
929 boolean dataSuccess = dottedPolylineMapObject.setData(customData);
930 System.out.println("Set dotted polyline custom data: " + dataSuccess);
931 // [java_MapObject_setData_4]
932
933 // [java_MapObject_getId_4]
934 // Get object ID
935 int objectId = dottedPolylineMapObject.getId();
936 System.out.println("Dotted polyline object ID: " + objectId);
937 // [java_MapObject_getId_4]
938
939 // [java_MapObject_getType_4]
940 // Get object type
941 String objectTypeString = dottedPolylineMapObject.getType();
942 System.out.println("Dotted polyline object type: " + objectTypeString);
943 // [java_MapObject_getType_4]
944
945 // [java_MapObject_getData_4]
946 // Get custom data
947 Map<String, Object> retrievedData = dottedPolylineMapObject.getData();
948 System.out.println("Dotted polyline custom data: " + retrievedData);
949 // [java_MapObject_getData_4]
950
951 // [java_DottedPolylineMapObject_setCollisionEnabled]
952 // Enable collision detection
953 boolean dottedCollisionSuccess = dottedPolylineMapObject.setCollisionEnabled(true);
954 System.out.println("Enabled collision detection for dotted polyline: " + dottedCollisionSuccess);
955 // [java_DottedPolylineMapObject_setCollisionEnabled]
956
957 // [java_DottedPolylineMapObject_setPlacement]
958 // Set placement type
959 boolean dottedPlacementSuccess = dottedPolylineMapObject.setPlacement(Placement.CENTER);
960 System.out.println("Set dotted polyline placement to CENTER: " + dottedPlacementSuccess);
961 // [java_DottedPolylineMapObject_setPlacement]
962
963 // [java_DottedPolylineMapObject_setPlacementMinRatio]
964 // Set placement min ratio
965 boolean dottedMinRatioSuccess = dottedPolylineMapObject.setPlacementMinRatio(0.5);
966 System.out.println("Set dotted polyline placement min ratio to 0.5: " + dottedMinRatioSuccess);
967 // [java_DottedPolylineMapObject_setPlacementMinRatio]
968
969 // [java_DottedPolylineMapObject_setPlacementSpacing]
970 // Set placement spacing
971 boolean dottedSpacingSuccess = dottedPolylineMapObject.setPlacementSpacing(10.0);
972 System.out.println("Set dotted polyline placement spacing to 10.0: " + dottedSpacingSuccess);
973 // [java_DottedPolylineMapObject_setPlacementSpacing]
974
975 // [java_DottedPolylineMapObject_setPriority]
976 // Set rendering priority
977 boolean dottedPrioritySuccess = dottedPolylineMapObject.setPriority(1);
978 System.out.println("Set dotted polyline rendering priority to 1: " + dottedPrioritySuccess);
979 // [java_DottedPolylineMapObject_setPriority]
980
981 // [java_DottedPolylineMapObject_setRepeatDistance]
982 // Set repeat distance
983 boolean dottedRepeatDistanceSuccess = dottedPolylineMapObject.setRepeatDistance(20.0);
984 System.out.println("Set dotted polyline repeat distance to 20.0: " + dottedRepeatDistanceSuccess);
985 // [java_DottedPolylineMapObject_setRepeatDistance]
986
987 // [java_DottedPolylineMapObject_setRepeatGroup]
988 // Set repeat group
989 boolean dottedRepeatGroupSuccess = dottedPolylineMapObject.setRepeatGroup(1);
990 System.out.println("Set dotted polyline repeat group to 1: " + dottedRepeatGroupSuccess);
991 // [java_DottedPolylineMapObject_setRepeatGroup]
992
993 // [java_DottedPolylineMapObject_setSize]
994 // Set size
995 Size dottedSize = new Size(16.0, 16.0);
996 boolean dottedSizeSuccess = dottedPolylineMapObject.setSize(dottedSize);
997 System.out.println("Set dotted polyline size to (" + dottedSize.getWidth() + ", " + dottedSize.getHeight() + "): " + dottedSizeSuccess);
998 // [java_DottedPolylineMapObject_setSize]
999 }
1000
1001 // [java_LocationWindow_removeDottedPolylineMapObject]
1002 // Remove dotted polyline map object
1003 if (dottedPolylineMapObject != null) {
1004 boolean removed = locationWindow.removeDottedPolylineMapObject(dottedPolylineMapObject);
1005 System.out.println("Removed dotted polyline map object: " + removed);
1006 dottedPolylineMapObject = null;
1007 }
1008 // [java_LocationWindow_removeDottedPolylineMapObject]
1009
1010 // Test multiple dotted polyline objects
1011 List<DottedPolylineMapObject> dottedPolylines = new ArrayList<>();
1012 for (int i = 0; i < 2; i++) {
1013 DottedPolylineMapObject dottedPolyline = locationWindow.addDottedPolylineMapObject();
1014 if (dottedPolyline != null) {
1015 List<Point> points = new ArrayList<>();
1016 points.add(new Point(i * 40.0, i * 40.0 + 100.0));
1017 points.add(new Point((i + 1) * 40.0, (i + 1) * 40.0 + 100.0));
1018 Polyline poly = new Polyline(points);
1019 LocationPolyline locPoly = new LocationPolyline(poly);
1020 dottedPolyline.setPolyLine(locPoly);
1021 dottedPolyline.setWidth(1.5);
1022 dottedPolyline.setColor(1.0, 0.0, 1.0, 0.6);
1023 dottedPolylines.add(dottedPolyline);
1024 System.out.println("Created dotted polyline " + i);
1025 }
1026 }
1027
1028 for (int i = 0; i < dottedPolylines.size(); i++) {
1029 locationWindow.removeDottedPolylineMapObject(dottedPolylines.get(i));
1030 System.out.println("Removed dotted polyline " + i);
1031 }
1032 }
1033
1037 private void demonstrateRemoveAllMapObjects() {
1038 System.out.println("--- Remove All Map Objects ---");
1039
1040 if (locationWindow == null) {
1041 System.out.println("LocationWindow not available yet");
1042 return;
1043 }
1044
1045 // Create various map objects
1046 CircleMapObject circle = locationWindow.addCircleMapObject();
1047 IconMapObject icon = locationWindow.addIconMapObject();
1048 PolygonMapObject polygon = locationWindow.addPolygonMapObject();
1049 PolylineMapObject polyline = locationWindow.addPolylineMapObject();
1050 DottedPolylineMapObject dottedPolyline = locationWindow.addDottedPolylineMapObject();
1051
1052 System.out.println("Created 5 map objects");
1053
1054 // [java_LocationWindow_removeAllMapObjects]
1055 // Remove all map objects
1056 locationWindow.removeAllMapObjects();
1057 System.out.println("Removed all map objects");
1058 // [java_LocationWindow_removeAllMapObjects]
1059 }
1060
1064 public void cleanup() {
1065 if (circleMapObject != null) {
1066 locationWindow.removeCircleMapObject(circleMapObject);
1067 circleMapObject = null;
1068 }
1069 if (iconMapObject != null) {
1070 locationWindow.removeIconMapObject(iconMapObject);
1071 iconMapObject = null;
1072 }
1073 if (polygonMapObject != null) {
1074 // Polygon objects are removed automatically when LocationWindow is destroyed
1075 polygonMapObject = null;
1076 }
1077 if (polylineMapObject != null) {
1078 locationWindow.removePolylineMapObject(polylineMapObject);
1079 polylineMapObject = null;
1080 }
1081 if (dottedPolylineMapObject != null) {
1082 locationWindow.removeDottedPolylineMapObject(dottedPolylineMapObject);
1083 dottedPolylineMapObject = null;
1084 }
1085 System.out.println("LocationWindowMapObjects example cleanup completed");
1086 }
1087}
1088
1089// Main class
1090class Main {
1091 public static void main(String[] args) {
1093 }
1094}