1import kotlinx.coroutines.delay
2import kotlinx.coroutines.runBlocking
5 * LocationWindowCommon usage example for Kotlin
6 * Demonstrates specific methods: setSublocationId, screenPositionToMeters, metersToScreenPosition,
7 * selectMapFeature, deselectMapFeature, deselectAllMapFeatures, selectedMapFeatures,
8 * zoomFactor, minZoomFactor, maxZoomFactor
10class LocationWindowCommonExample {
12 private var locationWindow: LocationWindow? = null
15 demonstrateLocationWindowCommonMethods()
19 * Demonstrate LocationWindowCommon methods
21 fun demonstrateLocationWindowCommonMethods() {
22 println("=== LocationWindowCommon Methods ===")
24 demonstrateSetSublocationId()
25 demonstrateCoordinateConversion()
26 demonstrateMapFeatureSelection()
27 demonstrateZoomProperties()
31 * Demonstrate setSublocationId method
33 fun demonstrateSetSublocationId() {
34 println("--- setSublocationId Method ---")
36 if (locationWindow == null) {
37 println("LocationWindow not available yet")
41 // [kotlin_LocationWindow_setSublocationId]
42 // Set sublocation ID to switch between floors
43 locationWindow!!.setSublocationId(1)
44 println("Set sublocation ID to 1 (first floor)")
45 // [kotlin_LocationWindow_setSublocationId]
47 // [kotlin_LocationWindow_setSublocationId_2]
48 // Set sublocation ID to another floor
49 locationWindow!!.setSublocationId(2)
50 println("Set sublocation ID to 2 (second floor)")
51 // [kotlin_LocationWindow_setSublocationId_2]
53 // [kotlin_LocationWindow_setSublocationId_3]
54 // Set sublocation ID to ground floor
55 locationWindow!!.setSublocationId(0)
56 println("Set sublocation ID to 0 (ground floor)")
57 // [kotlin_LocationWindow_setSublocationId_3]
59 // Test with different sublocation IDs
60 val sublocationIds = listOf(1, 2, 3, 0, 5)
61 for (id in sublocationIds) {
62 locationWindow!!.setSublocationId(id)
63 println("Switched to sublocation ID: $id")
68 * Demonstrate coordinate conversion methods
70 fun demonstrateCoordinateConversion() {
71 println("--- Coordinate Conversion Methods ---")
73 if (locationWindow == null) {
74 println("LocationWindow not available yet")
78 // [kotlin_LocationWindow_screenPositionToMeters]
79 // Convert screen position to meters
80 val screenPoint = Point(100.0, 200.0)
81 val metersPoint = locationWindow!!.screenPositionToMeters(screenPoint)
82 println("Screen position (${screenPoint.x}, ${screenPoint.y}) converted to meters: (${metersPoint.x}, ${metersPoint.y})")
83 // [kotlin_LocationWindow_screenPositionToMeters]
85 // [kotlin_LocationWindow_screenPositionToMeters_2]
86 // Convert another screen position to meters
87 val screenPoint2 = Point(500.0, 300.0)
88 val metersPoint2 = locationWindow!!.screenPositionToMeters(screenPoint2)
89 println("Screen position (${screenPoint2.x}, ${screenPoint2.y}) converted to meters: (${metersPoint2.x}, ${metersPoint2.y})")
90 // [kotlin_LocationWindow_screenPositionToMeters_2]
92 // [kotlin_LocationWindow_metersToScreenPosition]
93 // Convert meters to screen position with clipping
94 val metersPoint3 = Point(50.0, 75.0)
95 val screenPoint3 = locationWindow!!.metersToScreenPosition(metersPoint3, true)
96 println("Meters position (${metersPoint3.x}, ${metersPoint3.y}) converted to screen with clipping: (${screenPoint3.x}, ${screenPoint3.y})")
97 // [kotlin_LocationWindow_metersToScreenPosition]
99 // [kotlin_LocationWindow_metersToScreenPosition_2]
100 // Convert meters to screen position without clipping
101 val metersPoint4 = Point(150.0, 200.0)
102 val screenPoint4 = locationWindow!!.metersToScreenPosition(metersPoint4, false)
103 println("Meters position (${metersPoint4.x}, ${metersPoint4.y}) converted to screen without clipping: (${screenPoint4.x}, ${screenPoint4.y})")
104 // [kotlin_LocationWindow_metersToScreenPosition_2]
106 // Test coordinate conversion with different values
107 val testScreenPoints = listOf(
113 for ((index, screenPoint) in testScreenPoints.withIndex()) {
114 val metersPoint = locationWindow!!.screenPositionToMeters(screenPoint)
115 val backToScreen = locationWindow!!.metersToScreenPosition(metersPoint, false)
116 println("Test $index: Screen (${screenPoint.x}, ${screenPoint.y}) -> Meters (${metersPoint.x}, ${metersPoint.y}) -> Screen (${backToScreen.x}, ${backToScreen.y})")
121 * Demonstrate map feature selection methods
123 fun demonstrateMapFeatureSelection() {
124 println("--- Map Feature Selection Methods ---")
126 if (locationWindow == null) {
127 println("LocationWindow not available yet")
131 // [kotlin_LocationWindow_selectMapFeature]
132 // Select map feature by ID
133 val featureId = "room_101"
134 val selected = locationWindow!!.selectMapFeature(featureId)
135 println("Selected map feature $featureId: $selected")
136 // [kotlin_LocationWindow_selectMapFeature]
138 // [kotlin_LocationWindow_selectMapFeature_2]
139 // Select another map feature
140 val featureId2 = "office_205"
141 val selected2 = locationWindow!!.selectMapFeature(featureId2)
142 println("Selected map feature $featureId2: $selected2")
143 // [kotlin_LocationWindow_selectMapFeature_2]
145 // [kotlin_LocationWindow_getSelectedMapFeatures]
146 // Get list of selected map features
147 val selectedFeatures = locationWindow!!.selectedMapFeatures
148 println("Currently selected map features: ${selectedFeatures.size} features")
149 for (feature in selectedFeatures) {
150 println(" - $feature")
152 // [kotlin_LocationWindow_getSelectedMapFeatures]
154 // [kotlin_LocationWindow_deselectMapFeature]
155 // Deselect specific map feature
156 val deselected = locationWindow!!.deselectMapFeature(featureId)
157 println("Deselected map feature $featureId: $deselected")
158 // [kotlin_LocationWindow_deselectMapFeature]
160 // [kotlin_LocationWindow_deselectMapFeature_2]
161 // Deselect another map feature
162 val deselected2 = locationWindow!!.deselectMapFeature(featureId2)
163 println("Deselected map feature $featureId2: $deselected2")
164 // [kotlin_LocationWindow_deselectMapFeature_2]
166 // [kotlin_LocationWindow_deselectAllMapFeatures]
167 // Deselect all map features
168 locationWindow!!.deselectAllMapFeatures()
169 println("Deselected all map features")
170 // [kotlin_LocationWindow_deselectAllMapFeatures]
172 // [kotlin_LocationWindow_getSelectedMapFeatures_2]
173 // Verify all features are deselected
174 val remainingFeatures = locationWindow!!.selectedMapFeatures
175 println("Remaining selected features after deselect all: ${remainingFeatures.size} features")
176 // [kotlin_LocationWindow_getSelectedMapFeatures_2]
178 // Test multiple feature selection and deselection
179 val testFeatureIds = listOf("room_101", "office_205", "meeting_room_301", "cafe_401")
181 // Select multiple features
182 for (featureId in testFeatureIds) {
183 val success = locationWindow!!.selectMapFeature(featureId)
184 println("Selected feature $featureId: $success")
187 // Check selected features
188 val allSelected = locationWindow!!.selectedMapFeatures
189 println("All selected features: ${allSelected.size} features")
191 // Deselect all at once
192 locationWindow!!.deselectAllMapFeatures()
193 println("Deselected all features at once")
197 * Demonstrate zoom properties
199 fun demonstrateZoomProperties() {
200 println("--- Zoom Properties ---")
202 if (locationWindow == null) {
203 println("LocationWindow not available yet")
207 // [kotlin_LocationWindow_getZoomFactor]
208 // Get current zoom factor
209 val currentZoom = locationWindow!!.zoomFactor
210 println("Current zoom factor: $currentZoom")
211 // [kotlin_LocationWindow_getZoomFactor]
213 // [kotlin_LocationWindow_setZoomFactor]
215 locationWindow!!.zoomFactor = 150.0
216 println("Set zoom factor to 150.0")
217 // [kotlin_LocationWindow_setZoomFactor]
219 // [kotlin_LocationWindow_getMinZoomFactor]
220 // Get minimum zoom factor
221 val minZoomFactor = locationWindow!!.minZoomFactor
222 println("Minimum zoom factor: $minZoomFactor")
223 // [kotlin_LocationWindow_getMinZoomFactor]
225 // [kotlin_LocationWindow_setMinZoomFactor]
226 // Set minimum zoom factor
227 locationWindow!!.minZoomFactor = 50.0
228 println("Set minimum zoom factor to 50.0")
229 // [kotlin_LocationWindow_setMinZoomFactor]
231 // [kotlin_LocationWindow_getMaxZoomFactor]
232 // Get maximum zoom factor
233 val maxZoomFactor = locationWindow!!.maxZoomFactor
234 println("Maximum zoom factor: $maxZoomFactor")
235 // [kotlin_LocationWindow_getMaxZoomFactor]
237 // [kotlin_LocationWindow_setMaxZoomFactor]
238 // Set maximum zoom factor
239 locationWindow!!.maxZoomFactor = 300.0
240 println("Set maximum zoom factor to 300.0")
241 // [kotlin_LocationWindow_setMaxZoomFactor]
243 // Test zoom factor changes
244 val testZoomFactors = listOf(100.0, 125.0, 150.0, 200.0, 250.0)
245 for (zoom in testZoomFactors) {
246 locationWindow!!.zoomFactor = zoom
247 println("Changed zoom factor to: ${locationWindow!!.zoomFactor}")
251 println("Testing zoom limits...")
252 locationWindow!!.zoomFactor = locationWindow!!.minZoomFactor
253 println("Set to minimum zoom: ${locationWindow!!.zoomFactor}")
255 locationWindow!!.zoomFactor = locationWindow!!.maxZoomFactor
256 println("Set to maximum zoom: ${locationWindow!!.zoomFactor}")
259 locationWindow!!.zoomFactor = 100.0
260 println("Reset zoom factor to default: ${locationWindow!!.zoomFactor}")
264 * Main demonstration method
266 suspend fun runExample() {
267 println("=== LocationWindowCommon Example ===")
269 // Simulate LocationWindow initialization
272 // TODO: User will implement LocationWindow initialization here
273 // locationWindow = getLocationWindow()
275 // Run demonstrations
276 demonstrateLocationWindowCommonMethods()
278 println("=== Example completed ===")
283 * Function to run the example
285fun main() = runBlocking {
286 val example = LocationWindowCommonExample()