}
private class ScrollCallback implements Runnable {
@Override
public void run() {
Panorama panorama = (Panorama)getComponent();
if (northButton.isMouseOver()) {
int scrollTop = Math.max(panorama.getScrollTop()
- (int)scrollDistance, 0);
if (scrollTop == 0
&& scheduledScrollCallback != null) {
scheduledScrollCallback.cancel();
scheduledScrollCallback = null;
}
panorama.setScrollTop(scrollTop);
} else if (southButton.isMouseOver()) {
int maxScrollTop = getMaxScrollTop();
int scrollTop = Math.min(panorama.getScrollTop()
+ (int)scrollDistance, maxScrollTop);
if (scrollTop == maxScrollTop
&& scheduledScrollCallback != null) {
scheduledScrollCallback.cancel();
scheduledScrollCallback = null;
}
panorama.setScrollTop(scrollTop);
} else if (eastButton.isMouseOver()) {
int maxScrollLeft = getMaxScrollLeft();
int scrollLeft = Math.min(panorama.getScrollLeft()
+ (int)scrollDistance, maxScrollLeft);
if (scrollLeft == maxScrollLeft
&& scheduledScrollCallback != null) {
scheduledScrollCallback.cancel();
scheduledScrollCallback = null;
}
panorama.setScrollLeft(scrollLeft);
} else if (westButton.isMouseOver()) {
int scrollLeft = Math.max(panorama.getScrollLeft()
- (int)scrollDistance, 0);
if (scrollLeft == 0
&& scheduledScrollCallback != null) {
scheduledScrollCallback.cancel();
scheduledScrollCallback = null;
}
panorama.setScrollLeft(scrollLeft);
}
scrollDistance = Math.min(scrollDistance * SCROLL_ACCELERATION,
MAXIMUM_SCROLL_DISTANCE);
}