コード例 #1
0
  private int checkBordersX(float scaleFactor, int xPos) {

    if ((mImageViewBase.getImageWidth() + xPos) * scaleFactor < mImageViewBase.getFrameWidth()) {
      xPos = (int) (mImageViewBase.getFrameWidth() / scaleFactor - mImageViewBase.getImageWidth());
    }

    if (xPos > 0) {
      xPos = 0;
    }

    return xPos;
  }
コード例 #2
0
  private int checkBordersY(float scaleFactor, int yPos) {

    if ((mImageViewBase.getImageHeight() + yPos) * scaleFactor < mImageViewBase.getFrameHeigth()) {
      yPos =
          (int) (mImageViewBase.getFrameHeigth() / scaleFactor - mImageViewBase.getImageHeight());
    }

    if (yPos > 0) {
      yPos = 0;
    }

    return yPos;
  }
コード例 #3
0
  private void pan(float dx, float dy, float scaleFactor, int xPos, int yPos) {

    // compute new position
    xPos += dx / scaleFactor;
    yPos += dy / scaleFactor;

    // check if we meet border
    xPos = checkBordersX(scaleFactor, xPos);
    yPos = checkBordersY(scaleFactor, yPos);

    // update position
    mImageViewBase.setImageXPosition(xPos);
    mImageViewBase.setImageYPosition(yPos);
  }