Ignore:
Timestamp:
2009-06-06T13:38:32+02:00 (11 years ago)
Author:
stoecker
Message:

fix #2302 - patch by jttt - some code cleanup for better encapsulation

Location:
trunk/src/org/openstreetmap/josm/command
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/command/MoveCommand.java

    r1169 r1636  
    1515import javax.swing.tree.MutableTreeNode;
    1616
    17 import org.openstreetmap.josm.Main;
    1817import org.openstreetmap.josm.data.coor.EastNorth;
    1918import org.openstreetmap.josm.data.coor.LatLon;
     
    8887    public void moveAgain(double x, double y) {
    8988        for (Node n : objects) {
    90             n.eastNorth = new EastNorth(n.eastNorth.east()+x, n.eastNorth.north()+y);
    91             n.coor = Main.proj.eastNorth2latlon(n.eastNorth);
     89            n.setEastNorth(n.eastNorth.add(x, y));
    9290        }
    9391        this.x += x;
     
    9795    @Override public boolean executeCommand() {
    9896        for (Node n : objects) {
    99             n.eastNorth = new EastNorth(n.eastNorth.east()+x, n.eastNorth.north()+y);
    100             n.coor = Main.proj.eastNorth2latlon(n.eastNorth);
     97            n.setEastNorth(n.eastNorth.add(x, y));
    10198            n.modified = true;
    10299        }
     
    108105        for (Node n : objects) {
    109106            OldState os = it.next();
    110             n.eastNorth = os.eastNorth;
    111             n.coor = os.latlon;
     107            n.setEastNorth(os.eastNorth);
    112108            n.modified = os.modified;
    113109        }
  • trunk/src/org/openstreetmap/josm/command/RotateCommand.java

    r1169 r1636  
    1313import javax.swing.tree.MutableTreeNode;
    1414
    15 import org.openstreetmap.josm.Main;
    1615import org.openstreetmap.josm.data.coor.EastNorth;
    17 import org.openstreetmap.josm.data.coor.LatLon;
    1816import org.openstreetmap.josm.data.osm.Node;
    1917import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    3634     * pivot point
    3735     */
    38     private Node pivot;
     36    private EastNorth pivot;
    3937
    4038    /**
     
    6260
    6361        this.objects = AllNodesVisitor.getAllNodes(objects);
    64         pivot = new Node(new LatLon(0,0));
    65         pivot.eastNorth = new EastNorth(0,0);
     62        pivot = new EastNorth(0,0);
    6663
    6764        for (Node n : this.objects) {
     
    7168            os.modified = n.modified;
    7269            oldState.put(n, os);
    73             pivot.eastNorth = new EastNorth(pivot.eastNorth.east()+os.eastNorth.east(), pivot.eastNorth.north()+os.eastNorth.north());
     70            pivot = pivot.add(os.eastNorth.east(), os.eastNorth.north());
    7471        }
    75         pivot.eastNorth = new EastNorth(pivot.eastNorth.east()/this.objects.size(), pivot.eastNorth.north()/this.objects.size());
    76         pivot.coor = Main.proj.eastNorth2latlon(pivot.eastNorth);
     72        pivot = new EastNorth(pivot.east()/this.objects.size(), pivot.north()/this.objects.size());
    7773
    7874        rotationAngle = Math.PI/2;
     
    8783    public void rotateAgain(EastNorth start, EastNorth end) {
    8884        // compute angle
    89         startAngle = Math.atan2(start.east()-pivot.eastNorth.east(), start.north()-pivot.eastNorth.north());
    90         double endAngle = Math.atan2(end.east()-pivot.eastNorth.east(), end.north()-pivot.eastNorth.north());
     85        startAngle = Math.atan2(start.east()-pivot.east(), start.north()-pivot.north());
     86        double endAngle = Math.atan2(end.east()-pivot.east(), end.north()-pivot.north());
    9187        rotationAngle += startAngle - endAngle;
    9288        rotateNodes(false);
     
    10298            double sinPhi = Math.sin(rotationAngle);
    10399            EastNorth oldEastNorth = oldState.get(n).eastNorth;
    104             double x = oldEastNorth.east() - pivot.eastNorth.east();
    105             double y = oldEastNorth.north() - pivot.eastNorth.north();
    106             double nx =  sinPhi * x + cosPhi * y + pivot.eastNorth.east();
    107             double ny = -cosPhi * x + sinPhi * y + pivot.eastNorth.north();
    108             n.eastNorth = new EastNorth(nx, ny);
    109             n.coor = Main.proj.eastNorth2latlon(n.eastNorth);
     100            double x = oldEastNorth.east() - pivot.east();
     101            double y = oldEastNorth.north() - pivot.north();
     102            double nx =  sinPhi * x + cosPhi * y + pivot.east();
     103            double ny = -cosPhi * x + sinPhi * y + pivot.north();
     104            n.setEastNorth(nx, ny);
    110105            if (setModified)
    111106                n.modified = true;
     
    121116        for (Node n : objects) {
    122117            MoveCommand.OldState os = oldState.get(n);
    123             n.eastNorth = os.eastNorth;
    124             n.coor = os.latlon;
     118            n.setEastNorth(os.eastNorth);
    125119            n.modified = os.modified;
    126120        }
Note: See TracChangeset for help on using the changeset viewer.