Ignore:
Timestamp:
2013-01-25T22:34:19+01:00 (11 years ago)
Author:
bastiK
Message:

session: save & restore map position and scale (see #4029)

File:
1 edited

Legend:

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

    r5519 r5670  
    219219    /**
    220220     * Constructs a new {@code MapView}.
    221      * @param contentPane The content pane used to register shortcuts in its {@link InputMap} and {@link ActionMap}
    222      */
    223     public MapView(final JPanel contentPane) {
     221     * @param contentPane The content pane used to register shortcuts in its
     222     * {@link InputMap} and {@link ActionMap}
     223     * @param viewportData the initial viewport of the map. Can be null, then
     224     * the viewport is derived from the layer data.
     225     */
     226    public MapView(final JPanel contentPane, final ViewportData viewportData) {
    224227        Main.pref.addPreferenceChangeListener(this);
    225228
     
    237240
    238241                mapMover = new MapMover(MapView.this, contentPane);
    239                 OsmDataLayer layer = getEditLayer();
    240                 if (layer != null) {
    241                     if (!zoomToDataSetBoundingBox(layer.data)) {
    242                         // no bounding box defined
    243                         AutoScaleAction.autoScale("data");
     242                if (viewportData != null) {
     243                    zoomTo(viewportData.getCenter(), viewportData.getScale());
     244                } else {
     245                    OsmDataLayer layer = getEditLayer();
     246                    if (layer != null) {
     247                        if (!zoomToDataSetBoundingBox(layer.data)) {
     248                            // no bounding box defined
     249                            AutoScaleAction.autoScale("data");
     250                        }
     251                    } else {
     252                        AutoScaleAction.autoScale("layer");
    244253                    }
    245                 } else {
    246                     AutoScaleAction.autoScale("layer");
    247254                }
    248255            }
Note: See TracChangeset for help on using the changeset viewer.