Ignore:
Timestamp:
2014-12-17T13:46:53+01:00 (9 years ago)
Author:
bastiK
Message:

fixed #10861 - Zoom to layer when opening new file (see #10860)

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

Legend:

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

    r7816 r7817  
    529529    @Override public void paint(Graphics g) {
    530530        if (initialViewport != null) {
    531             if (initialViewport.getBounds() != null) {
    532                 BoundingXYVisitor box = new BoundingXYVisitor();
    533                 box.visit(initialViewport.getBounds());
    534                 recalculateCenterScale(box);
    535             } else {
    536                 zoomTo(initialViewport.getCenter(), initialViewport.getScale(), true);
    537             }
     531            zoomTo(initialViewport);
    538532            initialViewport = null;
    539533        }
     
    693687    /**
    694688     * Set the new dimension to the view.
    695      */
     689     *
     690     * @deprecated use #zoomTo(BoundingXYVisitor)
     691     */
     692    @Deprecated
    696693    public void recalculateCenterScale(BoundingXYVisitor box) {
    697         if (box == null) {
    698             box = new BoundingXYVisitor();
    699         }
    700         if (box.getBounds() == null) {
    701             box.visit(getProjection().getWorldBoundsLatLon());
    702         }
    703         if (!box.hasExtend()) {
    704             box.enlargeBoundingBox();
    705         }
    706 
    707         zoomTo(box.getBounds());
     694        zoomTo(box);
    708695    }
    709696
  • trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java

    r7816 r7817  
    4343import org.openstreetmap.josm.data.osm.Way;
    4444import org.openstreetmap.josm.data.osm.WaySegment;
     45import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
    4546import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors;
    4647import org.openstreetmap.josm.data.preferences.IntegerProperty;
     
    580581        zoomTo(new ProjectionBounds(getProjection().latlon2eastNorth(box.getMin()),
    581582                getProjection().latlon2eastNorth(box.getMax())));
     583    }
     584
     585    public void zoomTo(ViewportData viewport) {
     586        if (viewport == null) return;
     587        if (viewport.getBounds() != null) {
     588            BoundingXYVisitor box = new BoundingXYVisitor();
     589            box.visit(viewport.getBounds());
     590            zoomTo(box);
     591        } else {
     592            zoomTo(viewport.getCenter(), viewport.getScale(), true);
     593        }
     594    }
     595
     596    /**
     597     * Set the new dimension to the view.
     598     */
     599    public void zoomTo(BoundingXYVisitor box) {
     600        if (box == null) {
     601            box = new BoundingXYVisitor();
     602        }
     603        if (box.getBounds() == null) {
     604            box.visit(getProjection().getWorldBoundsLatLon());
     605        }
     606        if (!box.hasExtend()) {
     607            box.enlargeBoundingBox();
     608        }
     609
     610        zoomTo(box.getBounds());
    582611    }
    583612
  • trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java

    r7781 r7817  
    451451                return;
    452452            box.enlargeBoundingBox();
    453             Main.map.mapView.recalculateCenterScale(box);
     453            Main.map.mapView.zoomTo(box);
    454454        }
    455455
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java

    r7578 r7817  
    746746                        BoundingXYVisitor bbox = new BoundingXYVisitor();
    747747                        yLayer.visitBoundingBox(bbox);
    748                         Main.map.mapView.recalculateCenterScale(bbox);
     748                        Main.map.mapView.zoomTo(bbox);
    749749                    }
    750750
Note: See TracChangeset for help on using the changeset viewer.