org.geotools.gui.tools
Class ZoomToolImpl

java.lang.Object
  extended byorg.geotools.gui.tools.AbstractTool
      extended byorg.geotools.gui.tools.PanToolImpl
          extended byorg.geotools.gui.tools.ZoomToolImpl
All Implemented Interfaces:
java.util.EventListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, PanTool, Tool, ZoomTool

public class ZoomToolImpl
extends PanToolImpl
implements ZoomTool

Provides both Click/Zoom and Drag/Zoom functionality. Processes MouseEvents on behalf of MapPane and constructs a CordinateTransform for the map's Context.
For Click/Zoom, pan the map so that the new extent has the click point in the middle of the map and then zoom in/out by the zoomFactor.
For Drag/Zoom, pan to the center of the dragged area and zoom in to include that area.

Version:
$Id: ZoomToolImpl.java 17672 2006-01-19 00:25:55Z desruisseaux $
Author:
Cameron Shorter

Field Summary
 
Fields inherited from class org.geotools.gui.tools.PanToolImpl
pressPoint, releasePoint
 
Fields inherited from class org.geotools.gui.tools.AbstractTool
context
 
Constructor Summary
ZoomToolImpl()
          Construct a ZoomTool.
ZoomToolImpl(double zoomFactor)
          Construct a ZoomTool
 
Method Summary
 void addMouseListener(java.awt.Component component, MapContext context)
          Register this tool to receive MouseEvents from component.
 void addMouseMotionListener(java.awt.Component component, MapContext context)
           
 double getZoomFactor()
          The factor to zoom in out by, zoomFactor=0.5 means zoom in, zoomFactor=2 means zoom out.
 void mouseClicked(java.awt.event.MouseEvent e)
          Set up Click/Zoom.
 void mouseReleased(java.awt.event.MouseEvent e)
          Set the release point in a click-drag operation and process the drag operation.
 void setZoomFactor(double zoomFactor)
          The factor to zoom in out by when processing mouseClicks. zoomFactor=0.5 means zoom in, zoomFactor=2 means zoom out.
 
Methods inherited from class org.geotools.gui.tools.PanToolImpl
applyZoomTransform, mousePressed
 
Methods inherited from class org.geotools.gui.tools.AbstractTool
addMouseListener, addMouseMotionListener, destroy, getContext, getCursor, getName, mouseDragged, mouseEntered, mouseExited, mouseMoved, paint, removeMouseListeners, setCursor, setName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.geotools.gui.tools.Tool
destroy, getContext, getCursor, getName, paint, removeMouseListeners, setCursor, setName
 

Constructor Detail

ZoomToolImpl

public ZoomToolImpl()
Construct a ZoomTool.


ZoomToolImpl

public ZoomToolImpl(double zoomFactor)
Construct a ZoomTool. /

Parameters:
zoomFactor - the factor to zoom in/out by, zoomFactor=2 means zoom in, zoomFactor=0.5 means zoom out.
Method Detail

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Set up Click/Zoom. Pan the map so that the new extent has the click point in the middle of the map and then zoom in/out by the zoomFactor.

Specified by:
mouseClicked in interface java.awt.event.MouseListener
Overrides:
mouseClicked in class PanToolImpl
Parameters:
e - The mouse clicked event.

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Set the release point in a click-drag operation and process the drag operation. The new areaOfInterest will be centered round the middle of the dragged area and zoomed in to include the all the dragged box. The aspect ratio of the old area of interest is maintained. That means, you cannot cause the map to become skinny or fat.

Specified by:
mouseReleased in interface java.awt.event.MouseListener
Overrides:
mouseReleased in class PanToolImpl
Parameters:
e - contains the mouse click.

addMouseListener

public void addMouseListener(java.awt.Component component,
                             MapContext context)
Register this tool to receive MouseEvents from component.

Specified by:
addMouseListener in interface Tool
Overrides:
addMouseListener in class PanToolImpl
Parameters:
component - The tool will process mouseEvents from this component.
context - The Context that will be changed by this Tool.

addMouseMotionListener

public void addMouseMotionListener(java.awt.Component component,
                                   MapContext context)
                            throws java.lang.IllegalArgumentException
Specified by:
addMouseMotionListener in interface Tool
Overrides:
addMouseMotionListener in class PanToolImpl
Throws:
java.lang.IllegalArgumentException

setZoomFactor

public void setZoomFactor(double zoomFactor)
The factor to zoom in out by when processing mouseClicks. zoomFactor=0.5 means zoom in, zoomFactor=2 means zoom out. Defaults to 2.

Specified by:
setZoomFactor in interface ZoomTool
Parameters:
zoomFactor - The factor to zoom in/out by.

getZoomFactor

public double getZoomFactor()
The factor to zoom in out by, zoomFactor=0.5 means zoom in, zoomFactor=2 means zoom out. Defaults to 2.

Specified by:
getZoomFactor in interface ZoomTool
Returns:
The factor to zoom in/out by.


Copyright © GeoTools. All Rights Reserved.