Class AlignInCircleAction
- All Implemented Interfaces:
ActionListener,Serializable,Cloneable,EventListener,Action,Destroyable
- Since:
- 146
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classInvalidSelection exception has to be raised when action can't be performedNested 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 TypeMethodDescriptionvoidPerform AlignInCircle action.static voidaddMoveCommandIfNeeded(Node n, PolarCoor coor, List<Command> cmds) Add aMoveCommandto move a node to a PolarCoor if there is a significant move.static CommandbuildCommand(DataSet ds) Builds "align in circle" command depending on the selected objects.collectNodesAnticlockwise(List<Way> ways) Assuming all ways can be joined into polygon, create an ordered list of node.Collect all nodes with more than one referrer.static CommandMove each node of the list of nodes to be arranged in a circle.sortByAngle(List<Node> nodes) 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.private static booleanvalidateGeometry(List<Node> nodes) 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
-
AlignInCircleAction
public AlignInCircleAction()Constructs a newAlignInCircleAction.
-
-
Method Details
-
addMoveCommandIfNeeded
Add aMoveCommandto move a node to a PolarCoor if there is a significant move.- Parameters:
n- Node to movecoor- polar coordinate where to move the nodecmds- list of commands- Since:
- 17386
-
actionPerformed
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
-
validateGeometry
-
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
private static List<Node> collectNodesAnticlockwise(List<Way> ways) throws AlignInCircleAction.InvalidSelection 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
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:
-