org.openstreetmap.josm.gui
Class DefaultNameFormatter

java.lang.Object
  extended by org.openstreetmap.josm.gui.DefaultNameFormatter
All Implemented Interfaces:
org.openstreetmap.josm.data.osm.history.HistoryNameFormatter, org.openstreetmap.josm.data.osm.NameFormatter

public class DefaultNameFormatter
extends java.lang.Object
implements org.openstreetmap.josm.data.osm.NameFormatter, org.openstreetmap.josm.data.osm.history.HistoryNameFormatter

This is the default implementation of a NameFormatter for names of OsmPrimitives.


Field Summary
static java.lang.String[] DEFAULT_NAMING_TAGS_FOR_RELATIONS
          the default list of tags which are used as naming tags in relations
 
Constructor Summary
DefaultNameFormatter()
           
 
Method Summary
 java.lang.String buildDefaultToolTip(org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive primitive)
          Builds a default tooltip text for an HistoryOsmPrimitive primitive.
 java.lang.String buildDefaultToolTip(org.openstreetmap.josm.data.osm.IPrimitive primitive)
          Builds a default tooltip text for the primitive primitive.
protected  void decorateNameWithId(java.lang.StringBuilder name, org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive primitive)
          Decorates the name of primitive with its id, if the preference osm-primitives.showid is set.
protected  java.lang.String decorateNameWithId(java.lang.String name, org.openstreetmap.josm.data.osm.IPrimitive primitive)
          Decorates the name of primitive with its id, if the preference osm-primitives.showid is set.
 java.lang.String format(org.openstreetmap.josm.data.osm.Changeset changeset)
          Formats a name for a changeset
 java.lang.String format(org.openstreetmap.josm.data.osm.history.HistoryNode node)
          Formats a name for a history node
 java.lang.String format(org.openstreetmap.josm.data.osm.history.HistoryRelation relation)
          Formats a name for a HistoryRelation)
 java.lang.String format(org.openstreetmap.josm.data.osm.history.HistoryWay way)
          Formats a name for a way
 java.lang.String format(org.openstreetmap.josm.data.osm.INode node)
          Formats a name for a node
 java.lang.String format(org.openstreetmap.josm.data.osm.IRelation relation)
          Formats a name for a relation
 java.lang.String format(org.openstreetmap.josm.data.osm.IWay way)
          Formats a name for a way
static DefaultNameFormatter getInstance()
          Replies the unique instance of this formatter
static java.util.List<java.lang.String> getNamingtagsForRelations()
          Replies the list of naming tags used in relations.
 java.util.Comparator<org.openstreetmap.josm.data.osm.Node> getNodeComparator()
           
 java.util.Comparator<org.openstreetmap.josm.data.osm.Relation> getRelationComparator()
           
 java.util.Comparator<org.openstreetmap.josm.data.osm.Way> getWayComparator()
           
static void registerFormatHook(NameFormatterHook hook)
          Registers a format hook.
static void unregisterFormatHook(NameFormatterHook hook)
          Unregisters a format hook.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_NAMING_TAGS_FOR_RELATIONS

public static final java.lang.String[] DEFAULT_NAMING_TAGS_FOR_RELATIONS
the default list of tags which are used as naming tags in relations

Constructor Detail

DefaultNameFormatter

public DefaultNameFormatter()
Method Detail

getInstance

public static DefaultNameFormatter getInstance()
Replies the unique instance of this formatter

Returns:
the unique instance of this formatter

registerFormatHook

public static void registerFormatHook(NameFormatterHook hook)
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

public static void unregisterFormatHook(NameFormatterHook hook)
Unregisters a format hook. Removes the hook from the list of format hooks.

Parameters:
hook - the format hook. Ignored if null.

getNamingtagsForRelations

public static java.util.List<java.lang.String> getNamingtagsForRelations()
Replies the list of naming tags used in relations. The list is given (in this order) by:

Returns:
the list of naming tags used in relations

decorateNameWithId

protected java.lang.String decorateNameWithId(java.lang.String name,
                                              org.openstreetmap.josm.data.osm.IPrimitive primitive)
Decorates the name of primitive with its id, if the preference osm-primitives.showid is set. Shows unique id if osm-primitives.showid.new-primitives is set

Parameters:
name - the name without the id
primitive - the primitive
Returns:
the decorated name

format

public java.lang.String format(org.openstreetmap.josm.data.osm.INode node)
Formats a name for a node

Specified by:
format in interface org.openstreetmap.josm.data.osm.NameFormatter
Parameters:
node - the node
Returns:
the name

getNodeComparator

public java.util.Comparator<org.openstreetmap.josm.data.osm.Node> getNodeComparator()
Specified by:
getNodeComparator in interface org.openstreetmap.josm.data.osm.NameFormatter

format

public java.lang.String format(org.openstreetmap.josm.data.osm.IWay way)
Formats a name for a way

Specified by:
format in interface org.openstreetmap.josm.data.osm.NameFormatter
Parameters:
way - the way
Returns:
the name

getWayComparator

public java.util.Comparator<org.openstreetmap.josm.data.osm.Way> getWayComparator()
Specified by:
getWayComparator in interface org.openstreetmap.josm.data.osm.NameFormatter

format

public java.lang.String format(org.openstreetmap.josm.data.osm.IRelation relation)
Formats a name for a relation

Specified by:
format in interface org.openstreetmap.josm.data.osm.NameFormatter
Parameters:
relation - the relation
Returns:
the name

getRelationComparator

public java.util.Comparator<org.openstreetmap.josm.data.osm.Relation> getRelationComparator()
Specified by:
getRelationComparator in interface org.openstreetmap.josm.data.osm.NameFormatter

format

public java.lang.String format(org.openstreetmap.josm.data.osm.Changeset changeset)
Formats a name for a changeset

Specified by:
format in interface org.openstreetmap.josm.data.osm.NameFormatter
Parameters:
changeset - the changeset
Returns:
the name

buildDefaultToolTip

public java.lang.String buildDefaultToolTip(org.openstreetmap.josm.data.osm.IPrimitive primitive)
Builds a default tooltip text for the primitive primitive.

Parameters:
primitive - the primitmive
Returns:
the tooltip text

decorateNameWithId

protected void decorateNameWithId(java.lang.StringBuilder name,
                                  org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive primitive)
Decorates the name of primitive with its id, if the preference osm-primitives.showid is set. The id is append to the StringBuilder passed in in name.

Parameters:
name - the name without the id
primitive - the primitive

format

public java.lang.String format(org.openstreetmap.josm.data.osm.history.HistoryNode node)
Formats a name for a history node

Specified by:
format in interface org.openstreetmap.josm.data.osm.history.HistoryNameFormatter
Parameters:
node - the node
Returns:
the name

format

public java.lang.String format(org.openstreetmap.josm.data.osm.history.HistoryWay way)
Formats a name for a way

Specified by:
format in interface org.openstreetmap.josm.data.osm.history.HistoryNameFormatter
Parameters:
way - the way
Returns:
the name

format

public java.lang.String format(org.openstreetmap.josm.data.osm.history.HistoryRelation relation)
Formats a name for a HistoryRelation)

Specified by:
format in interface org.openstreetmap.josm.data.osm.history.HistoryNameFormatter
Parameters:
relation - the relation
Returns:
the name

buildDefaultToolTip

public java.lang.String buildDefaultToolTip(org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive primitive)
Builds a default tooltip text for an HistoryOsmPrimitive primitive.

Parameters:
primitive - the primitmive
Returns:
the tooltip text