19 private LocationWindow locationWindow;
20 private CameraListener cameraListener;
23 demonstrateLocationWindowCameraMethods();
29 private void demonstrateLocationWindowCameraMethods() {
30 System.out.println(
"=== LocationWindowCamera Methods ===");
32 demonstrateCameraProperties();
33 demonstrateGetSetCamera();
34 demonstrateCameraListeners();
35 demonstrateFlyToMethod();
36 demonstrateMoveToMethod();
37 demonstrateZoomProperties();
38 demonstrateCameraScenarios();
44 private void demonstrateCameraProperties() {
45 System.out.println(
"--- Camera Properties Setup ---");
47 if (locationWindow ==
null) {
48 System.out.println(
"LocationWindow not available yet");
54 locationWindow.setMinZoomFactor(10.0f);
55 System.out.println(
"Set minimum zoom factor to 10.0 pixels per meter");
60 locationWindow.setMaxZoomFactor(1000.0f);
61 System.out.println(
"Set maximum zoom factor to 1000.0 pixels per meter");
68 private void demonstrateGetSetCamera() {
69 System.out.println(
"--- getCamera and setCamera Methods ---");
71 if (locationWindow ==
null) {
72 System.out.println(
"LocationWindow not available yet");
78 Camera currentCamera = locationWindow.getCamera();
79 System.out.println(
"Current camera position:");
80 System.out.println(
" Point: (" + currentCamera.point.x +
", " + currentCamera.point.y +
")");
81 System.out.println(
" Zoom: " + currentCamera.zoom);
82 System.out.println(
" Rotation: " + currentCamera.rotation +
"°");
87 Point newPoint =
new Point(100.0, 200.0);
88 Camera newCamera =
new Camera(newPoint, 50.0, 0.0);
89 System.out.println(
"Created camera with point (" + newPoint.x +
", " + newPoint.y +
"), zoom 50.0, rotation 0°");
94 System.out.println(
"Camera properties:");
95 System.out.println(
" Point: (" + newCamera.point.x +
", " + newCamera.point.y +
")");
96 System.out.println(
" Zoom: " + newCamera.zoom);
97 System.out.println(
" Rotation: " + newCamera.rotation +
"°");
102 locationWindow.setCamera(newCamera);
103 System.out.println(
"Set camera position to (" + newPoint.x +
", " + newPoint.y +
") with zoom 50.0 and rotation 0°");
108 Point rotatedPoint =
new Point(150.0, 250.0);
109 Camera rotatedCamera =
new Camera(rotatedPoint, 75.0, 45.0);
110 locationWindow.setCamera(rotatedCamera);
111 System.out.println(
"Set camera position to (" + rotatedPoint.x +
", " + rotatedPoint.y +
") with zoom 75.0 and rotation 45°");
115 Camera[] testCameras = {
116 new Camera(
new Point(0.0, 0.0), 10.0, 0.0),
117 new Camera(
new Point(50.0, 75.0), 500.0, 0.0),
118 new Camera(
new Point(100.0, 150.0), 100.0, 30.0),
121 for (
int i = 0; i < testCameras.length; i++) {
122 Camera camera = testCameras[i];
123 locationWindow.setCamera(camera);
124 System.out.println(
"Test camera " + i +
": Point (" + camera.point.x +
", " + camera.point.y +
"), Zoom " + camera.zoom +
", Rotation " + camera.rotation +
"°");
131 private void demonstrateCameraListeners() {
132 System.out.println(
"--- Camera Listener Methods ---");
134 if (locationWindow ==
null) {
135 System.out.println(
"LocationWindow not available yet");
141 cameraListener =
new CameraListenerImpl();
142 locationWindow.addCameraListener(cameraListener);
143 System.out.println(
"Added camera listener");
148 locationWindow.removeCameraListener(cameraListener);
149 cameraListener =
null;
150 System.out.println(
"Removed camera listener");
154 CameraListener[] listeners = {
155 new CameraListenerImpl(),
156 new CameraListenerImpl(),
157 new CameraListenerImpl(),
160 for (
int i = 0; i < listeners.length; i++) {
161 locationWindow.addCameraListener(listeners[i]);
162 System.out.println(
"Added camera listener " + i);
165 for (
int i = 0; i < listeners.length; i++) {
166 locationWindow.removeCameraListener(listeners[i]);
167 System.out.println(
"Removed camera listener " + i);
174 private void demonstrateFlyToMethod() {
175 System.out.println(
"--- flyTo Method ---");
177 if (locationWindow ==
null) {
178 System.out.println(
"LocationWindow not available yet");
184 Point targetPoint =
new Point(150.0, 250.0);
185 Camera targetCamera =
new Camera(targetPoint, 75.0, 45.0);
186 CameraCallback callback =
new CameraCallbackImpl();
187 locationWindow.flyTo(targetCamera, 2000, callback);
188 System.out.println(
"Started fly to animation to point (" + targetPoint.x +
", " + targetPoint.y +
")");
193 Point targetPoint2 =
new Point(300.0, 400.0);
194 Camera targetCamera2 =
new Camera(targetPoint2, 25.0, 180.0);
195 CameraCallback callback2 =
new CameraCallbackImpl();
196 locationWindow.flyTo(targetCamera2, 3000, callback2);
197 System.out.println(
"Started fly to animation to point (" + targetPoint2.x +
", " + targetPoint2.y +
") with 3 second duration");
201 Object[][] flyToTests = {
202 {
new Point(50.0, 50.0), 100.0, 0.0, 1000},
203 {
new Point(200.0, 300.0), 200.0, 90.0, 1500},
204 {
new Point(400.0, 100.0), 50.0, 270.0, 2500},
207 for (
int i = 0; i < flyToTests.length; i++) {
208 Point point = (Point) flyToTests[i][0];
209 double zoom = (Double) flyToTests[i][1];
210 double rotation = (Double) flyToTests[i][2];
211 int duration = (Integer) flyToTests[i][3];
213 Camera camera =
new Camera(point, zoom, rotation);
214 CameraCallback testCallback =
new CameraCallbackImpl();
215 locationWindow.flyTo(camera, duration, testCallback);
216 System.out.println(
"Fly to test " + i +
": Point (" + point.x +
", " + point.y +
"), Zoom " + zoom +
", Rotation " + rotation +
"°, Duration " + duration +
"ms");
223 private void demonstrateMoveToMethod() {
224 System.out.println(
"--- moveTo Method ---");
226 if (locationWindow ==
null) {
227 System.out.println(
"LocationWindow not available yet");
233 Point targetPoint =
new Point(200.0, 300.0);
234 Camera targetCamera =
new Camera(targetPoint, 100.0, 90.0);
235 CameraCallback callback =
new CameraCallbackImpl();
236 locationWindow.moveTo(targetCamera, 1500, AnimationType.LINEAR, callback);
237 System.out.println(
"Started move to with linear animation");
242 CameraCallback callback2 =
new CameraCallbackImpl();
243 locationWindow.moveTo(targetCamera, 1500, AnimationType.CUBIC, callback2);
244 System.out.println(
"Started move to with cubic animation");
249 CameraCallback callback3 =
new CameraCallbackImpl();
250 locationWindow.moveTo(targetCamera, 1500, AnimationType.SINE, callback3);
251 System.out.println(
"Started move to with sine animation");
256 Point instantPoint =
new Point(300.0, 400.0);
257 Camera instantCamera =
new Camera(instantPoint, 25.0, 180.0);
258 CameraCallback instantCallback =
new CameraCallbackImpl();
259 locationWindow.moveTo(instantCamera, 0, AnimationType.NONE, instantCallback);
260 System.out.println(
"Executed instant move to position (" + instantPoint.x +
", " + instantPoint.y +
")");
264 AnimationType[] animationTypes = {
265 AnimationType.LINEAR,
272 for (
int i = 0; i < animationTypes.length; i++) {
273 AnimationType animationType = animationTypes[i];
274 Point testPoint =
new Point(100.0 + i * 50.0, 200.0 + i * 50.0);
275 Camera testCamera =
new Camera(testPoint, 50.0 + i * 10.0, i * 30.0);
276 CameraCallback testCallback =
new CameraCallbackImpl();
277 locationWindow.moveTo(testCamera, 1000, animationType, testCallback);
278 System.out.println(
"Move to test " + i +
": Animation " + animationType.name() +
", Point (" + testPoint.x +
", " + testPoint.y +
")");
285 private void demonstrateZoomProperties() {
286 System.out.println(
"--- Zoom Properties ---");
288 if (locationWindow ==
null) {
289 System.out.println(
"LocationWindow not available yet");
295 float currentZoom = locationWindow.getZoomFactor();
296 System.out.println(
"Current zoom factor: " + currentZoom +
" pixels per meter");
301 locationWindow.setZoomFactor(200.0f);
302 System.out.println(
"Set zoom factor to 200.0 pixels per meter");
307 float minZoom = locationWindow.getMinZoomFactor();
308 System.out.println(
"Minimum zoom factor: " + minZoom +
" pixels per meter");
313 float maxZoom = locationWindow.getMaxZoomFactor();
314 System.out.println(
"Maximum zoom factor: " + maxZoom +
" pixels per meter");
318 float[] zoomLevels = {50.0f, 100.0f, 150.0f, 300.0f, 500.0f, 800.0f};
320 for (
int i = 0; i < zoomLevels.length; i++) {
321 float zoom = zoomLevels[i];
322 locationWindow.setZoomFactor(zoom);
323 System.out.println(
"Set zoom factor to " + zoom +
" pixels per meter");
326 float actualZoom = locationWindow.getZoomFactor();
327 System.out.println(
"Actual zoom factor: " + actualZoom +
" pixels per meter");
334 private void demonstrateCameraScenarios() {
335 System.out.println(
"--- Camera Scenarios ---");
337 if (locationWindow ==
null) {
338 System.out.println(
"LocationWindow not available yet");
344 Camera overviewCamera =
new Camera(
new Point(0.0, 0.0), 10.0, 0.0);
345 Camera detailCamera =
new Camera(
new Point(50.0, 75.0), 500.0, 0.0);
346 Camera angledCamera =
new Camera(
new Point(100.0, 150.0), 100.0, 30.0);
348 System.out.println(
"Created cameras for different scenarios:");
349 System.out.println(
" Overview camera: zoom " + overviewCamera.zoom);
350 System.out.println(
" Detail camera: zoom " + detailCamera.zoom);
351 System.out.println(
" Angled camera: rotation " + angledCamera.rotation +
"°");
355 Camera[] scenarios = {overviewCamera, detailCamera, angledCamera};
356 String[] scenarioNames = {
"Overview",
"Detail",
"Angled"};
358 for (
int i = 0; i < scenarios.length; i++) {
359 Camera scenario = scenarios[i];
360 String name = scenarioNames[i];
362 CameraCallback scenarioCallback =
new CameraCallbackImpl();
363 locationWindow.moveTo(scenario, 2000, AnimationType.CUBIC, scenarioCallback);
364 System.out.println(
"Transitioning to " + name +
" scenario");
372 if (cameraListener !=
null && locationWindow !=
null) {
373 locationWindow.removeCameraListener(cameraListener);
374 cameraListener =
null;
375 System.out.println(
"Camera listener removed");