public void magnify(double magnification) {
    double prev = myMagnification;
    myMagnification = magnification;

    if (myCachedImage == null) {
      Rectangle bounds = myViewportComponent.getBounds();
      if (bounds.width <= 0 || bounds.height <= 0) return;

      BufferedImage image =
        ImageUtil.createImage(myViewportComponent.getGraphics(), bounds.width, bounds.height, BufferedImage.TYPE_INT_RGB);

      Graphics graphics = image.getGraphics();
      graphics.setClip(0, 0, bounds.width, bounds.height);
      myViewportComponent.paint(graphics);

      myCachedImage = image;
    }
    if (Double.compare(prev, magnification) != 0) {
      myViewportComponent.repaint();
    }
  }
public void magnify(double magnification)