public void pan(float dx, float dy) {
    final float aspectQuotient = mAspectQuotient.get();

    mState.setPanX(mState.getPanX() + dx / mState.getZoomX(aspectQuotient));
    mState.setPanY(mState.getPanY() + dy / mState.getZoomY(aspectQuotient));

    limitPan();

    mState.notifyObservers();
  }
  public void zoom(float f, float x, float y) {
    final float aspectQuotient = mAspectQuotient.get();

    final float prevZoomX = mState.getZoomX(aspectQuotient);
    final float prevZoomY = mState.getZoomY(aspectQuotient);

    mState.setZoom(mState.getZoom() * f);
    limitZoom();

    final float newZoomX = mState.getZoomX(aspectQuotient);
    final float newZoomY = mState.getZoomY(aspectQuotient);

    mState.setPanX(mState.getPanX() + (x - .5f) * (1f / prevZoomX - 1f / newZoomX));
    mState.setPanY(mState.getPanY() + (y - .5f) * (1f / prevZoomY - 1f / newZoomY));

    limitPan();

    mState.notifyObservers();
  }
Пример #3
0
 private void resetZoomState() {
   mZoomState.setPanX(0.5f);
   mZoomState.setPanY(0.5f);
   mZoomState.setZoom(1f);
   mZoomState.notifyObservers();
 }