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

Last change on this file since 8394 was 8378, checked in by Don-vip, 9 years ago

fix copyright/license headers globally

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