Class ZoomOutListenerImpl

java.lang.Object
org.gvsig.fmap.mapcontrol.tools.ZoomOutListenerImpl
All Implemented Interfaces:
PointListener, ToolListener

public class ZoomOutListenerImpl extends Object implements PointListener

Listener for doing a zoom out operation on the extent of the ViewPort of the associated MapControl object, selecting a point of the MapControl by a single click of any mouse's button.

Calculates the new extent r with this equations:
ViewPort vp = mapControl.getMapContext().getViewPort();
Point2D p2 = vp.toMapPoint(event.getPoint());
double factor = 1/MapContext.ZOOMOUTFACTOR;
Rectangle2D.Double r = new Rectangle2D.Double();
double nuevoX = p2.getX() - ((vp.getExtent().getWidth() * factor) / 2.0);
double nuevoY = p2.getY() - ((vp.getExtent().getHeight() * factor) / 2.0);
r.x = nuevoX;
r.y = nuevoY;
r.width = vp.getExtent().getWidth() * factor;
r.height = vp.getExtent().getHeight() * factor;
vp.setExtent(r);

The ultimately extent will be an adaptation from that, calculated by the ViewPort bearing in mind the ratio of the available rectangle.

Author:
Vicente Caballero Navarro
See Also:
  • Constructor Details

    • ZoomOutListenerImpl

      public ZoomOutListenerImpl(MapControl mapControl)

      Creates a new ZoomOutListenerImpl object.

      Parameters:
      mapControl - the MapControl where will be applied the changes
  • Method Details

    • point

      public void point(PointEvent event)
      Description copied from interface: PointListener

      Called when one click is pressed on the associated MapControl, or the location of the cursor of the mouse has changed on it.

      Specified by:
      point in interface PointListener
      Parameters:
      event - mouse event with the coordinates of the point selected on the associated MapControl
    • getImageCursor

      public Image getImageCursor()
      Description copied from interface: ToolListener

      Gets the Cursor associated to this tool.

      Specified by:
      getImageCursor in interface ToolListener
      Returns:
      component with the bitmap associated to this tool
    • cancelDrawing

      public boolean cancelDrawing()
      Description copied from interface: ToolListener

      Determines if the drawing process that this tool executes on the MapControl instance could be canceled or not.

      Specified by:
      cancelDrawing in interface ToolListener
      Returns:
      true if is cancellable; otherwise returns false
    • pointDoubleClick

      public void pointDoubleClick(PointEvent event)
      Description copied from interface: PointListener

      Called when a double click is pressed on the associated MapControl.

      Specified by:
      pointDoubleClick in interface PointListener
      Parameters:
      event - mouse event and the coordinates of the point selected on the associated MapControl