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.
Constructor and Description |
---|
ZoomOutListenerImpl(MapControl mapControl)
Creates a new
ZoomOutListenerImpl object. |
Modifier and Type | Method and Description |
---|---|
boolean |
cancelDrawing()
Determines if the drawing process that this tool executes on the
MapControl
instance could be canceled or not. |
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 . |
public ZoomOutListenerImpl(MapControl mapControl)
Creates a new ZoomOutListenerImpl
object.
mapControl
- the MapControl
where will be applied the changespublic void point(PointEvent event)
PointListener
Called when one click is pressed on the associated MapControl
, or the location of the cursor
of the mouse has changed on it.
point
in interface PointListener
event
- mouse event with the coordinates of the point selected on the associated MapControl
public Image getImageCursor()
ToolListener
Gets the Cursor
associated to this tool.
getImageCursor
in interface ToolListener
public boolean cancelDrawing()
ToolListener
Determines if the drawing process that this tool executes on the MapControl
instance could be canceled or not.
cancelDrawing
in interface ToolListener
true
if is cancellable; otherwise returns false
public void pointDoubleClick(PointEvent event)
PointListener
Called when a double click is pressed on the associated MapControl
.
pointDoubleClick
in interface PointListener
event
- mouse event and the coordinates of the point selected on the associated MapControl