org.openstreetmap.josm.command
Class MoveCommand

java.lang.Object
  extended by org.openstreetmap.josm.command.PseudoCommand
      extended by org.openstreetmap.josm.command.Command
          extended by org.openstreetmap.josm.command.MoveCommand

public class MoveCommand
extends Command

MoveCommand moves a set of OsmPrimitives along the map. It can be moved again to collect several MoveCommands into one command.


Nested Class Summary
static class MoveCommand.OldState
          Small helper for holding the interesting part of the old data state of the objects.
 
Field Summary
private  double backupX
           
private  double backupY
           
private  java.util.Collection<Node> nodes
          The objects that should be moved.
private  java.util.List<MoveCommand.OldState> 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 Summary
MoveCommand(java.util.Collection<OsmPrimitive> objects, double x, double y)
          Create a MoveCommand and assign the initial object set and movement vector.
MoveCommand(java.util.Collection<OsmPrimitive> objects, EastNorth offset)
           
MoveCommand(java.util.Collection<OsmPrimitive> objects, EastNorth start, EastNorth end)
           
MoveCommand(Node node, LatLon position)
           
MoveCommand(OsmPrimitive osm, double x, double y)
           
MoveCommand(OsmPrimitive p, EastNorth start, EastNorth end)
           
 
Method Summary
 void applyVectorTo(EastNorth currentEN)
          Change the displacement vector to have endpoint @param currentEN starting point is startEN
 void changeStartPoint(EastNorth newDraggedStartPoint)
          Changes base point of movement
 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.
 void moveAgain(double x, double y)
          Move the same set of objects again by the specified vector.
 void moveAgainTo(double x, double y)
           
 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()
           
 
Methods inherited from class org.openstreetmap.josm.command.Command
checkAndConfirmOutlyingOperation, getLayer, getOrig, invalidBecauselayerRemoved
 
Methods inherited from class org.openstreetmap.josm.command.PseudoCommand
getChildren
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nodes

private java.util.Collection<Node> nodes
The objects that should be moved.


startEN

private EastNorth startEN
Starting position, base command point, current (mouse-drag) position = startEN + (x,y) =


x

private double x
x difference movement. Coordinates are in northern/eastern


y

private double y
y difference movement. Coordinates are in northern/eastern


backupX

private double backupX

backupY

private double backupY

oldState

private java.util.List<MoveCommand.OldState> oldState
List of all old states of the objects.

Constructor Detail

MoveCommand

public MoveCommand(OsmPrimitive osm,
                   double x,
                   double y)

MoveCommand

public MoveCommand(Node node,
                   LatLon position)

MoveCommand

public MoveCommand(java.util.Collection<OsmPrimitive> objects,
                   EastNorth offset)

MoveCommand

public MoveCommand(java.util.Collection<OsmPrimitive> objects,
                   double x,
                   double y)
Create a MoveCommand and assign the initial object set and movement vector.


MoveCommand

public MoveCommand(java.util.Collection<OsmPrimitive> objects,
                   EastNorth start,
                   EastNorth end)

MoveCommand

public MoveCommand(OsmPrimitive p,
                   EastNorth start,
                   EastNorth end)
Method Detail

moveAgain

public void moveAgain(double x,
                      double y)
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.


moveAgainTo

public void moveAgainTo(double x,
                        double y)

applyVectorTo

public void applyVectorTo(EastNorth currentEN)
Change the displacement vector to have endpoint @param currentEN starting point is startEN


changeStartPoint

public void changeStartPoint(EastNorth newDraggedStartPoint)
Changes base point of movement

Parameters:
newDraggedStartPoint - - new starting point after movement (where user clicks to start new drag)

saveCheckpoint

public void saveCheckpoint()
Save curent displacement to restore in case of some problems


resetToCheckpoint

public void resetToCheckpoint()
Restore old displacement in case of some problems


updateCoordinates

private void updateCoordinates()

executeCommand

public boolean executeCommand()
Description copied from class: Command
Executes the command on the dataset. This implementation will remember all primitives returned by fillModifiedData for restoring them on undo.

Overrides:
executeCommand in class Command

undoCommand

public void undoCommand()
Description copied from class: Command
Undoes 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:
undoCommand in class Command

fillModifiedData

public void fillModifiedData(java.util.Collection<OsmPrimitive> modified,
                             java.util.Collection<OsmPrimitive> deleted,
                             java.util.Collection<OsmPrimitive> added)
Description copied from class: Command
Fill in the changed data this command operates on. Add to the lists, don't clear them.

Specified by:
fillModifiedData in class Command
Parameters:
modified - The modified primitives
deleted - The deleted primitives
added - The added primitives

getDescriptionText

public java.lang.String getDescriptionText()
Description copied from class: PseudoCommand
Provides a description text representing this command.

Specified by:
getDescriptionText in class PseudoCommand

getDescriptionIcon

public javax.swing.Icon getDescriptionIcon()
Description copied from class: PseudoCommand
Provides a descriptive icon of this command.

Overrides:
getDescriptionIcon in class PseudoCommand

getParticipatingPrimitives

public java.util.Collection<Node> getParticipatingPrimitives()
Description copied from class: Command
Return the primitives that take part in this command.

Overrides:
getParticipatingPrimitives in class Command


JOSM