- Timestamp:
- 2013-12-22T18:18:43+01:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java
r6380 r6509 31 31 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; 32 32 import org.openstreetmap.josm.gui.dialogs.ValidatorDialog.ValidatorBoundingXYVisitor; 33 import org.openstreetmap.josm.gui.download.DownloadDialog; 33 34 import org.openstreetmap.josm.gui.layer.Layer; 34 35 import org.openstreetmap.josm.tools.Shortcut; … … 244 245 } 245 246 else if (mode.equals("download")) { 246 if (!Main.pref.get("osm-download.bounds").isEmpty()) { 247 Bounds bounds = DownloadDialog.getSavedDownloadBounds(); 248 if (bounds != null) { 247 249 try { 248 v.visit( new Bounds(Main.pref.get("osm-download.bounds"), ";"));250 v.visit(bounds); 249 251 } catch (Exception e) { 250 e.printStackTrace();252 Main.warn(e); 251 253 } 252 254 } -
trunk/src/org/openstreetmap/josm/actions/DownloadAction.java
r6380 r6509 26 26 */ 27 27 public class DownloadAction extends JosmAction { 28 29 /** 30 * Constructs a new {@code DownloadAction}. 31 */ 28 32 public DownloadAction() { 29 33 super(tr("Download from OSM..."), "download", tr("Download map data from the OSM server."), -
trunk/src/org/openstreetmap/josm/actions/NewAction.java
r6380 r6509 13 13 import org.openstreetmap.josm.tools.Shortcut; 14 14 15 /** 16 * Creates a blank new OSM data layer. 17 * @since 169 18 */ 15 19 public class NewAction extends JosmAction { 16 20 21 /** 22 * Constructs a {@code NewAction}. 23 */ 17 24 public NewAction() { 18 25 super(tr("New Layer"), "new", tr("Create a new map layer."), -
trunk/src/org/openstreetmap/josm/data/Bounds.java
r6380 r6509 276 276 * @return Center of the bounding box. 277 277 */ 278 public LatLon getCenter() 279 { 278 public LatLon getCenter() { 280 279 if (crosses180thMeridian()) { 281 280 double lat = (minLat + maxLat) / 2; -
trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r6422 r6509 47 47 import org.openstreetmap.josm.data.projection.Projection; 48 48 import org.openstreetmap.josm.data.projection.Projections; 49 import org.openstreetmap.josm.gui.download.DownloadDialog; 49 50 import org.openstreetmap.josm.gui.help.Helpful; 50 51 import org.openstreetmap.josm.gui.preferences.projection.ProjectionPreference; … … 193 194 private Polygon paintPoly = null; 194 195 196 /** 197 * Constructs a new {@code NavigatableComponent}. 198 */ 195 199 public NavigatableComponent() { 196 200 setLayout(null); … … 202 206 203 207 private EastNorth calculateDefaultCenter() { 204 Bounds b = Main.getProjection().getWorldBoundsLatLon();205 double lat = (b.getMaxLat() + b.getMinLat())/2;206 double lon = (b.getMaxLon() + b.getMinLon())/2;207 // FIXME is it correct? b.getCenter() makes some adjustments...208 return Main.getProjection().latlon2eastNorth( new LatLon(lat, lon));208 Bounds b = DownloadDialog.getSavedDownloadBounds(); 209 if (b == null) { 210 b = Main.getProjection().getWorldBoundsLatLon(); 211 } 212 return Main.getProjection().latlon2eastNorth(b.getCenter()); 209 213 } 210 214 … … 412 416 int width = getWidth()/2; 413 417 int height = getHeight()/2; 418 if (width == 0 || height == 0) { 419 throw new IllegalStateException("Cannot zoom into undimensioned NavigatableComponent"); 420 } 414 421 LatLon l1 = new LatLon(b.getMinLat(), lon); 415 422 LatLon l2 = new LatLon(b.getMaxLat(), lon); -
trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java
r6380 r6509 307 307 308 308 /** 309 * Remembers the current settings in the download dialog 310 * 309 * Remembers the current settings in the download dialog. 311 310 */ 312 311 public void rememberSettings() { … … 320 319 } 321 320 321 /** 322 * Restores the previous settings in the download dialog. 323 */ 322 324 public void restoreSettings() { 323 325 cbDownloadOsmData.setSelected(Main.pref.getBoolean("download.osm", true)); … … 339 341 boundingBoxChanged(currentBounds,null); 340 342 } 341 else if (!Main.pref.get("osm-download.bounds").isEmpty()) { 342 // read the bounding box from the preferences 343 else { 344 Bounds bounds = getSavedDownloadBounds(); 345 if (bounds != null) { 346 currentBounds = bounds; 347 boundingBoxChanged(currentBounds, null); 348 } 349 } 350 } 351 352 /** 353 * Returns the previously saved bounding box from preferences. 354 * @return The bounding box saved in preferences if any, {@code null} otherwise 355 * @since 6509 356 */ 357 public static Bounds getSavedDownloadBounds() { 358 String value = Main.pref.get("osm-download.bounds"); 359 if (!value.isEmpty()) { 343 360 try { 344 currentBounds = new Bounds(Main.pref.get("osm-download.bounds"), ";"); 345 boundingBoxChanged(currentBounds,null); 346 } 347 catch (Exception e) { 348 e.printStackTrace(); 349 } 350 } 351 } 352 361 return new Bounds(value, ";"); 362 } catch (IllegalArgumentException e) { 363 Main.warn(e); 364 } 365 } 366 return null; 367 } 368 369 /** 370 * Determines if the dialog autorun is enabled in preferences. 371 * @return {@code true} if the download dialog must be open at startup, {@code false} otherwise 372 */ 353 373 public static boolean isAutorunEnabled() { 354 374 return Main.pref.getBoolean("download.autorun",false); … … 362 382 363 383 /** 364 * Replies the currently selected download area. May be null, if no download area is selected yet. 384 * Replies the currently selected download area. 385 * @return the currently selected download area. May be {@code null}, if no download area is selected yet. 365 386 */ 366 387 public Bounds getSelectedDownloadArea() {
Note:
See TracChangeset
for help on using the changeset viewer.