public class SplitWayAction extends JosmAction
Modifier and Type | Class and Description |
---|---|
static class |
SplitWayAction.SplitWayResult
Represents the result of a
SplitWayAction |
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 |
---|
SplitWayAction()
Create a new SplitWayAction.
|
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(ActionEvent e)
Called when the action is executed.
|
static List<List<Node>> |
buildSplitChunks(Way wayToSplit,
List<Node> splitPoints)
Splits the nodes of
wayToSplit into a list of node sequences
which are separated at the nodes in splitPoints . |
private List<Way> |
getApplicableWays(List<Way> selectedWays,
List<Node> selectedNodes) |
static SplitWayAction.SplitWayResult |
split(OsmDataLayer layer,
Way way,
List<Node> atNodes,
Collection<? extends OsmPrimitive> selection)
Splits the way
way at the nodes in atNodes and replies
the result of this process in an instance of SplitWayAction.SplitWayResult . |
static SplitWayAction.SplitWayResult |
splitWay(OsmDataLayer layer,
Way way,
List<List<Node>> wayChunks,
Collection<? extends OsmPrimitive> selection)
Splits the way
way into chunks of wayChunks and replies
the result of this process in an instance of SplitWayAction.SplitWayResult . |
protected void |
updateEnabledState()
Override 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.
|
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 SplitWayAction()
public void actionPerformed(ActionEvent e)
private List<Way> getApplicableWays(List<Way> selectedWays, List<Node> selectedNodes)
public static List<List<Node>> buildSplitChunks(Way wayToSplit, List<Node> splitPoints)
wayToSplit
into a list of node sequences
which are separated at the nodes in splitPoints
.
This method displays warning messages if wayToSplit
and/or
splitPoints
aren't consistent.
Returns null, if building the split chunks fails.wayToSplit
- the way to split. Must not be null.splitPoints
- the nodes where the way is split. Must not be null.public static SplitWayAction.SplitWayResult splitWay(OsmDataLayer layer, Way way, List<List<Node>> wayChunks, Collection<? extends OsmPrimitive> selection)
way
into chunks of wayChunks
and replies
the result of this process in an instance of SplitWayAction.SplitWayResult
.
Note that changes are not applied to the data yet. You have to
submit the command in SplitWayAction.SplitWayResult.getCommand()
first,
i.e. Main.main.undoredo.add(result.getCommand())
.layer
- the layer which the way belongs to. Must not be null.way
- the way to split. Must not be null.wayChunks
- the list of way chunks into the way is split. Must not be null.selection
- The list of currently selected primitivespublic static SplitWayAction.SplitWayResult split(OsmDataLayer layer, Way way, List<Node> atNodes, Collection<? extends OsmPrimitive> selection)
way
at the nodes in atNodes
and replies
the result of this process in an instance of SplitWayAction.SplitWayResult
.
Note that changes are not applied to the data yet. You have to
submit the command in SplitWayAction.SplitWayResult.getCommand()
first,
i.e. Main.main.undoredo.add(result.getCommand())
.
Replies null if the way couldn't be split at the given nodes.layer
- the layer which the way belongs to. Must not be null.way
- the way to split. Must not be null.atNodes
- the list of nodes where the way is split. Must not be null.selection
- The list of currently selected primitivesprotected 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()