Changeset 4209 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2011-07-07T11:10:48+02:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/DefaultNameFormatter.java
r4144 r4209 12 12 import java.util.Comparator; 13 13 import java.util.HashSet; 14 import java.util.LinkedList; 14 15 import java.util.List; 15 16 import java.util.Set; … … 43 44 static private DefaultNameFormatter instance; 44 45 46 private static final LinkedList<NameFormatterHook> formatHooks = new LinkedList<NameFormatterHook>(); 47 45 48 /** 46 49 * Replies the unique instance of this formatter … … 53 56 } 54 57 return instance; 58 } 59 60 /** 61 * Registers a format hook. Adds the hook at the first position of the format hooks. 62 * (for plugins) 63 * 64 * @param hook the format hook. Ignored if null. 65 */ 66 public static void registerFormatHook(NameFormatterHook hook) { 67 if (hook == null) return; 68 if (!formatHooks.contains(hook)) { 69 formatHooks.add(0,hook); 70 } 71 } 72 73 /** 74 * Unregisters a format hook. Removes the hook from the list of format hooks. 75 * 76 * @param hook the format hook. Ignored if null. 77 */ 78 public static void unregisterFormatHook(NameFormatterHook hook) { 79 if (hook == null) return; 80 if (formatHooks.contains(hook)) { 81 formatHooks.remove(hook); 82 } 55 83 } 56 84 … … 141 169 } 142 170 name = decorateNameWithId(name, node); 171 172 for (NameFormatterHook hook: formatHooks) { 173 String hookResult = hook.checkFormat(node, name); 174 if (hookResult != null) { 175 return hookResult; 176 } 177 } 178 143 179 return name; 144 180 } … … 217 253 } 218 254 name = decorateNameWithId(name, way); 255 256 for (NameFormatterHook hook: formatHooks) { 257 String hookResult = hook.checkFormat(way, name); 258 if (hookResult != null) { 259 return hookResult; 260 } 261 } 262 219 263 return name; 220 264 } … … 264 308 } 265 309 name = decorateNameWithId(name, relation); 310 311 for (NameFormatterHook hook: formatHooks) { 312 String hookResult = hook.checkFormat(relation, name); 313 if (hookResult != null) { 314 return hookResult; 315 } 316 } 317 266 318 return name; 267 319 } … … 355 407 if (admin_level != null) { 356 408 name += "["+admin_level+"]"; 409 } 410 411 for (NameFormatterHook hook: formatHooks) { 412 String hookResult = hook.checkRelationTypeName(relation, name); 413 if (hookResult != null) { 414 return hookResult; 415 } 357 416 } 358 417 -
trunk/src/org/openstreetmap/josm/gui/OsmPrimitivRenderer.java
r3844 r4209 25 25 */ 26 26 public class OsmPrimitivRenderer implements ListCellRenderer, TableCellRenderer { 27 private DefaultNameFormatter formatter = new DefaultNameFormatter();27 private DefaultNameFormatter formatter = DefaultNameFormatter.getInstance(); 28 28 29 29 /**
Note:
See TracChangeset
for help on using the changeset viewer.