Changeset 9819 in osm
- Timestamp:
- 2008-08-14T12:50:12+02:00 (16 years ago)
- Location:
- applications/editors/josm/plugins/slippy_map_chooser/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/slippy_map_chooser/src/SlippyMapChooser.java
r9623 r9819 21 21 import org.openstreetmap.gui.jmapviewer.MemoryTileCache; 22 22 import org.openstreetmap.gui.jmapviewer.OsmMercator; 23 import org.openstreetmap.gui.jmapviewer.OsmTile Loader;23 import org.openstreetmap.gui.jmapviewer.OsmTileSource; 24 24 import org.openstreetmap.gui.jmapviewer.interfaces.MapMarker; 25 import org.openstreetmap.gui.jmapviewer.interfaces.TileSource; 25 26 import org.openstreetmap.josm.gui.download.DownloadDialog; 26 27 import org.openstreetmap.josm.gui.download.DownloadSelection; … … 48 49 // screen size 49 50 private Dimension iScreenSize; 51 52 private TileSource[] sources = { new OsmTileSource.Mapnik(), new OsmTileSource.TilesAtHome() }; 50 53 51 54 /** … … 203 206 int h = iScreenSize.height * 90 / 100; 204 207 co.setBounds((iScreenSize.width - w) / 2, (iScreenSize.height - h) / 2, w, h); 205 208 206 209 } 207 210 // shrink … … 212 215 int h = iDownloadDialogDimension.height; 213 216 co.setBounds((iScreenSize.width - w) / 2, (iScreenSize.height - h) / 2, w, h); 214 215 } 216 217 218 } 219 217 220 repaint(); 218 221 } 219 220 public void toggleMapSource(int mapSource) {222 223 public void toggleMapSource(int mapSource) { 221 224 this.tileCache = new MemoryTileCache(); 222 if(mapSource == SourceButton.MAPNIK){ 223 this.tileLoader = new OsmTileLoader(this,OsmTileLoader.MAP_MAPNIK); 224 }else{ 225 this.tileLoader = new OsmTileLoader(this,OsmTileLoader.MAP_OSMA); 226 } 227 repaint(); 225 if (mapSource == SourceButton.MAPNIK) { 226 this.setTileSource(sources[0]); 227 } else { 228 this.setTileSource(sources[1]); 229 } 228 230 } 229 231 -
applications/editors/josm/plugins/slippy_map_chooser/src/SourceButton.java
r9623 r9819 1 import java.awt.Color;2 1 import java.awt.Graphics; 3 2 import java.awt.Point; 4 3 5 4 import javax.swing.ImageIcon; 6 import javax.vecmath.Color3f;7 5 8 6 import org.openstreetmap.josm.tools.ImageProvider; 9 7 8 public class SourceButton { 10 9 10 private int x = 0; 11 private int y = 30; 11 12 12 13 public class SourceButton {14 15 private int x =0;16 private int y = 30;17 18 private int enlagedWidth = 200;19 private int enlargedHeight = 50;20 21 13 private ImageIcon enlargeImage; 22 14 private ImageIcon shrinkImage; 23 15 private ImageIcon imageMapnik; 24 16 private ImageIcon imageOsmarender; 25 17 26 18 private boolean isEnlarged = false; 27 19 28 20 private boolean isMapnik = true; 29 30 private static final String SOURCE_1 = "Osmarender"; 31 private static final String SOURCE_2 = "Mapnik"; 32 21 33 22 public static final int HIDE_OR_SHOW = 1; 34 23 public static final int MAPNIK = 2; 35 24 public static final int OSMARENDER = 3; 36 37 38 public SourceButton(){ 25 26 public SourceButton() { 39 27 enlargeImage = ImageProvider.get("", "layer-switcher-maximize.png"); 40 shrinkImage = ImageProvider.get("", "layer-switcher-minimize.png"); 28 shrinkImage = ImageProvider.get("", "layer-switcher-minimize.png"); 41 29 imageMapnik = ImageProvider.get("", "blue_Mapnik.png"); 42 30 imageOsmarender = ImageProvider.get("", "blue_Osmarender.png"); 31 } 32 33 public void paint(Graphics g) { 34 35 if (isEnlarged) { 36 if (isMapnik) { 37 g.drawImage(imageMapnik.getImage(), g.getClipBounds().width 38 - imageMapnik.getIconWidth(), y, null); 39 } else { 40 g.drawImage(imageOsmarender.getImage(), g.getClipBounds().width 41 - imageMapnik.getIconWidth(), y, null); 42 } 43 44 if (shrinkImage != null) { 45 this.x = g.getClipBounds().width - shrinkImage.getIconWidth(); 46 g.drawImage(shrinkImage.getImage(), x, y, null); 47 } 48 49 } else { 50 if (enlargeImage != null) { 51 this.x = g.getClipBounds().width - enlargeImage.getIconWidth(); 52 g.drawImage(enlargeImage.getImage(), x, y, null); 53 } 54 } 55 } 56 57 public void toggle() { 58 this.isEnlarged = !this.isEnlarged; 43 59 44 60 } 45 46 public void paint(Graphics g){47 48 if(isEnlarged){49 if(isMapnik){50 g.drawImage(imageMapnik.getImage(), g.getClipBounds().width - imageMapnik.getIconWidth(), y, null);51 }else{52 g.drawImage(imageOsmarender.getImage(), g.getClipBounds().width - imageMapnik.getIconWidth(), y, null);53 }54 61 55 if(shrinkImage != null){ 56 this.x = g.getClipBounds().width-shrinkImage.getIconWidth(); 57 g.drawImage(shrinkImage.getImage(),x,y, null); 58 } 59 60 }else{ 61 if(enlargeImage != null){ 62 this.x = g.getClipBounds().width-enlargeImage.getIconWidth(); 63 g.drawImage(enlargeImage.getImage(),x,y, null); 64 } 65 } 66 } 67 68 public void toggle(){ 69 this.isEnlarged = !this.isEnlarged; 70 71 } 72 73 public int hit(Point point){ 74 if(isEnlarged){ 75 if(x < point.x && point.x < x + shrinkImage.getIconWidth()){ 76 if(y < point.y && point.y < y + shrinkImage.getIconHeight() ){ 62 public int hit(Point point) { 63 if (isEnlarged) { 64 if (x < point.x && point.x < x + shrinkImage.getIconWidth()) { 65 if (y < point.y && point.y < y + shrinkImage.getIconHeight()) { 77 66 return HIDE_OR_SHOW; 78 67 } 79 } else if(x-imageMapnik.getIconWidth() < point.x && point.x < x ){80 if(y < point.y && point.y < y +imageMapnik.getIconHeight()/2 ){68 } else if (x - imageMapnik.getIconWidth() < point.x && point.x < x) { 69 if (y < point.y && point.y < y + imageMapnik.getIconHeight() / 2) { 81 70 isMapnik = false; 82 71 return OSMARENDER; 83 }else if(y+imageMapnik.getIconHeight()/2 < point.y && point.y < y +imageMapnik.getIconHeight() ){ 72 } else if (y + imageMapnik.getIconHeight() / 2 < point.y 73 && point.y < y + imageMapnik.getIconHeight()) { 84 74 isMapnik = true; 85 75 return MAPNIK; 86 76 } 87 77 } 88 } else{89 if (x < point.x && point.x < x + enlargeImage.getIconWidth()){90 if (y < point.y && point.y < y + enlargeImage.getIconHeight() ){78 } else { 79 if (x < point.x && point.x < x + enlargeImage.getIconWidth()) { 80 if (y < point.y && point.y < y + enlargeImage.getIconHeight()) { 91 81 return HIDE_OR_SHOW; 92 82 } 93 83 } 94 84 } 95 85 96 86 return 0; 97 87 }
Note:
See TracChangeset
for help on using the changeset viewer.