Changeset 13921 in osm for applications/editors/josm/plugins
- Timestamp:
- 2009-02-28T01:56:46+01:00 (16 years ago)
- Location:
- applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapLayer.java
r13712 r13921 12 12 import java.awt.event.MouseEvent; 13 13 import java.awt.image.ImageObserver; 14 import java.util.ArrayList;15 14 import java.util.HashMap; 16 15 … … 322 321 g.setColor(Color.DARK_GRAY); 323 322 323 float fadeBackground = SlippyMapPreferences.getFadeBackground(); 324 324 325 for (int x = z12x0 - 1; x <= z12x1; x++) 325 326 { … … 351 352 Point p2 = pixelpos[x - z12x0 + 2][y - z12y0 + 2]; 352 353 g.drawImage(img, p.x, p.y, p2.x - p.x, p2.y - p.y, this); 353 } 354 } 355 } 354 355 if(fadeBackground != 0f) { 356 //dimm by painting opaque rect... 357 g.setColor(new Color(1f,1f,1f,fadeBackground)); 358 g.fillRect(p.x, p.y, p2.x - p.x, p2.y - p.y); 359 }//end of if dim != 0 360 }//end of if img != null 361 }//end of for 362 }//end of for 356 363 357 364 for (int x = z12x0 - 1; x <= z12x1; x++) … … 374 381 int texty = p.y + 2 + fontHeight; 375 382 SlippyMapTile tile = tileStorage[currentZoomLevel].get(key); 383 if(tile == null) { 384 continue; 385 } 376 386 p = pixelpos[x - z12x0 + 1][y - z12y0 + 2]; 377 387 g.drawString("x=" + x + " y=" + y + " z=" + currentZoomLevel + "", p.x + 2, texty); … … 408 418 } 409 419 } 410 } 420 } //end of for 411 421 } 412 422 -
applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapPreferenceSetting.java
r13712 r13921 8 8 import javax.swing.JLabel; 9 9 import javax.swing.JPanel; 10 import javax.swing.JSlider; 10 11 import javax.swing.JSpinner; 11 12 … … 29 30 private JCheckBox autoloadTiles = new JCheckBox(tr("autoload tiles")); 30 31 private JSpinner maxZoomLvl = new JSpinner(); 32 private JSlider fadeBackground = new JSlider(0, 100); 31 33 32 34 public void addGui(PreferenceDialog gui) … … 60 62 maxZoomLvlPanel.add(this.maxZoomLvl, GBC.eol().fill(GBC.HORIZONTAL)); 61 63 64 JPanel fadeBackgroundPanel = new JPanel(); 65 fadeBackgroundPanel.add(new JLabel(tr("Fade background: ")), GBC.std()); 66 fadeBackgroundPanel.add(GBC.glue(5, 0), GBC.std().fill(GBC.HORIZONTAL)); 67 fadeBackgroundPanel.add(this.fadeBackground, GBC.eol().fill(GBC.HORIZONTAL)); 68 62 69 slippymapTab.add(mapUrlPanel, GBC.eol().fill(GBC.HORIZONTAL)); 63 70 slippymapTab.add(autozoomPanel, GBC.eol().fill(GBC.HORIZONTAL)); 64 71 slippymapTab.add(autoloadPanel, GBC.eol().fill(GBC.HORIZONTAL)); 65 72 slippymapTab.add(maxZoomLvlPanel, GBC.eol().fill(GBC.HORIZONTAL)); 73 slippymapTab.add(fadeBackgroundPanel, GBC.eol().fill(GBC.HORIZONTAL)); 66 74 slippymapTab.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.VERTICAL)); 67 75 … … 84 92 this.autoloadTiles.setSelected(SlippyMapPreferences.getAutoloadTiles()); 85 93 this.maxZoomLvl.setValue(SlippyMapPreferences.getMaxZoomLvl()); 94 this.fadeBackground.setValue(Math.round(SlippyMapPreferences.getFadeBackground()*100f)); 86 95 } 87 96 … … 100 109 SlippyMapPreferences.setAutoloadTiles(this.autoloadTiles.isSelected()); 101 110 SlippyMapPreferences.setMaxZoomLvl((Integer)this.maxZoomLvl.getValue()); 111 SlippyMapPreferences.setFadeBackground(this.fadeBackground.getValue()/100f); 102 112 //restart isn't required 103 113 return false; -
applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapPreferences.java
r13712 r13921 18 18 private static final String PREFERENCE_AUTOLOADTILES = PREFERENCE_PREFIX + ".autoload_tiles"; 19 19 private static final String PREFERENCE_MAX_ZOOM_LVL = PREFERENCE_PREFIX + ".max_zoom_lvl"; 20 private static final String PREFERENCE_FADE_BACKGROUND = PREFERENCE_PREFIX + ".fade_background"; 20 21 21 22 public static String getMapUrl() … … 66 67 } 67 68 69 public static void setFadeBackground(float fadeBackground) { 70 Main.pref.put(SlippyMapPreferences.PREFERENCE_FADE_BACKGROUND, fadeBackground + ""); 71 } 72 73 /** 74 * 75 * @return number between 0 and 1, inclusive 76 */ 77 public static float getFadeBackground() { 78 String fadeBackground = Main.pref.get(PREFERENCE_FADE_BACKGROUND); 79 80 if (fadeBackground == null || "".equals(fadeBackground)) 81 { 82 fadeBackground = "0.0"; 83 Main.pref.put(PREFERENCE_FADE_BACKGROUND, fadeBackground); 84 } 85 86 float parsed; 87 try { 88 parsed = Float.parseFloat(fadeBackground); 89 } catch (Exception ex) { 90 setFadeBackground(0.1f); 91 System.out.println("Error while parsing setting fade background to float! returning 0.1, because of error:"); 92 ex.printStackTrace(System.out); 93 return 0.1f; 94 } 95 if(parsed < 0f) { 96 parsed = 0f; 97 } else { 98 if(parsed > 1f) { 99 parsed = 1f; 100 } 101 } 102 return parsed; 103 } 104 68 105 public static void setAutoloadTiles(boolean autoloadTiles) { 69 106 Main.pref.put(SlippyMapPreferences.PREFERENCE_AUTOLOADTILES, autoloadTiles); 70 107 } 71 108 72 109 public static int getMaxZoomLvl() 73 110 {
Note:
See TracChangeset
for help on using the changeset viewer.