Ignore:
Timestamp:
2011-10-08T13:01:32+02:00 (13 years ago)
Author:
bastik
Message:

rework in order to get attribution for wms layers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/AttributionSupport.java

    r26794 r26806  
    1616import java.util.HashMap;
    1717
    18 import org.openstreetmap.gui.jmapviewer.interfaces.TileSource;
     18import org.openstreetmap.gui.jmapviewer.interfaces.Attributed;
    1919
    2020public class AttributionSupport {
    2121
    22     private TileSource tileSource;
     22    private Attributed source;
    2323
    2424    private Image attrImage;
     
    3838    }
    3939
    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();
    4343        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();
    4747            if (attrTermsUrl != null && attrTermsText == null) {
    4848                attrTermsText = tr("Background Terms of Use");
     
    5555
    5656    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())
    5858            return;
    5959        // Draw attribution
     
    9191
    9292        g.setFont(ATTR_FONT);
    93         String attributionText = tileSource.getAttributionText(zoom, topLeft, bottomRight);
     93        String attributionText = source.getAttributionText(zoom, topLeft, bottomRight);
    9494        if (attributionText != null) {
    9595            Rectangle2D stringBounds = g.getFontMetrics().getStringBounds(attributionText, g);
     
    108108
    109109    public boolean handleAttribution(Point p, boolean click) {
    110         if (tileSource == null || !tileSource.requiresAttribution())
     110        if (source == null || !source.requiresAttribution())
    111111            return false;
    112112
     
    114114
    115115        if (attrTextBounds != null && attrTextBounds.contains(p)) {
    116             String attributionURL = tileSource.getAttributionLinkURL();
     116            String attributionURL = source.getAttributionLinkURL();
    117117            if (attributionURL != null) {
    118118                if (click) {
     
    122122            }
    123123        } else if (attrImageBounds != null && attrImageBounds.contains(p)) {
    124             String attributionImageURL = tileSource.getAttributionImageURL();
     124            String attributionImageURL = source.getAttributionImageURL();
    125125            if (attributionImageURL != null) {
    126126                if (click) {
    127                     FeatureAdapter.openLink(tileSource.getAttributionImageURL());
     127                    FeatureAdapter.openLink(source.getAttributionImageURL());
    128128                }
    129129                return true;
    130130            }
    131131        } else if (attrToUBounds != null && attrToUBounds.contains(p)) {
    132             String termsOfUseURL = tileSource.getTermsOfUseURL();
     132            String termsOfUseURL = source.getTermsOfUseURL();
    133133            if (termsOfUseURL != null) {
    134134                if (click) {
Note: See TracChangeset for help on using the changeset viewer.