Changeset 22 in josm for src/org/openstreetmap/josm/command
- Timestamp:
- 2005-10-23T22:13:33+02:00 (20 years ago)
- Location:
- src/org/openstreetmap/josm/command
- Files:
-
- 1 added
- 4 edited
-
AddCommand.java (modified) (6 diffs)
-
CombineCommand.java (added)
-
Command.java (modified) (2 diffs)
-
DataSet.java (modified) (3 diffs)
-
MoveCommand.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/command/AddCommand.java
r21 r22 2 2 3 3 import java.awt.Component; 4 import java.util.Collection; 4 5 import java.util.Iterator; 5 6 6 7 import javax.swing.JLabel; 7 8 9 import org.openstreetmap.josm.Main; 8 10 import org.openstreetmap.josm.data.osm.Key; 9 11 import org.openstreetmap.josm.data.osm.LineSegment; … … 26 28 */ 27 29 private final OsmPrimitive osm; 28 /**29 * The dataset to add the primitive to.30 */31 private final DataSet ds;32 30 33 31 /** 34 32 * Create the command and specify the element to add. 35 33 */ 36 public AddCommand(OsmPrimitive osm , DataSet dataSet) {34 public AddCommand(OsmPrimitive osm) { 37 35 this.osm = osm; 38 this.ds = dataSet;39 36 } 40 37 … … 42 39 osm.visit(this); 43 40 } 44 41 45 42 public Component commandDescription() { 46 43 SelectionComponentVisitor v = new SelectionComponentVisitor(); 47 44 osm.visit(v); 48 45 return new JLabel(v.name, v.icon, JLabel.LEADING); 46 } 47 48 public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) { 49 if (!added.contains(osm)) 50 added.add(osm); 49 51 } 50 52 … … 54 56 */ 55 57 public void visit(Node n) { 56 ds.nodes.add(n); 58 Main.main.ds.nodes.add(n); 57 59 } 58 60 … … 62 64 */ 63 65 public void visit(LineSegment ls) { 64 ds.pendingLineSegments.add(ls); 66 Main.main.ds.pendingLineSegments.add(ls); 65 67 } 66 68 … … 70 72 */ 71 73 public void visit(Track t) { 72 ds.addTrack(t);73 for (Iterator<LineSegment> it = ds.pendingLineSegments.iterator(); it.hasNext();) 74 Main.main.ds.tracks.add(t); 75 for (Iterator<LineSegment> it = Main.main.ds.pendingLineSegments.iterator(); it.hasNext();) 74 76 if (t.segments().contains(it.next())) 75 77 it.remove(); -
src/org/openstreetmap/josm/command/Command.java
r21 r22 2 2 3 3 import java.awt.Component; 4 import java.util.Collection; 5 6 import org.openstreetmap.josm.data.osm.OsmPrimitive; 4 7 5 8 6 9 /** 7 10 * Classes implementing Command modify a dataset in a specific way. A command is 8 * one atomic action on a dataset, such as move or delete. 11 * one atomic action on a specific dataset, such as move or delete. 9 12 * 10 13 * @author imi … … 16 19 */ 17 20 void executeCommand(); 18 21 19 22 /** 20 23 * Give a description of the command as component to draw 21 24 */ 22 25 Component commandDescription(); 26 27 /** 28 * Fill in the changed data this command operates on (for sending to the server). 29 * Add to the lists, don't clear them. 30 * @param modified The modified primitives 31 * @param deleted The deleted primitives 32 * @param added The added primitives 33 */ 34 void fillModifiedData(Collection<OsmPrimitive> modified, 35 Collection<OsmPrimitive> deleted, 36 Collection<OsmPrimitive> added); 23 37 } -
src/org/openstreetmap/josm/command/DataSet.java
r21 r22 205 205 */ 206 206 public void mergeFrom(DataSet ds, boolean mergeEqualNodes) { 207 System.out.println(nodes.size()+" "+pendingLineSegments.size()+" "+tracks.size()); 208 if (mergeEqualNodes) { 207 if (mergeEqualNodes && !nodes.isEmpty()) { 209 208 Map<Node, Node> mergeMap = new HashMap<Node, Node>(); 210 209 Set<Node> nodesToAdd = new HashSet<Node>(); … … 247 246 pendingLineSegments.addAll(ds.pendingLineSegments); 248 247 } 249 System.out.println(nodes.size()+" "+pendingLineSegments.size()+" "+tracks.size());250 248 } 251 249 … … 258 256 return; 259 257 for (OsmPrimitive osm : list) { 260 osm.setSelected(false , this);258 osm.setSelected(false); 261 259 if (osm.keys != null) 262 260 clearSelection(osm.keys.keySet()); -
src/org/openstreetmap/josm/command/MoveCommand.java
r21 r22 63 63 return new JLabel("Move "+objects.size()+" primitives "+xstr+" "+ystr); 64 64 } 65 66 public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) { 67 for (OsmPrimitive osm : objects) 68 if (!modified.contains(osm)) 69 modified.add(osm); 70 } 65 71 }
Note:
See TracChangeset
for help on using the changeset viewer.
