Changeset 12778 in osm for applications/editors/josm/plugins/slippy_map_chooser/src/SourceButton.java
- Timestamp:
- 2009-01-01T18:28:53+01:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/slippy_map_chooser/src/SourceButton.java
r9819 r12778 8 8 public class SourceButton { 9 9 10 11 10 private int x = 0; 11 private int y = 30; 12 12 13 14 15 16 13 private ImageIcon enlargeImage; 14 private ImageIcon shrinkImage; 15 private ImageIcon imageMapnik; 16 private ImageIcon imageOsmarender; 17 17 18 18 private boolean isEnlarged = false; 19 19 20 20 private boolean isMapnik = true; 21 21 22 23 24 22 public static final int HIDE_OR_SHOW = 1; 23 public static final int MAPNIK = 2; 24 public static final int OSMARENDER = 3; 25 25 26 27 28 29 30 31 26 public SourceButton() { 27 enlargeImage = ImageProvider.get("", "layer-switcher-maximize.png"); 28 shrinkImage = ImageProvider.get("", "layer-switcher-minimize.png"); 29 imageMapnik = ImageProvider.get("", "blue_Mapnik.png"); 30 imageOsmarender = ImageProvider.get("", "blue_Osmarender.png"); 31 } 32 32 33 33 public void paint(Graphics g) { 34 34 35 36 37 38 39 40 41 42 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 43 44 45 46 47 44 if (shrinkImage != null) { 45 this.x = g.getClipBounds().width - shrinkImage.getIconWidth(); 46 g.drawImage(shrinkImage.getImage(), x, y, null); 47 } 48 48 49 50 51 52 53 54 55 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 56 57 58 57 public void toggle() { 58 this.isEnlarged = !this.isEnlarged; 59 59 60 60 } 61 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 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()) { 66 return HIDE_OR_SHOW; 67 } 68 } else if (x - imageMapnik.getIconWidth() < point.x && point.x < x) { 69 if (y < point.y && point.y < y + imageMapnik.getIconHeight() / 2) { 70 isMapnik = false; 71 return OSMARENDER; 72 } else if (y + imageMapnik.getIconHeight() / 2 < point.y 73 && point.y < y + imageMapnik.getIconHeight()) { 74 isMapnik = true; 75 return MAPNIK; 76 } 77 } 78 } else { 79 if (x < point.x && point.x < x + enlargeImage.getIconWidth()) { 80 if (y < point.y && point.y < y + enlargeImage.getIconHeight()) { 81 return HIDE_OR_SHOW; 82 } 83 } 84 } 85 85 86 87 86 return 0; 87 } 88 88 }
Note:
See TracChangeset
for help on using the changeset viewer.