org.openstreetmap.josm.actions
Class UnGlueAction

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by org.openstreetmap.josm.actions.JosmAction
          extended by org.openstreetmap.josm.actions.UnGlueAction
All Implemented Interfaces:
java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action, Destroyable

public class UnGlueAction
extends JosmAction

Duplicate nodes that are used by multiple ways. Resulting nodes are identical, up to their position. This is the opposite of the MergeNodesAction. If a single node is selected, it will copy that node and remove all tags from the old one

See Also:
Serialized Form

Field Summary
private  Node selectedNode
           
private  java.util.Set<Node> selectedNodes
           
private  Way selectedWay
           
 
Fields inherited from class org.openstreetmap.josm.actions.JosmAction
sc
 
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
 
Fields 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
UnGlueAction()
          Create a new UnGlueAction.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Called when the action is executed.
protected  boolean checkAndConfirmOutlyingUnglue()
           
private  boolean checkForUnglueNode(java.util.Collection<? extends OsmPrimitive> selection)
          Checks if selection is suitable for ungluing.
private  boolean checkSelection(java.util.Collection<? extends OsmPrimitive> selection)
          Checks if the selection consists of something we can work with.
private  boolean checkSelection2(java.util.Collection<? extends OsmPrimitive> selection)
          Checks if the selection consists of something we can work with.
private  void fixRelations(Node originalNode, java.util.List<Command> cmds, java.util.List<Node> newNodes)
          put all newNodes into the same relation(s) that originalNode is in
private  Way modifyWay(Node originalNode, Way w, java.util.List<Command> cmds, java.util.List<Node> newNodes)
          dupe the given node of the given way assume that OrginalNode is in the way -> the new node will be put into the parameter newNodes.
private  void unglueNode(java.awt.event.ActionEvent e)
          Assumes there is one tagged Node stored in selectedNode that it will try to unglue (= copy node and remove all tags from the old one.
private  void unglueWays()
          dupe a single node into as many nodes as there are ways using it, OR dupe a single node once, and put the copy on the selected way
private  void unglueWays2()
          dupe all nodes that are selected, and put the copies on the selected way
protected  void updateEnabledState()
          Override in subclasses to update the enabled state of the action when something in the JOSM state changes, i.e.
protected  void updateEnabledState(java.util.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
destroy, getCurrentDataSet, getEditLayer, getShortcut, initEnabledState, installAdapters, setTooltip
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

selectedNode

private Node selectedNode

selectedWay

private Way selectedWay

selectedNodes

private java.util.Set<Node> selectedNodes
Constructor Detail

UnGlueAction

public UnGlueAction()
Create a new UnGlueAction.

Method Detail

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Called when the action is executed. This method does some checking on the selection and calls the matching unGlueWay method.


unglueNode

private void unglueNode(java.awt.event.ActionEvent e)
Assumes there is one tagged Node stored in selectedNode that it will try to unglue (= copy node and remove all tags from the old one. Relations will not be removed)


checkForUnglueNode

private boolean checkForUnglueNode(java.util.Collection<? extends OsmPrimitive> selection)
Checks if selection is suitable for ungluing. This is the case when there's a single, tagged node selected that's part of at least one way (ungluing an unconnected node does not make sense. Due to the call order in actionPerformed, this is only called when the node is only part of one or less ways.

Parameters:
The - selection to check against
Returns:
Selection is suitable

checkSelection

private boolean checkSelection(java.util.Collection<? extends OsmPrimitive> selection)
Checks if the selection consists of something we can work with. Checks only if the number and type of items selected looks good. If this method returns "true", selectedNode and selectedWay will be set. Returns true if either one node is selected or one node and one way are selected and the node is part of the way. The way will be put into the object variable "selectedWay", the node into "selectedNode".


checkSelection2

private boolean checkSelection2(java.util.Collection<? extends OsmPrimitive> selection)
Checks if the selection consists of something we can work with. Checks only if the number and type of items selected looks good. Returns true if one way and any number of nodes that are part of that way are selected. Note: "any" can be none, then all nodes of the way are used. The way will be put into the object variable "selectedWay", the nodes into "selectedNodes".


modifyWay

private Way modifyWay(Node originalNode,
                      Way w,
                      java.util.List<Command> cmds,
                      java.util.List<Node> newNodes)
dupe the given node of the given way assume that OrginalNode is in the way -> the new node will be put into the parameter newNodes. -> the add-node command will be put into the parameter cmds. -> the changed way will be returned and must be put into cmds by the caller!


fixRelations

private void fixRelations(Node originalNode,
                          java.util.List<Command> cmds,
                          java.util.List<Node> newNodes)
put all newNodes into the same relation(s) that originalNode is in


unglueWays

private void unglueWays()
dupe a single node into as many nodes as there are ways using it, OR dupe a single node once, and put the copy on the selected way


unglueWays2

private void unglueWays2()
dupe all nodes that are selected, and put the copies on the selected way


updateEnabledState

protected void updateEnabledState()
Description copied from class: JosmAction
Override 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. See JosmAction.updateEnabledState(Collection) to respond to changes in the collection of selected primitives. Default behavior is empty.

Overrides:
updateEnabledState in class JosmAction
See Also:
JosmAction.updateEnabledState(Collection), JosmAction.initEnabledState()

updateEnabledState

protected void updateEnabledState(java.util.Collection<? extends OsmPrimitive> selection)
Description copied from class: JosmAction
Override 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:
updateEnabledState in class JosmAction
Parameters:
selection - the collection of selected primitives; may be empty, but not null
See Also:
JosmAction.updateEnabledState(), JosmAction.initEnabledState()

checkAndConfirmOutlyingUnglue

protected boolean checkAndConfirmOutlyingUnglue()


JOSM