org.gvsig.fmap.mapcontrol.tools
Class ZoomInListenerImpl

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

public class ZoomInListenerImpl
extends java.lang.Object
implements RectangleListener

Listener for doing a zoom in operation of the extent of the ViewPort of the associated MapControl object, defining a rectangular area.

If the area defined is smaller than 3 pixels x 3 pixels holds the zoom, otherwise, calculates the new extent r with this equations:
double factor = 1/MapContext.ZOOMINFACTOR;
Rectangle2D rect = event.getWorldCoordRect();
Rectangle2D.Double r = new Rectangle2D.Double();
ViewPort vp = mapCtrl.getMapContext().getViewPort();
double nuevoX = rect.getMaxX() - ((vp.getExtent().getWidth() * factor) / 2.0);
double nuevoY = rect.getMaxY() - ((vp.getExtent().getHeight() * factor) / 2.0);
Rectangle2D.Double r; // This will be the new extent
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 where display the graphical information.

Author:
Vicente Caballero Navarro
See Also:
MapContext.ZOOMINFACTOR, ViewPort.setEnvelope(Envelope), ZoomOutListenerImpl, ZoomOutRightButtonListener

Constructor Summary
ZoomInListenerImpl()
           
ZoomInListenerImpl(MapControl mapCtrl)
          Creates a new ZoomInListenerImpl 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 rectangle(EnvelopeEvent event)
          Called when user executes a double click with the mouse, finishing the drawn of the rectangle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZoomInListenerImpl

public ZoomInListenerImpl()

ZoomInListenerImpl

public ZoomInListenerImpl(MapControl mapCtrl)

Creates a new ZoomInListenerImpl object.

Parameters:
mapCtrl - the MapControl where is defined the rectangle
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

rectangle

public void rectangle(EnvelopeEvent event)
Description copied from interface: RectangleListener

Called when user executes a double click with the mouse, finishing the drawn of the rectangle.

All features of the active and vector layers of the associated MapControl object that their area intersect with the polygonal area defined in the event, will be selected.

Specified by:
rectangle in interface RectangleListener
Parameters:
event - mouse event and information about the rectangle defined


Copyright © 2014 gvSIG Association. All Rights Reserved.