Changeset 1912 in josm for trunk/src/org


Ignore:
Timestamp:
2009-08-05T10:25:23+02:00 (15 years ago)
Author:
Gubaer
Message:

Updated w.getNodes().contains(..) to w.containsNode(...)

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

Legend:

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

    r1862 r1912  
    113113            // distance between two nodes.
    114114            if (nodes.size() > 0) {
    115                 if (nodes.size() == 1 && way.getNodes().contains(nodes.get(0))) {
     115                if (nodes.size() == 1 && way.containsNode(nodes.get(0))) {
    116116                    regular = true;
    117117                } else {
    118118
    119                     center = nodes.get(way.getNodes().contains(nodes.get(0)) ? 1 : 0).getEastNorth();
     119                    center = nodes.get(way.containsNode(nodes.get(0)) ? 1 : 0).getEastNorth();
    120120                    if (nodes.size() == 2) {
    121121                        radius = distance(nodes.get(0).getEastNorth(), nodes.get(1).getEastNorth());
  • trunk/src/org/openstreetmap/josm/actions/MergeNodesAction.java

    r1862 r1912  
    225225                    continue;
    226226                }
    227                 if (w.getNodes().contains(sn)) {
     227                if (w.containsNode(sn)) {
    228228                    modify = true;
    229229                }
  • trunk/src/org/openstreetmap/josm/actions/UnGlueAction.java

    r1899 r1912  
    7070                    continue;
    7171                }
    72                 if (!w.getNodes().contains(selectedNode)) {
     72                if (!w.containsNode(selectedNode)) {
    7373                    continue;
    7474                }
     
    9595                        continue;
    9696                    }
    97                     if (!w.getNodes().contains(n)) {
     97                    if (!w.containsNode(n)) {
    9898                        continue;
    9999                    }
     
    191191        boolean isPartOfWay = false;
    192192        for(Way w : getCurrentDataSet().ways) {
    193             if(w.getNodes().contains(n)) {
     193            if(w.containsNode((Node)n)) {
    194194                isPartOfWay = true;
    195195                break;
     
    232232                selectedNode = (Node) p;
    233233                if (size == 1 || selectedWay != null)
    234                     return size == 1 || selectedWay.getNodes().contains(selectedNode);
     234                    return size == 1 || selectedWay.containsNode(selectedNode);
    235235            } else if (p instanceof Way) {
    236236                selectedWay = (Way) p;
    237237                if (size == 2 && selectedNode != null)
    238                     return selectedWay.getNodes().contains(selectedNode);
     238                    return selectedWay.containsNode(selectedNode);
    239239            }
    240240        }
     
    276276            if (p instanceof Node) {
    277277                Node n = (Node) p;
    278                 if (!selectedWay.getNodes().contains(n))
     278                if (!selectedWay.containsNode(n))
    279279                    return false;
    280280                selectedNodes.add(n);
     
    372372                    continue;
    373373                }
    374                 if (!w.getNodes().contains(selectedNode)) {
     374                if (!w.containsNode(selectedNode)) {
    375375                    continue;
    376376                }
  • trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java

    r1899 r1912  
    128128                        return;
    129129                    switch(c) {
    130                     case way:
    131                         Main.map.mapView.setCursor(cursorJoinWay);
     130                        case way:
     131                            Main.map.mapView.setCursor(cursorJoinWay);
     132                            break;
     133                        case node:
     134                            Main.map.mapView.setCursor(cursorJoinNode);
     135                            break;
     136                        default:
     137                            Main.map.mapView.setCursor(cursorCrosshair);
    132138                        break;
    133                     case node:
    134                         Main.map.mapView.setCursor(cursorJoinNode);
    135                         break;
    136                     default:
    137                         Main.map.mapView.setCursor(cursorCrosshair);
    138                     break;
    139139                    }
    140140                }
     
    503503
    504504                // Connected to a node that's already in the way
    505                 if(way.getNodes().contains(n)) {
     505                if(way.containsNode(n)) {
    506506                    wayIsFinished = true;
    507507                    selection.clear();
     
    810810
    811811        switch (segs.size()) {
    812         case 0:
    813             return;
    814         case 2:
    815             // This computes the intersection between
    816             // the two segments and adjusts the node position.
    817             Iterator<Pair<Node,Node>> i = segs.iterator();
    818             Pair<Node,Node> seg = i.next();
    819             EastNorth A = seg.a.getEastNorth();
    820             EastNorth B = seg.b.getEastNorth();
    821             seg = i.next();
    822             EastNorth C = seg.a.getEastNorth();
    823             EastNorth D = seg.b.getEastNorth();
    824 
    825             double u=det(B.east() - A.east(), B.north() - A.north(), C.east() - D.east(), C.north() - D.north());
    826 
    827             // Check for parallel segments and do nothing if they are
    828             // In practice this will probably only happen when a way has been duplicated
    829 
    830             if (u == 0) return;
    831 
    832             // q is a number between 0 and 1
    833             // It is the point in the segment where the intersection occurs
    834             // if the segment is scaled to lenght 1
    835 
    836             double q = det(B.north() - C.north(), B.east() - C.east(), D.north() - C.north(), D.east() - C.east()) / u;
    837             EastNorth intersection = new EastNorth(
    838                     B.east() + q * (A.east() - B.east()),
    839                     B.north() + q * (A.north() - B.north()));
    840 
    841             int snapToIntersectionThreshold
    842             = Main.pref.getInteger("edit.snap-intersection-threshold",10);
    843 
    844             // only adjust to intersection if within snapToIntersectionThreshold pixel of mouse click; otherwise
    845             // fall through to default action.
    846             // (for semi-parallel lines, intersection might be miles away!)
    847             if (Main.map.mapView.getPoint(n).distance(Main.map.mapView.getPoint(intersection)) < snapToIntersectionThreshold) {
    848                 n.setEastNorth(intersection);
     812            case 0:
    849813                return;
    850             }
    851 
    852         default:
    853             EastNorth P = n.getEastNorth();
    854         seg = segs.iterator().next();
    855         A = seg.a.getEastNorth();
    856         B = seg.b.getEastNorth();
    857         double a = P.distanceSq(B);
    858         double b = P.distanceSq(A);
    859         double c = A.distanceSq(B);
    860         q = (a - b + c) / (2*c);
    861         n.setEastNorth(new EastNorth(B.east() + q * (A.east() - B.east()), B.north() + q * (A.north() - B.north())));
     814            case 2:
     815                // This computes the intersection between
     816                // the two segments and adjusts the node position.
     817                Iterator<Pair<Node,Node>> i = segs.iterator();
     818                Pair<Node,Node> seg = i.next();
     819                EastNorth A = seg.a.getEastNorth();
     820                EastNorth B = seg.b.getEastNorth();
     821                seg = i.next();
     822                EastNorth C = seg.a.getEastNorth();
     823                EastNorth D = seg.b.getEastNorth();
     824
     825                double u=det(B.east() - A.east(), B.north() - A.north(), C.east() - D.east(), C.north() - D.north());
     826
     827                // Check for parallel segments and do nothing if they are
     828                // In practice this will probably only happen when a way has been duplicated
     829
     830                if (u == 0) return;
     831
     832                // q is a number between 0 and 1
     833                // It is the point in the segment where the intersection occurs
     834                // if the segment is scaled to lenght 1
     835
     836                double q = det(B.north() - C.north(), B.east() - C.east(), D.north() - C.north(), D.east() - C.east()) / u;
     837                EastNorth intersection = new EastNorth(
     838                        B.east() + q * (A.east() - B.east()),
     839                        B.north() + q * (A.north() - B.north()));
     840
     841                int snapToIntersectionThreshold
     842                = Main.pref.getInteger("edit.snap-intersection-threshold",10);
     843
     844                // only adjust to intersection if within snapToIntersectionThreshold pixel of mouse click; otherwise
     845                // fall through to default action.
     846                // (for semi-parallel lines, intersection might be miles away!)
     847                if (Main.map.mapView.getPoint(n).distance(Main.map.mapView.getPoint(intersection)) < snapToIntersectionThreshold) {
     848                    n.setEastNorth(intersection);
     849                    return;
     850                }
     851
     852            default:
     853                EastNorth P = n.getEastNorth();
     854            seg = segs.iterator().next();
     855            A = seg.a.getEastNorth();
     856            B = seg.b.getEastNorth();
     857            double a = P.distanceSq(B);
     858            double b = P.distanceSq(A);
     859            double c = A.distanceSq(B);
     860            q = (a - b + c) / (2*c);
     861            n.setEastNorth(new EastNorth(B.east() + q * (A.east() - B.east()), B.north() + q * (A.north() - B.north())));
    862862        }
    863863    }
Note: See TracChangeset for help on using the changeset viewer.