Package org.openstreetmap.josm.command
Class ChangeCommand
- java.lang.Object
-
- org.openstreetmap.josm.command.Command
-
- org.openstreetmap.josm.command.ChangeCommand
-
- All Implemented Interfaces:
PseudoCommand
public class ChangeCommand extends Command
Command that basically replaces one OSM primitive by another of the same type.- Since:
- 93
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.openstreetmap.josm.command.Command
Command.OldNodeState
-
-
Field Summary
Fields Modifier and Type Field Description private OsmPrimitive
newOsm
private OsmPrimitive
osm
-
Fields inherited from class org.openstreetmap.josm.command.Command
IS_INCOMPLETE, IS_OK, IS_OUTSIDE
-
-
Constructor Summary
Constructors Constructor Description ChangeCommand(DataSet data, OsmPrimitive osm, OsmPrimitive newOsm)
Constructs a newChangeCommand
in the context of a given data set.ChangeCommand(OsmPrimitive osm, OsmPrimitive newOsm)
Constructs a newChangeCommand
in the context ofosm
data set.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.OsmPrimitive
getNewOsmPrimitive()
Returns the new OSM primitive.OsmPrimitive
getOsmPrimitive()
Returns the original OSM primitive to modify.int
hashCode()
private void
sanityChecks()
-
Methods inherited from class org.openstreetmap.josm.command.Command
checkOutlyingOrIncompleteOperation, ensurePrimitivesAreInDataset, getAffectedDataSet, getOrig, getParticipatingPrimitives, undoCommand
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.openstreetmap.josm.command.PseudoCommand
getChildren
-
-
-
-
Field Detail
-
osm
private final OsmPrimitive osm
-
newOsm
private final OsmPrimitive newOsm
-
-
Constructor Detail
-
ChangeCommand
public ChangeCommand(OsmPrimitive osm, OsmPrimitive newOsm)
Constructs a newChangeCommand
in the context ofosm
data set.- Parameters:
osm
- The existing primitive to modify. It must belong to a data setnewOsm
- The new primitive- Throws:
java.lang.IllegalArgumentException
- if sanity checks fail
-
ChangeCommand
public ChangeCommand(DataSet data, OsmPrimitive osm, OsmPrimitive newOsm)
Constructs a newChangeCommand
in the context of a given data set.- Parameters:
data
- The data setosm
- The existing primitive to modifynewOsm
- The new primitive- Throws:
java.lang.IllegalArgumentException
- if sanity checks fail- Since:
- 11240
-
-
Method Detail
-
sanityChecks
private void sanityChecks()
-
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.The layer should be invalidated after execution so that it can be re-painted.
- Overrides:
executeCommand
in classCommand
- Returns:
- true
-
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 classCommand
- Parameters:
modified
- The modified primitivesdeleted
- The deleted primitivesadded
- The added primitives
-
getDescriptionText
public java.lang.String getDescriptionText()
Description copied from interface:PseudoCommand
Provides a description text representing this command.- Returns:
- description text representing this command
-
getDescriptionIcon
public javax.swing.Icon getDescriptionIcon()
Description copied from interface:PseudoCommand
Provides a descriptive icon of this command.- Returns:
- descriptive icon of this command
-
getOsmPrimitive
public final OsmPrimitive getOsmPrimitive()
Returns the original OSM primitive to modify. It belongs to a dataset.- Returns:
- the original OSM primitive to modify
- Since:
- 14283
-
getNewOsmPrimitive
public final OsmPrimitive getNewOsmPrimitive()
Returns the new OSM primitive.- Returns:
- the new OSM primitive
- Since:
- 14283
-
-