Ignore:
Timestamp:
2014-12-17T01:49:45+01:00 (11 years ago)
Author:
bastiK
Message:

fixed #10860 - set initial viewport correctly when mapview is opened

File:
1 edited

Legend:

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

    r7448 r7816  
    3232import org.openstreetmap.josm.data.ProjectionBounds;
    3333import org.openstreetmap.josm.data.SystemOfMeasurement;
     34import org.openstreetmap.josm.data.ViewportData;
    3435import org.openstreetmap.josm.data.coor.CachedLatLon;
    3536import org.openstreetmap.josm.data.coor.EastNorth;
     
    182183    private Polygon paintPoly = null;
    183184
     185    protected ViewportData initialViewport;
     186
    184187    /**
    185188     * Constructs a new {@code NavigatableComponent}.
     
    406409
    407410    /**
    408      * Zoom to the given coordinate.
     411     * Zoom to the given coordinate and scale.
     412     *
    409413     * @param newCenter The center x-value (easting) to zoom to.
    410414     * @param newScale The scale to use.
    411415     */
    412416    public void zoomTo(EastNorth newCenter, double newScale) {
     417        zoomTo(newCenter, newScale, false);
     418    }
     419
     420    /**
     421     * Zoom to the given coordinate and scale.
     422     *
     423     * @param newCenter The center x-value (easting) to zoom to.
     424     * @param newScale The scale to use.
     425     * @param initial true if this call initializes the viewport.
     426     */
     427    public void zoomTo(EastNorth newCenter, double newScale, boolean initial) {
    413428        Bounds b = getProjection().getWorldBoundsLatLon();
    414429        LatLon cl = Projections.inverseProject(newCenter);
     
    446461
    447462        if (!newCenter.equals(center) || (scale != newScale)) {
    448             pushZoomUndo(center, scale);
    449             zoomNoUndoTo(newCenter, newScale);
     463            if (!initial) {
     464                pushZoomUndo(center, scale);
     465            }
     466            zoomNoUndoTo(newCenter, newScale, initial);
    450467        }
    451468    }
     
    453470    /**
    454471     * Zoom to the given coordinate without adding to the zoom undo buffer.
     472     *
    455473     * @param newCenter The center x-value (easting) to zoom to.
    456474     * @param newScale The scale to use.
    457      */
    458     private void zoomNoUndoTo(EastNorth newCenter, double newScale) {
     475     * @param initial true if this call initializes the viewport.
     476     */
     477    private void zoomNoUndoTo(EastNorth newCenter, double newScale, boolean intial) {
    459478        if (!newCenter.equals(center)) {
    460479            EastNorth oldCenter = center;
    461480            center = newCenter;
    462             firePropertyChange(PROPNAME_CENTER, oldCenter, newCenter);
     481            if (!intial) {
     482                firePropertyChange(PROPNAME_CENTER, oldCenter, newCenter);
     483            }
    463484        }
    464485        if (scale != newScale) {
    465486            double oldScale = scale;
    466487            scale = newScale;
    467             firePropertyChange(PROPNAME_SCALE, oldScale, newScale);
    468         }
    469 
    470         repaint();
    471         fireZoomChanged();
     488            if (!intial) {
     489                firePropertyChange(PROPNAME_SCALE, oldScale, newScale);
     490            }
     491        }
     492
     493        if (!intial) {
     494            repaint();
     495            fireZoomChanged();
     496        }
    472497    }
    473498
     
    595620            ZoomData zoom = zoomUndoBuffer.pop();
    596621            zoomRedoBuffer.push(new ZoomData(center, scale));
    597             zoomNoUndoTo(zoom.getCenterEastNorth(), zoom.getScale());
     622            zoomNoUndoTo(zoom.getCenterEastNorth(), zoom.getScale(), false);
    598623        }
    599624    }
     
    603628            ZoomData zoom = zoomRedoBuffer.pop();
    604629            zoomUndoBuffer.push(new ZoomData(center, scale));
    605             zoomNoUndoTo(zoom.getCenterEastNorth(), zoom.getScale());
     630            zoomNoUndoTo(zoom.getCenterEastNorth(), zoom.getScale(), false);
    606631        }
    607632    }
Note: See TracChangeset for help on using the changeset viewer.