Changeset 1725 in josm


Ignore:
Timestamp:
2009-07-03T23:15:39+02:00 (15 years ago)
Author:
stoecker
Message:

some cleanups

Location:
trunk/src/org/openstreetmap/josm
Files:
9 edited

Legend:

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

    r1640 r1725  
    3737
    3838        List<WaySegment> wss = Main.map.mapView.getNearestWaySegments(
    39             Main.map.mapView.getPoint(node.getEastNorth()));
     39            Main.map.mapView.getPoint(node));
    4040        HashMap<Way, List<Integer>> insertPoints = new HashMap<Way, List<Integer>>();
    4141        for (WaySegment ws : wss) {
  • trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java

    r1722 r1725  
    798798            // fall through to default action.
    799799            // (for semi-parallel lines, intersection might be miles away!)
    800             if (Main.map.mapView.getPoint(n.getEastNorth()).distance(Main.map.mapView.getPoint(intersection)) < snapToIntersectionThreshold) {
     800            if (Main.map.mapView.getPoint(n).distance(Main.map.mapView.getPoint(intersection)) < snapToIntersectionThreshold) {
    801801                n.setEastNorth(intersection);
    802802                return;
     
    838838        g2.setStroke(new BasicStroke(3, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
    839839        GeneralPath b = new GeneralPath();
    840         Point p1=mv.getPoint(currentBaseNode.getEastNorth());
     840        Point p1=mv.getPoint(currentBaseNode);
    841841        Point p2=mv.getPoint(currentMouseEastNorth);
    842842
  • trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java

    r1712 r1725  
    282282                {
    283283                    Way w = (Way)osm;
    284                     Point p1 = c.getPoint(w.nodes.get(nearestWS.lowerIndex).getEastNorth());
    285                     Point p2 = c.getPoint(w.nodes.get(nearestWS.lowerIndex+1).getEastNorth());
     284                    Point p1 = c.getPoint(w.nodes.get(nearestWS.lowerIndex));
     285                    Point p2 = c.getPoint(w.nodes.get(nearestWS.lowerIndex+1));
    286286                    if(SimplePaintVisitor.isLargeSegment(p1, p2, Main.pref.getInteger("mappaint.node.virtual-space", 70)))
    287287                    {
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java

    r1722 r1725  
    650650        }
    651651
    652         Point pFrom = nc.getPoint(fromNode.getEastNorth());
    653         Point pVia = nc.getPoint(viaNode.getEastNorth());
     652        Point pFrom = nc.getPoint(fromNode);
     653        Point pVia = nc.getPoint(viaNode);
    654654
    655655        //if(restrictionDebug) {
     
    663663        //        toNode = toWay.nodes.get(toWay.nodes.size()-2);
    664664        //    }
    665         //    Point pTo = nc.getPoint(toNode.eastNorth);
     665        //    Point pTo = nc.getPoint(toNode);
    666666
    667667        //    /* debug output of interesting nodes */
     
    887887                        for (Node n : w.nodes)
    888888                        {
    889                             p = nc.getPoint(n.getEastNorth());
     889                            p = nc.getPoint(n);
    890890                            poly.addPoint(p.x,p.y);
    891891                        }
     
    941941                    for (Node n : wInner.nodes)
    942942                    {
    943                         Point pInner = nc.getPoint(n.getEastNorth());
     943                        Point pInner = nc.getPoint(n);
    944944                        polygon.addPoint(pInner.x,pInner.y);
    945945                    }
    946946                    if(!wInner.isClosed())
    947947                    {
    948                         Point pInner = nc.getPoint(wInner.nodes.get(0).getEastNorth());
     948                        Point pInner = nc.getPoint(wInner.nodes.get(0));
    949949                        polygon.addPoint(pInner.x,pInner.y);
    950950                    }
     
    10651065        for (Node n : w.nodes)
    10661066        {
    1067             Point p = nc.getPoint(n.getEastNorth());
     1067            Point p = nc.getPoint(n);
    10681068            polygon.addPoint(p.x,p.y);
    10691069        }
     
    10881088
    10891089    protected void drawNode(Node n, ImageIcon icon, boolean annotate, Boolean selected) {
    1090         Point p = nc.getPoint(n.getEastNorth());
     1090        Point p = nc.getPoint(n);
    10911091        if ((p.x < 0) || (p.y < 0) || (p.x > nc.getWidth()) || (p.y > nc.getHeight())) return;
    10921092
     
    11301130            displaySegments(col, width, dashed, dashedColor);
    11311131        }
    1132         Point p1 = nc.getPoint(n1.getEastNorth());
    1133         Point p2 = nc.getPoint(n2.getEastNorth());
     1132        Point p1 = nc.getPoint(n1);
     1133        Point p2 = nc.getPoint(n2);
    11341134
    11351135        if (!isSegmentVisible(p1, p2)) {
     
    12091209    public void drawNode(Node n, Color color, int size, int radius, boolean fill) {
    12101210        if (isZoomOk(null) && size > 1) {
    1211             Point p = nc.getPoint(n.getEastNorth());
     1211            Point p = nc.getPoint(n);
    12121212            if ((p.x < 0) || (p.y < 0) || (p.x > nc.getWidth())
    12131213                    || (p.y > nc.getHeight()))
     
    14561456     */
    14571457    protected void drawOrderNumber(Node n1, Node n2, int orderNumber) {
    1458         Point p1 = nc.getPoint(n1.getEastNorth());
    1459         Point p2 = nc.getPoint(n2.getEastNorth());
     1458        Point p1 = nc.getPoint(n1);
     1459        Point p2 = nc.getPoint(n2);
    14601460        drawOrderNumber(p1, p2, orderNumber);
    14611461    }
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java

    r1640 r1725  
    271271        Iterator<Node> it = w.nodes.iterator();
    272272        if (it.hasNext()) {
    273             Point lastP = nc.getPoint(it.next().getEastNorth());
     273            Point lastP = nc.getPoint(it.next());
    274274            while(it.hasNext())
    275275            {
    276                 Point p = nc.getPoint(it.next().getEastNorth());
     276                Point p = nc.getPoint(it.next());
    277277                if(isSegmentVisible(lastP, p) && isLargeSegment(lastP, p, virtualNodeSpace))
    278278                {
     
    321321        Iterator<Node> it = w.nodes.iterator();
    322322        if (it.hasNext()) {
    323             Point lastP = nc.getPoint(it.next().getEastNorth());
     323            Point lastP = nc.getPoint(it.next());
    324324            for (int orderNumber = 1; it.hasNext(); orderNumber++) {
    325                 Point p = nc.getPoint(it.next().getEastNorth());
     325                Point p = nc.getPoint(it.next());
    326326                drawSegment(lastP, p, wayColor,
    327327                    showOnlyHeadArrowOnly ? !it.hasNext() : showThisDirectionArrow);
     
    352352
    353353            if (m.member instanceof Node) {
    354                 Point p = nc.getPoint(((Node) m.member).getEastNorth());
     354                Point p = nc.getPoint((Node) m.member);
    355355                if (p.x < 0 || p.y < 0
    356356                    || p.x > nc.getWidth() || p.y > nc.getHeight()) continue;
     
    363363                for (Node n : ((Way) m.member).nodes) {
    364364                    if (n.incomplete || n.deleted) continue;
    365                     Point p = nc.getPoint(n.getEastNorth());
     365                    Point p = nc.getPoint(n);
    366366                    if (first) {
    367367                        path.moveTo(p.x, p.y);
     
    410410    public void drawNode(Node n, Color color, int size, int radius, boolean fill) {
    411411        if (size > 1) {
    412             Point p = nc.getPoint(n.getEastNorth());
     412            Point p = nc.getPoint(n);
    413413            if ((p.x < 0) || (p.y < 0) || (p.x > nc.getWidth())
    414414                    || (p.y > nc.getHeight()))
  • trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java

    r1722 r1725  
    1818import org.openstreetmap.josm.data.Bounds;
    1919import org.openstreetmap.josm.data.ProjectionBounds;
     20import org.openstreetmap.josm.data.coor.CachedLatLon;
    2021import org.openstreetmap.josm.data.coor.EastNorth;
    2122import org.openstreetmap.josm.data.coor.LatLon;
     
    149150    }
    150151
     152    public Point getPoint(LatLon latlon) {
     153        if(latlon == null)
     154            return new Point();
     155        else if(latlon instanceof CachedLatLon)
     156            return getPoint(((CachedLatLon)latlon).getEastNorth());
     157        else
     158            return getPoint(getProjection().latlon2eastNorth(latlon));
     159    }
     160    public Point getPoint(Node n) {
     161        return getPoint(n.getEastNorth());
     162    }
     163
    151164    /**
    152165     * Zoom to the given coordinate.
     
    179192    }
    180193
     194    public void zoomTo(LatLon newCenter) {
     195        if(newCenter instanceof CachedLatLon)
     196            zoomTo(((CachedLatLon)newCenter).getEastNorth(), scale);
     197        else
     198            zoomTo(getProjection().latlon2eastNorth(newCenter), scale);
     199    }
     200
    181201    public void zoomToFactor(double x, double y, double factor) {
    182202        double newScale = scale*factor;
     
    228248            if (n.deleted || n.incomplete)
    229249                continue;
    230             Point sp = getPoint(n.getEastNorth());
     250            Point sp = getPoint(n);
    231251            double dist = p.distanceSq(sp);
    232252            if (dist < minDistanceSq) {
     
    263283                }
    264284
    265                 Point A = getPoint(lastN.getEastNorth());
    266                 Point B = getPoint(n.getEastNorth());
     285                Point A = getPoint(lastN);
     286                Point B = getPoint(n);
    267287                double c = A.distanceSq(B);
    268288                double a = p.distanceSq(B);
     
    372392                    continue;
    373393                }
    374                 Point A = getPoint(lastN.getEastNorth());
    375                 Point B = getPoint(n.getEastNorth());
     394                Point A = getPoint(lastN);
     395                Point B = getPoint(n);
    376396                double c = A.distanceSq(B);
    377397                double a = p.distanceSq(B);
     
    387407        for (Node n : getData().nodes) {
    388408            if (!n.deleted && !n.incomplete
    389                     && getPoint(n.getEastNorth()).distanceSq(p) < snapDistance) {
     409                    && getPoint(n).distanceSq(p) < snapDistance) {
    390410                nearest.add(n);
    391411            }
     
    406426        for (Node n : getData().nodes) {
    407427            if (!n.deleted && !n.incomplete
    408                     && getPoint(n.getEastNorth()).distanceSq(p) < snapDistance) {
     428                    && getPoint(n).distanceSq(p) < snapDistance) {
    409429                nearest.add(n);
    410430            }
  • trunk/src/org/openstreetmap/josm/gui/SelectionManager.java

    r1640 r1725  
    280280            // nodes
    281281            for (Node n : nc.getData().nodes) {
    282                 if (!n.deleted && !n.incomplete && r.contains(nc.getPoint(n.getEastNorth())))
     282                if (!n.deleted && !n.incomplete && r.contains(nc.getPoint(n)))
    283283                    selection.add(n);
    284284            }
     
    290290                if (alt) {
    291291                    for (Node n : w.nodes) {
    292                         if (!n.incomplete && r.contains(nc.getPoint(n.getEastNorth()))) {
     292                        if (!n.incomplete && r.contains(nc.getPoint(n))) {
    293293                            selection.add(w);
    294294                            break;
     
    298298                    boolean allIn = true;
    299299                    for (Node n : w.nodes) {
    300                         if (!n.incomplete && !r.contains(nc.getPoint(n.getEastNorth()))) {
     300                        if (!n.incomplete && !r.contains(nc.getPoint(n))) {
    301301                            allIn = false;
    302302                            break;
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java

    r1682 r1725  
    190190        Visitor conflictPainter = new AbstractVisitor(){
    191191            public void visit(Node n) {
    192                 Point p = nc.getPoint(n.getEastNorth());
     192                Point p = nc.getPoint(n);
    193193                g.drawRect(p.x-1, p.y-1, 2, 2);
    194194            }
    195195            public void visit(Node n1, Node n2) {
    196                 Point p1 = nc.getPoint(n1.getEastNorth());
    197                 Point p2 = nc.getPoint(n2.getEastNorth());
     196                Point p1 = nc.getPoint(n1);
     197                Point p2 = nc.getPoint(n2);
    198198                g.drawLine(p1.x, p1.y, p2.x, p2.y);
    199199            }
  • trunk/src/org/openstreetmap/josm/gui/layer/GeoImageLayer.java

    r1724 r1725  
    404404                    if (e.pos == null)
    405405                        continue;
    406                     Point p = Main.map.mapView.getPoint(e.pos.getEastNorth());
     406                    Point p = Main.map.mapView.getPoint(e.pos);
    407407                    Rectangle r = new Rectangle(p.x-ICON_SIZE/2, p.y-ICON_SIZE/2, ICON_SIZE, ICON_SIZE);
    408408                    if (r.contains(ev.getPoint())) {
     
    536536
    537537            if (centerToggle.getModel().isSelected())
    538                 Main.map.mapView.zoomTo(currentImageEntry.pos.getEastNorth());
     538                Main.map.mapView.zoomTo(currentImageEntry.pos);
    539539
    540540            dlg.setTitle(currentImageEntry.image +
     
    612612                }
    613613
    614                 Point p = mv.getPoint(e.pos.getEastNorth());
     614                Point p = mv.getPoint(e.pos);
    615615                Rectangle r = new Rectangle(p.x-ICON_SIZE / 2, p.y-ICON_SIZE / 2, ICON_SIZE, ICON_SIZE);
    616616                if (r.contains(mousePosition)) {
     
    624624            ImageEntry e = data.get(i);
    625625            if (e.pos != null) {
    626                 Point p = mv.getPoint(e.pos.getEastNorth());
     626                Point p = mv.getPoint(e.pos);
    627627                Rectangle r = new Rectangle(p.x-ICON_SIZE / 2, p.y-ICON_SIZE / 2, ICON_SIZE, ICON_SIZE);
    628628                g.drawImage(e.getIcon(), r.x, r.y, null);
Note: See TracChangeset for help on using the changeset viewer.