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

fix slippy map attribution handling and allow bounds and attribution specification in maps specification (not exposed to user currently)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/TMSLayer.java

    r4188 r4195  
    159159    private Image attrImage;
    160160    private String attrTermsUrl;
    161     private Rectangle attrImageBounds, attrToUBounds;
     161    private Rectangle attrImageBounds, attrToUBounds, attrTextBounds;
    162162    private static final Font InfoFont = new Font("sansserif", Font.BOLD, 13);
    163163    private static final Font ATTR_FONT = new Font("Arial", Font.PLAIN, 10);
     
    233233    public static TileSource getTileSource(ImageryInfo info) {
    234234        if (info.getImageryType() == ImageryType.TMS) {
    235             if(ImageryInfo.isUrlWithPatterns(info.getUrl()))
    236                 return new TemplatedTMSTileSource(info.getName(), info.getUrl(), info.getMinZoom(), info.getMaxZoom());
    237             else
    238                 return new TMSTileSource(info.getName(),info.getUrl(), info.getMinZoom(), info.getMaxZoom());
     235            if(ImageryInfo.isUrlWithPatterns(info.getUrl())) {
     236                TMSTileSource t = new TemplatedTMSTileSource(info.getName(), info.getUrl(), info.getMinZoom(), info.getMaxZoom());
     237                info.setAttribution(t);
     238                return t;
     239            } else {
     240                TMSTileSource t = new TMSTileSource(info.getName(),info.getUrl(), info.getMinZoom(), info.getMaxZoom());
     241                info.setAttribution(t);
     242                return t;
     243            }
    239244        } else if (info.getImageryType() == ImageryType.BING)
    240245            return new BingAerialTileSource();
     
    317322        if(!isProjectionSupported(Main.getProjection())) {
    318323              JOptionPane.showMessageDialog(Main.parent,
    319                   tr("TMS layers do not support the projection {1}.\n{2}\n"
     324                  tr("TMS layers do not support the projection {0}.\n{1}\n"
    320325                  + "Change the projection or remove the layer.",
    321326                      Main.getProjection().toCode(), nameSupportedProjections()),
     
    455460                                return;
    456461
    457                             if(attrImageBounds != null && attrImageBounds.contains(e.getPoint())) {
     462                            if((attrImageBounds != null && attrImageBounds.contains(e.getPoint()))
     463                            || (attrTextBounds != null && attrTextBounds.contains(e.getPoint()))) {
    458464                                try {
    459465                                    java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
     
    12001206            // Draw terms of use text
    12011207            Rectangle2D termsStringBounds = g.getFontMetrics().getStringBounds("Background Terms of Use", g);
    1202             int textHeight = (int) termsStringBounds.getHeight() - 5;
     1208            int textRealHeight = (int) termsStringBounds.getHeight();
     1209            int textHeight = textRealHeight - 5;
    12031210            int textWidth = (int) termsStringBounds.getWidth();
    12041211            int termsTextY = mv.getHeight() - textHeight;
     
    12061213                int x = 2;
    12071214                int y = mv.getHeight() - textHeight;
    1208                 attrToUBounds = new Rectangle(x, y, textWidth, textHeight);
     1215                attrToUBounds = new Rectangle(x, y-textHeight, textWidth, textRealHeight);
    12091216                myDrawString(g, "Background Terms of Use", x, y);
    12101217            }
     
    12281235                int y = mv.getHeight() - textHeight;
    12291236                myDrawString(g, attributionText, x, y);
     1237                attrTextBounds = new Rectangle(x, y-textHeight, textWidth, textRealHeight);
    12301238            }
    12311239
Note: See TracChangeset for help on using the changeset viewer.