public class MoveCommand extends Command
Command.OldNodeState| Modifier and Type | Field and Description |
|---|---|
private double |
backupX |
private double |
backupY |
private java.util.Collection<Node> |
nodes
The objects that should be moved.
|
private java.util.List<Command.OldNodeState> |
oldState
List of all old states of the objects.
|
private EastNorth |
startEN
Starting position, base command point, current (mouse-drag) position = startEN + (x,y) =
|
private double |
x
x difference movement.
|
private double |
y
y difference movement.
|
| Constructor and Description |
|---|
MoveCommand(java.util.Collection<OsmPrimitive> objects,
double x,
double y)
Constructs a new
MoveCommand and assign the initial object set and movement vector. |
MoveCommand(java.util.Collection<OsmPrimitive> objects,
EastNorth offset)
Constructs a new
MoveCommand to move a collection of primitives. |
MoveCommand(java.util.Collection<OsmPrimitive> objects,
EastNorth start,
EastNorth end)
Constructs a new
MoveCommand to move a collection of primitives. |
MoveCommand(Node node,
LatLon position)
Constructs a new
MoveCommand to move a node. |
MoveCommand(OsmPrimitive osm,
double x,
double y)
Constructs a new
MoveCommand to move a primitive. |
MoveCommand(OsmPrimitive p,
EastNorth start,
EastNorth end)
Constructs a new
MoveCommand to move a primitive. |
| Modifier and Type | Method and Description |
|---|---|
void |
applyVectorTo(EastNorth currentEN)
Change the displacement vector to have endpoint
currentEN. |
void |
changeStartPoint(EastNorth newDraggedStartPoint)
Changes base point of movement
|
boolean |
equals(java.lang.Object obj) |
boolean |
executeCommand()
Executes the command on the dataset.
|
void |
fillModifiedData(java.util.Collection<OsmPrimitive> modified,
java.util.Collection<OsmPrimitive> deleted,
java.util.Collection<OsmPrimitive> added)
Fill in the changed data this command operates on.
|
javax.swing.Icon |
getDescriptionIcon()
Provides a descriptive icon of this command.
|
java.lang.String |
getDescriptionText()
Provides a description text representing this command.
|
java.util.Collection<Node> |
getParticipatingPrimitives()
Return the primitives that take part in this command.
|
int |
hashCode() |
void |
moveAgain(double x,
double y)
Move the same set of objects again by the specified vector.
|
void |
moveAgainTo(double x,
double y)
Move again to the specified coordinates.
|
void |
resetToCheckpoint()
Restore old displacement in case of some problems
|
void |
saveCheckpoint()
Save curent displacement to restore in case of some problems
|
void |
undoCommand()
Undoes the command.
|
private void |
updateCoordinates() |
checkAndConfirmOutlyingOperation, getAffectedDataSet, getLayer, getOrig, invalidateAffectedLayers, invalidBecauselayerRemovedgetChildrenprivate EastNorth startEN
private double x
private double y
private double backupX
private double backupY
private final java.util.List<Command.OldNodeState> oldState
public MoveCommand(OsmPrimitive osm, double x, double y)
MoveCommand to move a primitive.osm - The primitive to movex - X difference movement. Coordinates are in northern/easterny - Y difference movement. Coordinates are in northern/easternpublic MoveCommand(Node node, LatLon position)
MoveCommand to move a node.node - The node to moveposition - The new location (lat/lon)public MoveCommand(java.util.Collection<OsmPrimitive> objects, EastNorth offset)
MoveCommand to move a collection of primitives.objects - The primitives to moveoffset - The movement vectorpublic MoveCommand(java.util.Collection<OsmPrimitive> objects, double x, double y)
MoveCommand and assign the initial object set and movement vector.objects - The primitives to movex - X difference movement. Coordinates are in northern/easterny - Y difference movement. Coordinates are in northern/easternpublic MoveCommand(java.util.Collection<OsmPrimitive> objects, EastNorth start, EastNorth end)
MoveCommand to move a collection of primitives.objects - The primitives to movestart - The starting position (northern/eastern)end - The ending position (northern/eastern)public MoveCommand(OsmPrimitive p, EastNorth start, EastNorth end)
MoveCommand to move a primitive.p - The primitive to movestart - The starting position (northern/eastern)end - The ending position (northern/eastern)public void moveAgain(double x, double y)
x - X difference movement. Coordinates are in northern/easterny - Y difference movement. Coordinates are in northern/easternpublic void moveAgainTo(double x, double y)
x - X coordinatey - Y coordinatemoveAgain(double, double)public void applyVectorTo(EastNorth currentEN)
currentEN.
starting point is startENcurrentEN - the new endpointpublic void changeStartPoint(EastNorth newDraggedStartPoint)
newDraggedStartPoint - - new starting point after movement (where user clicks to start new drag)public final void saveCheckpoint()
public void resetToCheckpoint()
private void updateCoordinates()
public boolean executeCommand()
CommandThe layer should be invalidated after execution so that it can be re-painted.
executeCommand in class CommandCommand.invalidateAffectedLayers()public void undoCommand()
CommandundoCommand in class Commandpublic void fillModifiedData(java.util.Collection<OsmPrimitive> modified, java.util.Collection<OsmPrimitive> deleted, java.util.Collection<OsmPrimitive> added)
CommandfillModifiedData in class Commandmodified - The modified primitivesdeleted - The deleted primitivesadded - The added primitivespublic java.lang.String getDescriptionText()
PseudoCommandgetDescriptionText in class PseudoCommandpublic javax.swing.Icon getDescriptionIcon()
PseudoCommandgetDescriptionIcon in class PseudoCommandpublic java.util.Collection<Node> getParticipatingPrimitives()
CommandgetParticipatingPrimitives in class Command