Package org.openstreetmap.josm.command
Class MoveCommand
java.lang.Object
org.openstreetmap.josm.command.Command
org.openstreetmap.josm.command.MoveCommand
- All Implemented Interfaces:
PseudoCommand
MoveCommand moves a set of OsmPrimitives along the map. It can be moved again
to collect several MoveCommands into one command.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.openstreetmap.josm.command.Command
Command.OldNodeState -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate doubleprivate doubleprivate Collection<Node>The objects that should be moved.private final List<Command.OldNodeState>List of all old states of the objects.private EastNorthStarting position, base command point, current (mouse-drag) position = startEN + (x,y) =private doublex difference movement.private doubley difference movement.Fields inherited from class org.openstreetmap.josm.command.Command
IS_INCOMPLETE, IS_OK, IS_OUTSIDE -
Constructor Summary
ConstructorsConstructorDescriptionMoveCommand(Collection<OsmPrimitive> objects, double x, double y) Constructs a newMoveCommandand assign the initial object set and movement vector.MoveCommand(Collection<OsmPrimitive> objects, EastNorth offset) Constructs a newMoveCommandto move a collection of primitives.MoveCommand(Collection<OsmPrimitive> objects, EastNorth start, EastNorth end) Constructs a newMoveCommandto move a collection of primitives.MoveCommand(DataSet ds, Collection<OsmPrimitive> objects, double x, double y) Constructs a newMoveCommandand assign the initial object set and movement vector.MoveCommand(DataSet ds, Collection<OsmPrimitive> objects, EastNorth start, EastNorth end) Constructs a newMoveCommandto move a collection of primitives.MoveCommand(DataSet ds, OsmPrimitive p, EastNorth start, EastNorth end) Constructs a newMoveCommandto move a primitive.MoveCommand(Node node, LatLon position) Constructs a newMoveCommandto move a node.MoveCommand(OsmPrimitive osm, double x, double y) Constructs a newMoveCommandto move a primitive.MoveCommand(OsmPrimitive p, EastNorth start, EastNorth end) Constructs a newMoveCommandto move a primitive. -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyVectorTo(EastNorth currentEN) Change the displacement vector to have endpointcurrentEN.voidchangeStartPoint(EastNorth newDraggedStartPoint) Changes base point of movementbooleanbooleanExecutes the command on the dataset.voidfillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) Fill in the changed data this command operates on.Provides a descriptive icon of this command.Provides a description text representing this command.doublegetDistance(Predicate<Node> predicate) Computes the move distance for one node matching the specified predicateprotected EastNorthGets the current move offset.Return the primitives that take part in this command.inthashCode()voidmoveAgain(double x, double y) Move the same set of objects again by the specified vector.voidmoveAgainTo(double x, double y) Move again to the specified coordinates.voidRestore old displacement in case of some problemsfinal voidSave current displacement to restore in case of some problemsvoidUndoes the command.private voidMethods inherited from class org.openstreetmap.josm.command.Command
checkOutlyingOrIncompleteOperation, ensurePrimitivesAreInDataset, getAffectedDataSet, getOrigMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.openstreetmap.josm.command.PseudoCommand
getChildren
-
Field Details
-
nodes
The objects that should be moved. -
startEN
Starting position, base command point, current (mouse-drag) position = startEN + (x,y) = -
x
x difference movement. Coordinates are in northern/eastern -
y
y difference movement. Coordinates are in northern/eastern -
backupX
-
backupY
-
oldState
List of all old states of the objects.
-
-
Constructor Details
-
MoveCommand
Constructs a newMoveCommandto move a primitive.- Parameters:
osm- The primitive to movex- X difference movement. Coordinates are in northern/easterny- Y difference movement. Coordinates are in northern/eastern
-
MoveCommand
Constructs a newMoveCommandto move a node.- Parameters:
node- The node to moveposition- The new location (lat/lon)
-
MoveCommand
Constructs a newMoveCommandto move a collection of primitives.- Parameters:
objects- The primitives to moveoffset- The movement vector
-
MoveCommand
Constructs a newMoveCommandand assign the initial object set and movement vector.- Parameters:
objects- The primitives to move. Must neither be null nor empty. Objects must belong to a data setx- X difference movement. Coordinates are in northern/easterny- Y difference movement. Coordinates are in northern/eastern- Throws:
NullPointerException- if objects is null or contain null itemNoSuchElementException- if objects is empty
-
MoveCommand
Constructs a newMoveCommandand assign the initial object set and movement vector.- Parameters:
ds- the dataset context for moving these primitives. Must not be null.objects- The primitives to move. Must neither be null.x- X difference movement. Coordinates are in northern/easterny- Y difference movement. Coordinates are in northern/eastern- Throws:
NullPointerException- if objects is null or contain null itemNoSuchElementException- if objects is empty- Since:
- 12759
-
MoveCommand
Constructs a newMoveCommandto move a collection of primitives.- Parameters:
ds- the dataset context for moving these primitives. Must not be null.objects- The primitives to movestart- The starting position (northern/eastern)end- The ending position (northern/eastern)- Since:
- 12759
-
MoveCommand
Constructs a newMoveCommandto move a collection of primitives.- Parameters:
objects- The primitives to movestart- The starting position (northern/eastern)end- The ending position (northern/eastern)
-
MoveCommand
Constructs a newMoveCommandto move a primitive.- Parameters:
ds- the dataset context for moving these primitives. Must not be null.p- The primitive to movestart- The starting position (northern/eastern)end- The ending position (northern/eastern)- Since:
- 12759
-
MoveCommand
Constructs a newMoveCommandto move a primitive.- Parameters:
p- The primitive to movestart- The starting position (northern/eastern)end- The ending position (northern/eastern)
-
-
Method Details
-
moveAgain
Move the same set of objects again by the specified vector. The vectors are added together and so the resulting will be moved to the previous vector plus this one. The move is immediately executed and any undo will undo both vectors to the original position the objects had before first moving.- Parameters:
x- X difference movement. Coordinates are in northern/easterny- Y difference movement. Coordinates are in northern/eastern
-
moveAgainTo
Move again to the specified coordinates.- Parameters:
x- X coordinatey- Y coordinate- See Also:
-
applyVectorTo
Change the displacement vector to have endpointcurrentEN. starting point is startEN- Parameters:
currentEN- the new endpoint
-
changeStartPoint
Changes base point of movement- Parameters:
newDraggedStartPoint- - new starting point after movement (where user clicks to start new drag)
-
saveCheckpoint
Save current displacement to restore in case of some problems -
resetToCheckpoint
Restore old displacement in case of some problems -
updateCoordinates
-
executeCommand
Description copied from class:CommandExecutes the command on the dataset. This implementation will remember all primitives returned by fillModifiedData for restoring them on undo.The layer should be invalidated after execution so that it can be re-painted.
- Overrides:
executeCommandin classCommand- Returns:
- true
-
undoCommand
Description copied from class:CommandUndoes the command. It can be assumed that all objects are in the same state they were before. It can also be assumed that executeCommand was called exactly once before. This implementation undoes all objects stored by a former call to executeCommand.- Overrides:
undoCommandin classCommand
-
fillModifiedData
public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) Description copied from class:CommandFill in the changed data this command operates on. Add to the lists, don't clear them.- Specified by:
fillModifiedDatain classCommand- Parameters:
modified- The modified primitivesdeleted- The deleted primitivesadded- The added primitives
-
getDescriptionText
Description copied from interface:PseudoCommandProvides a description text representing this command.- Returns:
- description text representing this command
-
getDescriptionIcon
Description copied from interface:PseudoCommandProvides a descriptive icon of this command.- Returns:
- descriptive icon of this command
-
getParticipatingPrimitives
Description copied from class:CommandReturn the primitives that take part in this command. The collection is computed during execution.- Specified by:
getParticipatingPrimitivesin interfacePseudoCommand- Overrides:
getParticipatingPrimitivesin classCommand- Returns:
- primitives that take part in this command
-
getOffset
Gets the current move offset.- Returns:
- The current move offset.
-
getDistance
Computes the move distance for one node matching the specified predicate- Parameters:
predicate- predicate to match- Returns:
- distance in metres
-
hashCode
-
equals
-