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 |
---|---|
(package private) static class |
AlignInLineAction.InvalidSelection
InvalidSelection exception has to be raised when action can't be performed
|
(package private) static class |
AlignInLineAction.Line
Class that represent a line
|
JosmAction.ActiveLayerChangeAdapter, JosmAction.LayerChangeAdapter, JosmAction.SelectionChangeAdapter
sc
Constructor and Description |
---|
AlignInLineAction()
Constructs a new
AlignInLineAction . |
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent e)
Operation depends on the selected objects:
|
private static Command |
alignMultiWay(java.util.Collection<Way> ways)
Align way in case of multiple way #6819
|
private static Command |
alignOnlyNodes(java.util.List<Node> nodes)
Align nodes in case 3 or more nodes are selected.
|
private static Command |
alignSingleNode(Node node,
java.util.List<AlignInLineAction.Line> lines)
Align a single node relative to a set of lines #9081
|
Command |
buildCommand(DataSet ds)
Builds "align in line" command depending on the selected objects.
|
private static java.util.List<AlignInLineAction.Line> |
getInvolvedLines(Node node,
java.util.List<Way> refWays)
Get lines useful to do alignment of a single node
|
private static Node[] |
nodeFurthestAppart(java.util.List<Node> nodes)
Return the two nodes the most distant from the provided list.
|
private static Node[] |
nodePairFurthestApart(java.util.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(java.util.Collection<? extends OsmPrimitive> selection)
Override in subclasses to update the enabled state of the action if the
collection of selected primitives changes.
|
checkAndConfirmOutlyingOperation, destroy, getLayerManager, getShortcut, initEnabledState, installAdapters, listenToLayerChange, listenToSelectionChange, setTooltip, updateEnabledStateOnCurrentSelection, updateEnabledStateOnCurrentSelection, updateEnabledStateOnModifiableSelection, waitFuture
public AlignInLineAction()
AlignInLineAction
.private static Node[] nodePairFurthestApart(java.util.List<Node> nodes)
nodes
- Nodes to be aligned.java.lang.IllegalArgumentException
- if nodes is emptyprivate static Node[] nodeFurthestAppart(java.util.List<Node> nodes)
nodes
- List of nodes to analyze.public void actionPerformed(java.awt.event.ActionEvent e)
public Command buildCommand(DataSet ds) throws AlignInLineAction.InvalidSelection
ds
- data set in which the command operatesAlignInLineAction.InvalidSelection
- if a polygon is selected, or if a node is used by 3 or more waysprivate static Command alignOnlyNodes(java.util.List<Node> nodes) throws AlignInLineAction.InvalidSelection
nodes
- Nodes to be aligned.AlignInLineAction.InvalidSelection
- If the nodes have same coordinates.private static Command alignMultiWay(java.util.Collection<Way> ways) throws AlignInLineAction.InvalidSelection
ways
- Collection of way to alignAlignInLineAction.InvalidSelection
- if a polygon is selected, or if a node is used by 3 or more waysprivate static java.util.List<AlignInLineAction.Line> getInvolvedLines(Node node, java.util.List<Way> refWays) throws AlignInLineAction.InvalidSelection
node
- Node to be alignedrefWays
- Ways where useful lines will be searchedAlignInLineAction.InvalidSelection
- if a node got more than 4 neighbours (self-crossing way)private static Command alignSingleNode(Node node, java.util.List<AlignInLineAction.Line> lines) throws AlignInLineAction.InvalidSelection
node
- Node to be alignedlines
- Lines to align node onAlignInLineAction.InvalidSelection
- if more than 2 linesprotected 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()
,
JosmAction.listenToLayerChange()
protected void updateEnabledState(java.util.Collection<? extends OsmPrimitive> selection)
JosmAction
updateEnabledState
in class JosmAction
selection
- the collection of selected primitives; may be empty, but not nullJosmAction.updateEnabledState()
,
JosmAction.initEnabledState()
,
JosmAction.listenToSelectionChange()