/**
* @see Screen#touchEvent(TouchEvent)
*/
protected boolean touchEvent(final TouchEvent message) {
final TouchGesture touchGesture = message.getGesture();
if (touchGesture != null) {
if (_mapManager.isPanning()) {
// If the user has performed a swipe gesture within the map area
// we will move the map accordingly.
if (touchGesture.getEvent() == TouchGesture.SWIPE
&& message.getY(1) < 240) {
int horizontal = 0;
int vertical = 0;
// Retrieve the swipe magnitude so we know how
// far to move the map.
final int magnitude = touchGesture.getSwipeMagnitude();
// Move the map in the direction of the swipe.
switch (touchGesture.getSwipeDirection()) {
case TouchGesture.SWIPE_NORTH:
vertical = magnitude / SCROLL_FACTOR;
// vertical = SCROLL_CHANGE;
break;
case TouchGesture.SWIPE_SOUTH:
vertical = -(magnitude / SCROLL_FACTOR);
// vertical = -(SCROLL_CHANGE * SCROLL_FACTOR);
break;
case TouchGesture.SWIPE_EAST:
horizontal = -(magnitude / SCROLL_FACTOR);
// horizontal = -(SCROLL_CHANGE);
break;
case TouchGesture.SWIPE_WEST:
horizontal = magnitude / SCROLL_FACTOR;
// horizontal = -SCROLL_CHANGE;
break;
}
update(horizontal, vertical);
}
}
// Performing a double tap gesture on the map will toggle panning
// mode
if (touchGesture.getEvent() == TouchGesture.DOUBLE_TAP
&& message.getY(1) < 240) {
togglePanMode();
}
}