diff --git a/src/org/openstreetmap/josm/actions/ImageryAdjustAction.java b/src/org/openstreetmap/josm/actions/ImageryAdjustAction.java
index a35cac3..09a6e35 100644
|
a
|
b
|
import org.openstreetmap.josm.actions.mapmode.MapMode;
|
| 27 | 27 | import org.openstreetmap.josm.data.coor.EastNorth; |
| 28 | 28 | import org.openstreetmap.josm.data.imagery.OffsetBookmark; |
| 29 | 29 | import org.openstreetmap.josm.gui.ExtendedDialog; |
| 30 | | import org.openstreetmap.josm.gui.layer.ImageryLayer; |
| | 30 | import org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer; |
| | 31 | import org.openstreetmap.josm.gui.layer.imagery.TileSourceDisplaySettings; |
| 31 | 32 | import org.openstreetmap.josm.gui.widgets.JMultilineLabel; |
| 32 | 33 | import org.openstreetmap.josm.gui.widgets.JosmTextField; |
| 33 | 34 | import org.openstreetmap.josm.tools.GBC; |
| … |
… |
public class ImageryAdjustAction extends MapMode implements AWTEventListener {
|
| 41 | 42 | private static volatile ImageryOffsetDialog offsetDialog; |
| 42 | 43 | private static Cursor cursor = ImageProvider.getCursor("normal", "move"); |
| 43 | 44 | |
| 44 | | private double oldDx, oldDy; |
| | 45 | private EastNorth old; |
| 45 | 46 | private EastNorth prevEastNorth; |
| 46 | | private transient ImageryLayer layer; |
| | 47 | private transient AbstractTileSourceLayer<?> layer; |
| 47 | 48 | private MapMode oldMapMode; |
| 48 | 49 | |
| 49 | 50 | /** |
| 50 | 51 | * Constructs a new {@code ImageryAdjustAction} for the given layer. |
| 51 | 52 | * @param layer The imagery layer |
| 52 | 53 | */ |
| 53 | | public ImageryAdjustAction(ImageryLayer layer) { |
| | 54 | public ImageryAdjustAction(AbstractTileSourceLayer<?> layer) { |
| 54 | 55 | super(tr("New offset"), "adjustimg", |
| 55 | 56 | tr("Adjust the position of this imagery layer"), Main.map, |
| 56 | 57 | cursor); |
| … |
… |
public class ImageryAdjustAction extends MapMode implements AWTEventListener {
|
| 66 | 67 | if (!layer.isVisible()) { |
| 67 | 68 | layer.setVisible(true); |
| 68 | 69 | } |
| 69 | | oldDx = layer.getDx(); |
| 70 | | oldDy = layer.getDy(); |
| | 70 | old = layer.getDisplaySettings().getDisplacement(); |
| 71 | 71 | addListeners(); |
| 72 | 72 | offsetDialog = new ImageryOffsetDialog(); |
| 73 | 73 | offsetDialog.setVisible(true); |
| … |
… |
public class ImageryAdjustAction extends MapMode implements AWTEventListener {
|
| 88 | 88 | super.exitMode(); |
| 89 | 89 | if (offsetDialog != null) { |
| 90 | 90 | if (layer != null) { |
| 91 | | layer.setOffset(oldDx, oldDy); |
| | 91 | layer.getDisplaySettings().setDisplacement(old); |
| 92 | 92 | } |
| 93 | 93 | offsetDialog.setVisible(false); |
| 94 | 94 | offsetDialog = null; |
| … |
… |
public class ImageryAdjustAction extends MapMode implements AWTEventListener {
|
| 154 | 154 | @Override |
| 155 | 155 | public void mouseDragged(MouseEvent e) { |
| 156 | 156 | 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); |
| 162 | 160 | if (offsetDialog != null) { |
| 163 | 161 | offsetDialog.updateOffset(); |
| 164 | 162 | } |
| … |
… |
public class ImageryAdjustAction extends MapMode implements AWTEventListener {
|
| 233 | 231 | String northing = ostr.substring(semicolon + 1).trim().replace(',', '.'); |
| 234 | 232 | double dx = Double.parseDouble(easting); |
| 235 | 233 | double dy = Double.parseDouble(northing); |
| 236 | | layer.setOffset(dx, dy); |
| | 234 | layer.getDisplaySettings().setDisplacement(new EastNorth(dx, dy)); |
| 237 | 235 | } catch (NumberFormatException nfe) { |
| 238 | 236 | // we repaint offset numbers in any case |
| 239 | 237 | if (Main.isTraceEnabled()) { |
| … |
… |
public class ImageryAdjustAction extends MapMode implements AWTEventListener {
|
| 258 | 256 | int precision = Main.getProjection().getDefaultZoomInPPD() >= 1.0 ? 2 : 7; |
| 259 | 257 | // US locale to force decimal separator to be '.' |
| 260 | 258 | try (Formatter us = new Formatter(Locale.US)) { |
| | 259 | TileSourceDisplaySettings ds = layer.getDisplaySettings(); |
| 261 | 260 | tOffset.setText(us.format(new StringBuilder() |
| 262 | 261 | .append("%1.").append(precision).append("f; %1.").append(precision).append('f').toString(), |
| 263 | | layer.getDx(), layer.getDy()).toString()); |
| | 262 | ds.getDx(), ds.getDy()).toString()); |
| 264 | 263 | } |
| 265 | 264 | } |
| 266 | 265 | |
| … |
… |
public class ImageryAdjustAction extends MapMode implements AWTEventListener {
|
| 297 | 296 | offsetDialog = null; |
| 298 | 297 | if (layer != null) { |
| 299 | 298 | if (getValue() != 1) { |
| 300 | | layer.setOffset(oldDx, oldDy); |
| | 299 | layer.getDisplaySettings().setDisplacement(old); |
| 301 | 300 | } else if (tBookmarkName.getText() != null && !tBookmarkName.getText().isEmpty()) { |
| 302 | 301 | OffsetBookmark.bookmarkOffset(tBookmarkName.getText(), layer); |
| 303 | 302 | } |
diff --git a/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java b/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java
index 188eee6..9da2f7a 100644
|
a
|
b
|
import org.openstreetmap.gui.jmapviewer.interfaces.TileLoaderListener;
|
| 63 | 63 | import org.openstreetmap.gui.jmapviewer.interfaces.TileSource; |
| 64 | 64 | import org.openstreetmap.gui.jmapviewer.tilesources.AbstractTMSTileSource; |
| 65 | 65 | import org.openstreetmap.josm.Main; |
| | 66 | import org.openstreetmap.josm.actions.ImageryAdjustAction; |
| 66 | 67 | import org.openstreetmap.josm.actions.RenameLayerAction; |
| 67 | 68 | import org.openstreetmap.josm.actions.SaveActionBase; |
| 68 | 69 | import org.openstreetmap.josm.data.Bounds; |
| … |
… |
implements ImageObserver, TileLoaderListener, ZoomChangeListener, FilterChangeLi
|
| 164 | 165 | |
| 165 | 166 | private final TileSourceDisplaySettings displaySettings = createDisplaySettings(); |
| 166 | 167 | |
| | 168 | private final ImageryAdjustAction adjustAction = new ImageryAdjustAction(this); |
| | 169 | |
| 167 | 170 | /** |
| 168 | 171 | * Creates Tile Source based Imagery Layer based on Imagery Info |
| 169 | 172 | * @param info imagery info |
| … |
… |
implements ImageObserver, TileLoaderListener, ZoomChangeListener, FilterChangeLi
|
| 285 | 288 | if (isVisible()) Main.map.repaint(); |
| 286 | 289 | } |
| 287 | 290 | |
| | 291 | |
| | 292 | @Override |
| | 293 | public double getDx() { |
| | 294 | return getDisplaySettings().getDx(); |
| | 295 | } |
| | 296 | |
| | 297 | @Override |
| | 298 | public double getDy() { |
| | 299 | return getDisplaySettings().getDy(); |
| | 300 | } |
| | 301 | |
| | 302 | @Override |
| | 303 | public void displace(double dx, double dy) { |
| | 304 | getDisplaySettings().addDisplacement(new EastNorth(dx, dy)); |
| | 305 | } |
| | 306 | |
| 288 | 307 | /** |
| 289 | 308 | * Marks layer as needing redraw on offset change |
| 290 | 309 | */ |
| 291 | 310 | @Override |
| 292 | 311 | public void setOffset(double dx, double dy) { |
| 293 | | super.setOffset(dx, dy); |
| 294 | | needRedraw = true; |
| | 312 | getDisplaySettings().setDisplacement(new EastNorth(dx, dy)); |
| | 313 | } |
| | 314 | |
| | 315 | @Override |
| | 316 | public Object getInfoComponent() { |
| | 317 | JPanel panel = (JPanel) super.getInfoComponent(); |
| | 318 | EastNorth offset = getDisplaySettings().getDisplacement(); |
| | 319 | if (offset.distanceSq(0, 0) > 1e-10) { |
| | 320 | panel.add(new JLabel(tr("Offset: ") + offset.east() + ';' + offset.north()), GBC.eol().insets(0, 5, 10, 0)); |
| | 321 | } |
| | 322 | return panel; |
| 295 | 323 | } |
| 296 | 324 | |
| | 325 | @Override |
| | 326 | protected Action getAdjustAction() { |
| | 327 | return adjustAction; |
| | 328 | } |
| 297 | 329 | |
| 298 | 330 | /** |
| 299 | 331 | * Returns average number of screen pixels per tile pixel for current mapview |
| … |
… |
implements ImageObserver, TileLoaderListener, ZoomChangeListener, FilterChangeLi
|
| 1881 | 1913 | public File createAndOpenSaveFileChooser() { |
| 1882 | 1914 | return SaveActionBase.createAndOpenSaveFileChooser(tr("Save WMS file"), WMSLayerImporter.FILE_FILTER); |
| 1883 | 1915 | } |
| | 1916 | |
| | 1917 | @Override |
| | 1918 | public void destroy() { |
| | 1919 | super.destroy(); |
| | 1920 | adjustAction.destroy(); |
| | 1921 | } |
| 1884 | 1922 | } |
diff --git a/src/org/openstreetmap/josm/gui/layer/ImageryLayer.java b/src/org/openstreetmap/josm/gui/layer/ImageryLayer.java
index 8ff9166..6c539cc 100644
|
a
|
b
|
import java.util.ArrayList;
|
| 15 | 15 | import java.util.List; |
| 16 | 16 | |
| 17 | 17 | import javax.swing.AbstractAction; |
| | 18 | import javax.swing.Action; |
| 18 | 19 | import javax.swing.Icon; |
| 19 | 20 | import javax.swing.JCheckBoxMenuItem; |
| 20 | 21 | import javax.swing.JComponent; |
| … |
… |
import javax.swing.JPopupMenu;
|
| 26 | 27 | import javax.swing.JSeparator; |
| 27 | 28 | |
| 28 | 29 | import org.openstreetmap.josm.Main; |
| 29 | | import org.openstreetmap.josm.actions.ImageryAdjustAction; |
| 30 | 30 | import org.openstreetmap.josm.data.ProjectionBounds; |
| 31 | 31 | import org.openstreetmap.josm.data.imagery.ImageryInfo; |
| 32 | 32 | import org.openstreetmap.josm.data.imagery.OffsetBookmark; |
| … |
… |
import org.openstreetmap.josm.data.preferences.ColorProperty;
|
| 34 | 34 | import org.openstreetmap.josm.data.preferences.IntegerProperty; |
| 35 | 35 | import org.openstreetmap.josm.gui.MenuScroller; |
| 36 | 36 | import org.openstreetmap.josm.gui.layer.imagery.ImageryFilterSettings; |
| | 37 | import org.openstreetmap.josm.gui.layer.imagery.TileSourceDisplaySettings; |
| 37 | 38 | import org.openstreetmap.josm.gui.widgets.UrlLabel; |
| 38 | 39 | import org.openstreetmap.josm.tools.GBC; |
| 39 | 40 | import org.openstreetmap.josm.tools.ImageProvider; |
| … |
… |
public abstract class ImageryLayer extends Layer {
|
| 61 | 62 | |
| 62 | 63 | protected Icon icon; |
| 63 | 64 | |
| 64 | | protected double dx; |
| 65 | | protected double dy; |
| 66 | | |
| 67 | | private final ImageryAdjustAction adjustAction = new ImageryAdjustAction(this); |
| 68 | | |
| 69 | 65 | private final ImageryFilterSettings filterSettings = new ImageryFilterSettings(); |
| 70 | 66 | |
| 71 | 67 | /** |
| … |
… |
public abstract class ImageryLayer extends Layer {
|
| 95 | 91 | return Main.map.mapView.getWidth() / (bounds.maxEast - bounds.minEast); |
| 96 | 92 | } |
| 97 | 93 | |
| | 94 | /** |
| | 95 | * Gets the x displacement of this layer. |
| | 96 | * To be removed end of 2016 |
| | 97 | * @return The x displacement. |
| | 98 | * @deprecated Use {@link TileSourceDisplaySettings#getDx()} |
| | 99 | */ |
| | 100 | @Deprecated |
| 98 | 101 | public double getDx() { |
| 99 | | return dx; |
| | 102 | // moved to AbstractTileSourceLayer/TileSourceDisplaySettings. Remains until all actions migrate. |
| | 103 | return 0; |
| 100 | 104 | } |
| 101 | 105 | |
| | 106 | /** |
| | 107 | * Gets the y displacement of this layer. |
| | 108 | * To be removed end of 2016 |
| | 109 | * @return The y displacement. |
| | 110 | * @deprecated Use {@link TileSourceDisplaySettings#getDy()} |
| | 111 | */ |
| | 112 | @Deprecated |
| 102 | 113 | public double getDy() { |
| 103 | | return dy; |
| | 114 | // moved to AbstractTileSourceLayer/TileSourceDisplaySettings. Remains until all actions migrate. |
| | 115 | return 0; |
| 104 | 116 | } |
| 105 | 117 | |
| 106 | 118 | /** |
| 107 | 119 | * Sets the displacement offset of this layer. The layer is automatically invalidated. |
| | 120 | * To be removed end of 2016 |
| 108 | 121 | * @param dx The x offset |
| 109 | 122 | * @param dy The y offset |
| | 123 | * @deprecated Use {@link TileSourceDisplaySettings} |
| 110 | 124 | */ |
| | 125 | @Deprecated |
| 111 | 126 | public void setOffset(double dx, double dy) { |
| 112 | | this.dx = dx; |
| 113 | | this.dy = dy; |
| 114 | | invalidate(); |
| | 127 | // moved to AbstractTileSourceLayer/TileSourceDisplaySettings. Remains until all actions migrate. |
| 115 | 128 | } |
| 116 | 129 | |
| | 130 | /** |
| | 131 | * To be removed end of 2016 |
| | 132 | * @param dx |
| | 133 | * @param dy |
| | 134 | * @deprecated Use {@link TileSourceDisplaySettings} |
| | 135 | */ |
| | 136 | @Deprecated |
| 117 | 137 | public void displace(double dx, double dy) { |
| 118 | | this.dx += dx; |
| 119 | | this.dy += dy; |
| 120 | | setOffset(this.dx, this.dy); |
| | 138 | // moved to AbstractTileSourceLayer/TileSourceDisplaySettings. Remains until all actions migrate. |
| 121 | 139 | } |
| 122 | 140 | |
| 123 | 141 | /** |
| … |
… |
public abstract class ImageryLayer extends Layer {
|
| 152 | 170 | panel.add(new JLabel(tr("URL: ")), GBC.std().insets(0, 5, 2, 0)); |
| 153 | 171 | panel.add(new UrlLabel(url), GBC.eol().insets(2, 5, 10, 0)); |
| 154 | 172 | } |
| 155 | | if (dx != 0 || dy != 0) { |
| 156 | | panel.add(new JLabel(tr("Offset: ") + dx + ';' + dy), GBC.eol().insets(0, 5, 10, 0)); |
| 157 | | } |
| 158 | 173 | } |
| 159 | 174 | return panel; |
| 160 | 175 | } |
| … |
… |
public abstract class ImageryLayer extends Layer {
|
| 215 | 230 | } |
| 216 | 231 | |
| 217 | 232 | public JComponent getOffsetMenuItem(JComponent subMenu) { |
| 218 | | JMenuItem adjustMenuItem = new JMenuItem(adjustAction); |
| | 233 | JMenuItem adjustMenuItem = new JMenuItem(getAdjustAction()); |
| 219 | 234 | if (OffsetBookmark.allBookmarks.isEmpty()) return adjustMenuItem; |
| 220 | 235 | |
| 221 | 236 | subMenu.add(adjustMenuItem); |
| … |
… |
public abstract class ImageryLayer extends Layer {
|
| 227 | 242 | continue; |
| 228 | 243 | } |
| 229 | 244 | JCheckBoxMenuItem item = new JCheckBoxMenuItem(new ApplyOffsetAction(b)); |
| 230 | | if (Utils.equalsEpsilon(b.dx, dx) && Utils.equalsEpsilon(b.dy, dy)) { |
| | 245 | if (Utils.equalsEpsilon(b.dx, getDx()) && Utils.equalsEpsilon(b.dy, getDy())) { |
| 231 | 246 | item.setSelected(true); |
| 232 | 247 | } |
| 233 | 248 | subMenu.add(item); |
| … |
… |
public abstract class ImageryLayer extends Layer {
|
| 244 | 259 | return hasBookmarks ? subMenu : adjustMenuItem; |
| 245 | 260 | } |
| 246 | 261 | |
| | 262 | protected abstract Action getAdjustAction(); |
| | 263 | |
| 247 | 264 | /** |
| 248 | 265 | * Gets the settings for the filter that is applied to this layer. |
| 249 | 266 | * @return The filter settings. |
| … |
… |
public abstract class ImageryLayer extends Layer {
|
| 313 | 330 | } |
| 314 | 331 | return img; |
| 315 | 332 | } |
| 316 | | |
| 317 | | @Override |
| 318 | | public void destroy() { |
| 319 | | super.destroy(); |
| 320 | | adjustAction.destroy(); |
| 321 | | } |
| 322 | 333 | } |
diff --git a/src/org/openstreetmap/josm/gui/layer/imagery/TileSourceDisplaySettings.java b/src/org/openstreetmap/josm/gui/layer/imagery/TileSourceDisplaySettings.java
index 196fbac..d534b36 100644
|
a
|
b
|
import java.util.concurrent.CopyOnWriteArrayList;
|
| 6 | 6 | |
| 7 | 7 | import org.openstreetmap.gui.jmapviewer.interfaces.TileSource; |
| 8 | 8 | import org.openstreetmap.josm.Main; |
| | 9 | import org.openstreetmap.josm.data.coor.EastNorth; |
| 9 | 10 | import org.openstreetmap.josm.data.preferences.BooleanProperty; |
| 10 | 11 | import org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer; |
| | 12 | import org.openstreetmap.josm.tools.CheckParameterUtil; |
| | 13 | import org.openstreetmap.josm.tools.bugreport.BugReport; |
| 11 | 14 | |
| 12 | 15 | /** |
| 13 | 16 | * This are the preferences of how to display a {@link TileSource}. |
| … |
… |
public class TileSourceDisplaySettings {
|
| 35 | 38 | */ |
| 36 | 39 | private static final String SHOW_ERRORS = "show-errors"; |
| 37 | 40 | |
| | 41 | private static final String DISPLACEMENT = "displacement"; |
| | 42 | |
| 38 | 43 | private static final String PREFERENCE_PREFIX = "imagery.generic"; |
| 39 | 44 | |
| 40 | 45 | /** |
| … |
… |
public class TileSourceDisplaySettings {
|
| 47 | 52 | */ |
| 48 | 53 | public static final BooleanProperty PROP_AUTO_ZOOM = new BooleanProperty(PREFERENCE_PREFIX + ".default_autozoom", true); |
| 49 | 54 | |
| | 55 | |
| 50 | 56 | /** if layers changes automatically, when user zooms in */ |
| 51 | 57 | private boolean autoZoom; |
| 52 | 58 | /** if layer automatically loads new tiles */ |
| … |
… |
public class TileSourceDisplaySettings {
|
| 54 | 60 | /** if layer should show errors on tiles */ |
| 55 | 61 | private boolean showErrors; |
| 56 | 62 | |
| | 63 | /** |
| | 64 | * The displacement |
| | 65 | */ |
| | 66 | private EastNorth displacement = new EastNorth(0, 0); |
| | 67 | |
| 57 | 68 | private final CopyOnWriteArrayList<DisplaySettingsChangeListener> listeners = new CopyOnWriteArrayList<>(); |
| 58 | 69 | |
| 59 | 70 | /** |
| … |
… |
public class TileSourceDisplaySettings {
|
| 149 | 160 | } |
| 150 | 161 | |
| 151 | 162 | /** |
| | 163 | * Gets the displacement in x (east) direction |
| | 164 | * @return The displacement. |
| | 165 | * @since xxx |
| | 166 | */ |
| | 167 | public double getDx() { |
| | 168 | return displacement.east(); |
| | 169 | } |
| | 170 | |
| | 171 | /** |
| | 172 | * Gets the displacement in y (north) direction |
| | 173 | * @return The displacement. |
| | 174 | * @since xxx |
| | 175 | */ |
| | 176 | public double getDy() { |
| | 177 | return displacement.north(); |
| | 178 | } |
| | 179 | |
| | 180 | /** |
| | 181 | * Gets the displacement of the image |
| | 182 | * @return The displacement. |
| | 183 | * @since xxx |
| | 184 | */ |
| | 185 | public EastNorth getDisplacement() { |
| | 186 | return displacement; |
| | 187 | } |
| | 188 | |
| | 189 | /** |
| | 190 | * Set the displacement |
| | 191 | * @param displacement The new displacement |
| | 192 | * @since xxx |
| | 193 | */ |
| | 194 | public void setDisplacement(EastNorth displacement) { |
| | 195 | CheckParameterUtil.ensureValidCoordinates(displacement, "displacement"); |
| | 196 | this.displacement = displacement; |
| | 197 | fireSettingsChange(DISPLACEMENT); |
| | 198 | } |
| | 199 | |
| | 200 | /** |
| | 201 | * Adds the given value to the displacement. |
| | 202 | * @param displacement The value to add. |
| | 203 | * @since xxx |
| | 204 | */ |
| | 205 | public void addDisplacement(EastNorth displacement) { |
| | 206 | CheckParameterUtil.ensureValidCoordinates(displacement, "displacement"); |
| | 207 | setDisplacement(this.displacement.add(displacement)); |
| | 208 | } |
| | 209 | |
| | 210 | /** |
| 152 | 211 | * Notifies all listeners that the paint settings have changed |
| 153 | 212 | * @param changedSetting The setting name |
| | 213 | * @since xxx |
| 154 | 214 | */ |
| 155 | 215 | private void fireSettingsChange(String changedSetting) { |
| 156 | 216 | DisplaySettingsChangeEvent e = new DisplaySettingsChangeEvent(changedSetting); |
| … |
… |
public class TileSourceDisplaySettings {
|
| 184 | 244 | data.put(AUTO_LOAD, Boolean.toString(autoLoad)); |
| 185 | 245 | data.put(AUTO_ZOOM, Boolean.toString(autoZoom)); |
| 186 | 246 | data.put(SHOW_ERRORS, Boolean.toString(showErrors)); |
| | 247 | data.put("dx", String.valueOf(getDx())); |
| | 248 | data.put("dy", String.valueOf(getDy())); |
| 187 | 249 | } |
| 188 | 250 | |
| 189 | 251 | /** |
| … |
… |
public class TileSourceDisplaySettings {
|
| 192 | 254 | * @see #storeTo(Map) |
| 193 | 255 | */ |
| 194 | 256 | public void loadFrom(Map<String, String> data) { |
| 195 | | String doAutoLoad = data.get(AUTO_LOAD); |
| 196 | | if (doAutoLoad != null) { |
| 197 | | setAutoLoad(Boolean.parseBoolean(doAutoLoad)); |
| 198 | | } |
| | 257 | try { |
| | 258 | String doAutoLoad = data.get(AUTO_LOAD); |
| | 259 | if (doAutoLoad != null) { |
| | 260 | setAutoLoad(Boolean.parseBoolean(doAutoLoad)); |
| | 261 | } |
| 199 | 262 | |
| 200 | | String doAutoZoom = data.get(AUTO_ZOOM); |
| 201 | | if (doAutoZoom != null) { |
| 202 | | setAutoZoom(Boolean.parseBoolean(doAutoZoom)); |
| 203 | | } |
| | 263 | String doAutoZoom = data.get(AUTO_ZOOM); |
| | 264 | if (doAutoZoom != null) { |
| | 265 | setAutoZoom(Boolean.parseBoolean(doAutoZoom)); |
| | 266 | } |
| | 267 | |
| | 268 | String doShowErrors = data.get(SHOW_ERRORS); |
| | 269 | if (doShowErrors != null) { |
| | 270 | setShowErrors(Boolean.parseBoolean(doShowErrors)); |
| | 271 | } |
| 204 | 272 | |
| 205 | | String doShowErrors = data.get(SHOW_ERRORS); |
| 206 | | if (doShowErrors != null) { |
| 207 | | setShowErrors(Boolean.parseBoolean(doShowErrors)); |
| | 273 | String dx = data.get("dx"); |
| | 274 | String dy = data.get("dy"); |
| | 275 | if (dx != null && dy != null) { |
| | 276 | setDisplacement(new EastNorth(Double.parseDouble(dx), Double.parseDouble(dy))); |
| | 277 | } |
| | 278 | } catch (RuntimeException e) { |
| | 279 | throw BugReport.intercept(e).put("data", data); |
| 208 | 280 | } |
| 209 | 281 | } |
| 210 | 282 | |
diff --git a/src/org/openstreetmap/josm/io/session/ImagerySessionImporter.java b/src/org/openstreetmap/josm/io/session/ImagerySessionImporter.java
index 2b68c71..df5f135 100644
|
a
|
b
|
public class ImagerySessionImporter implements SessionLayerImporter {
|
| 53 | 53 | AbstractTileSourceLayer<?> tsLayer = (AbstractTileSourceLayer<?>) layer; |
| 54 | 54 | tsLayer.getDisplaySettings().loadFrom(attributes); |
| 55 | 55 | } |
| 56 | | if (attributes.containsKey("dx") && attributes.containsKey("dy")) { |
| 57 | | layer.setOffset(Double.parseDouble(attributes.get("dx")), Double.parseDouble(attributes.get("dy"))); |
| 58 | | } |
| 59 | 56 | return layer; |
| 60 | 57 | } |
| 61 | 58 | } |
diff --git a/test/unit/org/openstreetmap/josm/io/session/SessionReaderTest.java b/test/unit/org/openstreetmap/josm/io/session/SessionReaderTest.java
index d2216ef..87bf617 100644
|
a
|
b
|
import org.junit.Test;
|
| 14 | 14 | import org.openstreetmap.josm.JOSMFixture; |
| 15 | 15 | import org.openstreetmap.josm.Main; |
| 16 | 16 | import org.openstreetmap.josm.TestUtils; |
| | 17 | import org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer; |
| 17 | 18 | import org.openstreetmap.josm.gui.layer.GpxLayer; |
| 18 | 19 | import org.openstreetmap.josm.gui.layer.ImageryLayer; |
| 19 | 20 | import org.openstreetmap.josm.gui.layer.Layer; |
| … |
… |
public class SessionReaderTest {
|
| 124 | 125 | final List<Layer> layers = testRead("bing.jos"); |
| 125 | 126 | assertEquals(layers.size(), 1); |
| 126 | 127 | assertTrue(layers.get(0) instanceof ImageryLayer); |
| 127 | | final ImageryLayer image = (ImageryLayer) layers.get(0); |
| | 128 | final AbstractTileSourceLayer<?> image = (AbstractTileSourceLayer<?>) layers.get(0); |
| 128 | 129 | assertEquals("Bing aerial imagery", image.getName()); |
| 129 | | assertEquals(image.getDx(), 12.34, 1e-9); |
| 130 | | assertEquals(image.getDy(), -56.78, 1e-9); |
| | 130 | assertEquals(image.getDisplaySettings().getDx(), 12.34, 1e-9); |
| | 131 | assertEquals(image.getDisplaySettings().getDy(), -56.78, 1e-9); |
| 131 | 132 | } |
| 132 | 133 | |
| 133 | 134 | /** |
diff --git a/test/unit/org/openstreetmap/josm/io/session/SessionWriterTest.java b/test/unit/org/openstreetmap/josm/io/session/SessionWriterTest.java
index 3cb237c..f1c922a 100644
|
a
|
b
|
import java.util.Map;
|
| 14 | 14 | import org.junit.BeforeClass; |
| 15 | 15 | import org.junit.Test; |
| 16 | 16 | import org.openstreetmap.josm.JOSMFixture; |
| | 17 | import org.openstreetmap.josm.data.coor.EastNorth; |
| 17 | 18 | import org.openstreetmap.josm.data.coor.LatLon; |
| 18 | 19 | import org.openstreetmap.josm.data.gpx.GpxData; |
| 19 | 20 | import org.openstreetmap.josm.data.gpx.WayPoint; |
| … |
… |
public class SessionWriterTest {
|
| 135 | 136 | } |
| 136 | 137 | |
| 137 | 138 | private ImageryLayer createImageryLayer() { |
| 138 | | ImageryLayer layer = new TMSLayer(new ImageryInfo("the name", "http://www.url.com/")); |
| 139 | | layer.setOffset(12, 34); |
| | 139 | TMSLayer layer = new TMSLayer(new ImageryInfo("the name", "http://www.url.com/")); |
| | 140 | layer.getDisplaySettings().setDisplacement(new EastNorth(12, 34)); |
| 140 | 141 | return layer; |
| 141 | 142 | } |
| 142 | 143 | |