- Timestamp:
- 2009-02-19T18:13:30+01:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/download/SlippyMapChooser.java
r1390 r1428 11 11 import java.awt.Graphics; 12 12 import java.awt.Point; 13 import java.awt.Rectangle; 13 14 import java.awt.Toolkit; 14 import java.awt.event.ComponentEvent;15 import java.awt.event.ComponentListener;16 15 import java.awt.geom.Point2D; 17 16 import java.util.Vector; … … 27 26 import org.openstreetmap.gui.jmapviewer.OsmTileLoader; 28 27 import org.openstreetmap.gui.jmapviewer.OsmTileSource; 29 import org.openstreetmap.gui.jmapviewer.OsmTileSource.CycleMap;30 28 import org.openstreetmap.gui.jmapviewer.interfaces.MapMarker; 31 29 import org.openstreetmap.gui.jmapviewer.interfaces.TileLoader; 32 30 import org.openstreetmap.gui.jmapviewer.interfaces.TileSource; 33 31 import org.openstreetmap.josm.Main; 34 import org.openstreetmap.josm.gui.download.DownloadDialog;35 import org.openstreetmap.josm.gui.download.DownloadSelection;36 32 37 33 /** … … 41 37 * 42 38 */ 43 public class SlippyMapChooser extends JMapViewer implements DownloadSelection , ComponentListener{39 public class SlippyMapChooser extends JMapViewer implements DownloadSelection { 44 40 45 41 private DownloadDialog iGui; … … 58 54 private Dimension iScreenSize; 59 55 60 private TileSource[] sources = { new OsmTileSource.Mapnik(), new OsmTileSource.TilesAtHome(),new OsmTileSource.CycleMap()}; 56 private TileSource[] sources = { new OsmTileSource.Mapnik(), new OsmTileSource.TilesAtHome(), 57 new OsmTileSource.CycleMap() }; 61 58 TileLoader cachedLoader; 62 59 TileLoader uncachedLoader; 63 60 JPanel slipyyMapTabPanel; 64 boolean firstShown = true;65 61 66 62 /** … … 74 70 setMapMarkerVisible(false); 75 71 setMinimumSize(new Dimension(350, 350 / 2)); 72 // We need to set an initial size - this prevents a wrong zoom selection for 73 // the area before the component has been displayed the first time 74 setBounds(new Rectangle(getMinimumSize())); 76 75 setFileCacheEnabled(Main.pref.getBoolean("slippy_map_chooser.file_cache", true)); 77 setMaxTilesInmemory(Main.pref.getInteger("slippy_map_chooser.max_tiles", 1000)); 78 addComponentListener(this); 76 setMaxTilesInMemory(Main.pref.getInteger("slippy_map_chooser.max_tiles", 1000)); 79 77 80 78 String mapStyle = Main.pref.get("slippy_map_chooser.mapstyle", "mapnik"); 81 if (mapStyle.equals("osmarender")) {79 if (mapStyle.equals("osmarender")) { 82 80 iSourceButton.setMapStyle(SourceButton.OSMARENDER); 83 81 this.setTileSource(sources[1]); 84 }else if(mapStyle.equals("cyclemap")){ 85 iSourceButton.setMapStyle(SourceButton.CYCLEMAP); 86 this.setTileSource(sources[2]); 87 } 88 else { 89 if(!mapStyle.equals("mapnik")) 82 } else if (mapStyle.equals("cyclemap")) { 83 iSourceButton.setMapStyle(SourceButton.CYCLEMAP); 84 this.setTileSource(sources[2]); 85 } else { 86 if (!mapStyle.equals("mapnik")) 90 87 Main.pref.put("slippy_map_chooser.mapstyle", "mapnik"); 91 88 } 92 89 } 93 90 94 public void setMaxTilesIn memory(int tiles) {91 public void setMaxTilesInMemory(int tiles) { 95 92 ((MemoryTileCache) getTileCache()).setCacheSize(tiles); 96 93 } … … 109 106 slipyyMapTabPanel.add(this, BorderLayout.CENTER); 110 107 slipyyMapTabPanel.add(new JLabel((tr("Zoom: Mousewheel or double click. " 111 + "Move map: Hold right mousebutton and move mouse. Select: Click."))), 112 BorderLayout.SOUTH); 108 + "Move map: Hold right mousebutton and move mouse. Select: Click."))), BorderLayout.SOUTH); 113 109 iGui.tabpane.add(slipyyMapTabPanel, tr("Slippy map")); 114 iGui.tabpane.addComponentListener(this);115 110 new OsmMapControl(this, slipyyMapTabPanel, iSizeButton, iSourceButton); 116 111 } … … 224 219 public void resizeSlippyMap() { 225 220 if (iScreenSize == null) { 226 Component c = 227 iGui.getParent().getParent().getParent().getParent().getParent().getParent() 228 .getParent().getParent().getParent(); 221 Component c = iGui.getParent().getParent().getParent().getParent().getParent().getParent().getParent() 222 .getParent().getParent(); 229 223 // remember the initial set screen dimensions 230 224 iDownloadDialogDimension = c.getSize(); … … 234 228 235 229 // resize 236 Component co = 237 iGui.getParent().getParent().getParent().getParent().getParent().getParent() 238 .getParent().getParent().getParent(); 230 Component co = iGui.getParent().getParent().getParent().getParent().getParent().getParent().getParent() 231 .getParent().getParent(); 239 232 Dimension currentDimension = co.getSize(); 240 233 … … 266 259 this.setTileSource(sources[0]); 267 260 Main.pref.put("slippy_map_chooser.mapstyle", "mapnik"); 268 } else if (mapSource == SourceButton.CYCLEMAP) {261 } else if (mapSource == SourceButton.CYCLEMAP) { 269 262 this.setTileSource(sources[2]); 270 263 Main.pref.put("slippy_map_chooser.mapstyle", "cyclemap"); 271 } else {264 } else { 272 265 this.setTileSource(sources[1]); 273 266 Main.pref.put("slippy_map_chooser.mapstyle", "osmarender"); … … 275 268 } 276 269 277 public void componentHidden(ComponentEvent e) {278 }279 280 public void componentMoved(ComponentEvent e) {281 }282 283 public void componentShown(ComponentEvent e) {284 }285 286 public void componentResized(ComponentEvent e) {287 if (!this.equals(e.getSource()) || getHeight() == 0 || getWidth() == 0)288 return;289 firstShown = false;290 // The bounding box has to be set after SlippyMapChooser's size has been291 // finally set - otherwise the zoom level will be totally wrong (too wide)292 boundingBoxChanged(iGui);293 }294 295 270 }
Note:
See TracChangeset
for help on using the changeset viewer.