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

fixed #14734 - Handling imagery offsets when reprojecting

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

Legend:

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

    r12028 r12093  
    8181import org.openstreetmap.josm.data.coor.LatLon;
    8282import org.openstreetmap.josm.data.imagery.ImageryInfo;
     83import org.openstreetmap.josm.data.imagery.OffsetBookmark;
    8384import org.openstreetmap.josm.data.imagery.TMSCachedTileLoader;
    8485import org.openstreetmap.josm.data.imagery.TileLoaderFactory;
     
    334335    @Override
    335336    @Deprecated
    336     public void displace(double dx, double dy) {
    337         getDisplaySettings().addDisplacement(new EastNorth(dx, dy));
    338     }
    339 
    340     /**
    341      * {@inheritDoc}
    342      * @deprecated Use {@link TileSourceDisplaySettings}
    343      */
    344     @Override
    345     @Deprecated
    346     public void setOffset(double dx, double dy) {
    347         getDisplaySettings().setDisplacement(new EastNorth(dx, dy));
     337    public void setOffset(OffsetBookmark offset) {
     338        getDisplaySettings().setOffsetBookmark(offset);
    348339    }
    349340
     
    18561847    public void projectionChanged(Projection oldValue, Projection newValue) {
    18571848        super.projectionChanged(oldValue, newValue);
     1849        displaySettings.setOffsetBookmark(displaySettings.getOffsetBookmark());
    18581850        if (tileCache != null) {
    18591851            tileCache.clear();
  • trunk/src/org/openstreetmap/josm/gui/layer/ImageryLayer.java

    r12085 r12093  
    3131import org.openstreetmap.josm.Main;
    3232import org.openstreetmap.josm.data.ProjectionBounds;
     33import org.openstreetmap.josm.data.coor.EastNorth;
    3334import org.openstreetmap.josm.data.imagery.ImageryInfo;
    3435import org.openstreetmap.josm.data.imagery.OffsetBookmark;
     
    108109     * Sets the displacement offset of this layer. The layer is automatically invalidated.
    109110     * To be removed end of 2016
    110      * @param dx The x offset
    111      * @param dy The y offset
     111     * @param offset the offset bookmark
    112112     * @deprecated Use {@link TileSourceDisplaySettings}
    113113     */
    114114    @Deprecated
    115     public void setOffset(double dx, double dy) {
    116         // moved to AbstractTileSourceLayer/TileSourceDisplaySettings. Remains until all actions migrate.
    117     }
    118 
    119     /**
    120      * To be removed end of 2016
    121      * @param dx deprecated
    122      * @param dy deprecated
    123      * @deprecated Use {@link TileSourceDisplaySettings}
    124      */
    125     @Deprecated
    126     public void displace(double dx, double dy) {
     115    public void setOffset(OffsetBookmark offset) {
    127116        // moved to AbstractTileSourceLayer/TileSourceDisplaySettings. Remains until all actions migrate.
    128117    }
     
    210199        @Override
    211200        public void actionPerformed(ActionEvent ev) {
    212             setOffset(b.getOffset().east(), b.getOffset().north());
     201            setOffset(b);
    213202            Main.main.menu.imageryMenu.refreshOffsetMenu();
    214203            Main.map.repaint();
     
    253242            }
    254243            JCheckBoxMenuItem item = new JCheckBoxMenuItem(new ApplyOffsetAction(b));
    255             if (Utils.equalsEpsilon(b.getOffset().east(), getDx()) &&
    256                     Utils.equalsEpsilon(b.getOffset().north(), getDy())) {
     244            EastNorth offset = b.getDisplacement(Main.getProjection());
     245            if (Utils.equalsEpsilon(offset.east(), getDx()) && Utils.equalsEpsilon(offset.north(), getDy())) {
    257246                item.setSelected(true);
    258247            }
  • 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
  • trunk/src/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreference.java

    r12084 r12093  
    912912                    return info.getName();
    913913                case 3:
    914                     return info.getOffset().east();
     914                    return info.getDisplacement().east();
    915915                case 4:
    916                     return info.getOffset().north();
     916                    return info.getDisplacement().north();
    917917                default:
    918918                    throw new ArrayIndexOutOfBoundsException();
     
    932932                case 3:
    933933                    double dx = Double.parseDouble((String) o);
    934                     info.setOffset(new EastNorth(dx, info.getOffset().north()));
     934                    info.setDisplacement(new EastNorth(dx, info.getDisplacement().north()));
    935935                    break;
    936936                case 4:
    937937                    double dy = Double.parseDouble((String) o);
    938                     info.setOffset(new EastNorth(info.getOffset().east(), dy));
     938                    info.setDisplacement(new EastNorth(info.getDisplacement().east(), dy));
    939939                    break;
    940940                default:
Note: See TracChangeset for help on using the changeset viewer.