Changeset 23 in josm for src/org/openstreetmap/josm/command
- Timestamp:
- 2005-10-27T00:38:03+02:00 (20 years ago)
- Location:
- src/org/openstreetmap/josm/command
- Files:
-
- 2 added
- 4 edited
-
AddCommand.java (modified) (3 diffs)
-
CombineAndDeleteCommand.java (added)
-
CombineCommand.java (modified) (2 diffs)
-
Command.java (modified) (1 diff)
-
DeleteCommand.java (added)
-
MoveCommand.java (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/command/AddCommand.java
r22 r23 43 43 SelectionComponentVisitor v = new SelectionComponentVisitor(); 44 44 osm.visit(v); 45 return new JLabel(v.name, v.icon, JLabel.LEADING); 45 return new JLabel("Add "+v.name, v.icon, JLabel.LEADING); 46 46 } 47 47 48 48 public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) { 49 if (!added.contains(osm)) 49 if (added != null && !added.contains(osm)) 50 50 added.add(osm); 51 51 } … … 65 65 public void visit(LineSegment ls) { 66 66 Main.main.ds.pendingLineSegments.add(ls); 67 Main.main.ds.addBackReference(ls.start, ls); 68 Main.main.ds.addBackReference(ls.end, ls); 67 69 } 68 70 … … 74 76 Main.main.ds.tracks.add(t); 75 77 for (Iterator<LineSegment> it = Main.main.ds.pendingLineSegments.iterator(); it.hasNext();) 76 if (t.segments ().contains(it.next()))78 if (t.segments.contains(it.next())) 77 79 it.remove(); 80 for (LineSegment ls : t.segments) { 81 Main.main.ds.addBackReference(ls, t); 82 Main.main.ds.addBackReference(ls.start, t); 83 Main.main.ds.addBackReference(ls.end, t); 84 } 78 85 } 79 86 -
src/org/openstreetmap/josm/command/CombineCommand.java
r22 r23 46 46 public void executeCommand() { 47 47 if (del instanceof LineSegment) { 48 LineSegment ls = (LineSegment) mod;49 Track t = (Track) del;50 if (!Main.main.ds.pendingLineSegments ().contains(ls))48 LineSegment ls = (LineSegment)del; 49 Track t = (Track)mod; 50 if (!Main.main.ds.pendingLineSegments.contains(ls)) 51 51 throw new IllegalStateException("Should not be able to select non-pending line segments."); 52 52 53 53 Main.main.ds.pendingLineSegments.remove(ls); 54 if (t.getStartingNode() != ls. getEnd())54 if (t.getStartingNode() != ls.end) 55 55 t.add(ls); 56 56 else 57 t. addStart(ls);57 t.segments.add(0,ls); 58 58 } else { 59 59 Track t1 = (Track)mod; 60 60 Track t2 = (Track)del; 61 t1.addAll(t2.segments ());61 t1.segments.addAll(t2.segments); 62 62 if (t1.keys == null) 63 63 t1.keys = t2.keys; 64 64 else 65 65 t1.keys.putAll(t2.keys); 66 t2.destroy();67 66 Main.main.ds.tracks.remove(t2); 68 67 } 68 Main.main.ds.rebuildBackReferences(); 69 69 } 70 70 … … 82 82 83 83 public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) { 84 if (!modified.contains(mod)) 84 if (modified != null && !modified.contains(mod)) 85 85 modified.add(mod); 86 if (deleted.contains(del)) 86 if (deleted != null && deleted.contains(del)) 87 87 throw new IllegalStateException("Deleted object twice: "+del); 88 88 deleted.add(del); -
src/org/openstreetmap/josm/command/Command.java
r22 r23 27 27 /** 28 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 29 * Add to the lists, don't clear them. The lists can be <code>null</code> 30 * in which case they are ignored. 31 * 32 * @param modified The modified primitives or <code>null</code> 33 * @param deleted The deleted primitives or <code>null</code> 34 * @param added The added primitives or <code>null</code> 33 35 */ 34 36 void fillModifiedData(Collection<OsmPrimitive> modified, -
src/org/openstreetmap/josm/command/MoveCommand.java
r22 r23 3 3 import java.awt.Component; 4 4 import java.util.Collection; 5 import java.util.HashSet;6 5 7 6 import javax.swing.JLabel; … … 9 8 import org.openstreetmap.josm.data.osm.Node; 10 9 import org.openstreetmap.josm.data.osm.OsmPrimitive; 10 import org.openstreetmap.josm.data.osm.visitor.AllNodesVisitor; 11 11 12 12 /** … … 49 49 50 50 public void executeCommand() { 51 Collection<Node> movingNodes= newHashSet<Node>();51 AllNodesVisitor visitor = new AllNodesVisitor(); 52 52 for (OsmPrimitive osm : objects) 53 movingNodes.addAll(osm.getAllNodes());54 for (Node n : movingNodes) {53 osm.visit(visitor); 54 for (Node n : visitor.nodes) { 55 55 n.coor.x += x; 56 56 n.coor.y += y; … … 65 65 66 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); 67 if (modified != null) 68 for (OsmPrimitive osm : objects) 69 if (!modified.contains(osm)) 70 modified.add(osm); 70 71 } 71 72 }
Note:
See TracChangeset
for help on using the changeset viewer.
