Changeset 7752 in josm
- Timestamp:
- 2014-11-27T17:45:21+01:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java
r7621 r7752 28 28 import java.util.Collection; 29 29 import java.util.Collections; 30 import java.util.HashMap; 30 31 import java.util.Iterator; 31 32 import java.util.List; 33 import java.util.Map; 32 34 import java.util.concurrent.Callable; 33 35 import java.util.concurrent.ExecutionException; … … 235 237 } 236 238 237 private static Boolean IS_GLYPH_VECTOR_DOUBLE_TRANSLATION_BUG = null;239 private static Map<Font,Boolean> IS_GLYPH_VECTOR_DOUBLE_TRANSLATION_BUG = new HashMap<>(); 238 240 239 241 /** … … 259 261 * method which apparently no longer gives a useful result for Java 7. 260 262 */ 261 public static boolean isGlyphVectorDoubleTranslationBug() { 262 if (IS_GLYPH_VECTOR_DOUBLE_TRANSLATION_BUG != null) 263 return IS_GLYPH_VECTOR_DOUBLE_TRANSLATION_BUG; 264 String overridePref = Main.pref.get("glyph-bug", "false"); 263 public static boolean isGlyphVectorDoubleTranslationBug(Font font) { 264 Boolean cached = IS_GLYPH_VECTOR_DOUBLE_TRANSLATION_BUG.get(font); 265 if (cached != null) 266 return cached; 267 String overridePref = Main.pref.get("glyph-bug", "auto"); 265 268 if ("auto".equals(overridePref)) { 266 269 FontRenderContext frc = new FontRenderContext(null, false, false); 267 Font font = new Font("Dialog", Font.PLAIN, 12);268 270 GlyphVector gv = font.createGlyphVector(frc, "x"); 269 271 gv.setGlyphTransform(0, AffineTransform.getTranslateInstance(1000, 1000)); … … 272 274 // x is about 1000 on normal stystems and about 2000 when the bug occurs 273 275 int x = shape.getBounds().x; 274 IS_GLYPH_VECTOR_DOUBLE_TRANSLATION_BUG = x > 1500; 275 return IS_GLYPH_VECTOR_DOUBLE_TRANSLATION_BUG; 276 boolean isBug = x > 1500; 277 IS_GLYPH_VECTOR_DOUBLE_TRANSLATION_BUG.put(font, isBug); 278 return isBug; 276 279 } else { 277 280 boolean override = Boolean.parseBoolean(overridePref); 278 IS_GLYPH_VECTOR_DOUBLE_TRANSLATION_BUG = override;279 return IS_GLYPH_VECTOR_DOUBLE_TRANSLATION_BUG;281 IS_GLYPH_VECTOR_DOUBLE_TRANSLATION_BUG.put(font, override); 282 return override; 280 283 } 281 284 } … … 1206 1209 double off = -rect.getY() - rect.getHeight()/2 + text.yOffset; 1207 1210 trfm.translate(-rect.getWidth()/2, off); 1208 if (isGlyphVectorDoubleTranslationBug( )) {1211 if (isGlyphVectorDoubleTranslationBug(text.font)) { 1209 1212 // scale the translation components by one half 1210 1213 AffineTransform tmp = AffineTransform.getTranslateInstance(-0.5 * trfm.getTranslateX(), -0.5 * trfm.getTranslateY());
Note:
See TracChangeset
for help on using the changeset viewer.