Class AlignInCircleAction

  • All Implemented Interfaces:
    java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action, Destroyable

    public final class AlignInCircleAction
    extends JosmAction
    Aligns all selected nodes within a circle. (Useful for roundabouts)
    Since:
    146
    See Also:
    Serialized Form
    • Constructor Detail

    • Method Detail

      • addMoveCommandIfNeeded

        public static void addMoveCommandIfNeeded​(Node n,
                                                  PolarCoor coor,
                                                  java.util.List<Command> cmds)
        Add a MoveCommand to move a node to a PolarCoor if there is a significant move.
        Parameters:
        n - Node to move
        coor - polar coordinate where to move the node
        cmds - list of commands
        Since:
        17386
      • actionPerformed

        public void actionPerformed​(java.awt.event.ActionEvent e)
        Perform AlignInCircle action.
      • buildCommand

        public static Command buildCommand​(DataSet ds)
                                    throws AlignInCircleAction.InvalidSelection
        Builds "align in circle" command depending on the selected objects. A fixed node is a node for which it is forbidden to change the angle relative to center of the circle. All other nodes are uniformly distributed.

        Case 1: One unclosed way. → allow action, and align selected way nodes If nodes contained by this way are selected, there are fix. If nodes outside from the way are selected there are ignored.

        Case 2: One or more ways are selected and can be joined into a polygon → allow action, and align selected ways nodes If 1 node outside of way is selected, it became center If 1 node outside and 1 node inside are selected there define center and radius If no outside node and 2 inside nodes are selected those 2 nodes define diameter In all other cases outside nodes are ignored In all cases, selected nodes are fix, nodes with more than one referrers are fix (first referrer is the selected way)

        Case 3: Only nodes are selected → Align these nodes, all are fix

        Case 4: Circularize selected ways → Circularize each way of the selection.

        Parameters:
        ds - data set in which the command operates
        Returns:
        the resulting command to execute to perform action, or null if nothing was changed
        Throws:
        AlignInCircleAction.InvalidSelection - if selection cannot be used
        Since:
        17386
      • moveNodesCommand

        public static Command moveNodesCommand​(java.util.List<Node> nodes,
                                               java.util.Set<Node> fixNodes,
                                               EastNorth center,
                                               double radius)
        Move each node of the list of nodes to be arranged in a circle.
        Parameters:
        nodes - The list of nodes to be moved.
        fixNodes - The list of nodes that must not be moved.
        center - A center of the circle formed by the nodes.
        radius - A radius of the circle formed by the nodes.
        Returns:
        the command that arranges the nodes in a circle.
        Since:
        18615
      • sortByAngle

        private static java.util.List<NodesortByAngle​(java.util.List<Node> nodes)
      • collectNodesWithExternReferrers

        private static java.util.List<NodecollectNodesWithExternReferrers​(java.util.List<Way> ways)
        Collect all nodes with more than one referrer.
        Parameters:
        ways - Ways from witch nodes are selected
        Returns:
        List of nodes with more than one referrer