1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.command;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | import java.util.Set;
|
---|
7 |
|
---|
8 | import org.openstreetmap.josm.data.osm.DataSet;
|
---|
9 | import org.openstreetmap.josm.data.osm.DefaultNameFormatter;
|
---|
10 | import org.openstreetmap.josm.data.osm.Node;
|
---|
11 | import org.openstreetmap.josm.data.osm.Way;
|
---|
12 |
|
---|
13 | /**
|
---|
14 | * Command that removes a set of nodes from a way.
|
---|
15 | * The same can be done with ChangeNodesCommand, but this is more
|
---|
16 | * efficient. (Needed for the tool to disconnect nodes from ways.)
|
---|
17 | *
|
---|
18 | * @author Giuseppe Bilotta
|
---|
19 | */
|
---|
20 | public class RemoveNodesCommand extends AbstractNodesCommand<Set<Node>> {
|
---|
21 |
|
---|
22 | /**
|
---|
23 | * Constructs a new {@code RemoveNodesCommand}.
|
---|
24 | * @param way The way to modify. Must not be null, and belong to a data set
|
---|
25 | * @param rmNodes The set of nodes to remove
|
---|
26 | * @since 15013
|
---|
27 | */
|
---|
28 | public RemoveNodesCommand(Way way, Set<Node> rmNodes) {
|
---|
29 | super(way.getDataSet(), way, rmNodes);
|
---|
30 | }
|
---|
31 |
|
---|
32 | /**
|
---|
33 | * Constructs a new {@code RemoveNodesCommand}.
|
---|
34 | * @param ds The target data set. Must not be {@code null}
|
---|
35 | * @param way The way to modify. Must not be null, and belong to a data set
|
---|
36 | * @param rmNodes The list of nodes to remove
|
---|
37 | * @since 15013
|
---|
38 | */
|
---|
39 | public RemoveNodesCommand(DataSet ds, Way way, Set<Node> rmNodes) {
|
---|
40 | super(ds, way, rmNodes);
|
---|
41 | }
|
---|
42 |
|
---|
43 | @Override
|
---|
44 | protected void modifyWay() {
|
---|
45 | way.removeNodes(cmdNodes);
|
---|
46 | }
|
---|
47 |
|
---|
48 | @Override
|
---|
49 | public String getDescriptionText() {
|
---|
50 | return tr("Removed nodes from {0}", way.getDisplayName(DefaultNameFormatter.getInstance()));
|
---|
51 | }
|
---|
52 | }
|
---|