Ticket #8934: 8934-4a-String2GlyphVector.patch
File 8934-4a-String2GlyphVector.patch, 3.7 KB (added by , 11 years ago) |
---|
-
src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java
444 444 /** 445 445 * Displays text at specified position including its halo, if applicable. 446 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} 447 * @param s text to display 449 448 * @param x X position 450 449 * @param y Y position 451 450 * @param disabled {@code true} if element is disabled (filtered out) 452 451 * @param text text style to use 453 452 */ 454 private void displayText(GlyphVector gv, String s, int x, int y, boolean disabled, TextElement text) { 453 private void displayText(String s, int x, int y, boolean disabled, TextElement text) { 454 FontRenderContext frc = g.getFontRenderContext(); 455 GlyphVector gv = text.font.createGlyphVector(frc, s); 456 displayText(gv, x, y, disabled, text); 457 } 458 459 /** 460 * Displays text at specified position including its halo, if applicable. 461 * 462 * @param gv text's glyphs to display 463 * @param x X position 464 * @param y Y position 465 * @param disabled {@code true} if element is disabled (filtered out) 466 * @param text text style to use 467 */ 468 private void displayText(GlyphVector gv, int x, int y, boolean disabled, TextElement text) { 455 469 if (isInactiveMode || disabled) { 456 470 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 } 471 g.drawGlyphVector(gv, x, y); 463 472 } else if (text.haloRadius != null) { 464 473 g.setStroke(new BasicStroke(2*text.haloRadius, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND)); 465 474 g.setColor(text.haloColor); 466 if (gv == null) {467 FontRenderContext frc = g.getFontRenderContext();468 gv = text.font.createGlyphVector(frc, s);469 }470 475 Shape textOutline = gv.getOutline(x, y); 471 476 g.draw(textOutline); 472 477 g.setStroke(new BasicStroke()); … … 474 479 g.fill(textOutline); 475 480 } else { 476 481 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 } 482 g.drawGlyphVector(gv, x, y); 483 483 } 484 484 } 485 485 … … 544 544 Font defaultFont = g.getFont(); 545 545 int x = (int)(centeredNBounds.getMinX() - nb.getMinX()); 546 546 int y = (int)(centeredNBounds.getMinY() - nb.getMinY()); 547 displayText(n ull, name, x, y, osm.isDisabled(), text);547 displayText(name, x, y, osm.isDisabled(), text); 548 548 g.setFont(defaultFont); 549 549 } 550 550 } … … 623 623 y += box.y + box.height + metrics.getAscent() + 2; 624 624 } else throw new AssertionError(); 625 625 } 626 displayText( null,s, x, y, n.isDisabled(), text);626 displayText(s, x, y, n.isDisabled(), text); 627 627 g.setFont(defaultFont); 628 628 } 629 629 … … 1169 1169 gv.setGlyphTransform(i, trfm); 1170 1170 } 1171 1171 } 1172 displayText(gv, null,0, 0, way.isDisabled(), text);1172 displayText(gv, 0, 0, way.isDisabled(), text); 1173 1173 } 1174 1174 1175 1175 /**