Changeset 26253 in osm


Ignore:
Timestamp:
2011-07-03T01:00:30+02:00 (13 years ago)
Author:
stoecker
Message:

allow proper attribution handling also in slippy map chooser of JOSM

Location:
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer
Files:
3 edited

Legend:

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

    r25369 r26253  
    1010import java.awt.Insets;
    1111import java.awt.Point;
     12import java.awt.Rectangle;
    1213import java.awt.event.ActionEvent;
    1314import java.awt.event.ActionListener;
     
    8687    public static final Font ATTR_FONT = new Font("Arial", Font.PLAIN, 10);
    8788    public static final Font ATTR_LINK_FONT;
     89
     90    protected Rectangle attrTextBounds = null;
     91    protected Rectangle attrToUBounds = null;
     92    protected Rectangle attrImageBounds = null;
    8893
    8994    static {
     
    753758
    754759        Rectangle2D termsStringBounds = g.getFontMetrics().getStringBounds("Background Terms of Use", g);
    755         int textHeight = (int) termsStringBounds.getHeight() - 5;
     760        int textRealHeight = (int) termsStringBounds.getHeight();
     761        int textHeight = textRealHeight - 5;
     762        int textWidth = (int) termsStringBounds.getWidth();
    756763        int termsTextY = getHeight() - textHeight;
    757764        if (attrTermsUrl != null) {
    758765            int x = 2;
    759766            int y = getHeight() - textHeight;
     767            attrToUBounds = new Rectangle(x, y-textHeight, textWidth, textRealHeight);
    760768            g.setColor(Color.black);
    761769            g.drawString("Background Terms of Use", x + 1, y + 1);
     
    767775        if (attrImage != null) {
    768776            int x = 2;
     777            int imgWidth = attrImage.getWidth(this);
    769778            int height = attrImage.getHeight(null);
    770779            int y = termsTextY - height - textHeight - 5;
     780            attrImageBounds = new Rectangle(x, y, imgWidth, height);
    771781            g.drawImage(attrImage, x, y, null);
    772782        }
     
    784794            g.setColor(Color.white);
    785795            g.drawString(attributionText, x, y);
     796            attrTextBounds = new Rectangle(x, y-textHeight, textWidth, textRealHeight);
    786797        }
    787798
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractOsmTileSource.java

    r26249 r26253  
    2626    @Override
    2727    public boolean requiresAttribution() {
    28         return false;
     28        return true;
    2929    }
    3030
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/TMSTileSource.java

    r26249 r26253  
    11package org.openstreetmap.gui.jmapviewer.tilesources;
    22
     3import java.awt.Image;
     4
     5import org.openstreetmap.gui.jmapviewer.Coordinate;
    36
    47public class TMSTileSource extends AbstractTSMTileSource {
    58    protected int maxZoom;
    69    protected int minZoom = 0;
     10    protected String attributionText;
     11    protected Image attributionImage;
     12    protected String attributionLinkURL;
     13    protected String termsOfUseURL;
    714
    815    public TMSTileSource(String name, String url, int maxZoom) {
     
    3037        return TileUpdate.IfNoneMatch;
    3138    }
     39
     40    @Override
     41    public boolean requiresAttribution() {
     42        return attributionText != null;
     43    }
     44
     45    @Override
     46    public String getAttributionText(int zoom, Coordinate topLeft, Coordinate botRight) {
     47        return attributionText;
     48    }
     49
     50    @Override
     51    public Image getAttributionImage() {
     52        return attributionImage;
     53    }
     54
     55    @Override
     56    public String getAttributionLinkURL() {
     57        return attributionLinkURL;
     58    }
     59
     60    @Override
     61    public String getTermsOfUseURL() {
     62        return termsOfUseURL;
     63    }
     64
     65    public void setAttributionText(String text) {
     66        attributionText = text;
     67    }
     68
     69    public void setAttributionImage(Image img) {
     70        attributionImage = img;
     71    }
     72
     73    public void setAttributionLinkURL(String text) {
     74        attributionLinkURL = text;
     75    }
     76
     77    public void setTermsOfUseURL(String text) {
     78        termsOfUseURL = text;
     79    }
    3280}
Note: See TracChangeset for help on using the changeset viewer.