Changeset 36533 in osm


Ignore:
Timestamp:
2026-11-26T22:04:20+01:00 (less than one hour ago)
Author:
stoecker
Message:

Reduction of redundant code and increased readability - patch by DanProgs (modified) - fix #24671

File:
1 edited

Legend:

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

    r36510 r36533  
    140140
    141141    public boolean handleAttribution(Point p, boolean click) {
    142         if (source == null || !source.requiresAttribution())
     142        if (source == null || !source.requiresAttribution()) {
    143143            return false;
     144        }
    144145
     146        String url = getUrlAtPoint(p);
     147        if (url != null) {
     148            if (click) {
     149                FeatureAdapter.openLink(url);
     150            }
     151            return true;
     152        }
     153
     154        return false;
     155    }
     156   
     157    private String getUrlAtPoint(Point p) {
    145158        if (attrTextBounds != null && attrTextBounds.contains(p)) {
    146             String attributionURL = source.getAttributionLinkURL();
    147             if (attributionURL != null) {
    148                 if (click) {
    149                     FeatureAdapter.openLink(attributionURL);
    150                 }
    151                 return true;
    152             }
    153         } else if (attrImageBounds != null && attrImageBounds.contains(p)) {
    154             String attributionImageURL = source.getAttributionImageURL();
    155             if (attributionImageURL != null) {
    156                 if (click) {
    157                     FeatureAdapter.openLink(source.getAttributionImageURL());
    158                 }
    159                 return true;
    160             }
    161         } else if (attrToUBounds != null && attrToUBounds.contains(p)) {
    162             String termsOfUseURL = source.getTermsOfUseURL();
    163             if (termsOfUseURL != null) {
    164                 if (click) {
    165                     FeatureAdapter.openLink(termsOfUseURL);
    166                 }
    167                 return true;
    168             }
     159            return source.getAttributionLinkURL();
    169160        }
    170         return false;
     161        if (attrImageBounds != null && attrImageBounds.contains(p)) {
     162            return source.getAttributionImageURL();
     163        }
     164        if (attrToUBounds != null && attrToUBounds.contains(p)) {
     165            return source.getTermsOfUseURL();
     166        }
     167        return null;
    171168    }
    172169
Note: See TracChangeset for help on using the changeset viewer.