13class LocationWindowCommonExample {
18 LocationWindowCommonExample() {
19 _demonstrateLocationWindowCommonMethods();
25 void _demonstrateLocationWindowCommonMethods() {
26 print(
"=== LocationWindowCommon Methods ===");
28 _demonstrateSetSublocationId();
29 _demonstrateSublocationQueries();
30 _demonstrateSublocationChangeListener();
31 _demonstrateUserLocationLayer();
32 _demonstrateCoordinateConversion();
33 _demonstrateMapFeatureSelection();
34 _demonstrateApplyLayerFilter();
35 _demonstrateDebugFlags();
36 _demonstrateZoomProperties();
42 void _demonstrateDebugFlags() {
43 print(
"--- Debug flags ---");
51 DebugFlag.DRAW_ALL_LABELS,
52 DebugFlag.SELECTION_BUFFER,
54 print(
"Debug flag enum values: ${allFlags.length}");
58 LocationWindow.setDebugFlag(DebugFlag.INFOS,
true);
59 LocationWindow.setDebugFlag(DebugFlag.STATS,
false);
60 print(
"Updated debug flags on LocationWindow");
64 bool infosOn = LocationWindow.getDebugFlag(DebugFlag.INFOS);
65 print(
"Debug flag INFOS enabled: $infosOn");
72 void _demonstrateSetSublocationId() {
73 print(
"--- setSublocationId Method ---");
76 print(
"LocationWindow not available yet");
83 print(
"Set sublocation ID to 1 (first floor)");
89 print(
"Set sublocation ID to 2 (second floor)");
95 print(
"Set sublocation ID to 0 (ground floor)");
99 List<int> sublocationIds = [1, 2, 3, 0, 5];
100 for (
int id in sublocationIds) {
102 print(
"Switched to sublocation ID: $id");
109 void _demonstrateSublocationQueries() {
110 print(
"--- getSublocationId & getEnclosingCamera ---");
113 print(
"LocationWindow not available yet");
119 if (currentId !=
null) {
120 print(
"Current sublocation id: $currentId");
122 print(
"Current sublocation id is not set");
127 BoundingBox boundingBox = BoundingBox(Point(0.0, 0.0), Point(20.0, 30.0));
129 print(
"Camera that fits bounding box: $camera");
136 void _demonstrateSublocationChangeListener() {
137 print(
"--- Sublocation Change Listener ---");
140 print(
"LocationWindow not available yet");
144 DemoSublocationChangeListener listener = DemoSublocationChangeListener();
148 print(
"Added sublocation change listener");
156 print(
"Removed sublocation change listener");
163 void _demonstrateUserLocationLayer() {
164 print(
"--- UserLocationLayer ---");
167 print(
"UserLocationLayer not available yet");
173 print(
"User location layer set visible");
178 print(
"User location layer is visible: $visible");
182 ScreenPoint anchor = ScreenPoint(100.0, 200.0);
184 print(
"Set user location anchor to: (${anchor.x}, ${anchor.y})");
189 print(
"Anchor enabled: $anchorEnabled");
194 print(
"Anchor reset to default");
201 void _demonstrateCoordinateConversion() {
202 print(
"--- Coordinate Conversion Methods ---");
205 print(
"LocationWindow not available yet");
211 Point screenPoint = Point(100.0, 200.0);
212 Point metersPoint =
_locationWindow!.screenPositionToMeters(screenPoint);
213 print(
"Screen position (${screenPoint.x}, ${screenPoint.y}) converted to meters: (${metersPoint.x}, ${metersPoint.y})");
218 Point screenPoint2 = Point(500.0, 300.0);
219 Point metersPoint2 =
_locationWindow!.screenPositionToMeters(screenPoint2);
220 print(
"Screen position (${screenPoint2.x}, ${screenPoint2.y}) converted to meters: (${metersPoint2.x}, ${metersPoint2.y})");
225 Point metersPoint3 = Point(50.0, 75.0);
226 Point screenPoint3 =
_locationWindow!.metersToScreenPosition(metersPoint3,
true);
227 print(
"Meters position (${metersPoint3.x}, ${metersPoint3.y}) converted to screen with clipping: (${screenPoint3.x}, ${screenPoint3.y})");
232 Point metersPoint4 = Point(150.0, 200.0);
233 Point screenPoint4 =
_locationWindow!.metersToScreenPosition(metersPoint4,
false);
234 print(
"Meters position (${metersPoint4.x}, ${metersPoint4.y}) converted to screen without clipping: (${screenPoint4.x}, ${screenPoint4.y})");
238 List<Point> testScreenPoints = [
241 Point(1000.0, 600.0),
244 for (
int i = 0; i < testScreenPoints.length; i++) {
245 Point screenPoint = testScreenPoints[i];
246 Point metersPoint =
_locationWindow!.screenPositionToMeters(screenPoint);
247 Point backToScreen =
_locationWindow!.metersToScreenPosition(metersPoint,
false);
248 print(
"Test $i: Screen (${screenPoint.x}, ${screenPoint.y}) -> Meters (${metersPoint.x}, ${metersPoint.y}) -> Screen (${backToScreen.x}, ${backToScreen.y})");
255 void _demonstrateMapFeatureSelection() {
256 print(
"--- Map Feature Selection Methods ---");
259 print(
"LocationWindow not available yet");
265 String featureId =
"room_101";
267 print(
"Selected map feature $featureId: $selected");
272 String featureId2 =
"office_205";
274 print(
"Selected map feature $featureId2: $selected2");
280 print(
"Currently selected map features: ${selectedFeatures.length} features");
281 for (String feature in selectedFeatures) {
282 print(
" - $feature");
289 print(
"Deselected map feature $featureId: $deselected");
295 print(
"Deselected map feature $featureId2: $deselected2");
301 print(
"Deselected all map features");
307 print(
"Remaining selected features after deselect all: ${remainingFeatures.length} features");
311 List<String> testFeatureIds = [
"room_101",
"office_205",
"meeting_room_301",
"cafe_401"];
314 for (String featureId in testFeatureIds) {
316 print(
"Selected feature $featureId: $success");
321 print(
"All selected features: ${allSelected.length} features");
325 print(
"Deselected all features at once");
331 void _demonstrateApplyLayerFilter() {
332 print(
"--- applyLayerFilter Method ---");
335 print(
"LocationWindow not available yet");
341 final condition = MapFilterCondition(property:
"category", values: [
"Toilet",
"Cafe"]);
346 final conditions = [MapFilterCondition(property:
"category", values: [
"Toilet",
"Cafe"])];
348 print(
"Applied layer filter: show venues with category Toilet or Cafe");
353 print(
"Reset layer filter: show all venues");
359 void _demonstrateZoomProperties() {
360 print(
"--- Zoom Properties ---");
363 print(
"LocationWindow not available yet");
370 print(
"Current zoom factor: $currentZoom");
376 print(
"Set zoom factor to 150.0");
382 print(
"Minimum zoom factor: $minZoomFactor");
388 print(
"Set minimum zoom factor to 50.0");
394 print(
"Maximum zoom factor: $maxZoomFactor");
400 print(
"Set maximum zoom factor to 300.0");
404 List<double> testZoomFactors = [100.0, 125.0, 150.0, 200.0, 250.0];
405 for (
double zoom in testZoomFactors) {
407 print(
"Changed zoom factor to: ${_locationWindow!.zoomFactor}");
411 print(
"Testing zoom limits...");
413 print(
"Set to minimum zoom: ${_locationWindow!.zoomFactor}");
416 print(
"Set to maximum zoom: ${_locationWindow!.zoomFactor}");
420 print(
"Reset zoom factor to default: ${_locationWindow!.zoomFactor}");
426 Future<void> runExample() async {
427 print(
"=== LocationWindowCommon Example ===");
430 await Future.delayed(Duration(milliseconds: 500));
436 _demonstrateLocationWindowCommonMethods();
438 print(
"=== Example completed ===");