Changeset 71 in josm for src/org/openstreetmap/josm/command
- Timestamp:
- 2006-03-25T16:21:09+01:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/command/MoveCommand.java
r34 r71 7 7 8 8 import org.openstreetmap.josm.Main; 9 import org.openstreetmap.josm.data.coor.LatLon; 10 import org.openstreetmap.josm.data.coor.EastNorth; 9 11 import org.openstreetmap.josm.data.osm.Node; 10 12 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 22 24 * The objects that should be moved. 23 25 */ 24 public List<Node> objects = new LinkedList<Node>();26 public Collection<Node> objects = new LinkedList<Node>(); 25 27 /** 26 28 * x difference movement. Coordinates are in northern/eastern … … 53 55 this.x = x; 54 56 this.y = y; 55 this.objects = getAffectedNodes(objects);57 this.objects = AllNodesVisitor.getAllNodes(objects); 56 58 for (Node n : this.objects) { 57 59 OldState os = new OldState(); 58 os.x = n. coor.x;59 os.y = n. coor.y;60 os.lat = n.coor.lat; 61 os.lon = n.coor.lon; 60 os.x = n.eastNorth.east(); 61 os.y = n.eastNorth.north(); 62 os.lat = n.coor.lat(); 63 os.lon = n.coor.lon(); 62 64 os.modified = n.modified; 63 65 oldState.add(os); … … 65 67 } 66 68 67 /**68 * @return a list of all nodes that will be moved if using the given set of69 * objects.70 */71 public static List<Node> getAffectedNodes(Collection<OsmPrimitive> objects) {72 AllNodesVisitor visitor = new AllNodesVisitor();73 for (OsmPrimitive osm : objects)74 osm.visit(visitor);75 return new LinkedList<Node>(visitor.nodes);76 }77 78 69 /** 79 70 * Move the same set of objects again by the specified vector. The vectors … … 86 77 public void moveAgain(double x, double y) { 87 78 for (Node n : objects) { 88 n.coor.x += x; 89 n.coor.y += y; 90 Main.pref.getProjection().xy2latlon(n.coor); 79 n.eastNorth = new EastNorth(n.eastNorth.east()+x, n.eastNorth.north()+y); 80 n.coor = Main.pref.getProjection().eastNorth2latlon(n.eastNorth); 91 81 } 92 82 this.x += x; … … 96 86 public void executeCommand() { 97 87 for (Node n : objects) { 98 n.coor.x += x; 99 n.coor.y += y; 100 Main.pref.getProjection().xy2latlon(n.coor); 88 n.eastNorth = new EastNorth(n.eastNorth.east()+x, n.eastNorth.north()+y); 89 n.coor = Main.pref.getProjection().eastNorth2latlon(n.eastNorth); 101 90 n.modified = true; 102 91 } … … 107 96 for (Node n : objects) { 108 97 OldState os = it.next(); 109 n.coor.x = os.x; 110 n.coor.y = os.y; 111 n.coor.lat = os.lat; 112 n.coor.lon = os.lon; 98 n.eastNorth = new EastNorth(os.x, os.y); 99 n.coor = new LatLon(os.lat, os.lon); 113 100 n.modified = os.modified; 114 101 }
Note:
See TracChangeset
for help on using the changeset viewer.