Changeset 32 in josm for src/org/openstreetmap/josm/command
- Timestamp:
- 2005-12-19T22:58:10+01:00 (20 years ago)
- Location:
- src/org/openstreetmap/josm/command
- Files:
-
- 2 edited
-
ChangeKeyValueCommand.java (modified) (3 diffs)
-
MoveCommand.java (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/command/ChangeKeyValueCommand.java
r31 r32 38 38 */ 39 39 private List<Map<Key, String>> oldProperties; 40 41 /** 42 * These are the old modified states of the data. 43 */ 44 private List<Boolean> oldModified = new LinkedList<Boolean>(); 40 45 41 46 public ChangeKeyValueCommand(Collection<OsmPrimitive> objects, Key key, String value) { … … 48 53 // save old 49 54 oldProperties = new LinkedList<Map<Key, String>>(); 50 for (OsmPrimitive osm : objects) 55 for (OsmPrimitive osm : objects) { 51 56 oldProperties.add(osm.keys == null ? null : new HashMap<Key, String>(osm.keys)); 57 oldModified.add(osm.modified); 58 } 52 59 53 60 if (value == null) { … … 70 77 public void undoCommand() { 71 78 Iterator<Map<Key, String>> it = oldProperties.iterator(); 72 for (OsmPrimitive osm : objects) 79 Iterator<Boolean> itMod = oldModified.iterator(); 80 for (OsmPrimitive osm : objects) { 73 81 osm.keys = it.next(); 82 osm.modified = itMod.next(); 83 } 74 84 } 75 85 -
src/org/openstreetmap/josm/command/MoveCommand.java
r31 r32 1 1 package org.openstreetmap.josm.command; 2 2 3 import java.awt.geom.Point2D;4 3 import java.util.Collection; 5 4 import java.util.Iterator; … … 33 32 34 33 /** 35 * x/y List of all old positions of the objects. 34 * Small helper for holding the interesting part of the old data state of the 35 * objects. 36 * @author imi 36 37 */ 37 private List<Point2D.Double> oldPositions = new LinkedList<Point2D.Double>(); 38 class OldState 39 { 40 double x,y; 41 boolean modified; 42 } 43 /** 44 * List of all old states of the objects. 45 */ 46 private List<OldState> oldState = new LinkedList<OldState>(); 38 47 39 48 /** … … 44 53 this.y = y; 45 54 this.objects = getAffectedNodes(objects); 46 for (Node n : this.objects) 47 oldPositions.add(new Point2D.Double(n.coor.x, n.coor.y)); 55 for (Node n : this.objects) { 56 OldState os = new OldState(); 57 os.x = n.coor.x; 58 os.y = n.coor.y; 59 os.modified = n.modified; 60 oldState.add(os); 61 } 48 62 } 49 63 … … 80 94 n.coor.x += x; 81 95 n.coor.y += y; 96 n.modified = true; 82 97 } 83 98 } 84 99 85 100 public void undoCommand() { 86 Iterator< Point2D.Double> it = oldPositions.iterator();101 Iterator<OldState> it = oldState.iterator(); 87 102 for (Node n : objects) { 88 Point2D.Double p = it.next(); 89 n.coor.x = p.x; 90 n.coor.y = p.y; 103 OldState os = it.next(); 104 n.coor.x = os.x; 105 n.coor.y = os.y; 106 n.modified = os.modified; 91 107 } 92 108 }
Note:
See TracChangeset
for help on using the changeset viewer.
