com.maryanovsky.map.client.actions.mouse
Class AreaSelectionAction

java.lang.Object
  extended by com.maryanovsky.map.client.actions.MapAction<HasAllDragHandlers>
      extended by com.maryanovsky.map.client.actions.mouse.AreaSelectionAction
All Implemented Interfaces:
EventHandler, DragCancelHandler, DragEndHandler, DragMoveHandler, DragStartHandler

public class AreaSelectionAction
extends MapAction<HasAllDragHandlers>
implements DragStartHandler, DragMoveHandler, DragEndHandler, DragCancelHandler

A drag action which allows the user to select the area he would like to be displayed on the map.

Author:
Maryanovsky Alexander

Field Summary
 
Fields inherited from class com.maryanovsky.map.client.actions.MapAction
isAnimated, mapWidget
 
Constructor Summary
AreaSelectionAction(MapWidget mapWidget, boolean keepRatio, boolean isAnimated)
          Creates a new AreaSelectionAction for the specified map widget, with optional ratio-keeping and animation of the transition.
 
Method Summary
protected  Widget createSelectionWidget()
          Creates the widget that will display the selected area.
 void onDragCancel(DragCancelEvent evt)
          Invoked when the mouse button is released without creating a drag event.
 void onDragEnd(DragEndEvent evt)
          Invoked when a drag gesture ends.
 void onDragMove(DragMoveEvent evt)
          Invoked when a drag gesture is in progress.
 void onDragStart(DragStartEvent evt)
          Invoked when a drag gesture starts.
 HandlerRegistration registerWith(HasAllDragHandlers dragSource)
          Registers for handling drag events from the specified source.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AreaSelectionAction

public AreaSelectionAction(MapWidget mapWidget,
                           boolean keepRatio,
                           boolean isAnimated)
Creates a new AreaSelectionAction for the specified map widget, with optional ratio-keeping and animation of the transition. If keepRatio is true, the displayed selection will be forced into the same width-to-height ratio as the map widget.

Parameters:
mapWidget - The target map widget.
keepRatio - Whether the width-to-height ratio of the selection rectangle should be restricted to match that of the map widget.
isAnimated - Whether the zoom-in transition is animated.
Method Detail

registerWith

public HandlerRegistration registerWith(HasAllDragHandlers dragSource)
Registers for handling drag events from the specified source.

Specified by:
registerWith in class MapAction<HasAllDragHandlers>

createSelectionWidget

protected Widget createSelectionWidget()
Creates the widget that will display the selected area. The default implementation returns a SimplePanel with another one embedded in it. The style names are map-AreaSelectionActionRectOuter and map-AreaSelectionActionRectInner.


onDragStart

public void onDragStart(DragStartEvent evt)
Invoked when a drag gesture starts.

Specified by:
onDragStart in interface DragStartHandler

onDragCancel

public void onDragCancel(DragCancelEvent evt)
Invoked when the mouse button is released without creating a drag event.

Specified by:
onDragCancel in interface DragCancelHandler

onDragMove

public void onDragMove(DragMoveEvent evt)
Invoked when a drag gesture is in progress.

Specified by:
onDragMove in interface DragMoveHandler

onDragEnd

public void onDragEnd(DragEndEvent evt)
Invoked when a drag gesture ends.

Specified by:
onDragEnd in interface DragEndHandler