Changeset 6122 in josm for trunk/src/org


Ignore:
Timestamp:
2013-08-09T09:30:55+02:00 (11 years ago)
Author:
bastiK
Message:

fixed #8934 - Text-halo-color and text-halo-radius Properties are not applied within area selectors (patch by AlfonZ)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java

    r6069 r6122  
    442442    }
    443443
     444    /**
     445     * Displays text at specified position including its halo, if applicable.
     446     *
     447     * @param gv Text's glyphs to display. If {@code null}, use text from {@code s} instead.
     448     * @param s text to display if {@code gv} is {@code null}
     449     * @param x X position
     450     * @param y Y position
     451     * @param disabled {@code true} if element is disabled (filtered out)
     452     * @param text text style to use
     453     */
     454    private void displayText(GlyphVector gv, String s, int x, int y, boolean disabled, TextElement text) {
     455        if (isInactiveMode || disabled) {
     456            g.setColor(inactiveColor);
     457            if (gv != null) {
     458                g.drawGlyphVector(gv, x, y);
     459            } else {
     460                g.setFont(text.font);
     461                g.drawString(s, x, y);
     462            }
     463        } else if (text.haloRadius != null) {
     464            g.setStroke(new BasicStroke(2*text.haloRadius, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND));
     465            g.setColor(text.haloColor);
     466            if (gv == null) {
     467                FontRenderContext frc = g.getFontRenderContext();
     468                gv = text.font.createGlyphVector(frc, s);
     469            }
     470            Shape textOutline = gv.getOutline(x, y);
     471            g.draw(textOutline);
     472            g.setStroke(new BasicStroke());
     473            g.setColor(text.color);
     474            g.fill(textOutline);
     475        } else {
     476            g.setColor(text.color);
     477            if (gv != null) {
     478                g.drawGlyphVector(gv, x, y);
     479            } else {
     480                g.setFont(text.font);
     481                g.drawString(s, x, y);
     482            }
     483        }
     484    }
     485   
    444486    protected void drawArea(OsmPrimitive osm, Path2D.Double path, Color color, MapImage fillImage, TextElement text) {
    445487
     
    500542                    area.contains(centeredNBounds) // slow but nice
    501543            ) {
    502                 if (isInactiveMode || osm.isDisabled()) {
    503                     g.setColor(inactiveColor);
    504                 } else {
    505                     g.setColor(text.color);
    506                 }
    507544                Font defaultFont = g.getFont();
    508                 g.setFont (text.font);
    509                 g.drawString (name,
    510                         (int)(centeredNBounds.getMinX() - nb.getMinX()),
    511                         (int)(centeredNBounds.getMinY() - nb.getMinY()));
     545                int x = (int)(centeredNBounds.getMinX() - nb.getMinX());
     546                int y = (int)(centeredNBounds.getMinY() - nb.getMinY());
     547                displayText(null, name, x, y, osm.isDisabled(), text);
    512548                g.setFont(defaultFont);
    513549            }
     
    588624            } else throw new AssertionError();
    589625        }
    590         if (isInactiveMode || n.isDisabled()) {
    591             g.setColor(inactiveColor);
    592         } else {
    593             g.setColor(text.color);
    594         }
    595         if (text.haloRadius != null) {
    596             g.setStroke(new BasicStroke(2*text.haloRadius, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND));
    597             g.setColor(text.haloColor);
    598             FontRenderContext frc = g.getFontRenderContext();
    599             GlyphVector gv = text.font.createGlyphVector(frc, s);
    600             Shape textOutline = gv.getOutline(x, y);
    601             g.draw(textOutline);
    602             g.setStroke(new BasicStroke());
    603             g.setColor(text.color);
    604             g.fill(textOutline);
    605         } else {
    606             g.drawString(s, x, y);
    607         }
     626        displayText(null, s, x, y, n.isDisabled(), text);
    608627        g.setFont(defaultFont);
    609628    }
     
    11511170            }
    11521171        }
    1153         if (text.haloRadius != null) {
    1154             Shape textOutline = gv.getOutline();
    1155             g.setStroke(new BasicStroke(2*text.haloRadius, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND));
    1156             g.setColor(text.haloColor);
    1157             g.draw(textOutline);
    1158             g.setStroke(new BasicStroke());
    1159             g.setColor(text.color);
    1160             g.fill(textOutline);
    1161         } else {
    1162             g.setColor(text.color);
    1163             g.drawGlyphVector(gv, 0, 0);
    1164         }
     1172        displayText(gv, null, 0, 0, way.isDisabled(), text);
    11651173    }
    11661174
Note: See TracChangeset for help on using the changeset viewer.