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");
55 System.out.println(
"Set minimum zoom factor to 10.0 pixels per meter");
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 +
"°");
83 System.out.println(
" Tilt: " + currentCamera.
tilt +
"° (0° = straight downward / map from above)");
88 Point newPoint =
new Point(100.0, 200.0);
89 Camera newCamera =
new Camera(newPoint, 50.0, 0.0, 0.0);
90 System.out.println(
"Created camera with point (" + newPoint.
x +
", " + newPoint.
y +
"), zoom 50.0, rotation 0°, tilt 0°");
95 System.out.println(
"Camera properties:");
96 System.out.println(
" Point: (" + newCamera.
point.
x +
", " + newCamera.
point.
y +
")");
97 System.out.println(
" Zoom: " + newCamera.
zoom);
98 System.out.println(
" Rotation: " + newCamera.
rotation +
"°");
99 System.out.println(
" Tilt: " + newCamera.
tilt +
"°");
104 locationWindow.setCamera(newCamera);
105 System.out.println(
"Set camera position to (" + newPoint.
x +
", " + newPoint.
y +
") with zoom 50.0, rotation 0°, tilt 0°");
110 Point rotatedPoint =
new Point(150.0, 250.0);
111 Camera rotatedCamera =
new Camera(rotatedPoint, 75.0, 45.0, 0.0);
112 locationWindow.setCamera(rotatedCamera);
113 System.out.println(
"Set camera position to (" + rotatedPoint.
x +
", " + rotatedPoint.
y +
") with zoom 75.0 and rotation 45°");
116 Camera tiltedCamera =
new Camera(rotatedPoint, 75.0, 45.0, 40.0);
117 locationWindow.setCamera(tiltedCamera);
118 System.out.println(
"Set camera with tilt " + tiltedCamera.
tilt +
"° for a perspective view");
121 Camera[] testCameras = {
122 new Camera(
new Point(0.0, 0.0), 10.0, 0.0, 0.0),
123 new Camera(
new Point(50.0, 75.0), 500.0, 0.0, 0.0),
124 new Camera(
new Point(100.0, 150.0), 100.0, 30.0, 0.0),
127 for (
int i = 0; i < testCameras.length; i++) {
128 Camera camera = testCameras[i];
129 locationWindow.setCamera(camera);
130 System.out.println(
"Test camera " + i +
": Point (" + camera.
point.
x +
", " + camera.
point.
y +
"), Zoom " + camera.
zoom +
", Rotation " + camera.
rotation +
"°, Tilt " + camera.
tilt +
"°");
137 private void demonstrateCameraListeners() {
138 System.out.println(
"--- Camera Listener Methods ---");
140 if (locationWindow ==
null) {
141 System.out.println(
"LocationWindow not available yet");
147 cameraListener =
new CameraListenerImpl();
148 locationWindow.addCameraListener(cameraListener);
149 System.out.println(
"Added camera listener");
154 locationWindow.removeCameraListener(cameraListener);
155 cameraListener =
null;
156 System.out.println(
"Removed camera listener");
160 CameraListener[] listeners = {
161 new CameraListenerImpl(),
162 new CameraListenerImpl(),
163 new CameraListenerImpl(),
166 for (
int i = 0; i < listeners.length; i++) {
167 locationWindow.addCameraListener(listeners[i]);
168 System.out.println(
"Added camera listener " + i);
171 for (
int i = 0; i < listeners.length; i++) {
172 locationWindow.removeCameraListener(listeners[i]);
173 System.out.println(
"Removed camera listener " + i);
180 private void demonstrateFlyToMethod() {
181 System.out.println(
"--- flyTo Method ---");
183 if (locationWindow ==
null) {
184 System.out.println(
"LocationWindow not available yet");
190 Point targetPoint =
new Point(150.0, 250.0);
191 Camera targetCamera =
new Camera(targetPoint, 75.0, 45.0, 30.0);
192 CameraCallback callback =
new CameraCallbackImpl();
193 locationWindow.flyTo(targetCamera, 2000, callback);
194 System.out.println(
"Started fly to animation to point (" + targetPoint.
x +
", " + targetPoint.
y +
")");
199 Point targetPoint2 =
new Point(300.0, 400.0);
200 Camera targetCamera2 =
new Camera(targetPoint2, 25.0, 180.0, 0.0);
201 CameraCallback callback2 =
new CameraCallbackImpl();
202 locationWindow.flyTo(targetCamera2, 3000, callback2);
203 System.out.println(
"Started fly to animation to point (" + targetPoint2.
x +
", " + targetPoint2.
y +
") with 3 second duration");
207 Object[][] flyToTests = {
208 {
new Point(50.0, 50.0), 100.0, 0.0, 1000},
209 {
new Point(200.0, 300.0), 200.0, 90.0, 1500},
210 {
new Point(400.0, 100.0), 50.0, 270.0, 2500},
213 for (
int i = 0; i < flyToTests.length; i++) {
214 Point point = (Point) flyToTests[i][0];
215 double zoom = (Double) flyToTests[i][1];
216 double rotation = (Double) flyToTests[i][2];
217 int duration = (Integer) flyToTests[i][3];
219 Camera camera =
new Camera(point, zoom, rotation, 0.0);
220 CameraCallback testCallback =
new CameraCallbackImpl();
221 locationWindow.flyTo(camera, duration, testCallback);
222 System.out.println(
"Fly to test " + i +
": Point (" + point.
x +
", " + point.
y +
"), Zoom " + zoom +
", Rotation " + rotation +
"°, Duration " + duration +
"ms");
229 private void demonstrateMoveToMethod() {
230 System.out.println(
"--- moveTo Method ---");
232 if (locationWindow ==
null) {
233 System.out.println(
"LocationWindow not available yet");
239 Point targetPoint =
new Point(200.0, 300.0);
240 Camera targetCamera =
new Camera(targetPoint, 100.0, 90.0, 0.0);
241 CameraCallback callback =
new CameraCallbackImpl();
242 locationWindow.moveTo(targetCamera, 1500, AnimationType.LINEAR, callback);
243 System.out.println(
"Started move to with linear animation");
248 CameraCallback callback2 =
new CameraCallbackImpl();
249 locationWindow.moveTo(targetCamera, 1500, AnimationType.CUBIC, callback2);
250 System.out.println(
"Started move to with cubic animation");
255 CameraCallback callback3 =
new CameraCallbackImpl();
256 locationWindow.moveTo(targetCamera, 1500, AnimationType.SINE, callback3);
257 System.out.println(
"Started move to with sine animation");
262 Point instantPoint =
new Point(300.0, 400.0);
263 Camera instantCamera =
new Camera(instantPoint, 25.0, 180.0, 0.0);
264 CameraCallback instantCallback =
new CameraCallbackImpl();
265 locationWindow.moveTo(instantCamera, 0, AnimationType.NONE, instantCallback);
266 System.out.println(
"Executed instant move to position (" + instantPoint.
x +
", " + instantPoint.
y +
")");
271 AnimationType[] animationTypes = {
272 AnimationType.LINEAR,
280 for (
int i = 0; i < animationTypes.length; i++) {
281 AnimationType animationType = animationTypes[i];
282 Point testPoint =
new Point(100.0 + i * 50.0, 200.0 + i * 50.0);
283 Camera testCamera =
new Camera(testPoint, 50.0 + i * 10.0, i * 30.0, 0.0);
284 CameraCallback testCallback =
new CameraCallbackImpl();
285 locationWindow.moveTo(testCamera, 1000, animationType, testCallback);
286 System.out.println(
"Move to test " + i +
": Animation " + animationType.name() +
", Point (" + testPoint.
x +
", " + testPoint.
y +
")");
293 private void demonstrateZoomProperties() {
294 System.out.println(
"--- Zoom Properties ---");
296 if (locationWindow ==
null) {
297 System.out.println(
"LocationWindow not available yet");
303 float currentZoom = locationWindow.getZoomFactor();
304 System.out.println(
"Current zoom factor: " + currentZoom +
" pixels per meter");
309 locationWindow.setZoomFactor(200.0f);
310 System.out.println(
"Set zoom factor to 200.0 pixels per meter");
315 float minZoom = locationWindow.getMinZoomFactor();
316 System.out.println(
"Minimum zoom factor: " + minZoom +
" pixels per meter");
321 float maxZoom = locationWindow.getMaxZoomFactor();
322 System.out.println(
"Maximum zoom factor: " + maxZoom +
" pixels per meter");
326 float[] zoomLevels = {50.0f, 100.0f, 150.0f, 300.0f, 500.0f, 800.0f};
328 for (
int i = 0; i < zoomLevels.length; i++) {
329 float zoom = zoomLevels[i];
330 locationWindow.setZoomFactor(zoom);
331 System.out.println(
"Set zoom factor to " + zoom +
" pixels per meter");
334 float actualZoom = locationWindow.getZoomFactor();
335 System.out.println(
"Actual zoom factor: " + actualZoom +
" pixels per meter");
342 private void demonstrateCameraScenarios() {
343 System.out.println(
"--- Camera Scenarios ---");
345 if (locationWindow ==
null) {
346 System.out.println(
"LocationWindow not available yet");
352 Camera overviewCamera =
new Camera(
new Point(0.0, 0.0), 10.0, 0.0, 0.0);
353 Camera detailCamera =
new Camera(
new Point(50.0, 75.0), 500.0, 0.0, 0.0);
354 Camera angledCamera =
new Camera(
new Point(100.0, 150.0), 100.0, 30.0, 25.0);
356 System.out.println(
"Created cameras for different scenarios:");
357 System.out.println(
" Overview camera: zoom " + overviewCamera.
zoom);
358 System.out.println(
" Detail camera: zoom " + detailCamera.
zoom);
359 System.out.println(
" Angled camera: rotation " + angledCamera.
rotation +
"°, tilt " + angledCamera.
tilt +
"°");
363 Camera[] scenarios = {overviewCamera, detailCamera, angledCamera};
364 String[] scenarioNames = {
"Overview",
"Detail",
"Angled"};
366 for (
int i = 0; i < scenarios.length; i++) {
367 Camera scenario = scenarios[i];
368 String name = scenarioNames[i];
370 CameraCallback scenarioCallback =
new CameraCallbackImpl();
371 locationWindow.moveTo(scenario, 2000, AnimationType.CUBIC, scenarioCallback);
372 System.out.println(
"Transitioning to " + name +
" scenario");
380 if (cameraListener !=
null && locationWindow !=
null) {
381 locationWindow.removeCameraListener(cameraListener);
382 cameraListener =
null;
383 System.out.println(
"Camera listener removed");