Changeset 24488 in osm for applications/editors/josm/plugins/slippymap
- Timestamp:
- 2010-12-01T06:06:51+01:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapLayer.java
r24487 r24488 14 14 import java.awt.event.MouseAdapter; 15 15 import java.awt.event.MouseEvent; 16 import java.awt.geom.Rectangle2D; 16 17 import java.awt.image.ImageObserver; 17 18 import java.io.IOException; … … 109 110 Tile showMetadataTile; 110 111 private Image attrImage; 111 private Rectangle attrImageBounds; 112 private Font attrFont = Font.decode("Arial-10"); 112 private String attrTermsUrl; 113 private Rectangle attrImageBounds, attrToUBounds; 114 private static Font ATTR_FONT = Font.decode("Arial 10"); 115 private static Font ATTR_LINK_FONT = Font.decode("Arial Underline 10"); 113 116 114 117 void redraw() … … 130 133 System.out.println("Got an attribution image " + attrImage.getHeight(this) + "x" + attrImage.getWidth(this)); 131 134 } 135 136 attrTermsUrl = tileSource.getTermsOfUseURL(); 132 137 } 133 138 … … 264 269 tileOptionMenu.show(e.getComponent(), e.getX(), e.getY()); 265 270 } else if (e.getButton() == MouseEvent.BUTTON1) { 266 if(attrImageBounds.contains(e.getPoint()) && tileSource.requiresAttribution()) { 271 if(!tileSource.requiresAttribution()) { 272 return; 273 } 274 275 if(attrImageBounds.contains(e.getPoint())) { 267 276 try { 268 277 java.awt.Desktop desktop = java.awt.Desktop.getDesktop(); 269 278 desktop.browse(new URI(tileSource.getAttributionLinkURL())); 279 } catch (IOException e1) { 280 e1.printStackTrace(); 281 } catch (URISyntaxException e1) { 282 e1.printStackTrace(); 283 } 284 } else if(attrToUBounds.contains(e.getPoint())) { 285 try { 286 java.awt.Desktop desktop = java.awt.Desktop.getDesktop(); 287 desktop.browse(new URI(tileSource.getTermsOfUseURL())); 270 288 } catch (IOException e1) { 271 289 e1.printStackTrace(); … … 942 960 g.setColor(Color.white); 943 961 Font font = g.getFont(); 944 g.setFont(attrFont); 945 g.drawString(tileSource.getAttributionText(currentZoomLevel, topLeft, botRight), 5 + attrImage.getWidth(this) + 2, mv.getHeight() - 5); 946 g.setFont(font); 962 g.setFont(ATTR_LINK_FONT); 963 964 // Draw terms of use text 965 Rectangle2D termsStringBounds = g.getFontMetrics().getStringBounds("Background Terms of Use", g); 966 int textHeight = (int) termsStringBounds.getHeight() - 5; 967 int textWidth = (int) termsStringBounds.getWidth(); 968 int termsTextY = mv.getHeight() - textHeight; 969 if(attrTermsUrl != null) { 970 int x = 2; 971 int y = mv.getHeight() - textHeight; 972 attrToUBounds = new Rectangle(x, y, textWidth, textHeight); 973 g.drawString("Background Terms of Use", x, y); 974 } 947 975 948 976 // Draw attribution logo 977 int imgWidth = attrImage.getWidth(this); 949 978 if(attrImage != null) { 950 int x = 5; 951 int y = mv.getHeight() - attrImage.getHeight(this) - 5; 952 attrImageBounds = new Rectangle(x, y, attrImage.getWidth(this), attrImage.getHeight(this)); 979 int x = 2; 980 int height = attrImage.getHeight(this); 981 int y = termsTextY - height; 982 attrImageBounds = new Rectangle(x, y, imgWidth, height); 953 983 g.drawImage(attrImage, x, y, this); 954 984 } 985 986 String attributionText = tileSource.getAttributionText(currentZoomLevel, topLeft, botRight); 987 Rectangle2D stringBounds = g.getFontMetrics().getStringBounds(attributionText, g); 988 g.drawString(attributionText, mv.getWidth() - (int) stringBounds.getWidth(), mv.getHeight() - textHeight); 989 990 g.setFont(font); 955 991 } 956 992 -
applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapPreferences.java
r24487 r24488 410 410 } 411 411 412 public String getTermsOfUseURL() { 413 return "http://opengeodata.org/microsoft-imagery-details"; 414 } 415 412 416 public String getAttributionText(int zoom, LatLon topLeft, LatLon botRight) { 413 417 Bounds windowBounds = new Bounds(topLeft, botRight);
Note:
See TracChangeset
for help on using the changeset viewer.