Class AlignInCircleAction

All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action, Destroyable

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

  • Method Details

    • addMoveCommandIfNeeded

      public static void addMoveCommandIfNeeded(Node n, PolarCoor coor, 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(ActionEvent e)
      Perform AlignInCircle action.
    • buildCommand

      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(List<Node> nodes, 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 List<Node> sortByAngle(List<Node> nodes)
    • validateGeometry

      private static boolean validateGeometry(List<Node> nodes)
    • collectNodesWithExternReferrers

      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
    • collectNodesAnticlockwise

      Assuming all ways can be joined into polygon, create an ordered list of node.
      Parameters:
      ways - List of ways to be joined
      Returns:
      Nodes anticlockwise ordered
      Throws:
      AlignInCircleAction.InvalidSelection - if selection cannot be used
    • 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:
    • updateEnabledState

      protected void updateEnabledState(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: