Changeset 16950 in josm for trunk/src/org
- Timestamp:
- 2020-08-28T22:38:19+02:00 (4 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/DefaultNameFormatter.java
r16937 r16950 7 7 import static org.openstreetmap.josm.tools.I18n.trn; 8 8 9 import java.awt.ComponentOrientation; 9 10 import java.util.ArrayList; 10 11 import java.util.Arrays; … … 15 16 import java.util.LinkedList; 16 17 import java.util.List; 18 import java.util.Locale; 17 19 import java.util.Map; 18 20 import java.util.Objects; … … 42 44 */ 43 45 public class DefaultNameFormatter implements NameFormatter, HistoryNameFormatter { 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'; 46 52 47 private static DefaultNameFormatter instance; 53 48 … … 147 142 primitive.getUniqueId() : primitive.getId(); 148 143 if (Config.getPref().getBoolean("osm-primitives.showversion") && version > 0) { 149 bdi(name,tr(" [id: {0}, v{1}]", id, version));144 name.append(tr(" [id: {0}, v{1}]", id, version)); 150 145 } else { 151 bdi(name,tr(" [id: {0}]", id));146 name.append(tr(" [id: {0}]", id)); 152 147 } 153 148 } else if (Config.getPref().getBoolean("osm-primitives.showversion")) { 154 bdi(name,tr(" [v{0}]", version));149 name.append(tr(" [v{0}]", version)); 155 150 } 156 151 } … … 211 206 n = node.isNew() ? tr("node") : Long.toString(node.getId()); 212 207 } 213 bdi(name,n);208 name.append(n); 214 209 } else { 215 210 preset.nameTemplate.appendText(name, (TemplateEngineDataProvider) node); 216 211 } 217 212 if (node.isLatLonKnown() && Config.getPref().getBoolean("osm-primitives.showcoor")) { 218 name.append(' '); 219 bdiParen(name, CoordinateFormatManager.getDefaultFormat().toString(node, ", ")); 213 name.append(" \u200E("); 214 name.append(CoordinateFormatManager.getDefaultFormat().toString(node, ", ")); 215 name.append(')'); 220 216 } 221 217 } … … 239 235 public String format(IWay<?> way) { 240 236 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-left 242 mark = '\u200E'; 243 } else { 244 // otherwise will insert Right-To-Left Mark to ensure proper display in the opposite case 245 mark = '\u200F'; 246 } 247 // Initialize base direction of the string 248 name.append(mark); 249 241 250 if (way.isIncomplete()) { 242 251 name.append(tr("incomplete")); … … 284 293 } 285 294 286 bdi(name,n);295 name.append(n); 287 296 } else { 288 297 preset.nameTemplate.appendText(name, (TemplateEngineDataProvider) way); … … 294 303 /* I18n: count of nodes as parameter */ 295 304 String nodes = trn("{0} node", "{0} nodes", nodesNo, nodesNo); 296 name.append(" "); 297 bdiParen(name, nodes); 305 name.append(mark).append(" (").append(nodes).append(')'); 298 306 } 299 307 decorateNameWithId(name, way); … … 635 643 636 644 /** 637 * Wraps the content in a bidirectional isolate638 * @param builder the builder to append to639 * @param content the text to wrap640 */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 isolate649 * @param builder the builder to append to650 * @param content the text to wrap651 */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 /**661 645 * Builds a default tooltip text for an HistoryOsmPrimitive <code>primitive</code>. 662 646 * -
trunk/src/org/openstreetmap/josm/gui/datatransfer/PrimitiveTransferable.java
r16937 r16950 91 91 sb.append(OsmPrimitiveType.from(primitive).getAPIName()).append(' ').append(primitive.getId()); 92 92 } 93 return sb.toString() ;93 return sb.toString().replace("\u200E", "").replace("\u200F", ""); 94 94 } 95 95 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDialog.java
r16947 r16950 129 129 try { 130 130 for (IPrimitive osm : sel) { 131 String heading = tr("Styles for \"{0}\":", osm.getDisplayName(DefaultNameFormatter.getInstance()) 132 .replace(Character.toString(DefaultNameFormatter.BIDI_FIRST_STRONG_ISOLATE), "") 133 .replace(Character.toString(DefaultNameFormatter.BIDI_POP_DIRECTIONAL_ISOLATE), "")); 131 String heading = tr("Styles for \"{0}\":", osm.getDisplayName(DefaultNameFormatter.getInstance())); 134 132 txtMappaint.println(heading); 135 133 txtMappaint.println(repeatString("=", heading.length()));
Note:
See TracChangeset
for help on using the changeset viewer.