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

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

Location:
trunk/src/org/openstreetmap/josm/actions
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/AlignInCircleAction.java

    r1415 r1636  
    1616import org.openstreetmap.josm.command.SequenceCommand;
    1717import org.openstreetmap.josm.data.coor.EastNorth;
    18 import org.openstreetmap.josm.data.coor.LatLon;
    1918import org.openstreetmap.josm.data.osm.Node;
    2019import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    135134        Collection<Node> nodes = new LinkedList<Node>();
    136135        Collection<Way> ways = new LinkedList<Way>();
    137         Node center = null;
     136        EastNorth center = null;
    138137        double radius = 0;
    139138        boolean regular = false;
     
    164163                } else {
    165164
    166                     center = (Node) nodes.toArray()[way.nodes.contains(nodes.toArray()[0]) ? 1 : 0];
     165                    center = ((Node) nodes.toArray()[way.nodes.contains(nodes.toArray()[0]) ? 1 : 0]).eastNorth;
    167166                    if (nodes.size() == 2)
    168167                        radius = distance(((Node) nodes.toArray()[0]).eastNorth, ((Node) nodes.toArray()[1]).eastNorth);
     
    184183        // Get average position of circumcircles of the triangles of all triplets of neighbour nodes
    185184        if (center == null) {
    186             center = new Node(new LatLon(0, 0));
    187             center.eastNorth = new EastNorth(0, 0); // to be independent of projection
     185            center = new EastNorth(0, 0);
    188186            Node n0 = (Node) nodes.toArray()[nodes.size() - 1];
    189187            Node n1 = (Node) nodes.toArray()[nodes.size() - 2];
     
    196194                if (cc == null)
    197195                    return;
    198                 center.eastNorth = new EastNorth(center.eastNorth.east() + cc.east(), center.eastNorth.north()
     196                center = new EastNorth(center.east() + cc.east(), center.north()
    199197                        + cc.north());
    200198            }
    201199
    202             center.eastNorth = new EastNorth(center.eastNorth.east() / nodes.size(), center.eastNorth.north()
     200            center = new EastNorth(center.east() / nodes.size(), center.north()
    203201                    / nodes.size());
    204             center.coor = Main.proj.eastNorth2latlon(center.eastNorth);
    205202        }
    206203
     
    212209        if (radius == 0) {
    213210            for (Node n : nodes) {
    214                 radius += distance(center.eastNorth, n.eastNorth);
     211                radius += distance(center, n.eastNorth);
    215212            }
    216213            radius = radius / nodes.size();
     
    223220        if (regular) { // Make a regular polygon
    224221            double angle = Math.PI * 2 / nodes.size();
    225             pc = new PolarCoor(((Node) nodes.toArray()[0]).eastNorth, center.eastNorth, 0);
    226 
    227             if (pc.angle > (new PolarCoor(((Node) nodes.toArray()[1]).eastNorth, center.eastNorth, 0).angle))
     222            pc = new PolarCoor(((Node) nodes.toArray()[0]).eastNorth, center, 0);
     223
     224            if (pc.angle > (new PolarCoor(((Node) nodes.toArray()[1]).eastNorth, center, 0).angle))
    228225                angle *= -1;
    229226
     
    236233        } else { // Move each node to that distance from the centre.
    237234            for (Node n : nodes) {
    238                 pc = new PolarCoor(n.eastNorth, center.eastNorth, 0);
     235                pc = new PolarCoor(n.eastNorth, center, 0);
    239236                pc.radius = radius;
    240237                EastNorth no = pc.toEastNorth();
  • trunk/src/org/openstreetmap/josm/actions/PasteAction.java

    r1592 r1636  
    1717import org.openstreetmap.josm.command.Command;
    1818import org.openstreetmap.josm.command.SequenceCommand;
     19import org.openstreetmap.josm.data.coor.EastNorth;
    1920import org.openstreetmap.josm.data.osm.DataSet;
    20 import org.openstreetmap.josm.data.osm.Relation;
    2121import org.openstreetmap.josm.data.osm.Node;
    2222import org.openstreetmap.josm.data.osm.OsmPrimitive;
     23import org.openstreetmap.josm.data.osm.Relation;
    2324import org.openstreetmap.josm.data.osm.RelationMember;
    2425import org.openstreetmap.josm.data.osm.Way;
    25 import org.openstreetmap.josm.data.coor.EastNorth;
    2626import org.openstreetmap.josm.gui.layer.Layer;
    2727import org.openstreetmap.josm.tools.Shortcut;
     
    7070            nnew.id = 0;
    7171            if (Main.main.editLayer() == source) {
    72                 nnew.eastNorth = new EastNorth(nnew.eastNorth.east() + offsetEast, nnew.eastNorth.north() + offsetNorth);
    73                 nnew.coor = Main.proj.eastNorth2latlon(nnew.eastNorth);
     72                nnew.setEastNorth(nnew.eastNorth.add(offsetEast, offsetNorth));
    7473            }
    7574            map.put(n, nnew);
  • trunk/src/org/openstreetmap/josm/actions/UnGlueAction.java

    r1499 r1636  
    2121import org.openstreetmap.josm.command.Command;
    2222import org.openstreetmap.josm.command.SequenceCommand;
    23 import org.openstreetmap.josm.data.coor.EastNorth;
    2423import org.openstreetmap.josm.data.osm.Node;
    2524import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    149148        if(e.getSource() instanceof JPanel) {
    150149            MapView mv = Main.map.mapView;
    151             n.eastNorth = mv.getEastNorth(mv.lastMEvent.getX(), mv.lastMEvent.getY());
    152             n.coor = Main.proj.eastNorth2latlon(n.eastNorth);
     150            n.setEastNorth(mv.getEastNorth(mv.lastMEvent.getX(), mv.lastMEvent.getY()));
    153151        }
    154152       
  • trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java

    r1545 r1636  
    801801            // (for semi-parallel lines, intersection might be miles away!)
    802802            if (Main.map.mapView.getPoint(n.eastNorth).distance(Main.map.mapView.getPoint(intersection)) < snapToIntersectionThreshold) {
    803                 n.eastNorth = intersection;
     803                n.setEastNorth(intersection);
    804804                return;
    805805            }
     
    814814            double c = A.distanceSq(B);
    815815            q = (a - b + c) / (2*c);
    816             n.eastNorth = new EastNorth(
    817                 B.east() + q * (A.east() - B.east()),
    818                 B.north() + q * (A.north() - B.north()));
     816            n.setEastNorth(B.east() + q * (A.east() - B.east()), B.north() + q * (A.north() - B.north()));
    819817        }
    820818    }
Note: See TracChangeset for help on using the changeset viewer.