Class LabelCompositionStrategy.DeriveLabelFromNameTagsCompositionStrategy
- java.lang.Object
-
- org.openstreetmap.josm.gui.mappaint.styleelement.LabelCompositionStrategy.DeriveLabelFromNameTagsCompositionStrategy
-
- All Implemented Interfaces:
LabelCompositionStrategy
,PreferenceChangedListener
- Enclosing interface:
- LabelCompositionStrategy
public static class LabelCompositionStrategy.DeriveLabelFromNameTagsCompositionStrategy extends Object implements LabelCompositionStrategy, PreferenceChangedListener
Strategy where the label is given by the value of one of the configured "name tags". The list of relevant name tags can be configured in the JOSM preferences see the preference optionsmappaint.nameOrder
andmappaint.nameComplementOrder
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.openstreetmap.josm.gui.mappaint.styleelement.LabelCompositionStrategy
LabelCompositionStrategy.DeriveLabelFromNameTagsCompositionStrategy, LabelCompositionStrategy.StaticLabelCompositionStrategy, LabelCompositionStrategy.TagLookupCompositionStrategy
-
-
Field Summary
Fields Modifier and Type Field Description private static String[]
DEFAULT_NAME_COMPLEMENT_TAGS
The list of default name complement tags from which a label candidate is derived.private static String[]
DEFAULT_NAME_TAGS
The list of default name tags from which a label candidate is derived.private List<String>
nameComplementTags
private List<String>
nameTags
-
Constructor Summary
Constructors Constructor Description DeriveLabelFromNameTagsCompositionStrategy()
Creates the strategy and initializes its name tags from the preferences.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static List<String>
buildNameTags(List<String> nameTags)
String
compose(IPrimitive primitive)
Replies the text value to be rendered as label for the primitiveprimitive
.List<String>
getNameComplementTags()
Replies an unmodifiable list of the name complement tags used to compose the label.List<String>
getNameTags()
Replies an unmodifiable list of the name tags used to compose the label.private String
getPrimitiveName(IPrimitive n)
void
initNameTagsFromPreferences()
Initializes the name tags to use from a list of default name tags (seeDEFAULT_NAME_TAGS
andDEFAULT_NAME_COMPLEMENT_TAGS
) and from name tags configured in the preferences using the keysmappaint.nameOrder
andmappaint.nameComplementOrder
.void
preferenceChanged(PreferenceChangeEvent e)
Triggered when a preference entry value changes.void
setNameComplementTags(List<String> nameComplementTags)
Sets the name complement tags to be looked up in order to build up the label.void
setNameTags(List<String> nameTags)
Sets the name tags to be looked up in order to build up the label.String
toString()
-
-
-
Field Detail
-
DEFAULT_NAME_TAGS
private static final String[] DEFAULT_NAME_TAGS
The list of default name tags from which a label candidate is derived.
-
DEFAULT_NAME_COMPLEMENT_TAGS
private static final String[] DEFAULT_NAME_COMPLEMENT_TAGS
The list of default name complement tags from which a label candidate is derived.
-
nameComplementTags
private List<String> nameComplementTags
-
-
Constructor Detail
-
DeriveLabelFromNameTagsCompositionStrategy
public DeriveLabelFromNameTagsCompositionStrategy()
Creates the strategy and initializes its name tags from the preferences.
-
-
Method Detail
-
buildNameTags
private static List<String> buildNameTags(List<String> nameTags)
-
setNameTags
public void setNameTags(List<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 ignored.
-
setNameComplementTags
public void setNameComplementTags(List<String> nameComplementTags)
Sets the name complement tags to be looked up in order to build up the label.- Parameters:
nameComplementTags
- the name complement tags. null values are ignored.- Since:
- 6541
-
getNameTags
public List<String> getNameTags()
Replies an unmodifiable list of the name tags used to compose the label.- Returns:
- the list of name tags
-
getNameComplementTags
public List<String> getNameComplementTags()
Replies an unmodifiable list of the name complement tags used to compose the label.- Returns:
- the list of name complement tags
- Since:
- 6541
-
initNameTagsFromPreferences
public final void initNameTagsFromPreferences()
Initializes the name tags to use from a list of default name tags (seeDEFAULT_NAME_TAGS
andDEFAULT_NAME_COMPLEMENT_TAGS
) and from name tags configured in the preferences using the keysmappaint.nameOrder
andmappaint.nameComplementOrder
.
-
getPrimitiveName
private String getPrimitiveName(IPrimitive n)
-
compose
public String compose(IPrimitive primitive)
Description copied from interface:LabelCompositionStrategy
Replies the text value to be rendered as label for the primitiveprimitive
.- Specified by:
compose
in interfaceLabelCompositionStrategy
- 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
-
preferenceChanged
public void preferenceChanged(PreferenceChangeEvent e)
Description copied from interface:PreferenceChangedListener
Triggered when a preference entry value changes.- Specified by:
preferenceChanged
in interfacePreferenceChangedListener
- Parameters:
e
- the preference change event
-
-