source: josm/trunk/src/org/openstreetmap/josm/command/ChangeNodesCommand.java@ 6887

Last change on this file since 6887 was 6881, checked in by Don-vip, 10 years ago

javadoc/code style/minor refactorization

  • Property svn:eol-style set to native
File size: 1.8 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.List;
8
9import javax.swing.Icon;
10
11import org.openstreetmap.josm.data.osm.Node;
12import org.openstreetmap.josm.data.osm.OsmPrimitive;
13import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
14import org.openstreetmap.josm.data.osm.Way;
15import org.openstreetmap.josm.gui.DefaultNameFormatter;
16import org.openstreetmap.josm.tools.ImageProvider;
17
18/**
19 * Command that changes the nodes list of a way.
20 * The same can be done with ChangeCommand, but this is more
21 * efficient. (Needed for the duplicate node fixing
22 * tool of the validator plugin, when processing large data sets.)
23 *
24 * @author Imi
25 */
26public class ChangeNodesCommand extends Command {
27
28 private final Way way;
29 private final List<Node> newNodes;
30
31 /**
32 * Constructs a new {@code ChangeNodesCommand}.
33 * @param way The way to modify
34 * @param newNodes The new list of nodes for the given way
35 */
36 public ChangeNodesCommand(Way way, List<Node> newNodes) {
37 this.way = way;
38 this.newNodes = newNodes;
39 }
40
41 @Override
42 public boolean executeCommand() {
43 super.executeCommand();
44 way.setNodes(newNodes);
45 way.setModified(true);
46 return true;
47 }
48
49 @Override
50 public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
51 modified.add(way);
52 }
53
54 @Override
55 public String getDescriptionText() {
56 return tr("Changed nodes of {0}", way.getDisplayName(DefaultNameFormatter.getInstance()));
57 }
58
59 @Override
60 public Icon getDescriptionIcon() {
61 return ImageProvider.get(OsmPrimitiveType.WAY);
62 }
63}
Note: See TracBrowser for help on using the repository browser.