org.gvsig.fmap.mapcontrol.tools
Class ZoomOutRightButtonListener

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

public class ZoomOutRightButtonListener
extends java.lang.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 the third button of the mouse.

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:
MapContext.ZOOMOUTFACTOR, ViewPort.setEnvelope(Envelope), ZoomInListenerImpl, ZoomOutListenerImpl

Constructor Summary
ZoomOutRightButtonListener(MapControl mapControl)
          Creates a new ZoomOutRightButtonListener object.
 
Method Summary
 boolean cancelDrawing()
          Determines if the drawing process that this tool executes on the MapControl instance could be canceled or not.
 java.awt.Image getImageCursor()
          Gets the Cursor associated to this tool.
 void point(PointEvent event)
          Called when one click is pressed on the associated MapControl, or the location of the cursor of the mouse has changed on it.
 void pointDoubleClick(PointEvent event)
          Called when a double click is pressed on the associated MapControl.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZoomOutRightButtonListener

public ZoomOutRightButtonListener(MapControl mapControl)

Creates a new ZoomOutRightButtonListener object.

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

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

getImageCursor

public java.awt.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

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

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


Copyright © 2014 gvSIG Association. All Rights Reserved.