- Timestamp:
- 2014-08-13T16:42:17+02:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r7343 r7383 60 60 import org.openstreetmap.josm.plugins.PluginInformation; 61 61 import org.openstreetmap.josm.tools.BugReportExceptionHandler; 62 import org.openstreetmap.josm.tools.FontsManager; 62 63 import org.openstreetmap.josm.tools.I18n; 63 64 import org.openstreetmap.josm.tools.ImageProvider; … … 346 347 Main.pref.updateSystemProperties(); 347 348 349 FontsManager.initialize(); 350 348 351 final JFrame mainFrame = new JFrame(tr("Java OpenStreetMap Editor")); 349 352 Main.parent = mainFrame; -
trunk/src/org/openstreetmap/josm/gui/mappaint/AreaElemStyle.java
r7136 r7383 34 34 } 35 35 36 public static AreaElemStyle create(Cascade c) { 36 public static AreaElemStyle create(final Environment env) { 37 final Cascade c = env.mc.getCascade(env.layer); 37 38 MapImage fillImage = null; 38 39 Color color = null; … … 75 76 Keyword textPos = c.get(TEXT_POSITION, null, Keyword.class); 76 77 if (textPos == null || "center".equals(textPos.val)) { 77 text = TextElement.create( c, PaintColors.AREA_TEXT.get(), true);78 text = TextElement.create(env, PaintColors.AREA_TEXT.get(), true); 78 79 } 79 80 -
trunk/src/org/openstreetmap/josm/gui/mappaint/BoxTextElemStyle.java
r7083 r7383 111 111 Cascade c = env.mc.getCascade(env.layer); 112 112 113 TextElement text = TextElement.create( c, DEFAULT_TEXT_COLOR, false);113 TextElement text = TextElement.create(env, DEFAULT_TEXT_COLOR, false); 114 114 if (text == null) return null; 115 115 // Skip any primitives that don't have text to draw. (Styles are recreated for any tag change.) -
trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyle.java
r7083 r7383 112 112 n = DEFAULT_FONT_NAME; 113 113 if (n == null) { 114 DEFAULT_FONT_NAME = n = Main.pref.get("mappaint.font", " Helvetica");114 DEFAULT_FONT_NAME = n = Main.pref.get("mappaint.font", "Droid Sans"); 115 115 } 116 116 } … … 174 174 } 175 175 176 protected static Font getFont(Cascade c ) {176 protected static Font getFont(Cascade c, String s) { 177 177 String name = c.get("font-family", getDefaultFontName(), String.class); 178 178 float size = c.get("font-size", getDefaultFontSize(), Float.class); … … 185 185 style = Font.ITALIC; 186 186 } 187 return getCachedFont(name, style | weight, Math.round(size)); 187 Font f = getCachedFont(name, style | weight, Math.round(size)); 188 if (f.canDisplayUpTo(s) == -1) 189 return f; 190 else { 191 // fallback if the string contains characters that cannot be 192 // rendered by the selected font 193 return getCachedFont("SansSerif", style | weight, Math.round(size)); 194 } 188 195 } 189 196 -
trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java
r7191 r7383 337 337 Cascade c = e.getValue(); 338 338 if (osm instanceof Way) { 339 addIfNotNull(sl, AreaElemStyle.create( c));339 addIfNotNull(sl, AreaElemStyle.create(env)); 340 340 addIfNotNull(sl, RepeatImageElemStyle.create(env)); 341 341 addIfNotNull(sl, LineElemStyle.createLine(env)); … … 354 354 } else if (osm instanceof Relation) { 355 355 if (((Relation)osm).isMultipolygon()) { 356 addIfNotNull(sl, AreaElemStyle.create( c));356 addIfNotNull(sl, AreaElemStyle.create(env)); 357 357 addIfNotNull(sl, RepeatImageElemStyle.create(env)); 358 358 addIfNotNull(sl, LineElemStyle.createLine(env)); -
trunk/src/org/openstreetmap/josm/gui/mappaint/LineTextElemStyle.java
r7083 r7383 18 18 this.text = text; 19 19 } 20 public static LineTextElemStyle create( Environment env) {21 Cascade c = env.mc.getCascade(env.layer);20 public static LineTextElemStyle create(final Environment env) { 21 final Cascade c = env.mc.getCascade(env.layer); 22 22 23 23 Keyword textPos = c.get(TEXT_POSITION, null, Keyword.class); … … 25 25 return null; 26 26 27 TextElement text = TextElement.create( c, PaintColors.TEXT.get(), false);27 TextElement text = TextElement.create(env, PaintColors.TEXT.get(), false); 28 28 if (text == null) 29 29 return null; -
trunk/src/org/openstreetmap/josm/gui/mappaint/TextElement.java
r7083 r7383 116 116 * @throws IllegalArgumentException thrown if {@code defaultTextColor} is null 117 117 */ 118 public static TextElement create( Cascade c, Color defaultTextColor, boolean defaultAnnotate) throws IllegalArgumentException{118 public static TextElement create(Environment env, Color defaultTextColor, boolean defaultAnnotate) throws IllegalArgumentException{ 119 119 CheckParameterUtil.ensureParameterNotNull(defaultTextColor); 120 Cascade c = env.mc.getCascade(env.layer); 120 121 121 122 LabelCompositionStrategy strategy = buildLabelCompositionStrategy(c, defaultAnnotate); 122 123 if (strategy == null) return null; 123 Font font = ElemStyle.getFont(c); 124 String s = strategy.compose(env.osm); 125 if (s == null) return null; 126 Font font = ElemStyle.getFont(c, s); 124 127 125 128 float xOffset = 0;
Note:
See TracChangeset
for help on using the changeset viewer.