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.HashSet;
|
---|
7 | import java.util.List;
|
---|
8 | import java.util.Set;
|
---|
9 |
|
---|
10 | import org.openstreetmap.josm.data.osm.DataSet;
|
---|
11 | import org.openstreetmap.josm.data.osm.DefaultNameFormatter;
|
---|
12 | import org.openstreetmap.josm.data.osm.Node;
|
---|
13 | import org.openstreetmap.josm.data.osm.Way;
|
---|
14 |
|
---|
15 | /**
|
---|
16 | * Command that removes a set of nodes from a way.
|
---|
17 | * The same can be done with ChangeNodesCommand, but this is more
|
---|
18 | * efficient. (Needed for the tool to disconnect nodes from ways.)
|
---|
19 | *
|
---|
20 | * @author Giuseppe Bilotta
|
---|
21 | */
|
---|
22 | public class RemoveNodesCommand extends AbstractNodesCommand<Set<Node>> {
|
---|
23 |
|
---|
24 | /**
|
---|
25 | * Constructs a new {@code RemoveNodesCommand}.
|
---|
26 | * @param way The way to modify. Must not be null, and belong to a data set
|
---|
27 | * @param rmNodes The list of nodes to remove
|
---|
28 | * @deprecated Use {@link #RemoveNodesCommand(Way, Set)}
|
---|
29 | */
|
---|
30 | @Deprecated
|
---|
31 | public RemoveNodesCommand(Way way, List<Node> rmNodes) {
|
---|
32 | super(way.getDataSet(), way, new HashSet<>(rmNodes));
|
---|
33 | }
|
---|
34 |
|
---|
35 | /**
|
---|
36 | * Constructs a new {@code RemoveNodesCommand}.
|
---|
37 | * @param way The way to modify. Must not be null, and belong to a data set
|
---|
38 | * @param rmNodes The set of nodes to remove
|
---|
39 | * @since 15013
|
---|
40 | */
|
---|
41 | public RemoveNodesCommand(Way way, Set<Node> rmNodes) {
|
---|
42 | super(way.getDataSet(), way, rmNodes);
|
---|
43 | }
|
---|
44 |
|
---|
45 | /**
|
---|
46 | * Constructs a new {@code RemoveNodesCommand}.
|
---|
47 | * @param ds The target data set. Must not be {@code null}
|
---|
48 | * @param way The way to modify. Must not be null, and belong to a data set
|
---|
49 | * @param rmNodes The list of nodes to remove
|
---|
50 | * @since 15013
|
---|
51 | */
|
---|
52 | public RemoveNodesCommand(DataSet ds, Way way, Set<Node> rmNodes) {
|
---|
53 | super(ds, way, rmNodes);
|
---|
54 | }
|
---|
55 |
|
---|
56 | @Override
|
---|
57 | protected void modifyWay() {
|
---|
58 | way.removeNodes(cmdNodes);
|
---|
59 | }
|
---|
60 |
|
---|
61 | @Override
|
---|
62 | public String getDescriptionText() {
|
---|
63 | return tr("Removed nodes from {0}", way.getDisplayName(DefaultNameFormatter.getInstance()));
|
---|
64 | }
|
---|
65 | }
|
---|