Ignore:
Timestamp:
2016-07-20T19:34:37+02:00 (3 years ago)
Author:
Don-vip
Message:

fix #13172 - Move ImageryLayer.d[xy] to the settings (patch by michael2402) - gsoc-core

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/ImageryAdjustAction.java

    r10467 r10571  
    2828import org.openstreetmap.josm.data.imagery.OffsetBookmark;
    2929import org.openstreetmap.josm.gui.ExtendedDialog;
    30 import org.openstreetmap.josm.gui.layer.ImageryLayer;
     30import org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer;
     31import org.openstreetmap.josm.gui.layer.imagery.TileSourceDisplaySettings;
    3132import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
    3233import org.openstreetmap.josm.gui.widgets.JosmTextField;
     
    4243    private static Cursor cursor = ImageProvider.getCursor("normal", "move");
    4344
    44     private double oldDx, oldDy;
     45    private EastNorth old;
    4546    private EastNorth prevEastNorth;
    46     private transient ImageryLayer layer;
     47    private transient AbstractTileSourceLayer<?> layer;
    4748    private MapMode oldMapMode;
    4849
     
    5152     * @param layer The imagery layer
    5253     */
    53     public ImageryAdjustAction(ImageryLayer layer) {
     54    public ImageryAdjustAction(AbstractTileSourceLayer<?> layer) {
    5455        super(tr("New offset"), "adjustimg",
    5556                tr("Adjust the position of this imagery layer"), Main.map,
     
    6768            layer.setVisible(true);
    6869        }
    69         oldDx = layer.getDx();
    70         oldDy = layer.getDy();
     70        old = layer.getDisplaySettings().getDisplacement();
    7171        addListeners();
    7272        offsetDialog = new ImageryOffsetDialog();
     
    8989        if (offsetDialog != null) {
    9090            if (layer != null) {
    91                 layer.setOffset(oldDx, oldDy);
     91                layer.getDisplaySettings().setDisplacement(old);
    9292            }
    9393            offsetDialog.setVisible(false);
     
    155155    public void mouseDragged(MouseEvent e) {
    156156        if (layer == null || prevEastNorth == null) return;
    157         EastNorth eastNorth =
    158             Main.map.mapView.getEastNorth(e.getX(), e.getY());
    159         double dx = layer.getDx()+eastNorth.east()-prevEastNorth.east();
    160         double dy = layer.getDy()+eastNorth.north()-prevEastNorth.north();
    161         layer.setOffset(dx, dy);
     157        EastNorth eastNorth = Main.map.mapView.getEastNorth(e.getX(), e.getY());
     158        EastNorth d = layer.getDisplaySettings().getDisplacement().add(eastNorth).subtract(prevEastNorth);
     159        layer.getDisplaySettings().setDisplacement(d);
    162160        if (offsetDialog != null) {
    163161            offsetDialog.updateOffset();
     
    234232                    double dx = Double.parseDouble(easting);
    235233                    double dy = Double.parseDouble(northing);
    236                     layer.setOffset(dx, dy);
     234                    layer.getDisplaySettings().setDisplacement(new EastNorth(dx, dy));
    237235                } catch (NumberFormatException nfe) {
    238236                    // we repaint offset numbers in any case
     
    259257            // US locale to force decimal separator to be '.'
    260258            try (Formatter us = new Formatter(Locale.US)) {
     259                TileSourceDisplaySettings ds = layer.getDisplaySettings();
    261260                tOffset.setText(us.format(new StringBuilder()
    262261                    .append("%1.").append(precision).append("f; %1.").append(precision).append('f').toString(),
    263                     layer.getDx(), layer.getDy()).toString());
     262                    ds.getDx(), ds.getDy()).toString());
    264263            }
    265264        }
     
    298297            if (layer != null) {
    299298                if (getValue() != 1) {
    300                     layer.setOffset(oldDx, oldDy);
     299                    layer.getDisplaySettings().setDisplacement(old);
    301300                } else if (tBookmarkName.getText() != null && !tBookmarkName.getText().isEmpty()) {
    302301                    OffsetBookmark.bookmarkOffset(tBookmarkName.getText(), layer);
Note: See TracChangeset for help on using the changeset viewer.