23 private LocationWindow locationWindow;
24 private InputListener inputListener;
25 private PickListener pickListener;
28 demonstrateLocationWindowInteractionMethods();
34 private void demonstrateLocationWindowInteractionMethods() {
35 System.out.println(
"=== LocationWindowInteraction Example ===");
37 demonstrateGestureProperties();
38 demonstratePickProperties();
39 demonstratePickMethods();
40 demonstrateInputListeners();
41 demonstratePickListeners();
48 private void demonstrateGestureProperties() {
49 System.out.println(
"--- Gesture Properties ---");
51 if (locationWindow ==
null) {
52 System.out.println(
"LocationWindow not available yet");
58 locationWindow.setStickToBorder(
true);
59 System.out.println(
"Set stick to border to true");
64 locationWindow.setRotateGestureEnabled(
true);
65 System.out.println(
"Set rotate gesture enabled to true");
70 locationWindow.setTiltGesturesEnabled(
true);
71 System.out.println(
"Set tilt gestures enabled to true");
76 locationWindow.setScrollGesturesEnabled(
true);
77 System.out.println(
"Set scroll gestures enabled to true");
82 locationWindow.setZoomGesturesEnabled(
true);
83 System.out.println(
"Set zoom gestures enabled to true");
87 Object[][] gestureTests = {
88 {
true,
true,
true,
true,
true},
89 {
false,
true,
true,
true,
false},
90 {
true,
false,
true,
false,
true},
91 {
false,
false,
false,
false,
false},
94 for (
int i = 0; i < gestureTests.length; i++) {
95 boolean rotate = (Boolean) gestureTests[i][0];
96 boolean tilt = (Boolean) gestureTests[i][1];
97 boolean scroll = (Boolean) gestureTests[i][2];
98 boolean zoom = (Boolean) gestureTests[i][3];
99 boolean stick = (Boolean) gestureTests[i][4];
101 locationWindow.setRotateGestureEnabled(rotate);
102 locationWindow.setTiltGesturesEnabled(tilt);
103 locationWindow.setScrollGesturesEnabled(scroll);
104 locationWindow.setZoomGesturesEnabled(zoom);
105 locationWindow.setStickToBorder(stick);
106 System.out.println(
"Gesture test " + i +
": Rotate=" + rotate +
", Tilt=" + tilt +
", Scroll=" + scroll +
", Zoom=" + zoom +
", Stick=" + stick);
113 private void demonstratePickProperties() {
114 System.out.println(
"--- Pick Properties ---");
116 if (locationWindow ==
null) {
117 System.out.println(
"LocationWindow not available yet");
123 locationWindow.setPickRadius(10.0);
124 System.out.println(
"Set pick radius to 10.0 pixels");
128 double[] pickRadiusTests = {5.0, 10.0, 20.0, 50.0, 100.0};
130 for (
int i = 0; i < pickRadiusTests.length; i++) {
131 double radius = pickRadiusTests[i];
132 locationWindow.setPickRadius(radius);
133 System.out.println(
"Pick radius test " + i +
": " + radius +
" pixels");
140 private void demonstratePickMethods() {
141 System.out.println(
"--- Pick Methods ---");
143 if (locationWindow ==
null) {
144 System.out.println(
"LocationWindow not available yet");
150 Point screenPoint =
new Point(100.0, 200.0);
151 locationWindow.pickMapObjectAt(screenPoint);
152 System.out.println(
"Picked map object at screen position (" + screenPoint.x +
", " + screenPoint.y +
")");
157 Point featurePoint =
new Point(150.0, 250.0);
158 locationWindow.pickMapFeatureAt(featurePoint);
159 System.out.println(
"Picked map feature at screen position (" + featurePoint.x +
", " + featurePoint.y +
")");
163 Point[] pickTests = {
164 new Point(50.0, 50.0),
165 new Point(200.0, 300.0),
166 new Point(400.0, 100.0),
167 new Point(300.0, 400.0),
170 for (
int i = 0; i < pickTests.length; i++) {
171 Point point = pickTests[i];
172 locationWindow.pickMapObjectAt(point);
173 locationWindow.pickMapFeatureAt(point);
174 System.out.println(
"Pick test " + i +
": Object and feature at (" + point.x +
", " + point.y +
")");
181 private void demonstrateInputListeners() {
182 System.out.println(
"--- Input Listeners ---");
184 if (locationWindow ==
null) {
185 System.out.println(
"LocationWindow not available yet");
191 inputListener =
new InputListenerImpl();
192 locationWindow.addInputListener(inputListener);
193 System.out.println(
"Added input listener");
198 locationWindow.removeInputListener(inputListener);
199 inputListener =
null;
200 System.out.println(
"Removed input listener");
204 InputListener[] listeners = {
205 new InputListenerImpl(),
206 new InputListenerImpl(),
207 new InputListenerImpl(),
210 for (
int i = 0; i < listeners.length; i++) {
211 locationWindow.addInputListener(listeners[i]);
212 System.out.println(
"Added input listener " + i);
215 for (
int i = 0; i < listeners.length; i++) {
216 locationWindow.removeInputListener(listeners[i]);
217 System.out.println(
"Removed input listener " + i);
224 private void demonstratePickListeners() {
225 System.out.println(
"--- Pick Listeners ---");
227 if (locationWindow ==
null) {
228 System.out.println(
"LocationWindow not available yet");
234 pickListener =
new PickListenerImpl();
235 locationWindow.addPickListener(pickListener);
236 System.out.println(
"Added pick listener");
240 PickListener[] listeners = {
241 new PickListenerImpl(),
242 new PickListenerImpl(),
243 new PickListenerImpl(),
246 for (
int i = 0; i < listeners.length; i++) {
247 locationWindow.addPickListener(listeners[i]);
248 System.out.println(
"Added pick listener " + i);
251 for (
int i = 0; i < listeners.length; i++) {
253 locationWindow.removePickListener(listeners[i]);
254 System.out.println(
"Removed pick listener " + i);
263 if (inputListener !=
null) {
264 locationWindow.removeInputListener(inputListener);
265 inputListener =
null;
267 if (pickListener !=
null) {
268 locationWindow.removePickListener(pickListener);
271 System.out.println(
"LocationWindowInteraction example cleanup completed");