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

Last change on this file since 6830 was 6316, checked in by Don-vip, 11 years ago

Sonar/FindBugs - Loose coupling

File size: 1.7 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 java.util.Set;
10
11import javax.swing.Icon;
12
13import org.openstreetmap.josm.data.osm.Node;
14import org.openstreetmap.josm.data.osm.Way;
15import org.openstreetmap.josm.data.osm.OsmPrimitive;
16import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
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 public RemoveNodesCommand(Way way, List<Node> rmNodes) {
33 super();
34 this.way = way;
35 this.rmNodes = new HashSet<Node>(rmNodes);
36 }
37
38 @Override public boolean executeCommand() {
39 super.executeCommand();
40 way.removeNodes(rmNodes);
41 way.setModified(true);
42 return true;
43 }
44
45 @Override public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
46 modified.add(way);
47 }
48
49 @Override
50 public String getDescriptionText() {
51 return tr("Removed nodes from {0}", way.getDisplayName(DefaultNameFormatter.getInstance()));
52 }
53
54 @Override
55 public Icon getDescriptionIcon() {
56 return ImageProvider.get(OsmPrimitiveType.WAY);
57 }
58}
Note: See TracBrowser for help on using the repository browser.