com.partnersoft.maps.model
Class MapEditContext

java.lang.Object
  extended by com.partnersoft.maps.model.MapEditContext
All Implemented Interfaces:
Immutable

public class MapEditContext
extends java.lang.Object
implements Immutable

Encapsulates the parameters for all map editing commands.

This allows us to add more parameters without modifying the method signatures for MapEditActor implementations.

Not all parameters will be valid for any given edit action. For example, a delete command will only have the current selection as a parameter.

Copyright 2007 Partner Software, Inc.

Version:
$Id: MapEditContext.java 2328 2010-01-06 15:38:22Z paul $
Author:
Paul Reavis

Method Summary
static MapEditContext forAdd(MapApp app)
           
static MapEditContext forAdd(MapApp app, MapEditTool tool, XyPoint point)
           
static MapEditContext forAdd(MapApp app, XyPoint point)
           
static MapEditContext forAdd(MapApp app, XyPoint point, SurveyedLocation surveyedLocation)
           
static MapEditContext forAddMany(MapApp app)
           
static MapEditContext forConnect(MapApp app)
           
static MapEditContext forConnect(MapApp app, XyPoint point)
           
static MapEditContext forConvert(MapApp app)
           
static MapEditContext forCopy(MapApp app)
           
static MapEditContext forDelete(MapApp app)
           
static MapEditContext forEdit(MapApp app)
           
static MapEditContext forMove(MapApp app)
           
static MapEditContext forMove(MapApp app, XyPoint point)
           
static MapEditContext forMove(MapApp app, XyPoint point, SurveyedLocation surveyedLocation)
           
static MapEditContext forRotate(MapApp app)
           
static MapEditContext forRotate(MapApp app, XyDirection direction)
           
static MapEditContext forRotate(MapApp app, XyPoint point)
           
static MapEditContext forSelection(MapApp app)
           
static MapEditContext forWheel(MapApp app)
           
 java.lang.String getAction()
           The editing mode or action - one of "add", "delete", "move", "copy", "convert", "menu", or "browse".
 int getActionCount()
          Returns the sequence number in a multi-part action (e.g.
 MapApp getApp()
           
 XyDirection getDirection()
          Returns the vector (generally from the selected item to the mouse click location) as a direction.
 double getDistance()
          Returns the distance moved in map units.
 MapViewFrame getFrame()
           
 XyPoint getLocation()
          The new location for the item (e.g.
 XyPoint getMenuLocation()
          The center of the wheel menu.
 int getPixelDistance()
          Returns the distance moved in pixel units.
 XyRotation getRotation()
          Returns the vector (generally from the selected item to the mouse click location) as a rotation.
 MapDataItem getSelected()
          The current selection.
 SurveyedLocation getSurveyedLocation()
           Set by MapEditLogic.addGPS() and .moveGPS() if the location was surveyed by a GPS.
 MapEditTool getTool()
          The current tool selection.
 XyVector getVector()
          Returns the vector (generally from the selected item location to the mouse click location).
 java.lang.String toString()
           
 MapEditContext withAction(java.lang.String newAction)
          Creates a MapEditContext with the same parameters as the current object, except with the new action.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

forSelection

public static MapEditContext forSelection(MapApp app)

forAdd

public static MapEditContext forAdd(MapApp app)

forAddMany

public static MapEditContext forAddMany(MapApp app)

forAdd

public static MapEditContext forAdd(MapApp app,
                                    XyPoint point)

forAdd

public static MapEditContext forAdd(MapApp app,
                                    MapEditTool tool,
                                    XyPoint point)

forAdd

public static MapEditContext forAdd(MapApp app,
                                    XyPoint point,
                                    SurveyedLocation surveyedLocation)

forConvert

public static MapEditContext forConvert(MapApp app)

forCopy

public static MapEditContext forCopy(MapApp app)

forDelete

public static MapEditContext forDelete(MapApp app)

forEdit

public static MapEditContext forEdit(MapApp app)

forMove

public static MapEditContext forMove(MapApp app)

forMove

public static MapEditContext forMove(MapApp app,
                                     XyPoint point,
                                     SurveyedLocation surveyedLocation)

forMove

public static MapEditContext forMove(MapApp app,
                                     XyPoint point)

forRotate

public static MapEditContext forRotate(MapApp app)

forRotate

public static MapEditContext forRotate(MapApp app,
                                       XyDirection direction)

forRotate

public static MapEditContext forRotate(MapApp app,
                                       XyPoint point)

forWheel

public static MapEditContext forWheel(MapApp app)

forConnect

public static MapEditContext forConnect(MapApp app)

forConnect

public static MapEditContext forConnect(MapApp app,
                                        XyPoint point)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getDistance

public double getDistance()
Returns the distance moved in map units. Returns zero if this was not a move action or if there was no selection.


getPixelDistance

public int getPixelDistance()
Returns the distance moved in pixel units. Returns zero if this was not a move action or if there was no selection.


getAction

public java.lang.String getAction()

The editing mode or action - one of "add", "delete", "move", "copy", "convert", "menu", or "browse".

RDC: added "add GPS" and "move GPS" to the list of actions.


getApp

public MapApp getApp()

getSelected

public MapDataItem getSelected()
The current selection.


getLocation

public XyPoint getLocation()
The new location for the item (e.g. designated by a move or add action).


getMenuLocation

public XyPoint getMenuLocation()
The center of the wheel menu. This is not necessarily the same as MapDataItem.getLocation() (e.g. if you select a line). Useful for some kinds of move commands.


getTool

public MapEditTool getTool()
The current tool selection.


getVector

public XyVector getVector()
Returns the vector (generally from the selected item location to the mouse click location).


getDirection

public XyDirection getDirection()
Returns the vector (generally from the selected item to the mouse click location) as a direction.

Returns:

withAction

public MapEditContext withAction(java.lang.String newAction)
Creates a MapEditContext with the same parameters as the current object, except with the new action.

Parameters:
newAction - - Action name to set in new MapEditContext.
Returns:

getRotation

public XyRotation getRotation()
Returns the vector (generally from the selected item to the mouse click location) as a rotation.

Returns:

getFrame

public MapViewFrame getFrame()

getSurveyedLocation

public SurveyedLocation getSurveyedLocation()

Set by MapEditLogic.addGPS() and .moveGPS() if the location was surveyed by a GPS. If the location was not surveyed, this returns null.

The surveyed location object provides a GUID to the drawing actor that will match up to a post-processed point. If post-processing is not being done, the GUID will be null. Actors should store the GUID with the locations to do post-procesasing.

Aside from the GUID, a surveyed location works exactly like a normal location. The latitude and longitude have already been projected and stored in the context's location.

Returns:

getActionCount

public int getActionCount()
Returns the sequence number in a multi-part action (e.g. when ADD_LOCKED).

Returns: