public class SplitWayAction extends JosmAction
Modifier and Type | Class and Description |
---|---|
(package private) static class |
SplitWayAction.SegmentToKeepSelectionDialog
A dialog to query which way segment should reuse the history of the way to split.
|
static class |
SplitWayAction.SplitWayResult
Represents the result of a
SplitWayAction |
static class |
SplitWayAction.Strategy
Determines which way chunk should reuse the old id and its history
|
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 |
---|
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 . |
protected static List<Way> |
createNewWaysFromChunks(Way way,
Iterable<List<Node>> wayChunks)
Creates new way objects for the way chunks and transfers the keys from the original way.
|
(package private) static SplitWayAction.SplitWayResult |
doSplitWay(OsmDataLayer layer,
Way way,
Way wayToKeep,
List<Way> newWays,
List<OsmPrimitive> newSelection) |
private List<Way> |
getApplicableWays(List<Way> selectedWays,
List<Node> selectedNodes)
Determine which ways to split.
|
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 . |
static SplitWayAction.SplitWayResult |
splitWay(OsmDataLayer layer,
Way way,
List<List<Node>> wayChunks,
Collection<? extends OsmPrimitive> selection,
SplitWayAction.Strategy splitStrategy)
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.
|
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)
selectedWays
- List of user selected ways.selectedNodes
- List of user selected nodes.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.protected static List<Way> createNewWaysFromChunks(Way way, Iterable<List<Node>> wayChunks)
way
- the original way whose keys are transferredwayChunks
- the way chunkspublic 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 splitWay(OsmDataLayer layer, Way way, List<List<Node>> wayChunks, Collection<? extends OsmPrimitive> selection, SplitWayAction.Strategy splitStrategy)
way
into chunks of wayChunks
and replies
the result of this process in an instance of SplitWayAction.SplitWayResult
.
The SplitWayAction.Strategy
is used to determine which
way chunk should reuse the old id and its history.
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 primitivessplitStrategy
- The strategy used to determine which way chunk should reuse the old id and its historystatic SplitWayAction.SplitWayResult doSplitWay(OsmDataLayer layer, Way way, Way wayToKeep, List<Way> newWays, List<OsmPrimitive> newSelection)
public 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()