source: josm/trunk/src/org/openstreetmap/josm/command/RemoveNodesCommand.java@ 6302

Last change on this file since 6302 was 6253, checked in by stoecker, 11 years ago

fix #5133 - add command to remove nodes from ways - patch by Giuseppe Bilotta

File size: 1.6 KB
Line 
1// License: GPL. See LICENSE file for details.
2package org.openstreetmap.josm.command;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.util.Collection;
7import java.util.HashSet;
8import java.util.List;
9import javax.swing.Icon;
10
11import org.openstreetmap.josm.data.osm.Node;
12import org.openstreetmap.josm.data.osm.Way;
13import org.openstreetmap.josm.data.osm.OsmPrimitive;
14import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
15import org.openstreetmap.josm.gui.DefaultNameFormatter;
16import org.openstreetmap.josm.tools.ImageProvider;
17
18/**
19 * Command that removes a set of nodes from a way.
20 * The same can be done with ChangeNodesCommand, but this is more
21 * efficient. (Needed for the tool to disconnect nodes from ways.)
22 *
23 * @author Giuseppe Bilotta
24 */
25public class RemoveNodesCommand extends Command {
26
27 private final Way way;
28 private final HashSet<Node> rmNodes;
29
30 public RemoveNodesCommand(Way way, List<Node> rmNodes) {
31 super();
32 this.way = way;
33 this.rmNodes = new HashSet<Node>(rmNodes);
34 }
35
36 @Override public boolean executeCommand() {
37 super.executeCommand();
38 way.removeNodes(rmNodes);
39 way.setModified(true);
40 return true;
41 }
42
43 @Override public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
44 modified.add(way);
45 }
46
47 @Override
48 public String getDescriptionText() {
49 return tr("Removed nodes from {0}", way.getDisplayName(DefaultNameFormatter.getInstance()));
50 }
51
52 @Override
53 public Icon getDescriptionIcon() {
54 return ImageProvider.get(OsmPrimitiveType.WAY);
55 }
56}
Note: See TracBrowser for help on using the repository browser.