Ticket #23654: josm_23654.patch

File josm_23654.patch, 3.3 KB (added by gaben, 4 weeks ago)
  • src/org/openstreetmap/gui/jmapviewer/AttributionSupport.java

     
    6969        // Draw terms of use text
    7070        int termsTextHeight = 0;
    7171        int termsTextY = height;
     72        int padding = 5;
    7273
    7374        if (attrTermsText != null) {
    7475            Rectangle2D termsStringBounds = g.getFontMetrics().getStringBounds(attrTermsText, g);
    7576            int textRealHeight = (int) termsStringBounds.getHeight();
    76             termsTextHeight = textRealHeight - 5;
     77            termsTextHeight = textRealHeight - padding;
    7778            int termsTextWidth = (int) termsStringBounds.getWidth();
    7879            termsTextY = height - termsTextHeight;
    7980            int x = 2;
    8081            int y = height - termsTextHeight;
    81             attrToUBounds = new Rectangle(x, y-termsTextHeight, termsTextWidth, textRealHeight);
    82             g.setColor(Color.black);
    83             g.drawString(attrTermsText, x + 1, y + 1);
    84             g.setColor(Color.white);
    85             g.drawString(attrTermsText, x, y);
     82            attrToUBounds = new Rectangle(x, y - termsTextHeight, termsTextWidth, textRealHeight);
     83            drawShadedText(g, attrTermsText, x, y);
    8684        } else {
    8785            attrToUBounds = null;
    8886        }
     
    102100        g.setFont(ATTR_FONT);
    103101        String attributionText = source.getAttributionText(zoom, topLeft, bottomRight);
    104102        if (attributionText == null) {
    105             // In case attribution text has been forgotte, display URL
     103            // In case the attribution text has been forgotten, display URL
    106104            attributionText = source.getAttributionLinkURL();
    107105        }
    108106        if (attributionText != null) {
    109107            Rectangle2D stringBounds = g.getFontMetrics().getStringBounds(attributionText, g);
    110             int textHeight = (int) stringBounds.getHeight() - 5;
    111             int x = width - (int) stringBounds.getWidth();
     108            int textHeight = (int) stringBounds.getHeight() - padding;
     109            int textWidth = (int) stringBounds.getWidth() + padding;
     110            int x = width - textWidth;
    112111            int y = height - textHeight;
    113             g.setColor(Color.black);
    114             g.drawString(attributionText, x + 1, y + 1);
    115             g.setColor(Color.white);
    116             g.drawString(attributionText, x, y);
    117             attrTextBounds = new Rectangle(x, y-textHeight, (int) stringBounds.getWidth(), (int) stringBounds.getHeight());
     112            drawShadedText(g, attributionText, x, y);
     113            attrTextBounds = new Rectangle(x, y - textHeight, (int) stringBounds.getWidth(), (int) stringBounds.getHeight());
    118114        } else {
    119115            attrTextBounds = null;
    120116        }
     
    122118        g.setFont(font);
    123119    }
    124120
     121    private static void drawShadedText(Graphics g, String text, int x, int y) {
     122        g.setColor(Color.black);
     123        g.drawString(text, x + 1, y + 1);
     124        g.setColor(Color.white);
     125        g.drawString(text, x, y);
     126    }
     127
    125128    public boolean handleAttributionCursor(Point p) {
    126129        if (attrTextBounds != null && attrTextBounds.contains(p)) {
    127130            return true;