Package org.openstreetmap.josm.actions
Class DistributeAction
java.lang.Object
javax.swing.AbstractAction
org.openstreetmap.josm.actions.JosmAction
org.openstreetmap.josm.actions.DistributeAction
- All Implemented Interfaces:
ActionListener,Serializable,Cloneable,EventListener,Action,Destroyable
Distributes the selected nodes to equal distances along a line.
- See Also:
-
Nested Class Summary
Nested 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 action.private static booleancheckDistributeNodes(Collection<Way> ways, Collection<Node> nodes) Test if nodes oriented algorithm applies to the selection.private static booleancheckDistributeWay(Collection<Way> ways, Collection<Node> nodes) Test if one way, no self-crossing, is selected with at most two of its nodes.private static Collection<Command>distributeNodes(Collection<Node> nodes) Distribute nodes when only nodes are selected.private static Collection<Command>distributeWay(Collection<Way> ways, Collection<Node> nodes) Distribute nodes contained by a way, keeping nodes order.Remove nodes without known coordinates from a collection.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.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
-
DistributeAction
public DistributeAction()Constructs a newDistributeAction.
-
-
Method Details
-
actionPerformed
Perform action. Select method according to user selection. Case 1: One Way (no self-crossing) and at most 2 nodes contains by this way: Distribute nodes keeping order along the way Case 2: Other Distribute nodes -
checkDistributeWay
Test if one way, no self-crossing, is selected with at most two of its nodes.- Parameters:
ways- Selected waysnodes- Selected nodes- Returns:
- true in this case
-
distributeWay
Distribute nodes contained by a way, keeping nodes order. If one or two nodes are selected, keep these nodes in place.- Parameters:
ways- Selected ways, must be collection of size 1.nodes- Selected nodes, at most two nodes.- Returns:
- Collection of command to be executed.
-
checkDistributeNodes
Test if nodes oriented algorithm applies to the selection.- Parameters:
ways- Selected waysnodes- Selected nodes- Returns:
- true in this case
-
distributeNodes
Distribute nodes when only nodes are selected. The general algorithm here is to find the two selected nodes that are furthest apart, and then to distribute all other selected nodes along the straight line between these nodes.- Parameters:
nodes- nodes to distribute- Returns:
- Commands to execute to perform action
- Throws:
IllegalArgumentException- if nodes is empty
-
removeNodesWithoutCoordinates
Remove nodes without known coordinates from a collection.- Parameters:
col- Collection of nodes to check- Returns:
- Set of nodes without coordinates
-
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:
-