diff --git a/src/org/openstreetmap/josm/Main.java b/src/org/openstreetmap/josm/Main.java
index fddff1a..7d028d4 100644
|
a
|
b
|
public abstract class Main {
|
| 1430 | 1430 | private static void fireProjectionChanged(Projection oldValue, Projection newValue, Bounds oldBounds) { |
| 1431 | 1431 | if (newValue == null ^ oldValue == null |
| 1432 | 1432 | || (newValue != null && oldValue != null && !Objects.equals(newValue.toCode(), oldValue.toCode()))) { |
| 1433 | | |
| | 1433 | if (Main.map != null) { |
| | 1434 | // This needs to be called first |
| | 1435 | Main.map.mapView.fixProjection(); |
| | 1436 | } |
| 1434 | 1437 | synchronized (Main.class) { |
| 1435 | 1438 | Iterator<WeakReference<ProjectionChangeListener>> it = listeners.iterator(); |
| 1436 | 1439 | while (it.hasNext()) { |
diff --git a/src/org/openstreetmap/josm/gui/MapViewState.java b/src/org/openstreetmap/josm/gui/MapViewState.java
index 982ccf7..6d143d7 100644
|
a
|
b
|
public final class MapViewState {
|
| 99 | 99 | topLeftOnScreen = position.getLocationOnScreen(); |
| 100 | 100 | } |
| 101 | 101 | |
| | 102 | private MapViewState(Projection projection, MapViewState mapViewState) { |
| | 103 | this.projection = projection; |
| | 104 | this.scale = mapViewState.scale; |
| | 105 | this.topLeft = mapViewState.topLeft; |
| | 106 | |
| | 107 | viewWidth = mapViewState.viewWidth; |
| | 108 | viewHeight = mapViewState.viewHeight; |
| | 109 | topLeftInWindow = mapViewState.topLeftInWindow; |
| | 110 | topLeftOnScreen = mapViewState.topLeftOnScreen; |
| | 111 | } |
| | 112 | |
| 102 | 113 | /** |
| 103 | 114 | * The scale in east/north units per pixel. |
| 104 | 115 | * @return The scale. |
| … |
… |
public final class MapViewState {
|
| 235 | 246 | } |
| 236 | 247 | |
| 237 | 248 | /** |
| | 249 | * Creates a state that uses the projection. |
| | 250 | * @param projection The projection to use. |
| | 251 | * @return The new state. |
| | 252 | */ |
| | 253 | public MapViewState usingProjection(Projection projection) { |
| | 254 | if (projection.equals(this.projection)) { |
| | 255 | return this; |
| | 256 | } else { |
| | 257 | return new MapViewState(projection, this); |
| | 258 | } |
| | 259 | } |
| | 260 | |
| | 261 | /** |
| 238 | 262 | * Create the default {@link MapViewState} object for the given map view. The screen position won't be set so that this method can be used |
| 239 | 263 | * before the view was added to the hirarchy. |
| 240 | 264 | * @param width The view width |
diff --git a/src/org/openstreetmap/josm/gui/NavigatableComponent.java b/src/org/openstreetmap/josm/gui/NavigatableComponent.java
index b6a15e5..3fcd541 100644
|
a
|
b
|
import org.openstreetmap.josm.data.preferences.BooleanProperty;
|
| 50 | 50 | import org.openstreetmap.josm.data.preferences.DoubleProperty; |
| 51 | 51 | import org.openstreetmap.josm.data.preferences.IntegerProperty; |
| 52 | 52 | import org.openstreetmap.josm.data.projection.Projection; |
| | 53 | import org.openstreetmap.josm.data.projection.ProjectionChangeListener; |
| 53 | 54 | import org.openstreetmap.josm.data.projection.Projections; |
| 54 | 55 | import org.openstreetmap.josm.gui.help.Helpful; |
| 55 | 56 | import org.openstreetmap.josm.gui.layer.NativeScaleLayer; |
| … |
… |
public class NavigatableComponent extends JComponent implements Helpful {
|
| 176 | 177 | public NavigatableComponent() { |
| 177 | 178 | setLayout(null); |
| 178 | 179 | state = MapViewState.createDefaultState(getWidth(), getHeight()); |
| | 180 | // uses weak link. |
| | 181 | Main.addProjectionChangeListener(new ProjectionChangeListener() { |
| | 182 | @Override |
| | 183 | public void projectionChanged(Projection oldValue, Projection newValue) { |
| | 184 | fixProjection(); |
| | 185 | } |
| | 186 | }); |
| 179 | 187 | } |
| 180 | 188 | |
| 181 | 189 | @Override |
| … |
… |
public class NavigatableComponent extends JComponent implements Helpful {
|
| 326 | 334 | } |
| 327 | 335 | |
| 328 | 336 | /** |
| | 337 | * Changes the projection settings used for this map view. |
| | 338 | * <p> |
| | 339 | * Made public temporarely, will be made private later. |
| | 340 | */ |
| | 341 | public void fixProjection() { |
| | 342 | state = state.usingProjection(Main.getProjection()); |
| | 343 | repaint(); |
| | 344 | } |
| | 345 | |
| | 346 | /** |
| 329 | 347 | * Gets the current view state. This includes the scale, the current view area and the position. |
| 330 | 348 | * @return The current state. |
| 331 | 349 | */ |