Class 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 or tagged nodes used by a single way or nodes which referenced more than once by a single way. This is the opposite of the MergeNodesAction.
    See Also:
    Serialized Form
    • 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.
      • unglueOneNodeAtMostOneWay

        private void unglueOneNodeAtMostOneWay​(Way way,
                                               PropertiesMembershipChoiceDialog dialog)
        Assumes there is one tagged Node stored in selectedNode that it will try to unglue. (i.e. copy node and remove all tags from the old one.)
        Parameters:
        way - way to modify
        dialog - the user dialog
      • checkSelectionOneNodeAtMostOneWay

        private boolean checkSelectionOneNodeAtMostOneWay​(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 will be set, selectedWay might 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".
        Parameters:
        selection - selected primitives
        Returns:
        true if either one node is selected or one node and one way are selected and the node is part of the way
      • checkSelectionOneWayAnyNodes

        private boolean checkSelectionOneWayAnyNodes​(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".
        Parameters:
        selection - selected primitives
        Returns:
        true if one way and any number of nodes that are part of that way are selected
      • modifyWay

        private static java.util.List<NodemodifyWay​(Node originalNode,
                                                      Way w,
                                                      java.util.List<Command> cmds,
                                                      java.util.List<Node> newNodes)
        dupe the given node of the given way assume that originalNode 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!
        Parameters:
        originalNode - original node to duplicate
        w - parent way
        cmds - List of commands that will contain the new "add node" command
        newNodes - List of nodes that will contain the new node
        Returns:
        The modified list of way nodes. Change command must be handled by the caller
      • updateMemberships

        private static void updateMemberships​(PropertiesMembershipChoiceDialog.ExistingBothNew memberships,
                                              Node originalNode,
                                              java.util.List<Node> newNodes,
                                              java.util.List<Command> cmds)
        put all newNodes into the same relation(s) that originalNode is in
        Parameters:
        memberships - where the memberships should be places
        originalNode - original node to duplicate
        cmds - List of commands that will contain the new "change relation" commands
        newNodes - List of nodes that contain the new node
      • unglueWays

        private void unglueWays()
                         throws UserCancelException
        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
        Throws:
        UserCancelException - if user cancels choice
      • execCommands

        private void execCommands​(java.util.List<Command> cmds,
                                  java.util.List<Node> newNodes)
        Add commands to undo-redo system.
        Parameters:
        cmds - Commands to execute
        newNodes - New created nodes by this set of command
      • unglueClosedOrSelfCrossingWay

        private boolean unglueClosedOrSelfCrossingWay​(Way way,
                                                      PropertiesMembershipChoiceDialog dialog)
        Duplicates a node used several times by the same way. See #9896. First occurrence is kept. A closed way will be "opened" when the closing node is unglued.
        Parameters:
        way - way to modify
        dialog - user dialog, might be null
        Returns:
        true if action is OK false if there is nothing to do