/** * Zooms in the on picture by scaling the image. It is extremely memory intensive. * * @param factor the amount to zoom by */ public void zoom(double factor) { // save the current zoom factor zoomFactor = factor; // calculate the new width and height and get an image that size int width = (int) (picture.getWidth() * zoomFactor); int height = (int) (picture.getHeight() * zoomFactor); BufferedImage bimg = picture.getBufferedImage(); // set the scroll image icon to the new image imageDisplay.setImage(bimg.getScaledInstance(width, height, Image.SCALE_DEFAULT)); imageDisplay.setCurrentX((int) (colIndex * zoomFactor)); imageDisplay.setCurrentY((int) (rowIndex * zoomFactor)); imageDisplay.revalidate(); checkScroll(); // check if need to reposition scroll }