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; }
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; }
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); }