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

some cleanups

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

Legend:

Unmodified
Added
Removed
  • 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.