Package org.openstreetmap.josm.data.osm
Class DefaultNameFormatter
java.lang.Object
org.openstreetmap.josm.data.osm.DefaultNameFormatter
- All Implemented Interfaces:
HistoryNameFormatter,NameFormatter
This is the default implementation of a
NameFormatter for names of IPrimitives
and HistoryOsmPrimitives.- Since:
- 12663 (moved from
guipackage), 1990
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String[]The default list of tags which are used as naming tags in relations.private static final List<NameFormatterHook>private static DefaultNameFormatterthe current list of tags used as naming tags in relationsprivate final Comparator<INode>private static final CachingProperty<Boolean>private static final CachingProperty<Boolean>private static final CachingProperty<Boolean>private static final CachingProperty<Boolean>private static final CachingProperty<Boolean>private final Comparator<IRelation<?>>private final Comparator<IWay<?>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static StringbuildDefaultToolTip(long id, Map<String, String> tags) buildDefaultToolTip(HistoryOsmPrimitive primitive) Builds a default tooltip text for an HistoryOsmPrimitiveprimitive.buildDefaultToolTip(IPrimitive primitive) Builds a default tooltip text for the primitiveprimitive.protected voiddecorateNameWithId(StringBuilder name, HistoryOsmPrimitive primitive) Decorates the name of primitive with its id, if the preferenceosm-primitives.showidis set.protected voiddecorateNameWithId(StringBuilder name, IPrimitive primitive) Decorates the name of primitive with its id and version, if the preferencesosm-primitives.showidandosm-primitives.showversionare set.protected voiddecorateNameWithNodes(StringBuilder name, IWay<?> way) Decorates the name of primitive with nodes countFormats a name for aChangeset.format(HistoryNode node) Formats a name for aHistoryNode.format(HistoryRelation relation) Formats a name for aHistoryRelation.format(HistoryWay way) Formats a name for aHistoryWay.Formats a name for aINode.format(IPrimitive osm) Formats a name for anIPrimitive.Formats a name for aIRelation.Formats a name for aIWay.private static StringformatAddress(Tagged osm) formatAsHtmlUnorderedList(Collection<? extends OsmPrimitive> primitives, int maxElements) Formats the given collection of primitives as an HTML unordered list.formatAsHtmlUnorderedList(OsmPrimitive primitive) Formats the given primitive as an HTML unordered list.private static Stringprivate static Stringprivate static StringBuilderformatRelationNameAndType(IRelation<?> relation, StringBuilder result, TaggingPreset preset) static DefaultNameFormatterReplies the unique instance of this formatterprivate static StringgetNameTagValue(IRelation<?> relation, String nameTag) Replies the list of naming tags used in relations.Gets a comparator that sorts the nodes by the string that this formatter would create for themComparator<IRelation<?>>Gets a comparator that sorts the relations by the string that this formatter would create for themprivate static StringgetRelationName(IRelation<?> relation) private static StringgetRelationTypeName(IRelation<?> relation) Comparator<IWay<?>>Gets a comparator that sorts the ways by the string that this formatter would create for themstatic voidRegisters a format hook.static StringremoveBiDiCharacters(String string) Removes the bidirectional text characters U+200C, U+200E, U+200F from the stringstatic voidUnregisters a format hook.
-
Field Details
-
instance
-
formatHooks
-
PROPERTY_SHOW_ID
-
PROPERTY_SHOW_ID_NEW_PRIMITIVES
-
PROPERTY_SHOW_VERSION
-
PROPERTY_SHOW_COOR
-
PROPERTY_LOCALIZE_NAME
-
HIGHWAY_RAILWAY_WATERWAY_LANDUSE_BUILDING
-
DEFAULT_NAMING_TAGS_FOR_RELATIONS
The default list of tags which are used as naming tags in relations. A ? prefix indicates a boolean value, for which the key (instead of the value) is used. -
namingTagsForRelations
the current list of tags used as naming tags in relations -
nodeComparator
-
wayComparator
-
relationComparator
-
-
Constructor Details
-
DefaultNameFormatter
public DefaultNameFormatter()
-
-
Method Details
-
getInstance
Replies the unique instance of this formatter- Returns:
- the unique instance of this formatter
-
registerFormatHook
Registers a format hook. Adds the hook at the first position of the format hooks. (for plugins)- Parameters:
hook- the format hook. Ignored if null.
-
unregisterFormatHook
Unregisters a format hook. Removes the hook from the list of format hooks.- Parameters:
hook- the format hook. Ignored if null.
-
getNamingtagsForRelations
Replies the list of naming tags used in relations. The list is given (in this order) by:- by the tag names in the preference
relation.nameOrder - by the default tags in
DEFAULT_NAMING_TAGS_FOR_RELATIONS
- Returns:
- the list of naming tags used in relations
- by the tag names in the preference
-
decorateNameWithId
Decorates the name of primitive with its id and version, if the preferencesosm-primitives.showidandosm-primitives.showversionare set. Shows unique id ifosm-primitives.showid.new-primitivesis set- Parameters:
name- the name without the idprimitive- the primitive
-
decorateNameWithNodes
Decorates the name of primitive with nodes count- Parameters:
name- the name without the nodes countway- the way- Since:
- 18808
-
format
Formats a name for anIPrimitive.- Parameters:
osm- the primitive- Returns:
- the name
- Since:
- 10991, 13564 (signature)
-
format
Description copied from interface:NameFormatterFormats a name for aINode.- Specified by:
formatin interfaceNameFormatter- Parameters:
node- the node- Returns:
- the name
-
getNodeComparator
Description copied from interface:NameFormatterGets a comparator that sorts the nodes by the string that this formatter would create for them- Specified by:
getNodeComparatorin interfaceNameFormatter- Returns:
- That comparator
-
format
Description copied from interface:NameFormatterFormats a name for aIWay.- Specified by:
formatin interfaceNameFormatter- Parameters:
way- the way- Returns:
- the name
-
formatLocalName
-
formatLocalName
-
formatAddress
-
getWayComparator
Description copied from interface:NameFormatterGets a comparator that sorts the ways by the string that this formatter would create for them- Specified by:
getWayComparatorin interfaceNameFormatter- Returns:
- That comparator
-
format
Description copied from interface:NameFormatterFormats a name for aIRelation.- Specified by:
formatin interfaceNameFormatter- Parameters:
relation- the relation- Returns:
- the name
-
formatRelationNameAndType
private static StringBuilder formatRelationNameAndType(IRelation<?> relation, StringBuilder result, TaggingPreset preset) -
getRelationComparator
Description copied from interface:NameFormatterGets a comparator that sorts the relations by the string that this formatter would create for them- Specified by:
getRelationComparatorin interfaceNameFormatter- Returns:
- That comparator
-
getRelationTypeName
-
getNameTagValue
-
getRelationName
-
format
Description copied from interface:NameFormatterFormats a name for aChangeset.- Specified by:
formatin interfaceNameFormatter- Parameters:
changeset- the changeset- Returns:
- the name
-
buildDefaultToolTip
Builds a default tooltip text for the primitiveprimitive.- Parameters:
primitive- the primitive- Returns:
- the tooltip text
-
buildDefaultToolTip
-
decorateNameWithId
Decorates the name of primitive with its id, if the preferenceosm-primitives.showidis set.The id is appended to the
StringBuilderpassed inname.- Parameters:
name- the name without the idprimitive- the primitive
-
format
Description copied from interface:HistoryNameFormatterFormats a name for aHistoryNode.- Specified by:
formatin interfaceHistoryNameFormatter- Parameters:
node- the node- Returns:
- the name
-
format
Description copied from interface:HistoryNameFormatterFormats a name for aHistoryWay.- Specified by:
formatin interfaceHistoryNameFormatter- Parameters:
way- the way- Returns:
- the name
-
format
Description copied from interface:HistoryNameFormatterFormats a name for aHistoryRelation.- Specified by:
formatin interfaceHistoryNameFormatter- Parameters:
relation- the relation- Returns:
- the name
-
buildDefaultToolTip
Builds a default tooltip text for an HistoryOsmPrimitiveprimitive.- Parameters:
primitive- the primitive- Returns:
- the tooltip text
-
formatAsHtmlUnorderedList
public String formatAsHtmlUnorderedList(Collection<? extends OsmPrimitive> primitives, int maxElements) Formats the given collection of primitives as an HTML unordered list.- Parameters:
primitives- collection of primitives to formatmaxElements- the maximum number of elements to display- Returns:
- HTML unordered list
-
formatAsHtmlUnorderedList
Formats the given primitive as an HTML unordered list.- Parameters:
primitive- primitive to format- Returns:
- HTML unordered list
-
removeBiDiCharacters
Removes the bidirectional text characters U+200C, U+200E, U+200F from the string- Parameters:
string- the string- Returns:
- the string with the bidirectional text characters removed
-