Changeset 30 in josm for src/org/openstreetmap/josm/command/MoveCommand.java
- Timestamp:
- 2005-12-03T14:14:35+01:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/command/MoveCommand.java
r23 r30 2 2 3 3 import java.awt.Component; 4 import java.awt.geom.Point2D; 4 5 import java.util.Collection; 6 import java.util.Iterator; 7 import java.util.LinkedList; 8 import java.util.List; 5 9 6 10 import javax.swing.JLabel; … … 21 25 * The objects that should be moved. 22 26 */ 23 private Collection<OsmPrimitive> objects;27 private List<OsmPrimitive> objects; 24 28 /** 25 29 * x difference movement. Coordinates are in northern/eastern … … 32 36 33 37 /** 38 * x/y List of all old positions of the objects. 39 */ 40 private List<Point2D.Double> oldPositions; 41 42 /** 34 43 * Create a MoveCommand and assign the initial object set and movement vector. 35 44 */ 36 45 public MoveCommand(Collection<OsmPrimitive> objects, double x, double y) { 37 this.objects = objects;46 this.objects = new LinkedList<OsmPrimitive>(objects); 38 47 this.x = x; 39 48 this.y = y; 40 }41 42 /**43 * Move the objects additional to the current movement.44 */45 public void move(double x, double y) {46 this.x += x;47 this.y += y;48 49 } 49 50 … … 58 59 } 59 60 61 public void undoCommand() { 62 AllNodesVisitor visitor = new AllNodesVisitor(); 63 for (OsmPrimitive osm : objects) 64 osm.visit(visitor); 65 Iterator<Point2D.Double> it = oldPositions.iterator(); 66 for (Node n : visitor.nodes) { 67 Point2D.Double p = it.next(); 68 n.coor.x = p.x; 69 n.coor.y = p.y; 70 } 71 } 72 60 73 public Component commandDescription() { 61 74 String xstr = Math.abs(x) + (x < 0 ? "W" : "E"); … … 65 78 66 79 public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) { 67 if (modified != null) 68 for (OsmPrimitive osm : objects) 69 if (!modified.contains(osm)) 70 modified.add(osm); 80 for (OsmPrimitive osm : objects) 81 if (!modified.contains(osm)) 82 modified.add(osm); 71 83 } 72 84 }
Note:
See TracChangeset
for help on using the changeset viewer.
