Ignore:
Timestamp:
2017-05-10T12:22:20+02:00 (7 years ago)
Author:
bastiK
Message:

fixed #14734 - Handling imagery offsets when reprojecting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/imagery/TileSourceDisplaySettings.java

    r11893 r12093  
    88import org.openstreetmap.josm.Main;
    99import org.openstreetmap.josm.data.coor.EastNorth;
     10import org.openstreetmap.josm.data.imagery.OffsetBookmark;
    1011import org.openstreetmap.josm.data.preferences.BooleanProperty;
    1112import org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer;
     
    6263    private boolean showErrors;
    6364
    64     /**
    65      * The displacement
    66      */
    67     private EastNorth displacement = new EastNorth(0, 0);
     65    private OffsetBookmark offsetBookmark = null;
     66    /**
     67     * the displacement (basically caches the displacement from the offsetBookmark
     68     * in the current projection)
     69     */
     70    private EastNorth displacement = EastNorth.ZERO;
    6871
    6972    private final CopyOnWriteArrayList<DisplaySettingsChangeListener> listeners = new CopyOnWriteArrayList<>();
     
    189192
    190193    /**
    191      * Set the displacement
    192      * @param displacement The new displacement
    193      * @since 10571
    194      */
    195     public void setDisplacement(EastNorth displacement) {
     194     * Sets an offset bookmark to use.
     195     *
     196     * @param offsetBookmark the offset bookmark, may be null
     197     */
     198    public void setOffsetBookmark(OffsetBookmark offsetBookmark) {
     199        this.offsetBookmark = offsetBookmark;
     200        if (offsetBookmark == null) {
     201            setDisplacement(EastNorth.ZERO);
     202        } else {
     203            setDisplacement(offsetBookmark.getDisplacement(Main.getProjection()));
     204        }
     205    }
     206
     207    /**
     208     * Gets the offset bookmark in use.
     209     * @return the offset bookmark, may be null
     210     */
     211    public OffsetBookmark getOffsetBookmark() {
     212        return this.offsetBookmark;
     213    }
     214
     215    private void setDisplacement(EastNorth displacement) {
    196216        CheckParameterUtil.ensureValidCoordinates(displacement, "displacement");
    197217        this.displacement = displacement;
    198218        fireSettingsChange(DISPLACEMENT);
    199     }
    200 
    201     /**
    202      * Adds the given value to the displacement.
    203      * @param displacement The value to add.
    204      * @since 10571
    205      */
    206     public void addDisplacement(EastNorth displacement) {
    207         CheckParameterUtil.ensureValidCoordinates(displacement, "displacement");
    208         setDisplacement(this.displacement.add(displacement));
    209219    }
    210220
Note: See TracChangeset for help on using the changeset viewer.