001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.command; 003 004import static org.openstreetmap.josm.tools.I18n.tr; 005 006import java.util.Set; 007 008import org.openstreetmap.josm.data.osm.DataSet; 009import org.openstreetmap.josm.data.osm.DefaultNameFormatter; 010import org.openstreetmap.josm.data.osm.Node; 011import org.openstreetmap.josm.data.osm.Way; 012 013/** 014 * Command that removes a set of nodes from a way. 015 * The same can be done with ChangeNodesCommand, but this is more 016 * efficient. (Needed for the tool to disconnect nodes from ways.) 017 * 018 * @author Giuseppe Bilotta 019 */ 020public class RemoveNodesCommand extends AbstractNodesCommand<Set<Node>> { 021 022 /** 023 * Constructs a new {@code RemoveNodesCommand}. 024 * @param way The way to modify. Must not be null, and belong to a data set 025 * @param rmNodes The set of nodes to remove 026 * @since 15013 027 */ 028 public RemoveNodesCommand(Way way, Set<Node> rmNodes) { 029 super(way.getDataSet(), way, rmNodes); 030 } 031 032 /** 033 * Constructs a new {@code RemoveNodesCommand}. 034 * @param ds The target data set. Must not be {@code null} 035 * @param way The way to modify. Must not be null, and belong to a data set 036 * @param rmNodes The list of nodes to remove 037 * @since 15013 038 */ 039 public RemoveNodesCommand(DataSet ds, Way way, Set<Node> rmNodes) { 040 super(ds, way, rmNodes); 041 } 042 043 @Override 044 protected void modifyWay() { 045 way.removeNodes(cmdNodes); 046 } 047 048 @Override 049 public String getDescriptionText() { 050 return tr("Removed nodes from {0}", way.getDisplayName(DefaultNameFormatter.getInstance())); 051 } 052}