@SuppressWarnings("unused")
	public void checkScroll() {
		// get the x and y position in pixels
		int xPos = (int) (this.xIndex * this.zoomFactor);
		int yPos = (int) (this.yIndex * this.zoomFactor);

		// only do this if the image is larger than normal
		if (this.zoomFactor > 1) {

			// get the rectangle that defines the current view
			JViewport viewport = this.scrollPane.getViewport();
			Rectangle rect = viewport.getViewRect();
			int rectMinX = (int) rect.getX();
			int rectWidth = (int) rect.getWidth();
			int rectMaxX = (rectMinX + rectWidth) - 1;
			int rectMinY = (int) rect.getY();
			int rectHeight = (int) rect.getHeight();
			int rectMaxY = (rectMinY + rectHeight) - 1;

			// get the maximum possible x and y index
			int maxIndexX = (int) (this.picture.getWidth() * this.zoomFactor)
					- rectWidth - 1;
			int maxIndexY = (int) (this.picture.getHeight() * this.zoomFactor)
					- rectHeight - 1;

			// calculate how to position the current position in the middle of
			// the viewing
			// area
			int viewX = xPos - (rectWidth / 2);
			int viewY = yPos - (rectHeight / 2);

			// reposition the viewX and viewY if outside allowed values
			if (viewX < 0) {
				viewX = 0;
			} else if (viewX > maxIndexX) {
				viewX = maxIndexX;
			}
			if (viewY < 0) {
				viewY = 0;
			} else if (viewY > maxIndexY) {
				viewY = maxIndexY;
			}

			// move the viewport upper left point
			viewport.scrollRectToVisible(new Rectangle(viewX, viewY, rectWidth,
					rectHeight));
		}
	}