public class DefaultNameFormatter extends Object implements NameFormatter, HistoryNameFormatter
NameFormatter
for names of OsmPrimitive
s
and HistoryOsmPrimitive
s.Modifier and Type | Field and Description |
---|---|
protected static String[] |
DEFAULT_NAMING_TAGS_FOR_RELATIONS
The default list of tags which are used as naming tags in relations.
|
private static List<NameFormatterHook> |
formatHooks |
private static DefaultNameFormatter |
instance |
private static List<String> |
namingTagsForRelations
the current list of tags used as naming tags in relations
|
private Comparator<Node> |
nodeComparator |
private Comparator<Relation> |
relationComparator |
private Comparator<Way> |
wayComparator |
Constructor and Description |
---|
DefaultNameFormatter() |
Modifier and Type | Method and Description |
---|---|
String |
buildDefaultToolTip(HistoryOsmPrimitive primitive)
Builds a default tooltip text for an HistoryOsmPrimitive
primitive . |
String |
buildDefaultToolTip(IPrimitive primitive)
Builds a default tooltip text for the primitive
primitive . |
private static String |
buildDefaultToolTip(long id,
Map<String,String> tags) |
protected void |
decorateNameWithId(StringBuilder name,
HistoryOsmPrimitive primitive)
Decorates the name of primitive with its id, if the preference
osm-primitives.showid is set.
|
protected void |
decorateNameWithId(StringBuilder name,
IPrimitive primitive)
Decorates the name of primitive with its id, if the preference
osm-primitives.showid is set.
|
String |
format(Changeset changeset)
Formats a name for a
Changeset . |
String |
format(HistoryNode node)
Formats a name for a
HistoryNode . |
String |
format(HistoryRelation relation)
Formats a name for a
HistoryRelation . |
String |
format(HistoryWay way)
Formats a name for a
HistoryWay . |
String |
format(Node node)
Formats a name for a
Node . |
String |
format(Relation relation)
Formats a name for a
Relation . |
String |
format(Way way)
Formats a name for a
Way . |
String |
formatAsHtmlUnorderedList(Collection<? extends OsmPrimitive> primitives)
Formats the given collection of primitives as an HTML unordered list.
|
String |
formatAsHtmlUnorderedList(OsmPrimitive... primitives)
Formats the given primitive(s) as an HTML unordered list.
|
private void |
formatRelationNameAndType(Relation relation,
StringBuilder result,
TaggingPreset preset) |
static DefaultNameFormatter |
getInstance()
Replies the unique instance of this formatter
|
private static String |
getNameTagValue(IRelation relation,
String nameTag) |
static List<String> |
getNamingtagsForRelations()
Replies the list of naming tags used in relations.
|
Comparator<Node> |
getNodeComparator() |
Comparator<Relation> |
getRelationComparator() |
private String |
getRelationName(IRelation relation) |
private static String |
getRelationTypeName(IRelation relation) |
Comparator<Way> |
getWayComparator() |
static void |
registerFormatHook(NameFormatterHook hook)
Registers a format hook.
|
static void |
unregisterFormatHook(NameFormatterHook hook)
Unregisters a format hook.
|
private static DefaultNameFormatter instance
private static final List<NameFormatterHook> formatHooks
protected static final String[] DEFAULT_NAMING_TAGS_FOR_RELATIONS
private static List<String> namingTagsForRelations
private final Comparator<Node> nodeComparator
private final Comparator<Way> wayComparator
private final Comparator<Relation> relationComparator
public DefaultNameFormatter()
public static DefaultNameFormatter getInstance()
public static void registerFormatHook(NameFormatterHook hook)
hook
- the format hook. Ignored if null.public static void unregisterFormatHook(NameFormatterHook hook)
hook
- the format hook. Ignored if null.public static List<String> getNamingtagsForRelations()
DEFAULT_NAMING_TAGS_FOR_RELATIONS
protected void decorateNameWithId(StringBuilder name, IPrimitive primitive)
name
- the name without the idprimitive
- the primitivepublic String format(Node node)
NameFormatter
Node
.format
in interface NameFormatter
node
- the nodepublic Comparator<Node> getNodeComparator()
getNodeComparator
in interface NameFormatter
public String format(Way way)
NameFormatter
Way
.format
in interface NameFormatter
way
- the waypublic Comparator<Way> getWayComparator()
getWayComparator
in interface NameFormatter
public String format(Relation relation)
NameFormatter
Relation
.format
in interface NameFormatter
relation
- the relationprivate void formatRelationNameAndType(Relation relation, StringBuilder result, TaggingPreset preset)
public Comparator<Relation> getRelationComparator()
getRelationComparator
in interface NameFormatter
private static String getRelationTypeName(IRelation relation)
private static String getNameTagValue(IRelation relation, String nameTag)
private String getRelationName(IRelation relation)
public String format(Changeset changeset)
NameFormatter
Changeset
.format
in interface NameFormatter
changeset
- the changesetpublic String buildDefaultToolTip(IPrimitive primitive)
primitive
.primitive
- the primitmiveprivate static String buildDefaultToolTip(long id, Map<String,String> tags)
protected void decorateNameWithId(StringBuilder name, HistoryOsmPrimitive primitive)
StringBuilder
passed in name
.name
- the name without the idprimitive
- the primitivepublic String format(HistoryNode node)
HistoryNameFormatter
HistoryNode
.format
in interface HistoryNameFormatter
node
- the nodepublic String format(HistoryWay way)
HistoryNameFormatter
HistoryWay
.format
in interface HistoryNameFormatter
way
- the waypublic String format(HistoryRelation relation)
HistoryNameFormatter
HistoryRelation
.format
in interface HistoryNameFormatter
relation
- the relationpublic String buildDefaultToolTip(HistoryOsmPrimitive primitive)
primitive
.primitive
- the primitmivepublic String formatAsHtmlUnorderedList(Collection<? extends OsmPrimitive> primitives)
primitives
- collection of primitives to formatpublic String formatAsHtmlUnorderedList(OsmPrimitive... primitives)
primitives
- primitive(s) to format