20class LocationWindowCameraExample {
24 LocationWindowCameraExample() {
25 _demonstrateLocationWindowCameraMethods();
31 void _demonstrateLocationWindowCameraMethods() {
32 print(
"=== LocationWindowCamera Methods ===");
34 _demonstrateCameraProperties();
35 _demonstrateGetSetCamera();
36 _demonstrateCameraListeners();
37 _demonstrateFlyToMethod();
38 _demonstrateMoveToMethod();
39 _demonstrateZoomProperties();
40 _demonstrateCameraScenarios();
46 void _demonstrateCameraProperties() {
47 print(
"--- Camera Properties Setup ---");
50 print(
"LocationWindow not available yet");
57 print(
"Set minimum zoom factor to 10.0 pixels per meter");
63 print(
"Set maximum zoom factor to 1000.0 pixels per meter");
70 void _demonstrateGetSetCamera() {
71 print(
"--- getCamera and setCamera Methods ---");
74 print(
"LocationWindow not available yet");
81 print(
"Current camera position:");
82 print(
" Point: (${currentCamera.point.x}, ${currentCamera.point.y})");
83 print(
" Zoom: ${currentCamera.zoom}");
84 print(
" Rotation: ${currentCamera.rotation}°");
85 print(
" Tilt: ${currentCamera.tilt}° (0° = straight downward / map from above)");
90 Point newPoint = Point(100.0, 200.0);
91 Camera newCamera = Camera(newPoint, 50.0, 0.0, 0.0);
92 print(
"Created camera with point (${newPoint.x}, ${newPoint.y}), zoom 50.0, rotation 0°, tilt 0°");
97 print(
"Camera properties:");
98 print(
" Point: (${newCamera.point.x}, ${newCamera.point.y})");
99 print(
" Zoom: ${newCamera.zoom}");
100 print(
" Rotation: ${newCamera.rotation}°");
101 print(
" Tilt: ${newCamera.tilt}°");
107 print(
"Set camera position to (${newPoint.x}, ${newPoint.y}) with zoom 50.0, rotation 0°, tilt 0°");
112 Point rotatedPoint = Point(150.0, 250.0);
113 Camera rotatedCamera = Camera(rotatedPoint, 75.0, 45.0, 0.0);
115 print(
"Set camera position to (${rotatedPoint.x}, ${rotatedPoint.y}) with zoom 75.0 and rotation 45°");
119 Camera tiltedCamera = Camera(rotatedPoint, 75.0, 45.0, 40.0);
121 print(
"Set camera with tilt ${tiltedCamera.tilt}° for a perspective view");
124 List<Camera> testCameras = [
125 Camera(Point(0.0, 0.0), 10.0, 0.0, 0.0),
126 Camera(Point(50.0, 75.0), 500.0, 0.0, 0.0),
127 Camera(Point(100.0, 150.0), 100.0, 30.0, 0.0),
130 for (
int i = 0; i < testCameras.length; i++) {
131 Camera camera = testCameras[i];
133 print(
"Test camera $i: Point (${camera.point.x}, ${camera.point.y}), Zoom ${camera.zoom}, Rotation ${camera.rotation}°, Tilt ${camera.tilt}°");
140 void _demonstrateCameraListeners() {
141 print(
"--- Camera Listener Methods ---");
144 print(
"LocationWindow not available yet");
152 print(
"Added camera listener");
159 print(
"Removed camera listener");
163 List<CameraListener> listeners = [
164 CameraListenerImpl(),
165 CameraListenerImpl(),
166 CameraListenerImpl(),
169 for (
int i = 0; i < listeners.length; i++) {
171 print(
"Added camera listener $i");
174 for (
int i = 0; i < listeners.length; i++) {
176 print(
"Removed camera listener $i");
183 void _demonstrateFlyToMethod() {
184 print(
"--- flyTo Method ---");
187 print(
"LocationWindow not available yet");
193 Point targetPoint = Point(150.0, 250.0);
194 Camera targetCamera = Camera(targetPoint, 75.0, 45.0, 30.0);
195 CameraCallback callback = CameraCallback(
196 onMoveFinished: (completed) {
198 print(
"Fly to animation completed successfully");
200 print(
"Fly to animation was cancelled");
205 print(
"Started fly to animation to point (${targetPoint.x}, ${targetPoint.y})");
210 Point targetPoint2 = Point(300.0, 400.0);
211 Camera targetCamera2 = Camera(targetPoint2, 25.0, 180.0, 0.0);
212 CameraCallback callback2 = CameraCallback(
213 onMoveFinished: (completed) {
214 print(
"Second fly to animation ${completed ? 'completed' : 'cancelled'}");
218 print(
"Started fly to animation to point (${targetPoint2.x}, ${targetPoint2.y}) with 3 second duration");
222 List<Map<String, dynamic>> flyToTests = [
223 {
"point": Point(50.0, 50.0),
"zoom": 100.0,
"rotation": 0.0,
"duration": 1000},
224 {
"point": Point(200.0, 300.0),
"zoom": 200.0,
"rotation": 90.0,
"duration": 1500},
225 {
"point": Point(400.0, 100.0),
"zoom": 50.0,
"rotation": 270.0,
"duration": 2500},
228 for (
int i = 0; i < flyToTests.length; i++) {
229 Map<String, dynamic> test = flyToTests[i];
230 Point point = test[
"point"];
231 double zoom = test[
"zoom"];
232 double rotation = test[
"rotation"];
233 int duration = test[
"duration"];
235 Camera camera = Camera(point, zoom, rotation, 0.0);
236 CameraCallback testCallback = CameraCallback(
237 onMoveFinished: (completed) {
238 print(
"Fly to test $i ${completed ? 'completed' : 'cancelled'}");
242 print(
"Fly to test $i: Point (${point.x}, ${point.y}), Zoom $zoom, Rotation ${rotation}°, Duration ${duration}ms");
249 void _demonstrateMoveToMethod() {
250 print(
"--- moveTo Method ---");
253 print(
"LocationWindow not available yet");
259 Point targetPoint = Point(200.0, 300.0);
260 Camera targetCamera = Camera(targetPoint, 100.0, 90.0, 0.0);
261 CameraCallback callback = CameraCallback(
262 onMoveFinished: (completed) {
263 print(
"Move to with linear animation ${completed ? 'completed' : 'cancelled'}");
266 _locationWindow!.moveTo(targetCamera, 1500, AnimationType.LINEAR, callback);
267 print(
"Started move to with linear animation");
272 CameraCallback callback2 = CameraCallback(
273 onMoveFinished: (completed) {
274 print(
"Move to with cubic animation ${completed ? 'completed' : 'cancelled'}");
277 _locationWindow!.moveTo(targetCamera, 1500, AnimationType.CUBIC, callback2);
278 print(
"Started move to with cubic animation");
283 CameraCallback callback3 = CameraCallback(
284 onMoveFinished: (completed) {
285 print(
"Move to with sine animation ${completed ? 'completed' : 'cancelled'}");
288 _locationWindow!.moveTo(targetCamera, 1500, AnimationType.SINE, callback3);
289 print(
"Started move to with sine animation");
294 Point instantPoint = Point(300.0, 400.0);
295 Camera instantCamera = Camera(instantPoint, 25.0, 180.0, 0.0);
296 CameraCallback instantCallback = CameraCallback(
297 onMoveFinished: (completed) {
298 print(
"Instant move to completed");
301 _locationWindow!.moveTo(instantCamera, 0, AnimationType.NONE, instantCallback);
302 print(
"Executed instant move to position (${instantPoint.x}, ${instantPoint.y})");
307 List<AnimationType> animationTypes = [
308 AnimationType.LINEAR,
316 for (
int i = 0; i < animationTypes.length; i++) {
317 AnimationType animationType = animationTypes[i];
318 Point testPoint = Point(100.0 + i * 50.0, 200.0 + i * 50.0);
319 Camera testCamera = Camera(testPoint, 50.0 + i * 10.0, i * 30.0, 0.0);
320 CameraCallback testCallback = CameraCallback(
321 onMoveFinished: (completed) {
322 print(
"Move to test with ${animationType.name} animation ${completed ? 'completed' : 'cancelled'}");
325 _locationWindow!.moveTo(testCamera, 1000, animationType, testCallback);
326 print(
"Move to test $i: Animation ${animationType.name}, Point (${testPoint.x}, ${testPoint.y})");
333 void _demonstrateZoomProperties() {
334 print(
"--- Zoom Properties ---");
337 print(
"LocationWindow not available yet");
344 print(
"Current zoom factor: $currentZoom pixels per meter");
350 print(
"Set zoom factor to 200.0 pixels per meter");
356 print(
"Minimum zoom factor: $minZoom pixels per meter");
362 print(
"Maximum zoom factor: $maxZoom pixels per meter");
366 List<double> zoomLevels = [50.0, 100.0, 150.0, 300.0, 500.0, 800.0];
368 for (
int i = 0; i < zoomLevels.length; i++) {
369 double zoom = zoomLevels[i];
371 print(
"Set zoom factor to $zoom pixels per meter");
375 print(
"Actual zoom factor: $actualZoom pixels per meter");
382 void _demonstrateCameraScenarios() {
383 print(
"--- Camera Scenarios ---");
386 print(
"LocationWindow not available yet");
392 Camera overviewCamera = Camera(Point(0.0, 0.0), 10.0, 0.0, 0.0);
393 Camera detailCamera = Camera(Point(50.0, 75.0), 500.0, 0.0, 0.0);
394 Camera angledCamera = Camera(Point(100.0, 150.0), 100.0, 30.0, 25.0);
396 print(
"Created cameras for different scenarios:");
397 print(
" Overview camera: zoom ${overviewCamera.zoom}");
398 print(
" Detail camera: zoom ${detailCamera.zoom}");
399 print(
" Angled camera: rotation ${angledCamera.rotation}°, tilt ${angledCamera.tilt}°");
403 List<Camera> scenarios = [overviewCamera, detailCamera, angledCamera];
404 List<String> scenarioNames = [
"Overview",
"Detail",
"Angled"];
406 for (
int i = 0; i < scenarios.length; i++) {
407 Camera scenario = scenarios[i];
408 String name = scenarioNames[i];
410 CameraCallback scenarioCallback = CameraCallback(
411 onMoveFinished: (completed) {
412 print(
"Transition to $name scenario ${completed ? 'completed' : 'cancelled'}");
416 _locationWindow!.moveTo(scenario, 2000, AnimationType.CUBIC, scenarioCallback);
417 print(
"Transitioning to $name scenario");
428 print(
"Camera listener removed");