public final class AlignInLineAction extends JosmAction
Case 1: 1 or 2 ways selected and no nodes selected: align nodes of ways taking care of intersection. Case 2: Single node selected and no ways selected: align this node relative to all referrer ways (2 at most). Case 3: Single node and ways selected: align this node relative to selected ways. Case 4.1: Only nodes selected, part of a non-closed way: align these nodes on the line passing through the extremity nodes (most distant in the way sequence). See https://josm.openstreetmap.de/ticket/9605#comment:3 Case 4.2: Only nodes selected, part of a closed way: align these nodes on the line passing through the most distant nodes. Case 4.3: Only nodes selected, part of multiple ways: align these nodes on the line passing through the most distant nodes.
Modifier and Type | Class and Description |
---|---|
private static class |
AlignInLineAction.InvalidSelection
InvalidSelection exception has to be raised when action can't be perform
|
private class |
AlignInLineAction.Line
Class that represent a line
|
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 |
---|
AlignInLineAction()
Constructs a new
AlignInLineAction . |
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(ActionEvent e)
Operation depends on the selected objects:
|
private Command |
alignMultiWay(Collection<Way> ways)
Align way in case of multiple way #6819
|
private Command |
alignOnlyNodes(List<Node> nodes)
Align nodes in case 3 or more nodes are selected.
|
private Command |
alignSingleNode(Node node,
List<AlignInLineAction.Line> lines)
Align a single node relative to a set of lines #9081
|
private List<AlignInLineAction.Line> |
getInvolvedLines(Node node,
List<Way> refWays)
Get lines useful to do alignment of a single node
|
private Node[] |
nodeFurthestAppart(List<Node> nodes)
Return the two nodes the most distant from the provided list.
|
private Node[] |
nodePairFurthestApart(List<Node> nodes)
Return 2 nodes making up the line along which provided nodes must be aligned.
|
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 AlignInLineAction()
AlignInLineAction
.private Node[] nodePairFurthestApart(List<Node> nodes)
nodes
- Nodes to be aligned.private Node[] nodeFurthestAppart(List<Node> nodes)
nodes
- List of nodes to analyze.public void actionPerformed(ActionEvent e)
private Command alignOnlyNodes(List<Node> nodes) throws AlignInLineAction.InvalidSelection
nodes
- Nodes to be aligned.AlignInLineAction.InvalidSelection
- If the nodes have same coordinates.private Command alignMultiWay(Collection<Way> ways) throws AlignInLineAction.InvalidSelection
ways
- Collection of way to alignAlignInLineAction.InvalidSelection
private List<AlignInLineAction.Line> getInvolvedLines(Node node, List<Way> refWays) throws AlignInLineAction.InvalidSelection
node
- Node to be alignedrefWays
- Ways where useful lines will be searchedAlignInLineAction.InvalidSelection
private Command alignSingleNode(Node node, List<AlignInLineAction.Line> lines) throws AlignInLineAction.InvalidSelection
node
- Node to be alignedlines
- Lines to align node onAlignInLineAction.InvalidSelection
protected 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()