Changeset 312 in josm for src/org/openstreetmap/josm/command
- Timestamp:
- 2007-08-23T15:59:32+02:00 (18 years ago)
- Location:
- src/org/openstreetmap/josm/command
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/command/MoveCommand.java
r307 r312 5 5 import static org.openstreetmap.josm.tools.I18n.trn; 6 6 7 import java.util.Arrays;8 7 import java.util.Collection; 9 8 import java.util.Collections; … … 47 46 * Small helper for holding the interesting part of the old data state of the 48 47 * objects. 49 * @author imi50 48 */ 51 class OldState 52 {53 double x,y,lat,lon;49 public static class OldState { 50 LatLon latlon; 51 EastNorth eastNorth; 54 52 boolean modified; 55 53 } 54 56 55 /** 57 56 * List of all old states of the objects. … … 72 71 for (Node n : this.objects) { 73 72 OldState os = new OldState(); 74 os.x = n.eastNorth.east(); 75 os.y = n.eastNorth.north(); 76 os.lat = n.coor.lat(); 77 os.lon = n.coor.lon(); 73 os.eastNorth = n.eastNorth; 74 os.latlon = n.coor; 78 75 os.modified = n.modified; 79 76 oldState.add(os); … … 110 107 for (Node n : objects) { 111 108 OldState os = it.next(); 112 n.eastNorth = new EastNorth(os.x, os.y);113 n.coor = new LatLon(os.lat, os.lon);109 n.eastNorth = os.eastNorth; 110 n.coor = os.latlon; 114 111 n.modified = os.modified; 115 112 } -
src/org/openstreetmap/josm/command/RotateCommand.java
r311 r312 4 4 import static org.openstreetmap.josm.tools.I18n.trn; 5 5 6 import java.util.Arrays;7 6 import java.util.Collection; 8 7 import java.util.HashMap; 9 import java.util.Iterator;10 8 import java.util.LinkedList; 11 import java.util.List;12 9 import java.util.Map; 13 10 … … 17 14 18 15 import org.openstreetmap.josm.Main; 19 import org.openstreetmap.josm.command.MoveCommand.OldState;20 16 import org.openstreetmap.josm.data.coor.EastNorth; 21 17 import org.openstreetmap.josm.data.coor.LatLon; … … 53 49 54 50 /** 55 * Small helper for holding the interesting part of the old data state of the56 * objects.57 */58 class OldState59 {60 double x,y,lat,lon;61 boolean modified;62 Node originalNode;63 }64 65 /**66 51 * List of all old states of the objects. 67 52 */ 68 private Map<Node, OldState> oldState = new HashMap<Node, OldState>(); 53 private Map<Node, MoveCommand.OldState> oldState = new HashMap<Node, MoveCommand.OldState>(); 69 54 70 55 /** … … 80 65 81 66 for (Node n : this.objects) { 82 OldState os = new OldState(); 83 os.x = n.eastNorth.east(); 84 os.y = n.eastNorth.north(); 85 os.lat = n.coor.lat(); 86 os.lon = n.coor.lon(); 67 MoveCommand.OldState os = new MoveCommand.OldState(); 68 os.eastNorth = n.eastNorth; 69 os.latlon = n.coor; 87 70 os.modified = n.modified; 88 71 oldState.put(n, os); 89 pivot.eastNorth = new EastNorth(pivot.eastNorth.east()+os. x, pivot.eastNorth.north()+os.y);72 pivot.eastNorth = new EastNorth(pivot.eastNorth.east()+os.eastNorth.east(), pivot.eastNorth.north()+os.eastNorth.north()); 90 73 pivot.coor = Main.proj.eastNorth2latlon(pivot.eastNorth); 91 74 } … … 118 101 double cosPhi = Math.cos(rotationAngle); 119 102 double sinPhi = Math.sin(rotationAngle); 120 double x = oldState.get(n).x - pivot.eastNorth.east(); 121 double y = oldState.get(n).y - pivot.eastNorth.north(); 103 EastNorth oldEastNorth = oldState.get(n).eastNorth; 104 double x = oldEastNorth.east() - pivot.eastNorth.east(); 105 double y = oldEastNorth.north() - pivot.eastNorth.north(); 122 106 double nx = sinPhi * x + cosPhi * y + pivot.eastNorth.east(); 123 107 double ny = -cosPhi * x + sinPhi * y + pivot.eastNorth.north(); 124 108 n.eastNorth = new EastNorth(nx, ny); 125 109 n.coor = Main.proj.eastNorth2latlon(n.eastNorth); 126 if (setModified) n.modified = true; 110 if (setModified) 111 n.modified = true; 127 112 } 128 113 } … … 134 119 @Override public void undoCommand() { 135 120 for (Node n : objects) { 136 OldState os = oldState.get(n); 137 n.eastNorth = new EastNorth(os.x, os.y);138 n.coor = new LatLon(os.lat, os.lon);121 MoveCommand.OldState os = oldState.get(n); 122 n.eastNorth = os.eastNorth; 123 n.coor = os.latlon; 139 124 n.modified = os.modified; 140 125 }
Note:
See TracChangeset
for help on using the changeset viewer.