- Timestamp:
- 2015-09-12T01:06:10+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java
r8729 r8751 135 135 136 136 /** 137 * Offset between calculated zoom level and zoom level used to download and show tiles. Negative values will result in 138 * lower resolution of imagery useful in "retina" displays, positive values will result in higher resolution 139 */ 140 public static final IntegerProperty ZOOM_OFFSET = new IntegerProperty(PREFERENCE_PREFIX + ".zoom_offset", 0); 141 142 /** 137 143 * use fairly small memory cache, as cached objects are quite big, as they contain BufferedImages 138 144 */ 139 public static final IntegerProperty MEMORY_CACHE_SIZE = new IntegerProperty(PREFERENCE_PREFIX + " cache.max_objects_ram", 200);145 public static final IntegerProperty MEMORY_CACHE_SIZE = new IntegerProperty(PREFERENCE_PREFIX + ".cache.max_objects_ram", (int)Math.max(200, 200 * Math.pow(4, ZOOM_OFFSET.get()))); 140 146 141 147 /* … … 280 286 protected int getBestZoom() { 281 287 double factor = getScaleFactor(1); // check the ratio between area of tilesize at zoom 1 to current view 282 double result = Math.log(factor)/Math.log(2)/2 +1;288 double result = Math.log(factor)/Math.log(2)/2; 283 289 /* 284 290 * Math.log(factor)/Math.log(2) - gives log base 2 of factor 285 291 * We divide result by 2, as factor contains ratio between areas. We could do Math.sqrt before log, or just divide log by 2 286 * In general, smaller zoom levels are more readable. We prefer big, 287 * block, pixelated (but readable) map text to small, smeared, 288 * unreadable underzoomed text. So, use .floor() instead of rounding 289 * to skew things a bit toward the lower zooms. 290 * Remember, that result here, should correspond to TMSLayer.paint(...) 291 * getScaleFactor(...) is supposed to be between 0.75 and 3 292 * 293 * ZOOM_OFFSET controls, whether we work with overzoomed or underzoomed tiles. Positive ZOOM_OFFSET 294 * is for working with underzoomed tiles (higher quality when working with aerial imagery), negative ZOOM_OFFSET 295 * is for working with overzoomed tiles (big, pixelated), which is good when working with high-dpi screens and/or 296 * maps as a imagery layer 292 297 */ 293 int intResult = (int) Math.floor(result); 294 i f (intResult > getMaxZoomLvl())295 return getMaxZoomLvl(); 296 i f (intResult < getMinZoomLvl())297 return getMinZoomLvl();298 299 int intResult = (int) Math.round(result + 1 + ZOOM_OFFSET.get() / 1.9); 300 301 intResult = Math.min(intResult, getMaxZoomLvl()); 302 intResult = Math.max(intResult, getMinZoomLvl()); 298 303 return intResult; 299 304 } … … 1192 1197 1193 1198 private boolean tooLarge() { 1194 return this.tilesSpanned() > 10;1199 return this.tilesSpanned() > 20; 1195 1200 } 1196 1201 … … 1374 1379 int zoom = currentZoomLevel; 1375 1380 if (autoZoom) { 1376 double pixelScaling = getScaleFactor(zoom); 1377 if (pixelScaling > 3 || pixelScaling < 0.7) { 1378 zoom = getBestZoom(); 1379 } 1381 zoom = getBestZoom(); 1380 1382 } 1381 1383 -
trunk/src/org/openstreetmap/josm/gui/preferences/imagery/CommonSettingsPanel.java
r8598 r8751 20 20 import org.openstreetmap.josm.data.imagery.CachedTileLoaderFactory; 21 21 import org.openstreetmap.josm.gui.layer.AbstractCachedTileSourceLayer; 22 import org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer; 22 23 import org.openstreetmap.josm.gui.layer.ImageryLayer; 23 24 import org.openstreetmap.josm.gui.widgets.JosmComboBox; … … 39 40 private final JSpinner maxElementsOnDisk; 40 41 private final JSpinner maxElementsInRam; 42 private final JSlider tilesZoom = new JSlider(-2, 2, 0); 41 43 42 44 … … 99 101 add(GBC.glue(5, 0), GBC.std()); 100 102 add(this.maxElementsInRam, GBC.eol()); 103 104 this.tilesZoom.setPaintLabels(true); 105 this.tilesZoom.setMajorTickSpacing(2); 106 this.tilesZoom.setMinorTickSpacing(1); 107 this.tilesZoom.setPaintTicks(true); 108 add(new JLabel(tr("Tiles zoom offset:"))); 109 add(GBC.glue(5, 0), GBC.std()); 110 add(this.tilesZoom, GBC.eol()); 101 111 } 102 112 … … 113 123 this.maxElementsOnDisk.setValue(AbstractCachedTileSourceLayer.MAX_DISK_CACHE_SIZE.get()); 114 124 this.maxElementsInRam.setValue(AbstractCachedTileSourceLayer.MEMORY_CACHE_SIZE.get()); 115 125 this.tilesZoom.setValue(AbstractTileSourceLayer.ZOOM_OFFSET.get()); 116 126 } 117 127 … … 124 134 ImageryLayer.PROP_FADE_COLOR.put(this.btnFadeColor.getBackground()); 125 135 ImageryLayer.PROP_SHARPEN_LEVEL.put(sharpen.getSelectedIndex()); 136 126 137 boolean restartRequired = false; 127 138 if (!AbstractCachedTileSourceLayer.MAX_DISK_CACHE_SIZE.get().equals(this.maxElementsOnDisk.getValue())) { … … 138 149 if (!AbstractCachedTileSourceLayer.MEMORY_CACHE_SIZE.get().equals(this.maxElementsInRam.getValue())) { 139 150 AbstractCachedTileSourceLayer.MEMORY_CACHE_SIZE.put((Integer) this.maxElementsInRam.getValue()); 151 restartRequired = true; 140 152 } 141 153 142 154 if (!AbstractTileSourceLayer.ZOOM_OFFSET.get().equals(this.tilesZoom.getValue())) { 155 // TODO: make warning about too small MEMORY_CACHE_SIZE? 156 AbstractTileSourceLayer.ZOOM_OFFSET.put(this.tilesZoom.getValue()); 157 restartRequired = true; 158 } 143 159 return restartRequired; 144 160 }
Note:
See TracChangeset
for help on using the changeset viewer.