13class LocationWindowCommonExample {
14 LocationWindow? _locationWindow;
17 LocationWindowCommonExample() {
18 _demonstrateLocationWindowCommonMethods();
24 void _demonstrateLocationWindowCommonMethods() {
25 print(
"=== LocationWindowCommon Methods ===");
27 _demonstrateSetSublocationId();
28 _demonstrateCoordinateConversion();
29 _demonstrateMapFeatureSelection();
30 _demonstrateZoomProperties();
36 void _demonstrateSetSublocationId() {
37 print(
"--- setSublocationId Method ---");
39 if (_locationWindow ==
null) {
40 print(
"LocationWindow not available yet");
46 _locationWindow!.setSublocationId(1);
47 print(
"Set sublocation ID to 1 (first floor)");
52 _locationWindow!.setSublocationId(2);
53 print(
"Set sublocation ID to 2 (second floor)");
58 _locationWindow!.setSublocationId(0);
59 print(
"Set sublocation ID to 0 (ground floor)");
63 List<int> sublocationIds = [1, 2, 3, 0, 5];
64 for (
int id in sublocationIds) {
65 _locationWindow!.setSublocationId(
id);
66 print(
"Switched to sublocation ID: $id");
73 void _demonstrateCoordinateConversion() {
74 print(
"--- Coordinate Conversion Methods ---");
76 if (_locationWindow ==
null) {
77 print(
"LocationWindow not available yet");
83 Point screenPoint = Point(100.0, 200.0);
84 Point metersPoint = _locationWindow!.screenPositionToMeters(screenPoint);
85 print(
"Screen position (${screenPoint.x}, ${screenPoint.y}) converted to meters: (${metersPoint.x}, ${metersPoint.y})");
90 Point screenPoint2 = Point(500.0, 300.0);
91 Point metersPoint2 = _locationWindow!.screenPositionToMeters(screenPoint2);
92 print(
"Screen position (${screenPoint2.x}, ${screenPoint2.y}) converted to meters: (${metersPoint2.x}, ${metersPoint2.y})");
97 Point metersPoint3 = Point(50.0, 75.0);
98 Point screenPoint3 = _locationWindow!.metersToScreenPosition(metersPoint3,
true);
99 print(
"Meters position (${metersPoint3.x}, ${metersPoint3.y}) converted to screen with clipping: (${screenPoint3.x}, ${screenPoint3.y})");
104 Point metersPoint4 = Point(150.0, 200.0);
105 Point screenPoint4 = _locationWindow!.metersToScreenPosition(metersPoint4,
false);
106 print(
"Meters position (${metersPoint4.x}, ${metersPoint4.y}) converted to screen without clipping: (${screenPoint4.x}, ${screenPoint4.y})");
110 List<Point> testScreenPoints = [
113 Point(1000.0, 600.0),
116 for (
int i = 0; i < testScreenPoints.length; i++) {
117 Point screenPoint = testScreenPoints[i];
118 Point metersPoint = _locationWindow!.screenPositionToMeters(screenPoint);
119 Point backToScreen = _locationWindow!.metersToScreenPosition(metersPoint,
false);
120 print(
"Test $i: Screen (${screenPoint.x}, ${screenPoint.y}) -> Meters (${metersPoint.x}, ${metersPoint.y}) -> Screen (${backToScreen.x}, ${backToScreen.y})");
127 void _demonstrateMapFeatureSelection() {
128 print(
"--- Map Feature Selection Methods ---");
130 if (_locationWindow ==
null) {
131 print(
"LocationWindow not available yet");
137 String featureId =
"room_101";
138 bool selected = _locationWindow!.selectMapFeature(featureId);
139 print(
"Selected map feature $featureId: $selected");
144 String featureId2 =
"office_205";
145 bool selected2 = _locationWindow!.selectMapFeature(featureId2);
146 print(
"Selected map feature $featureId2: $selected2");
151 List<String> selectedFeatures = _locationWindow!.selectedMapFeatures;
152 print(
"Currently selected map features: ${selectedFeatures.length} features");
153 for (String feature in selectedFeatures) {
154 print(
" - $feature");
160 bool deselected = _locationWindow!.deselectMapFeature(featureId);
161 print(
"Deselected map feature $featureId: $deselected");
166 bool deselected2 = _locationWindow!.deselectMapFeature(featureId2);
167 print(
"Deselected map feature $featureId2: $deselected2");
172 _locationWindow!.deselectAllMapFeatures();
173 print(
"Deselected all map features");
178 List<String> remainingFeatures = _locationWindow!.selectedMapFeatures;
179 print(
"Remaining selected features after deselect all: ${remainingFeatures.length} features");
183 List<String> testFeatureIds = [
"room_101",
"office_205",
"meeting_room_301",
"cafe_401"];
186 for (String featureId in testFeatureIds) {
187 bool success = _locationWindow!.selectMapFeature(featureId);
188 print(
"Selected feature $featureId: $success");
192 List<String> allSelected = _locationWindow!.selectedMapFeatures;
193 print(
"All selected features: ${allSelected.length} features");
196 _locationWindow!.deselectAllMapFeatures();
197 print(
"Deselected all features at once");
203 void _demonstrateZoomProperties() {
204 print(
"--- Zoom Properties ---");
206 if (_locationWindow ==
null) {
207 print(
"LocationWindow not available yet");
213 double currentZoom = _locationWindow!.zoomFactor;
214 print(
"Current zoom factor: $currentZoom");
219 _locationWindow!.zoomFactor = 150.0;
220 print(
"Set zoom factor to 150.0");
225 double minZoomFactor = _locationWindow!.minZoomFactor;
226 print(
"Minimum zoom factor: $minZoomFactor");
231 _locationWindow!.minZoomFactor = 50.0;
232 print(
"Set minimum zoom factor to 50.0");
237 double maxZoomFactor = _locationWindow!.maxZoomFactor;
238 print(
"Maximum zoom factor: $maxZoomFactor");
243 _locationWindow!.maxZoomFactor = 300.0;
244 print(
"Set maximum zoom factor to 300.0");
248 List<double> testZoomFactors = [100.0, 125.0, 150.0, 200.0, 250.0];
249 for (
double zoom in testZoomFactors) {
250 _locationWindow!.zoomFactor = zoom;
251 print(
"Changed zoom factor to: ${_locationWindow!.zoomFactor}");
255 print(
"Testing zoom limits...");
256 _locationWindow!.zoomFactor = _locationWindow!.minZoomFactor;
257 print(
"Set to minimum zoom: ${_locationWindow!.zoomFactor}");
259 _locationWindow!.zoomFactor = _locationWindow!.maxZoomFactor;
260 print(
"Set to maximum zoom: ${_locationWindow!.zoomFactor}");
263 _locationWindow!.zoomFactor = 100.0;
264 print(
"Reset zoom factor to default: ${_locationWindow!.zoomFactor}");
270 Future<void> runExample() async {
271 print(
"=== LocationWindowCommon Example ===");
274 await Future.delayed(Duration(milliseconds: 500));
280 _demonstrateLocationWindowCommonMethods();
282 print(
"=== Example completed ===");