Package org.openstreetmap.josm.command
Class TransformNodesCommand
java.lang.Object
org.openstreetmap.josm.command.Command
org.openstreetmap.josm.command.TransformNodesCommand
- All Implemented Interfaces:
PseudoCommand
- Direct Known Subclasses:
RotateCommand,ScaleCommand
Abstract class with common services for nodes rotation and scaling commands.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.openstreetmap.josm.command.Command
Command.OldNodeState -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Collection<Node>The nodes to transform.protected final Map<Node,Command.OldNodeState> List of all old states of the nodes.Fields inherited from class org.openstreetmap.josm.command.Command
IS_INCOMPLETE, IS_OK, IS_OUTSIDE -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedTransformNodesCommand(Collection<? extends OsmPrimitive> objects) Creates a TransformNodesObject. -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanFinally apply the transformation of the nodes.voidfillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) Fill in the changed data this command operates on.voidFlag all nodes as modified.Provides a descriptive icon of this command.Provides a description text representing this command.Get the center of the nodes under modification.Collection<? extends OsmPrimitive>Return the primitives that take part in this command.Get the nodes with the current transformation applied.abstract voidhandleEvent(EastNorth currentEN) Handling of a mouse event (e.g.inthashCode()protected final voidStores the state of the nodes before the command.protected abstract voidImplementation for the nodes transformation.voidRestore the state of the nodes from the backup.Methods 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 nodes to transform. -
oldStates
List of all old states of the nodes.
-
-
Constructor Details
-
TransformNodesCommand
Creates a TransformNodesObject. Find out the impacted nodes and store their initial state.- Parameters:
objects- objects to fetch nodes from. Must neither be null nor empty. Items must belong to a data set- Throws:
NullPointerException- if objects is null or contain null itemNoSuchElementException- if objects is empty
-
-
Method Details
-
storeOldState
Stores the state of the nodes before the command. -
handleEvent
Handling of a mouse event (e.g. dragging event).- Parameters:
currentEN- the current world position of the mouse
-
transformNodes
Implementation for the nodes transformation. No parameters are given here, you should handle the user input in handleEvent() and store it internally. -
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:
executeCommandin classCommand- Returns:
- true
-
flagNodesAsModified
Flag all nodes as modified. -
undoCommand
Restore the state of the nodes from the backup.- 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
-
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
-
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
-
getTransformedNodes
Get the nodes with the current transformation applied.- Returns:
- nodes with the current transformation applied
-
getNodesCenter
Get the center of the nodes under modification. It's just the barycenter.- Returns:
- center east/north of the nodes under modification
- See Also:
-
hashCode
-
equals
-