Esempio n. 1
0
  /** 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));
    }
  }
Esempio n. 2
0
 /**
  * Starts a pan-zoom animation.
  *
  * @param toX what x coordinate to zoom to
  * @param toY what y coordinate to zoom to
  * @param zoomTo the new zoom factor
  * @param duration_msec how long to animate
  * @param zoomPanAnimationInterpolationPower 1 means a linear interpolation will be done between
  *     the two animation endpoints. 2 would be quadratic, etc. A higher the number causes a faster
  *     beginning and a slower and smoother the ending.
  */
 public void startPanZoomAnimation(
     int toX,
     int toY,
     float zoomTo,
     long duration_msec,
     float zoomPanAnimationInterpolationPower) {
   this.zoomTo = zoomTo;
   this.panTo = new Vector2i(toX, toY);
   this.panFrom = drawOffset.clone();
   this.zoomFrom = zoom;
   this.zoomPanAnimationStartTime = System.currentTimeMillis();
   this.zoomPanAnimationEndTime = System.currentTimeMillis() + duration_msec;
   this.zoomPanAnimationInterpolationPower = zoomPanAnimationInterpolationPower;
 }
Esempio n. 3
0
 /** set the pan in progress to the specified amount */
 public void setPanInProgress(int x, int y) {
   drawOffsetExtra.set(x, y);
 }
Esempio n. 4
0
 /** reset the pan to the origin and zoom to 1.0 */
 public void resetView() {
   drawOffset.set(0, 0);
   setZoom(1.0f);
 }
Esempio n. 5
0
 /** pan up by the standard amount */
 public void panUp() {
   drawOffset.y -= getHeight() / (DEFAULT_PAN_DIVISOR * zoom);
 }
Esempio n. 6
0
 /** apply the pan in progress */
 public void applyPanInProgress() {
   drawOffset.add(drawOffsetExtra);
   drawOffsetExtra.set(0, 0);
 }
Esempio n. 7
0
 /** pan down by the standard amount */
 public void panDown() {
   drawOffset.y += getHeight() / (DEFAULT_PAN_DIVISOR * zoom);
 }
Esempio n. 8
0
 /** pan right by the standard amount */
 public void panRight() {
   drawOffset.x += getWidth() / (DEFAULT_PAN_DIVISOR * zoom);
 }
Esempio n. 9
0
 /** pan left by the standard amount */
 public void panLeft() {
   drawOffset.x -= getWidth() / (DEFAULT_PAN_DIVISOR * zoom);
 }
Esempio n. 10
0
 /** set the aggregate y-axis pan */
 public void setPanY(int y) {
   drawOffset.y = y;
 }
Esempio n. 11
0
 /** set the aggregate x-axis pan */
 public void setPanX(int x) {
   drawOffset.x = x;
 }