This feature prevents zooming to carry-out the size of view box. Via an Interactor overriding it verifies that the x and y values applied on the scaling matrix of the rendering transform do not become smaller than 1.

   1 canvas.getInteractors().add(new AbstractImageZoomInteractor() {
   2 
   3     @Override
   4     public boolean startInteraction(InputEvent ie) {
   5         int mods = ie.getModifiers();
   6         boolean b = ie.getID() == MouseEvent.MOUSE_PRESSED;
   7         return b;
   8     }
   9 
  10     @Override
  11     public void mouseReleased(MouseEvent e) {
  12         JGVTComponent c = (JGVTComponent) e.getSource();
  13         AffineTransform pt = c.getPaintingTransform();
  14         AffineTransform rt = (AffineTransform) c.getRenderingTransform().clone();
  15 
  16         if (pt != null) {
  17             rt.preConcatenate(pt);
  18 
  19             if (rt.getScaleX() < 1 || rt.getScaleY() < 1) {
  20                 // If the zoom-out goes beyond the ViewBox sets the original transformation
  21                 c.resetRenderingTransform();
  22             } else {
  23                 c.setRenderingTransform(rt);
  24             }
  25         }
  26     }
  27 });

ZoomOutLimit (last edited 2012-06-22 14:16:13 by drool)