/** applies the next step in the pan-zoom animation, if any */ private void stepPanZoomAnimation() { if (zoomPanAnimationEndTime == 0) return; long now = System.currentTimeMillis(); if (now >= zoomPanAnimationEndTime) { zoom = zoomTo; drawOffset.x = panTo.x; drawOffset.y = panTo.y; stopPanZoomAnimation(); } else { long duration = zoomPanAnimationEndTime - zoomPanAnimationStartTime; long diff = zoomPanAnimationEndTime - now; float alpha = (float) Math.pow(diff / (float) duration, zoomPanAnimationInterpolationPower); float beta = 1.0f - alpha; zoom = (zoomFrom * alpha) + (zoomTo * beta); drawOffset.x = (int) ((panFrom.x * alpha) + (panTo.x * beta)); drawOffset.y = (int) ((panFrom.y * alpha) + (panTo.y * beta)); } }
/** pan down by the standard amount */ public void panDown() { drawOffset.y += getHeight() / (DEFAULT_PAN_DIVISOR * zoom); }
/** pan up by the standard amount */ public void panUp() { drawOffset.y -= getHeight() / (DEFAULT_PAN_DIVISOR * zoom); }
/** set the aggregate y-axis pan */ public void setPanY(int y) { drawOffset.y = y; }