Changeset 10394 in josm for trunk


Ignore:
Timestamp:
2016-06-16T00:07:13+02:00 (8 years ago)
Author:
wiktorn
Message:

Fix zoom to bounds.

Patch by: michael2402

See: #12964

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

Legend:

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

    r10391 r10394  
    570570            @Override
    571571            public void layerAdded(LayerAddEvent e) {
     572                Layer layer = e.getAddedLayer();
    572573                if (map == null) {
    573                     Layer layer = e.getAddedLayer();
    574                     ProjectionBounds viewProjectionBounds = layer.getViewProjectionBounds();
    575                     Main.main.createMapFrame(layer, viewProjectionBounds == null ? null : new ViewportData(viewProjectionBounds));
     574                    Main.main.createMapFrame(layer, null);
     575                    Main.map.setVisible(true);
     576                }
     577                ProjectionBounds viewProjectionBounds = layer.getViewProjectionBounds();
     578                if (viewProjectionBounds != null) {
     579                    Main.map.mapView.scheduleZoomTo(new ViewportData(viewProjectionBounds));
    576580                }
    577581            }
     
    820824    public final synchronized void addLayer(final Layer layer, ViewportData viewport) {
    821825        getLayerManager().addLayer(layer);
    822         if (map != null) {
    823             Main.map.setVisible(true);
    824         } else if (viewport != null) {
    825             Main.map.mapView.zoomTo(viewport);
     826        if (viewport != null) {
     827            Main.map.mapView.scheduleZoomTo(viewport);
    826828        }
    827829    }
  • trunk/src/org/openstreetmap/josm/gui/MapView.java

    r10378 r10394  
    12911291        return layerManager;
    12921292    }
     1293
     1294    /**
     1295     * Schedule a zoom to the given position on the next redraw.
     1296     * Temporary, may be removed without warning.
     1297     * @param viewportData
     1298     * @since xxx
     1299     */
     1300    public void scheduleZoomTo(ViewportData viewportData) {
     1301        initialViewport = viewportData;
     1302    }
    12931303}
Note: See TracChangeset for help on using the changeset viewer.