org.openstreetmap.josm.gui.mappaint
Class LabelCompositionStrategy.DeriveLabelFromNameTagsCompositionStrategy

java.lang.Object
  extended by org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy
      extended by org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.DeriveLabelFromNameTagsCompositionStrategy
Enclosing class:
LabelCompositionStrategy

public static class LabelCompositionStrategy.DeriveLabelFromNameTagsCompositionStrategy
extends LabelCompositionStrategy


Nested Class Summary
 
Nested classes/interfaces inherited from class org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy
LabelCompositionStrategy.DeriveLabelFromNameTagsCompositionStrategy, LabelCompositionStrategy.StaticLabelCompositionStrategy, LabelCompositionStrategy.TagLookupCompositionStrategy
 
Field Summary
static java.lang.String[] DEFAULT_NAME_TAGS
          The list of default name tags from which a label candidate is derived.
private  java.util.List<java.lang.String> nameTags
           
 
Constructor Summary
LabelCompositionStrategy.DeriveLabelFromNameTagsCompositionStrategy()
          Creates the strategy and initializes its name tags from the preferences.
 
Method Summary
 java.lang.String compose(OsmPrimitive primitive)
          Replies the text value to be rendered as label for the primitive primitive.
 java.util.List<java.lang.String> getNameTags()
          Replies an unmodifiable list of the name tags used to compose the label.
private  java.lang.String getPrimitiveName(OsmPrimitive n)
           
 void initNameTagsFromPreferences()
          Initializes the name tags to use from a list of default name tags (see DEFAULT_NAME_TAGS) and from name tags configured in the preferences using the preference key mappaint.nameOrder.
 void setNameTags(java.util.List<java.lang.String> nameTags)
          Sets the name tags to be looked up in order to build up the label
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_NAME_TAGS

public static final java.lang.String[] DEFAULT_NAME_TAGS
The list of default name tags from which a label candidate is derived.


nameTags

private java.util.List<java.lang.String> nameTags
Constructor Detail

LabelCompositionStrategy.DeriveLabelFromNameTagsCompositionStrategy

public LabelCompositionStrategy.DeriveLabelFromNameTagsCompositionStrategy()

Creates the strategy and initializes its name tags from the preferences.

Note: If the list of name tags in the preferences changes, strategy instances are not notified. It's up to the client to listen to preference changes and invoke initNameTagsFromPreferences() accordingly.

Method Detail

setNameTags

public void setNameTags(java.util.List<java.lang.String> nameTags)
Sets the name tags to be looked up in order to build up the label

Parameters:
nameTags - the name tags. null values are ignore.

getNameTags

public java.util.List<java.lang.String> getNameTags()
Replies an unmodifiable list of the name tags used to compose the label.

Returns:
the list of name tags

initNameTagsFromPreferences

public void initNameTagsFromPreferences()
Initializes the name tags to use from a list of default name tags (see DEFAULT_NAME_TAGS) and from name tags configured in the preferences using the preference key mappaint.nameOrder.


getPrimitiveName

private java.lang.String getPrimitiveName(OsmPrimitive n)

compose

public java.lang.String compose(OsmPrimitive primitive)
Description copied from class: LabelCompositionStrategy
Replies the text value to be rendered as label for the primitive primitive.

Specified by:
compose in class LabelCompositionStrategy
Parameters:
primitive - the primitive
Returns:
the text value to be rendered or null, if primitive is null or if no suitable value could be composed

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


JOSM