13class LocationWindowCommonExample {
19 LocationWindowCommonExample() {
20 _demonstrateLocationWindowCommonMethods();
26 void _demonstrateLocationWindowCommonMethods() {
27 print(
"=== LocationWindowCommon Methods ===");
29 _demonstrateSetSublocationId();
30 _demonstrateSublocationQueries();
31 _demonstrateSublocationChangeListener();
32 _demonstrateUserLocationView();
33 _demonstrateUserLocationLayer();
34 _demonstrateCoordinateConversion();
35 _demonstrateMapFeatureSelection();
36 _demonstrateApplyLayerFilter();
37 _demonstrateDebugFlags();
38 _demonstrateZoomProperties();
44 void _demonstrateDebugFlags() {
45 print(
"--- Debug flags ---");
53 DebugFlag.DRAW_ALL_LABELS,
54 DebugFlag.SELECTION_BUFFER,
56 print(
"Debug flag enum values: ${allFlags.length}");
60 LocationWindow.setDebugFlag(DebugFlag.INFOS,
true);
61 LocationWindow.setDebugFlag(DebugFlag.STATS,
false);
62 print(
"Updated debug flags on LocationWindow");
66 bool infosOn = LocationWindow.getDebugFlag(DebugFlag.INFOS);
67 print(
"Debug flag INFOS enabled: $infosOn");
74 void _demonstrateSetSublocationId() {
75 print(
"--- setSublocationId Method ---");
78 print(
"LocationWindow not available yet");
85 print(
"Set sublocation ID to 1 (first floor)");
91 print(
"Set sublocation ID to 2 (second floor)");
97 print(
"Set sublocation ID to 0 (ground floor)");
101 List<int> sublocationIds = [1, 2, 3, 0, 5];
102 for (
int id in sublocationIds) {
104 print(
"Switched to sublocation ID: $id");
111 void _demonstrateSublocationQueries() {
112 print(
"--- getSublocationId & getEnclosingCamera ---");
115 print(
"LocationWindow not available yet");
121 if (currentId !=
null) {
122 print(
"Current sublocation id: $currentId");
124 print(
"Current sublocation id is not set");
129 BoundingBox boundingBox = BoundingBox(Point(0.0, 0.0), Point(20.0, 30.0));
131 print(
"Camera that fits bounding box: $camera");
138 void _demonstrateSublocationChangeListener() {
139 print(
"--- Sublocation Change Listener ---");
142 print(
"LocationWindow not available yet");
146 DemoSublocationChangeListener listener = DemoSublocationChangeListener();
150 print(
"Added sublocation change listener");
158 print(
"Removed sublocation change listener");
165 void _demonstrateUserLocationView() {
166 print(
"--- UserLocationView ---");
169 print(
"UserLocationView not available yet");
175 print(
"Arrow icon object: $arrow");
180 print(
"Accuracy circle object: $accuracyCircle");
187 void _demonstrateUserLocationLayer() {
188 print(
"--- UserLocationLayer ---");
191 print(
"UserLocationLayer not available yet");
197 print(
"User location layer set visible");
202 print(
"User location layer is visible: $visible");
206 ScreenPoint anchor = ScreenPoint(100.0, 200.0);
208 print(
"Set user location anchor to: (${anchor.x}, ${anchor.y})");
213 print(
"Anchor enabled: $anchorEnabled");
218 print(
"Anchor reset to default");
225 void _demonstrateCoordinateConversion() {
226 print(
"--- Coordinate Conversion Methods ---");
229 print(
"LocationWindow not available yet");
235 Point screenPoint = Point(100.0, 200.0);
236 Point metersPoint =
_locationWindow!.screenPositionToMeters(screenPoint);
237 print(
"Screen position (${screenPoint.x}, ${screenPoint.y}) converted to meters: (${metersPoint.x}, ${metersPoint.y})");
242 Point screenPoint2 = Point(500.0, 300.0);
243 Point metersPoint2 =
_locationWindow!.screenPositionToMeters(screenPoint2);
244 print(
"Screen position (${screenPoint2.x}, ${screenPoint2.y}) converted to meters: (${metersPoint2.x}, ${metersPoint2.y})");
249 Point metersPoint3 = Point(50.0, 75.0);
250 Point screenPoint3 =
_locationWindow!.metersToScreenPosition(metersPoint3,
true);
251 print(
"Meters position (${metersPoint3.x}, ${metersPoint3.y}) converted to screen with clipping: (${screenPoint3.x}, ${screenPoint3.y})");
256 Point metersPoint4 = Point(150.0, 200.0);
257 Point screenPoint4 =
_locationWindow!.metersToScreenPosition(metersPoint4,
false);
258 print(
"Meters position (${metersPoint4.x}, ${metersPoint4.y}) converted to screen without clipping: (${screenPoint4.x}, ${screenPoint4.y})");
262 List<Point> testScreenPoints = [
265 Point(1000.0, 600.0),
268 for (
int i = 0; i < testScreenPoints.length; i++) {
269 Point screenPoint = testScreenPoints[i];
270 Point metersPoint =
_locationWindow!.screenPositionToMeters(screenPoint);
271 Point backToScreen =
_locationWindow!.metersToScreenPosition(metersPoint,
false);
272 print(
"Test $i: Screen (${screenPoint.x}, ${screenPoint.y}) -> Meters (${metersPoint.x}, ${metersPoint.y}) -> Screen (${backToScreen.x}, ${backToScreen.y})");
279 void _demonstrateMapFeatureSelection() {
280 print(
"--- Map Feature Selection Methods ---");
283 print(
"LocationWindow not available yet");
289 String featureId =
"room_101";
291 print(
"Selected map feature $featureId: $selected");
296 String featureId2 =
"office_205";
298 print(
"Selected map feature $featureId2: $selected2");
304 print(
"Currently selected map features: ${selectedFeatures.length} features");
305 for (String feature in selectedFeatures) {
306 print(
" - $feature");
313 print(
"Deselected map feature $featureId: $deselected");
319 print(
"Deselected map feature $featureId2: $deselected2");
325 print(
"Deselected all map features");
331 print(
"Remaining selected features after deselect all: ${remainingFeatures.length} features");
335 List<String> testFeatureIds = [
"room_101",
"office_205",
"meeting_room_301",
"cafe_401"];
338 for (String featureId in testFeatureIds) {
340 print(
"Selected feature $featureId: $success");
345 print(
"All selected features: ${allSelected.length} features");
349 print(
"Deselected all features at once");
355 void _demonstrateApplyLayerFilter() {
356 print(
"--- applyLayerFilter Method ---");
359 print(
"LocationWindow not available yet");
365 final condition = MapFilterCondition(property:
"category", values: [
"Toilet",
"Cafe"]);
370 final conditions = [MapFilterCondition(property:
"category", values: [
"Toilet",
"Cafe"])];
372 print(
"Applied layer filter: show venues with category Toilet or Cafe");
377 print(
"Reset layer filter: show all venues");
383 void _demonstrateZoomProperties() {
384 print(
"--- Zoom Properties ---");
387 print(
"LocationWindow not available yet");
394 print(
"Current zoom factor: $currentZoom");
400 print(
"Set zoom factor to 150.0");
406 print(
"Minimum zoom factor: $minZoomFactor");
412 print(
"Set minimum zoom factor to 50.0");
418 print(
"Maximum zoom factor: $maxZoomFactor");
424 print(
"Set maximum zoom factor to 300.0");
428 List<double> testZoomFactors = [100.0, 125.0, 150.0, 200.0, 250.0];
429 for (
double zoom in testZoomFactors) {
431 print(
"Changed zoom factor to: ${_locationWindow!.zoomFactor}");
435 print(
"Testing zoom limits...");
437 print(
"Set to minimum zoom: ${_locationWindow!.zoomFactor}");
440 print(
"Set to maximum zoom: ${_locationWindow!.zoomFactor}");
444 print(
"Reset zoom factor to default: ${_locationWindow!.zoomFactor}");
450 Future<void> runExample() async {
451 print(
"=== LocationWindowCommon Example ===");
454 await Future.delayed(Duration(milliseconds: 500));
460 _demonstrateLocationWindowCommonMethods();
462 print(
"=== Example completed ===");