Changeset 10343 in josm


Ignore:
Timestamp:
2016-06-08T23:01:38+02:00 (5 years ago)
Author:
Don-vip
Message:

fix #12934 - Add new MapViewState class that stores the current state of the map view (patch by michael2402) - gsoc-core

Location:
trunk
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java

    r10342 r10343  
    4747import org.openstreetmap.josm.data.projection.Projection;
    4848import org.openstreetmap.josm.data.projection.Projections;
     49import org.openstreetmap.josm.gui.MapViewState.MapViewPoint;
    4950import org.openstreetmap.josm.gui.download.DownloadDialog;
    5051import org.openstreetmap.josm.gui.help.Helpful;
     
    365366
    366367    public ProjectionBounds getProjectionBounds() {
    367         return new ProjectionBounds(
    368                 new EastNorth(
    369                         center.east() - getWidth()/2.0*scale,
    370                         center.north() - getHeight()/2.0*scale),
    371                         new EastNorth(
    372                                 center.east() + getWidth()/2.0*scale,
    373                                 center.north() + getHeight()/2.0*scale));
     368        return new MapViewState(this).getViewArea().getProjectionBounds();
    374369    }
    375370
     
    383378    /* FIXME: replace with better method - used by Main to reset Bounds when projection changes, don't use otherwise */
    384379    public Bounds getRealBounds() {
    385         return new Bounds(
    386                 getProjection().eastNorth2latlon(new EastNorth(
    387                         center.east() - getWidth()/2.0*scale,
    388                         center.north() - getHeight()/2.0*scale)),
    389                         getProjection().eastNorth2latlon(new EastNorth(
    390                                 center.east() + getWidth()/2.0*scale,
    391                                 center.north() + getHeight()/2.0*scale)));
     380        return new MapViewState(this).getViewArea().getCornerBounds();
    392381    }
    393382
     
    408397
    409398    public ProjectionBounds getProjectionBounds(Rectangle r) {
    410         EastNorth p1 = getEastNorth(r.x, r.y);
    411         EastNorth p2 = getEastNorth(r.x + r.width, r.y + r.height);
    412         ProjectionBounds pb = new ProjectionBounds(p1);
    413         pb.extend(p2);
    414         return pb;
     399        MapViewState state = new MapViewState(this);
     400        MapViewPoint p1 = state.getForView(r.getMinX(), r.getMinY());
     401        MapViewPoint p2 = state.getForView(r.getMaxX(), r.getMaxY());
     402        return p1.rectTo(p2).getProjectionBounds();
    415403    }
    416404
Note: See TracChangeset for help on using the changeset viewer.