- Timestamp:
- 2011-03-12T10:27:24+01:00 (14 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/MapPainter.java
r3968 r3979 12 12 import java.awt.Polygon; 13 13 import java.awt.Rectangle; 14 import java.awt.Shape; 14 15 import java.awt.TexturePaint; 15 16 import java.awt.font.FontRenderContext; … … 315 316 gv.setGlyphTransform(i, trfm); 316 317 } 317 g.setColor(text.color); 318 g.drawGlyphVector(gv, 0, 0); 319 318 if (text.haloRadius != null) { 319 Shape textOutline = gv.getOutline(); 320 g.setStroke(new BasicStroke(2*text.haloRadius, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND)); 321 g.setColor(text.haloColor); 322 g.draw(textOutline); 323 g.setStroke(new BasicStroke()); 324 g.setColor(text.color); 325 g.fill(textOutline); 326 } else { 327 g.setColor(text.color); 328 g.drawGlyphVector(gv, 0, 0); 329 } 320 330 } 321 331 … … 489 499 return; 490 500 491 if (inactive || n.isDisabled()) {492 g.setColor(inactiveColor);493 } else {494 g.setColor(text.color);495 }496 501 Font defaultFont = g.getFont(); 497 502 g.setFont(text.font); … … 538 543 } else throw new AssertionError(); 539 544 } 540 g.drawString(s, x, y); 545 if (inactive || n.isDisabled()) { 546 g.setColor(inactiveColor); 547 } else { 548 g.setColor(text.color); 549 } 550 if (text.haloRadius != null) { 551 g.setStroke(new BasicStroke(2*text.haloRadius, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND)); 552 g.setColor(text.haloColor); 553 FontRenderContext frc = g.getFontRenderContext(); 554 GlyphVector gv = text.font.createGlyphVector(frc, s); 555 Shape textOutline = gv.getOutline(x, y); 556 g.draw(textOutline); 557 g.setStroke(new BasicStroke()); 558 g.setColor(text.color); 559 g.fill(textOutline); 560 } else { 561 g.drawString(s, x, y); 562 } 541 563 g.setFont(defaultFont); 542 564 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/NodeElemStyle.java
r3969 r3979 6 6 import java.awt.BasicStroke; 7 7 import java.awt.Color; 8 import java.awt.Font;9 8 import java.awt.Stroke; 10 9 … … 93 92 public VerticalTextAlignment vAlign; 94 93 95 public NodeTextElement( String textKey, HorizontalTextAlignment hAlign, VerticalTextAlignment vAlign, Font font, int xOffset, int yOffset, Color color) {96 super(text Key, font, xOffset, yOffset, color);94 public NodeTextElement(TextElement text, HorizontalTextAlignment hAlign, VerticalTextAlignment vAlign) { 95 super(text); 97 96 CheckParameterUtil.ensureParameterNotNull(hAlign); 98 97 CheckParameterUtil.ensureParameterNotNull(vAlign); … … 192 191 vAlign = VerticalTextAlignment.BELOW; 193 192 } 194 text = new NodeTextElement(te .textKey, hAlign, vAlign, te.font, te.xOffset, te.yOffset, te.color);193 text = new NodeTextElement(te, hAlign, vAlign); 195 194 } 196 195 -
trunk/src/org/openstreetmap/josm/gui/mappaint/TextElement.java
r3967 r3979 10 10 11 11 import org.openstreetmap.josm.tools.CheckParameterUtil; 12 import org.openstreetmap.josm.tools.Utils; 12 13 13 14 public class TextElement { … … 19 20 public int yOffset; 20 21 public Color color; 22 public Float haloRadius; 23 public Color haloColor; 21 24 22 public TextElement(String textKey, Font font, int xOffset, int yOffset, Color color ) {25 public TextElement(String textKey, Font font, int xOffset, int yOffset, Color color, Float haloRadius, Color haloColor) { 23 26 CheckParameterUtil.ensureParameterNotNull(font); 24 27 CheckParameterUtil.ensureParameterNotNull(color); … … 28 31 this.yOffset = yOffset; 29 32 this.color = color; 33 this.haloRadius = haloRadius; 34 this.haloColor = haloColor; 35 } 36 37 public TextElement(TextElement other) { 38 this.textKey = other.textKey; 39 this.font = other.font; 40 this.xOffset = other.xOffset; 41 this.yOffset = other.yOffset; 42 this.color = other.color; 43 this.haloColor = other.haloColor; 44 this.haloRadius = other.haloRadius; 30 45 } 31 46 … … 58 73 59 74 Color color = c.get("text-color", defTextColor, Color.class); 60 61 return new TextElement(textKey, font, (int) xOffset, - (int) yOffset, color); 75 float alpha = c.get("text-opacity", 1f, Float.class); 76 color = new Color(color.getRed(), color.getGreen(), 77 color.getBlue(), Utils.color_float2int(alpha)); 78 79 Float haloRadius = c.get("text-halo-radius", null, Float.class); 80 if (haloRadius != null && haloRadius <= 0) { 81 haloRadius = null; 82 } 83 Color haloColor = null; 84 if (haloRadius != null) { 85 haloColor = c.get("text-halo-color", Utils.complement(color), Color.class); 86 float haloAlpha = c.get("text-halo-opacity", 1f, Float.class); 87 haloColor = new Color(haloColor.getRed(), haloColor.getGreen(), 88 haloColor.getBlue(), Utils.color_float2int(haloAlpha)); 89 } 90 91 return new TextElement(textKey, font, (int) xOffset, - (int) yOffset, color, haloRadius, haloColor); 62 92 } 63 93 … … 71 101 xOffset == other.xOffset && 72 102 yOffset == other.yOffset && 73 equal(color, other.color); 103 equal(color, other.color) && 104 equal(haloRadius, other.haloRadius) && 105 equal(haloColor, other.haloColor); 74 106 } 75 107 … … 82 114 hash = 79 * hash + yOffset; 83 115 hash = 79 * hash + color.hashCode(); 116 hash = 79 * hash + (haloRadius != null ? Float.floatToIntBits(haloRadius) : 0); 117 hash = 79 * hash + (haloColor != null ? haloColor.hashCode() : 0); 84 118 return hash; 85 119 } -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r3879 r3979 160 160 } 161 161 162 public static Color complement(Color clr) { 163 return new Color(255 - clr.getRed(), 255 - clr.getGreen(), 255 - clr.getBlue(), clr.getAlpha()); 164 } 162 165 }
Note:
See TracChangeset
for help on using the changeset viewer.