Changeset 16937 in josm for trunk/src/org
- Timestamp:
- 2020-08-26T21:58:28+02:00 (4 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/DefaultNameFormatter.java
r16824 r16937 7 7 import static org.openstreetmap.josm.tools.I18n.trn; 8 8 9 import java.awt.ComponentOrientation;10 9 import java.util.ArrayList; 11 10 import java.util.Arrays; … … 16 15 import java.util.LinkedList; 17 16 import java.util.List; 18 import java.util.Locale;19 17 import java.util.Map; 20 18 import java.util.Objects; … … 44 42 */ 45 43 public class DefaultNameFormatter implements NameFormatter, HistoryNameFormatter { 46 44 /** 45 * U+2068 FIRST STRONG ISOLATE 46 */ 47 public static final char BIDI_FIRST_STRONG_ISOLATE = '\u2068'; 48 /** 49 * U+2069 POP DIRECTIONAL ISOLATE 50 */ 51 public static final char BIDI_POP_DIRECTIONAL_ISOLATE = '\u2069'; 47 52 private static DefaultNameFormatter instance; 48 53 … … 142 147 primitive.getUniqueId() : primitive.getId(); 143 148 if (Config.getPref().getBoolean("osm-primitives.showversion") && version > 0) { 144 name.append(tr(" [id: {0}, v{1}]", id, version));149 bdi(name, tr(" [id: {0}, v{1}]", id, version)); 145 150 } else { 146 name.append(tr(" [id: {0}]", id));151 bdi(name, tr(" [id: {0}]", id)); 147 152 } 148 153 } else if (Config.getPref().getBoolean("osm-primitives.showversion")) { 149 name.append(tr(" [v{0}]", version));154 bdi(name, tr(" [v{0}]", version)); 150 155 } 151 156 } … … 206 211 n = node.isNew() ? tr("node") : Long.toString(node.getId()); 207 212 } 208 name.append(n);213 bdi(name, n); 209 214 } else { 210 215 preset.nameTemplate.appendText(name, (TemplateEngineDataProvider) node); 211 216 } 212 217 if (node.isLatLonKnown() && Config.getPref().getBoolean("osm-primitives.showcoor")) { 213 name.append(" \u200E("); 214 name.append(CoordinateFormatManager.getDefaultFormat().toString(node, ", ")); 215 name.append(')'); 218 name.append(' '); 219 bdiParen(name, CoordinateFormatManager.getDefaultFormat().toString(node, ", ")); 216 220 } 217 221 } … … 235 239 public String format(IWay<?> way) { 236 240 StringBuilder name = new StringBuilder(); 237 238 char mark;239 // If current language is left-to-right (almost all languages)240 if (ComponentOrientation.getOrientation(Locale.getDefault()).isLeftToRight()) {241 // will insert Left-To-Right Mark to ensure proper display of text in the case when object name is right-to-left242 mark = '\u200E';243 } else {244 // otherwise will insert Right-To-Left Mark to ensure proper display in the opposite case245 mark = '\u200F';246 }247 // Initialize base direction of the string248 name.append(mark);249 250 241 if (way.isIncomplete()) { 251 242 name.append(tr("incomplete")); … … 293 284 } 294 285 295 name.append(n);286 bdi(name, n); 296 287 } else { 297 288 preset.nameTemplate.appendText(name, (TemplateEngineDataProvider) way); … … 303 294 /* I18n: count of nodes as parameter */ 304 295 String nodes = trn("{0} node", "{0} nodes", nodesNo, nodesNo); 305 name.append(mark).append(" (").append(nodes).append(')'); 296 name.append(" "); 297 bdiParen(name, nodes); 306 298 } 307 299 decorateNameWithId(name, way); … … 643 635 644 636 /** 637 * Wraps the content in a bidirectional isolate 638 * @param builder the builder to append to 639 * @param content the text to wrap 640 */ 641 private static void bdi(StringBuilder builder, String content) { 642 builder.append(BIDI_FIRST_STRONG_ISOLATE); 643 builder.append(content); 644 builder.append(BIDI_POP_DIRECTIONAL_ISOLATE); 645 } 646 647 /** 648 * Wraps the content in parenthesis and a bidirectional isolate 649 * @param builder the builder to append to 650 * @param content the text to wrap 651 */ 652 private static void bdiParen(StringBuilder builder, String content) { 653 builder.append(BIDI_FIRST_STRONG_ISOLATE); 654 builder.append('('); 655 builder.append(content); 656 builder.append(')'); 657 builder.append(BIDI_POP_DIRECTIONAL_ISOLATE); 658 } 659 660 /** 645 661 * Builds a default tooltip text for an HistoryOsmPrimitive <code>primitive</code>. 646 662 * -
trunk/src/org/openstreetmap/josm/gui/datatransfer/PrimitiveTransferable.java
r16326 r16937 91 91 sb.append(OsmPrimitiveType.from(primitive).getAPIName()).append(' ').append(primitive.getId()); 92 92 } 93 return sb.toString() .replace("\u200E", "").replace("\u200F", "");93 return sb.toString(); 94 94 } 95 95 }
Note:
See TracChangeset
for help on using the changeset viewer.