com.esri.adf.web.faces.event
Class MapEvent

java.lang.Object
  extended by java.util.EventObject
      extended by javax.faces.event.FacesEvent
          extended by javax.faces.event.ActionEvent
              extended by com.esri.adf.web.faces.event.ADFEvent
                  extended by com.esri.adf.web.faces.event.MapEvent
All Implemented Interfaces:
Serializable

public class MapEvent
extends ADFEvent

A MapEvent object is created by the MapControl when a map tool is invoked. This object is passed to the execute(MapEvent) method of the MapToolAction or to the tool method designated by the user.

In addition to the information provided by the ADFEvent base class, this class gives the tools access to the ClientActionArgs as well as a shortcut to the WebGeometry representing the shape that the client had drawn on the map to invoke the tool.

More often than not, the tools will only invoke this shortcut method getWebGeometry() to get to the geometry. This geometry is in screen coordinates. You can use the toMapGeometry(WebMap) method on the WebGeometry to convert it to map coordinates:

 public void myToolMethod(MapEvent event) {
   WebContext ctx = event.getWebContext();
   WebGeometry screenGeom = event.getWebGeometry();
   WebGeometry mapGeom = screen.toMapGeometry(ctx.getWebMap());
   ...
 }
 

The getWebGeometry() method in this class is actually a shortcut to ClientActionArgs.getWebGeometry(). The actual type of geometry ( WebPoint, WebExtent, etc.) depends on the ClientActionArgs that it comes from. The ClientActionArgs in turn depends on the client action (Javascript method) called on the map control on the client. The out of the box client actions are defined in the ClientActions interface. The mappings for out of the box client actions are as follows:

Client Action - ClientActionArgs - WebGeometry mappings
Client JavaScript Action     ClientActionArgs WebGeometry
ClientActions.MAP_POINT(adf.MapPoint) PointArgs WebPoint
ClientActions.MAP_LINE(adf.MapLine) LineArgs WebPolyline
ClientActions.MAP_RECTANGLE(adf.MapRectangle) DragRectangleArgs WebExtent
ClientActions.MAP_CIRCLE(adf.MapCircle) CircleArgs WebCircle
ClientActions.MAP_OVAL(adf.MapOval) OvalArgs WebOval
ClientActions.MAP_POLYLINE(adf.MapPolyline) PolylineArgs WebPolyline
ClientActions.MAP_POLYGON(adf.MapPolygon) PolygonArgs WebPolygon
ClientActions.MAP_PAN(adf.MapPan) DragImageArgs WebPoint

So if the client action associated with the myToolMethod() tool from above was adf.MapPoint, the corresponding geometry would be WebPoint, in which case you would cast the mapGeom to WebPoint:

 WebPoint mapPt = (WebPoint) mapGeom;
 

See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.esri.adf.web.faces.event.ADFEvent
context, parameters
 
Fields inherited from class java.util.EventObject
source
 
Constructor Summary
MapEvent(javax.faces.component.UIComponent source, javax.faces.context.FacesContext facesContext, WebContext context, MapToolAction toolAction, ClientActionArgs clientActionArgs, ToolItem toolItem)
           Constructs the MapEvent object with the given tool and ClientActionArgs.
 
Method Summary
 ClientActionArgs getClientActionArgs()
           Returns the ClientActionArgs which represents the action performed at the client.
 WebGeometry getMapGeometry()
           Returns the WebGeometry in map coordinates corresponding to the client action performed by the user.
 MapToolAction getMapToolAction()
           Returns the MapToolAction that needs to be invoked to process this event.
 ToolItem getToolItem()
           Returns the ToolItem associated with the tool action that gets invoked to process this event.
 WebGeometry getWebGeometry()
           Returns the WebGeometry in screen coordinates corresponding to the client action performed by the user.
 
Methods inherited from class com.esri.adf.web.faces.event.ADFEvent
getParameter, getWebContext
 
Methods inherited from class javax.faces.event.ActionEvent
isAppropriateListener, processListener
 
Methods inherited from class javax.faces.event.FacesEvent
getComponent, getPhaseId, queue, setPhaseId
 
Methods inherited from class java.util.EventObject
getSource, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MapEvent

public MapEvent(javax.faces.component.UIComponent source,
                javax.faces.context.FacesContext facesContext,
                WebContext context,
                MapToolAction toolAction,
                ClientActionArgs clientActionArgs,
                ToolItem toolItem)

Constructs the MapEvent object with the given tool and ClientActionArgs. The MapControl creates this event and also passes this event object to the associated tool action.

If the toolAction is not null, the map control calls the execute(MapEvent) method of this MapToolAction. Otherwise, it calls the tool method associated with the toolItem

Parameters:
source - the UIComponent that created this event
facesContext - the current FacesContext
context - the associated WebContext
toolAction - the MapToolAction that gets invoked to process this event
clientActionArgs - the ClientActionArgs associated with this event
toolItem - the ToolItem of the tool method that gets invoked to process this event
Method Detail

getClientActionArgs

public ClientActionArgs getClientActionArgs()

Returns the ClientActionArgs which represents the action performed at the client. This object is created by the MapControl depending on the client action (Javascript method) that was invoked at the client. The detailed mappings table is here.

Returns:
the ClientActionArgs which represents the action performed at the client

getMapToolAction

public MapToolAction getMapToolAction()

Returns the MapToolAction that needs to be invoked to process this event.

If it is not null, the MapControl calls the execute(MapEvent) method of this tool action. If it is null, then it invokes the tool method associated with the ToolItem returned by the getToolItem() method.

Returns:
the MapToolAction that needs to be invoked to process this event

getToolItem

public ToolItem getToolItem()

Returns the ToolItem associated with the tool action that gets invoked to process this event.

If getMapToolAction() returns null, the MapControl invokes the tool method associated with the ToolItem returned by this method.

Returns:
the ToolItem associated with the tool action that gets invoked to process this event

getWebGeometry

public WebGeometry getWebGeometry()

Returns the WebGeometry in screen coordinates corresponding to the client action performed by the user.

This method is actually a shortcut to ClientActionArgs.getWebGeometry(). The actual type of geometry (WebPoint, WebExtent, etc.) depends on the ClientActionArgs that it comes from. The ClientActionArgs in turn depends on the client action (Javascript method) called on the map control on the client. The detailed mappings table is here.

Returns:
the WebGeometry in screen coordinates corresponding to the client action performed by the user

getMapGeometry

public WebGeometry getMapGeometry()

Returns the WebGeometry in map coordinates corresponding to the client action performed by the user.

This method is actually a shortcut to ClientActionArgs.getMapGeometry(). The actual type of geometry (WebPoint, WebExtent, etc.) depends on the ClientActionArgs that it comes from. The ClientActionArgs in turn depends on the client action (Javascript method) called on the map control on the client. The detailed mappings table is here.

Returns:
the WebGeometry in map coordinates corresponding to the client action performed by the user