org.openstreetmap.josm.command
Class TransformNodesCommand

java.lang.Object
  extended by org.openstreetmap.josm.command.PseudoCommand
      extended by org.openstreetmap.josm.command.Command
          extended by org.openstreetmap.josm.command.TransformNodesCommand
Direct Known Subclasses:
RotateCommand, ScaleCommand

public abstract class TransformNodesCommand
extends Command

Abstract class with common services for nodes rotation and scaling commands.


Nested Class Summary
static class TransformNodesCommand.OldState
          Small helper for holding the interesting part of the old data state of the nodes.
 
Field Summary
protected  java.util.Collection<Node> nodes
          The nodes to transform.
protected  java.util.Map<Node,TransformNodesCommand.OldState> oldStates
          List of all old states of the nodes.
 
Constructor Summary
TransformNodesCommand(java.util.Collection<OsmPrimitive> objects)
          Creates a TransformNodesObject.
 
Method Summary
 boolean executeCommand()
          Finally apply the transformation of the nodes.
 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.
 void flagNodesAsModified()
          Flag all nodes as modified.
 javax.swing.Icon getDescriptionIcon()
          Provides a descriptive icon of this command.
 java.lang.String getDescriptionText()
          Provides a description text representing this command.
 EastNorth getNodesCenter()
          Get the center of the nodes under modification.
 java.util.Collection<? extends OsmPrimitive> getParticipatingPrimitives()
          Return the primitives that take part in this command.
 java.util.Collection<Node> getTransformedNodes()
          Get the nodes with the current transformation applied.
abstract  void handleEvent(EastNorth currentEN)
          Handling of a mouse event (e.g.
protected  void storeOldState()
          Stores the state of the nodes before the command.
protected abstract  void transformNodes()
          Implementation for the nodes transformation.
 void undoCommand()
          Restore the state of the nodes from the backup.
 
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

protected java.util.Collection<Node> nodes
The nodes to transform.


oldStates

protected java.util.Map<Node,TransformNodesCommand.OldState> oldStates
List of all old states of the nodes.

Constructor Detail

TransformNodesCommand

public TransformNodesCommand(java.util.Collection<OsmPrimitive> objects)
Creates a TransformNodesObject. Find out the impacted nodes and store their initial state.

Method Detail

storeOldState

protected void storeOldState()
Stores the state of the nodes before the command.


handleEvent

public abstract void handleEvent(EastNorth currentEN)
Handling of a mouse event (e.g. dragging event).

Parameters:
currentEN - the current world position of the mouse

transformNodes

protected abstract void transformNodes()
Implementation for the nodes transformation. No parameters are given here, you should handle the user input in handleEvent() and store it internally.


executeCommand

public boolean executeCommand()
Finally apply the transformation of the nodes. This is called when the user is happy with the current state of the command and its effects.

Overrides:
executeCommand in class Command

flagNodesAsModified

public void flagNodesAsModified()
Flag all nodes as modified.


undoCommand

public void undoCommand()
Restore the state of the nodes from the backup.

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

getParticipatingPrimitives

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

Overrides:
getParticipatingPrimitives in class Command

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

getTransformedNodes

public java.util.Collection<Node> getTransformedNodes()
Get the nodes with the current transformation applied.


getNodesCenter

public EastNorth getNodesCenter()
Get the center of the nodes under modification. It's just the barycenter.



JOSM