Changeset 10486 in josm
- Timestamp:
- 2016-06-25T11:14:09+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/Main.java
r10463 r10486 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(); -
trunk/src/org/openstreetmap/josm/gui/MapViewState.java
r10462 r10486 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. … … 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 * @since 10486 253 */ 254 public MapViewState usingProjection(Projection projection) { 255 if (projection.equals(this.projection)) { 256 return this; 257 } else { 258 return new MapViewState(projection, this); 259 } 260 } 261 262 /** 238 263 * 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 264 * before the view was added to the hirarchy. -
trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r10466 r10486 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; … … 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 … … 324 332 protected boolean isVisibleOnScreen() { 325 333 return SwingUtilities.getWindowAncestor(this) != null && isShowing(); 334 } 335 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(); 326 344 } 327 345
Note:
See TracChangeset
for help on using the changeset viewer.