public abstract class Command extends java.lang.Object implements PseudoCommand
DataSet
it is operating on.Modifier and Type | Class and Description |
---|---|
private static class |
Command.CloneVisitor |
static class |
Command.OldNodeState
Small helper for holding the interesting part of the old data state of the objects.
|
Modifier and Type | Field and Description |
---|---|
private java.util.Map<OsmPrimitive,PrimitiveData> |
cloneMap
the map of OsmPrimitives in the original state to OsmPrimitives in cloned state
|
private DataSet |
data
the dataset which this command is applied to
|
static int |
IS_INCOMPLETE
IS_INCOMPLETE: operation on incomplete target
|
static int |
IS_OK
IS_OK : operation is okay
|
static int |
IS_OUTSIDE
IS_OUTSIDE : operation on element outside of download area
|
Constructor and Description |
---|
Command(DataSet data)
Creates a new command in the context of a specific data set, without data layer
|
Modifier and Type | Method and Description |
---|---|
static int |
checkOutlyingOrIncompleteOperation(java.util.Collection<? extends OsmPrimitive> primitives,
java.util.Collection<? extends OsmPrimitive> ignore)
Check whether user is about to operate on data outside of the download area.
|
protected void |
ensurePrimitivesAreInDataset()
Ensures that all primitives that are participating in this command belong to the affected data set.
|
boolean |
equals(java.lang.Object obj) |
boolean |
executeCommand()
Executes the command on the dataset.
|
abstract 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.
|
DataSet |
getAffectedDataSet()
Gets the data set this command affects.
|
PrimitiveData |
getOrig(OsmPrimitive osm)
Lets other commands access the original version
of the object.
|
java.util.Collection<? extends OsmPrimitive> |
getParticipatingPrimitives()
Return the primitives that take part in this command.
|
int |
hashCode() |
void |
undoCommand()
Undoes the command.
|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
getChildren, getDescriptionIcon, getDescriptionText
public static final int IS_OK
public static final int IS_OUTSIDE
public static final int IS_INCOMPLETE
private java.util.Map<OsmPrimitive,PrimitiveData> cloneMap
public boolean executeCommand()
The layer should be invalidated after execution so that it can be re-painted.
public void undoCommand()
public PrimitiveData getOrig(OsmPrimitive osm)
osm
- The requested OSM objectpublic DataSet getAffectedDataSet()
null
if no layer was set and no edit layer was found.public abstract void fillModifiedData(java.util.Collection<OsmPrimitive> modified, java.util.Collection<OsmPrimitive> deleted, java.util.Collection<OsmPrimitive> added)
modified
- The modified primitivesdeleted
- The deleted primitivesadded
- The added primitivespublic java.util.Collection<? extends OsmPrimitive> getParticipatingPrimitives()
getParticipatingPrimitives
in interface PseudoCommand
public static int checkOutlyingOrIncompleteOperation(java.util.Collection<? extends OsmPrimitive> primitives, java.util.Collection<? extends OsmPrimitive> ignore)
primitives
- the primitives to operate onignore
- null
or a primitive to be ignoredprotected void ensurePrimitivesAreInDataset()
java.lang.AssertionError
- if no DataSet
is set or if any primitive does not belong to that dataset.public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object