public final class DistributeAction extends JosmAction
JosmAction.LayerChangeAdapter, JosmAction.SelectionChangeAdapter
sc
changeSupport, enabled
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 and Description |
---|
DistributeAction()
Constructs a new
DistributeAction . |
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(ActionEvent e)
Perform action.
|
private static Boolean |
checkDistributeNodes(Collection<Way> ways,
Collection<Node> nodes)
Test if nodes oriented algorithm applies to the selection.
|
private static boolean |
checkDistributeWay(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.
|
private static Set<Node> |
removeNodesWithoutCoordinates(Collection<Node> col)
Remove nodes without knowned coordinates from a collection.
|
protected void |
updateEnabledState()
Override in subclasses to update the enabled state of the action when
something in the JOSM state changes, i.e.
|
protected void |
updateEnabledState(Collection<? extends OsmPrimitive> selection)
Override in subclasses to update the enabled state of the action if the
collection of selected primitives changes.
|
destroy, getCurrentDataSet, getEditLayer, getShortcut, initEnabledState, installAdapters, setTooltip
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
public DistributeAction()
DistributeAction
.public void actionPerformed(ActionEvent e)
private static boolean checkDistributeWay(Collection<Way> ways, Collection<Node> nodes)
ways
- Selected waysnodes
- Selected nodesprivate static Collection<Command> distributeWay(Collection<Way> ways, Collection<Node> nodes)
ways
- Selected ways, must be collection of size 1.nodes
- Selected nodes, at most two nodes.private static Boolean checkDistributeNodes(Collection<Way> ways, Collection<Node> nodes)
ways
- Selected waysnodes
- Selected nodesprivate static Collection<Command> distributeNodes(Collection<Node> nodes)
nodes
- nodes to distributeIllegalArgumentException
- if nodes is emptyprivate static Set<Node> removeNodesWithoutCoordinates(Collection<Node> col)
col
- Collection of nodes to checkprotected void updateEnabledState()
JosmAction
JosmAction.updateEnabledState(Collection)
to respond to changes in the collection
of selected primitives.
Default behavior is empty.updateEnabledState
in class JosmAction
JosmAction.updateEnabledState(Collection)
,
JosmAction.initEnabledState()
protected void updateEnabledState(Collection<? extends OsmPrimitive> selection)
JosmAction
updateEnabledState
in class JosmAction
selection
- the collection of selected primitives; may be empty, but not nullJosmAction.updateEnabledState()
,
JosmAction.initEnabledState()