Changeset 26806 in osm for applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/AttributionSupport.java
- Timestamp:
- 2011-10-08T13:01:32+02:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/AttributionSupport.java
r26794 r26806 16 16 import java.util.HashMap; 17 17 18 import org.openstreetmap.gui.jmapviewer.interfaces. TileSource;18 import org.openstreetmap.gui.jmapviewer.interfaces.Attributed; 19 19 20 20 public class AttributionSupport { 21 21 22 private TileSource tileSource;22 private Attributed source; 23 23 24 24 private Image attrImage; … … 38 38 } 39 39 40 public void initialize( TileSource tileSource) {41 this. tileSource = tileSource;42 boolean requireAttr = tileSource.requiresAttribution();40 public void initialize(Attributed source) { 41 this.source = source; 42 boolean requireAttr = source.requiresAttribution(); 43 43 if (requireAttr) { 44 attrImage = tileSource.getAttributionImage();45 attrTermsText = tileSource.getTermsOfUseText();46 attrTermsUrl = tileSource.getTermsOfUseURL();44 attrImage = source.getAttributionImage(); 45 attrTermsText = source.getTermsOfUseText(); 46 attrTermsUrl = source.getTermsOfUseURL(); 47 47 if (attrTermsUrl != null && attrTermsText == null) { 48 48 attrTermsText = tr("Background Terms of Use"); … … 55 55 56 56 public void paintAttribution(Graphics g, int width, int height, Coordinate topLeft, Coordinate bottomRight, int zoom, ImageObserver observer) { 57 if ( tileSource == null || !tileSource.requiresAttribution())57 if (source == null || !source.requiresAttribution()) 58 58 return; 59 59 // Draw attribution … … 91 91 92 92 g.setFont(ATTR_FONT); 93 String attributionText = tileSource.getAttributionText(zoom, topLeft, bottomRight);93 String attributionText = source.getAttributionText(zoom, topLeft, bottomRight); 94 94 if (attributionText != null) { 95 95 Rectangle2D stringBounds = g.getFontMetrics().getStringBounds(attributionText, g); … … 108 108 109 109 public boolean handleAttribution(Point p, boolean click) { 110 if ( tileSource == null || !tileSource.requiresAttribution())110 if (source == null || !source.requiresAttribution()) 111 111 return false; 112 112 … … 114 114 115 115 if (attrTextBounds != null && attrTextBounds.contains(p)) { 116 String attributionURL = tileSource.getAttributionLinkURL();116 String attributionURL = source.getAttributionLinkURL(); 117 117 if (attributionURL != null) { 118 118 if (click) { … … 122 122 } 123 123 } else if (attrImageBounds != null && attrImageBounds.contains(p)) { 124 String attributionImageURL = tileSource.getAttributionImageURL();124 String attributionImageURL = source.getAttributionImageURL(); 125 125 if (attributionImageURL != null) { 126 126 if (click) { 127 FeatureAdapter.openLink( tileSource.getAttributionImageURL());127 FeatureAdapter.openLink(source.getAttributionImageURL()); 128 128 } 129 129 return true; 130 130 } 131 131 } else if (attrToUBounds != null && attrToUBounds.contains(p)) { 132 String termsOfUseURL = tileSource.getTermsOfUseURL();132 String termsOfUseURL = source.getTermsOfUseURL(); 133 133 if (termsOfUseURL != null) { 134 134 if (click) {
Note:
See TracChangeset
for help on using the changeset viewer.