Package org.openstreetmap.josm.actions
Class MergeNodesAction
java.lang.Object
javax.swing.AbstractAction
org.openstreetmap.josm.actions.JosmAction
org.openstreetmap.josm.actions.MergeNodesAction
- All Implemented Interfaces:
ActionListener,Serializable,Cloneable,EventListener,Action,Destroyable
Merges a collection of nodes into one node.
The "surviving" node will be the one with the lowest positive id.
(I.e. it was uploaded to the server and is the oldest one.)
However we use the location of the node that was selected *last*.
The "surviving" node will be moved to that location if it is
different from the last selected node.
- Since:
- 422
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.openstreetmap.josm.actions.JosmAction
JosmAction.ActiveLayerChangeAdapter, JosmAction.LayerChangeAdapter, JosmAction.SelectionChangeAdapter -
Field Summary
Fields inherited from class org.openstreetmap.josm.actions.JosmAction
scFields inherited from class javax.swing.AbstractAction
changeSupport, enabledFields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidactionPerformed(ActionEvent event) static voiddoMergeNodes(OsmDataLayer layer, Collection<Node> nodes, Node targetLocationNode) Merges the nodes innodesat the specified node's location.fixParentWays(Collection<Node> nodesToDelete, Node targetNode) Fixes the parent ways referring to one of the nodes.static CommandmergeNodes(Collection<Node> nodes, Node targetLocationNode) Merges the nodes innodesat the specified node's location.static CommandmergeNodes(Collection<Node> nodes, Node targetNode, Node targetLocationNode) Merges the nodes innodesonto one of the nodes.static NodeselectTargetLocationNode(List<Node> candidates) Select the location of the target node after merge.static NodeselectTargetNode(Collection<Node> candidates) Find which node to merge into (i.e.protected voidOverride in subclasses to update the enabled state of the action when something in the JOSM state changes, i.e.protected voidupdateEnabledState(Collection<? extends OsmPrimitive> selection) Override in subclasses to update the enabled state of the action if the collection of selected primitives changes.Methods inherited from class org.openstreetmap.josm.actions.JosmAction
buildActiveLayerChangeAdapter, buildLayerChangeAdapter, checkAndConfirmOutlyingOperation, destroy, getLayerManager, getShortcut, initEnabledState, installAdapters, listenToLayerChange, listenToSelectionChange, setHelpId, setToolbarId, setTooltip, updateEnabledStateOnCurrentSelection, updateEnabledStateOnCurrentSelection, updateEnabledStateOnModifiableSelection, waitFutureMethods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
-
Constructor Details
-
MergeNodesAction
public MergeNodesAction()Constructs a newMergeNodesAction.
-
-
Method Details
-
actionPerformed
-
selectTargetLocationNode
Select the location of the target node after merge.- Parameters:
candidates- the collection of candidate nodes- Returns:
- the coordinates of this node are later used for the target node
-
selectTargetNode
Find which node to merge into (i.e. which one will be left)- Parameters:
candidates- the collection of candidate nodes- Returns:
- the selected target node
-
fixParentWays
Fixes the parent ways referring to one of the nodes. Replies null, if the ways could not be fixed, i.e. because a way would have to be deleted which is referred to by a relation.- Parameters:
nodesToDelete- the collection of nodes to be deletedtargetNode- the target node the other nodes are merged to- Returns:
- a list of commands; null, if the ways could not be fixed
-
doMergeNodes
public static void doMergeNodes(OsmDataLayer layer, Collection<Node> nodes, Node targetLocationNode) Merges the nodes innodesat the specified node's location. Uses the dataset managed bylayeras reference.- Parameters:
layer- layer the reference data layer. Must not be nullnodes- the collection of nodes. Ignored if nulltargetLocationNode- this node's location will be used for the target node- Throws:
IllegalArgumentException- iflayeris null
-
mergeNodes
Merges the nodes innodesat the specified node's location.- Parameters:
nodes- the collection of nodes. Ignored if null.targetLocationNode- this node's location will be used for the targetNode.- Returns:
- The command necessary to run in order to perform action, or
nullif there is nothing to do - Throws:
IllegalArgumentException- iflayeris null- Since:
- 12689
-
mergeNodes
Merges the nodes innodesonto one of the nodes.- Parameters:
nodes- the collection of nodes. Ignored if null.targetNode- the target node the collection of nodes is merged to. Must not be null.targetLocationNode- this node's location will be used for the targetNode.- Returns:
- The command necessary to run in order to perform action, or
nullif there is nothing to do - Throws:
IllegalArgumentException- if layer is null
-
updateEnabledState
Description copied from class:JosmActionOverride in subclasses to update the enabled state of the action when something in the JOSM state changes, i.e. when a layer is removed or added. SeeJosmAction.updateEnabledState(Collection)to respond to changes in the collection of selected primitives. Default behavior is empty.- Overrides:
updateEnabledStatein classJosmAction- See Also:
-
updateEnabledState
Description copied from class:JosmActionOverride in subclasses to update the enabled state of the action if the collection of selected primitives changes. This method is called with the new selection.- Overrides:
updateEnabledStatein classJosmAction- Parameters:
selection- the collection of selected primitives; may be empty, but not null- See Also:
-