1package com.navigine.examples
3import com.navigine.idl.kotlin.LocationWindow
4import com.navigine.idl.kotlin.InputListener
5import com.navigine.idl.kotlin.PickListener
6import com.navigine.idl.kotlin.MapObjectPickResult
7import com.navigine.idl.kotlin.LocationPoint
8import com.navigine.idl.kotlin.MapObject
9import com.navigine.idl.kotlin.Point
12 * LocationWindowInteraction usage example for Kotlin
13 * Demonstrates specific methods: stickToBorder, rotateGestureEnabled, tiltGesturesEnabled,
14 * scrollGesturesEnabled, zoomGesturesEnabled, pickRadius, pickMapObjectAt, pickMapFeatureAt,
15 * addPickListener, addInputListener, removeInputListener
17class LocationWindowInteractionExample {
18 private var locationWindow: LocationWindow? = null
19 private var inputListener: InputListener? = null
20 private var pickListener: PickListener? = null
23 demonstrateLocationWindowInteractionMethods()
27 * Demonstrate LocationWindowInteraction methods
29 private fun demonstrateLocationWindowInteractionMethods() {
30 println("=== LocationWindowInteraction Example ===")
32 demonstrateGestureProperties()
33 demonstratePickProperties()
34 demonstratePickMethods()
35 demonstrateInputListeners()
36 demonstratePickListeners()
41 * Demonstrate gesture properties
43 private fun demonstrateGestureProperties() {
44 println("--- Gesture Properties ---")
46 if (locationWindow == null) {
47 println("LocationWindow not available yet")
51 // [kotlin_LocationWindow_setStickToBorder]
52 // Set stick to border property
53 locationWindow!!.stickToBorder = true
54 println("Set stick to border to true")
55 // [kotlin_LocationWindow_setStickToBorder]
57 // [kotlin_LocationWindow_setRotateGestureEnabled]
58 // Set rotate gesture enabled
59 locationWindow!!.rotateGestureEnabled = true
60 println("Set rotate gesture enabled to true")
61 // [kotlin_LocationWindow_setRotateGestureEnabled]
63 // [kotlin_LocationWindow_setTiltGesturesEnabled]
64 // Set tilt gestures enabled
65 locationWindow!!.tiltGesturesEnabled = true
66 println("Set tilt gestures enabled to true")
67 // [kotlin_LocationWindow_setTiltGesturesEnabled]
69 // [kotlin_LocationWindow_setScrollGesturesEnabled]
70 // Set scroll gestures enabled
71 locationWindow!!.scrollGesturesEnabled = true
72 println("Set scroll gestures enabled to true")
73 // [kotlin_LocationWindow_setScrollGesturesEnabled]
75 // [kotlin_LocationWindow_setZoomGesturesEnabled]
76 // Set zoom gestures enabled
77 locationWindow!!.zoomGesturesEnabled = true
78 println("Set zoom gestures enabled to true")
79 // [kotlin_LocationWindow_setZoomGesturesEnabled]
81 // Test different gesture combinations
82 val gestureTests = listOf(
83 listOf(true, true, true, true, true),
84 listOf(false, true, true, true, false),
85 listOf(true, false, true, false, true),
86 listOf(false, false, false, false, false),
89 gestureTests.forEachIndexed { i, test ->
96 locationWindow!!.rotateGestureEnabled = rotate
97 locationWindow!!.tiltGesturesEnabled = tilt
98 locationWindow!!.scrollGesturesEnabled = scroll
99 locationWindow!!.zoomGesturesEnabled = zoom
100 locationWindow!!.stickToBorder = stick
101 println("Gesture test $i: Rotate=$rotate, Tilt=$tilt, Scroll=$scroll, Zoom=$zoom, Stick=$stick")
106 * Demonstrate pick properties
108 private fun demonstratePickProperties() {
109 println("--- Pick Properties ---")
111 if (locationWindow == null) {
112 println("LocationWindow not available yet")
116 // [kotlin_LocationWindow_setPickRadius]
118 locationWindow!!.pickRadius = 10.0
119 println("Set pick radius to 10.0 pixels")
120 // [kotlin_LocationWindow_setPickRadius]
122 // Test different pick radius values
123 val pickRadiusTests = listOf(5.0, 10.0, 20.0, 50.0, 100.0)
125 pickRadiusTests.forEachIndexed { i, radius ->
126 locationWindow!!.pickRadius = radius
127 println("Pick radius test $i: $radius pixels")
132 * Demonstrate pick methods
134 private fun demonstratePickMethods() {
135 println("--- Pick Methods ---")
137 if (locationWindow == null) {
138 println("LocationWindow not available yet")
142 // [kotlin_LocationWindow_pickMapObjectAt]
143 // Pick map object at screen position
144 val screenPoint = Point(100.0, 200.0)
145 locationWindow!!.pickMapObjectAt(screenPoint)
146 println("Picked map object at screen position (${screenPoint.x}, ${screenPoint.y})")
147 // [kotlin_LocationWindow_pickMapObjectAt]
149 // [kotlin_LocationWindow_pickMapFeatureAt]
150 // Pick map feature at screen position
151 val featurePoint = Point(150.0, 250.0)
152 locationWindow!!.pickMapFeatureAt(featurePoint)
153 println("Picked map feature at screen position (${featurePoint.x}, ${featurePoint.y})")
154 // [kotlin_LocationWindow_pickMapFeatureAt]
156 // Test pick at different positions
157 val pickTests = listOf(
164 pickTests.forEachIndexed { i, point ->
165 locationWindow!!.pickMapObjectAt(point)
166 locationWindow!!.pickMapFeatureAt(point)
167 println("Pick test $i: Object and feature at (${point.x}, ${point.y})")
172 * Demonstrate input listeners
174 private fun demonstrateInputListeners() {
175 println("--- Input Listeners ---")
177 if (locationWindow == null) {
178 println("LocationWindow not available yet")
182 // [kotlin_LocationWindow_addInputListener]
183 // Add input listener
184 inputListener = InputListenerImpl()
185 locationWindow!!.addInputListener(inputListener!!)
186 println("Added input listener")
187 // [kotlin_LocationWindow_addInputListener]
189 // [kotlin_LocationWindow_removeInputListener]
190 // Remove input listener
191 locationWindow!!.removeInputListener(inputListener!!)
193 println("Removed input listener")
194 // [kotlin_LocationWindow_removeInputListener]
196 // Test multiple listeners
197 val listeners = listOf(
203 listeners.forEachIndexed { i, listener ->
204 locationWindow!!.addInputListener(listener)
205 println("Added input listener $i")
208 listeners.forEachIndexed { i, listener ->
209 locationWindow!!.removeInputListener(listener)
210 println("Removed input listener $i")
215 * Demonstrate pick listeners
217 private fun demonstratePickListeners() {
218 println("--- Pick Listeners ---")
220 if (locationWindow == null) {
221 println("LocationWindow not available yet")
225 // [kotlin_LocationWindow_addPickListener]
227 pickListener = PickListenerImpl()
228 locationWindow!!.addPickListener(pickListener!!)
229 println("Added pick listener")
230 // [kotlin_LocationWindow_addPickListener]
232 // Test multiple pick listeners
233 val listeners = listOf(
239 listeners.forEachIndexed { i, listener ->
240 locationWindow!!.addPickListener(listener)
241 println("Added pick listener $i")
244 listeners.forEachIndexed { i, listener ->
245 // [kotlin_LocationWindow_removePickListener]
246 locationWindow!!.removePickListener(listener)
247 println("Removed pick listener $i")
248 // [kotlin_LocationWindow_removePickListener]
255 private fun cleanup() {
256 if (inputListener != null) {
257 locationWindow?.removeInputListener(inputListener!!)
260 if (pickListener != null) {
261 locationWindow?.removePickListener(pickListener!!)
264 println("LocationWindowInteraction example cleanup completed")
268// Input listener implementation
269class InputListenerImpl : InputListener {
270 // [kotlin_InputListener_onViewTap]
271 override fun onViewTap(screenPoint: Point) {
272 println("View tapped at screen position (${screenPoint.x}, ${screenPoint.y})")
274 // [kotlin_InputListener_onViewTap]
276 // [kotlin_InputListener_onViewDoubleTap]
277 override fun onViewDoubleTap(screenPoint: Point) {
278 println("View double tapped at screen position (${screenPoint.x}, ${screenPoint.y})")
280 // [kotlin_InputListener_onViewDoubleTap]
282 // [kotlin_InputListener_onViewLongTap]
283 override fun onViewLongTap(screenPoint: Point) {
284 println("View long tapped at screen position (${screenPoint.x}, ${screenPoint.y})")
286 // [kotlin_InputListener_onViewLongTap]
289// Pick listener implementation
290class PickListenerImpl : PickListener {
291 // [kotlin_PickListener_onMapObjectPickComplete]
292 override fun onMapObjectPickComplete(mapObjectPickResult: MapObjectPickResult?, screenPosition: Point) {
293 if (mapObjectPickResult != null) {
294 // [kotlin_MapObjectPickResult_getPoint]
295 val point = mapObjectPickResult.point
296 println("Map object picked at screen position (${screenPosition.x}, ${screenPosition.y})")
297 println(" Object location: (${point.x}, ${point.y})")
298 // [kotlin_MapObjectPickResult_getPoint]
300 // [kotlin_MapObjectPickResult_getMapObject]
301 val mapObject = mapObjectPickResult.mapObject
302 println(" Object type: ${mapObject::class.simpleName}")
303 // [kotlin_MapObjectPickResult_getMapObject]
305 println("No map object found at screen position (${screenPosition.x}, ${screenPosition.y})")
308 // [kotlin_PickListener_onMapObjectPickComplete]
310 // [kotlin_PickListener_onMapFeaturePickComplete]
311 override fun onMapFeaturePickComplete(mapFeaturePickResult: Map<String, String>?, screenPosition: Point) {
312 if (mapFeaturePickResult != null) {
313 println("Map feature picked at screen position (${screenPosition.x}, ${screenPosition.y})")
314 println(" Feature properties: $mapFeaturePickResult")
316 println("No map feature found at screen position (${screenPosition.x}, ${screenPosition.y})")
319 // [kotlin_PickListener_onMapFeaturePickComplete]
324 LocationWindowInteractionExample()