Ignore:
Timestamp:
2011-03-27T13:41:58+02:00 (15 years ago)
Author:
bastiK
Message:

see #6150 mapcss - extended functionality for instruction text: ... (patch by Gubaer)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/TextElement.java

    r4003 r4007  
    99import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1010import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.DeriveLabelFromNameTagsCompositionStrategy;
     11import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.StaticLabelCompositionStrategy;
    1112import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.TagLookupCompositionStrategy;
     13import org.openstreetmap.josm.gui.mappaint.MapPaintStyles.TagKeyReference;
    1214import org.openstreetmap.josm.tools.CheckParameterUtil;
    1315import org.openstreetmap.josm.tools.Utils;
     
    8183     */
    8284    protected static LabelCompositionStrategy buildLabelCompositionStrategy(Cascade c, boolean defaultAnnotate){
    83         Keyword textKW = c.get("text", null, Keyword.class, true);
    84         if (textKW == null) {
    85             String textKey = c.get("text", null, String.class);
    86             if (textKey == null)
    87                 return defaultAnnotate ? AUTO_LABEL_COMPOSITION_STRATEGY : null;
    88             return new TagLookupCompositionStrategy(textKey);
    89         } else if (textKW.val.equals("auto"))
     85        /*
     86         * If the cascade includes a TagKeyReference we will lookup the rendered label
     87         * from a tag value.
     88         */
     89        TagKeyReference tkr = c.get("text", null, TagKeyReference.class, true);
     90        if (tkr != null)
     91            return new TagLookupCompositionStrategy(tkr.key);
     92
     93        /*
     94         * Check whether the label composition strategy is given by
     95         * a keyword
     96         */
     97        Keyword keyword = c.get("text", null, Keyword.class, true);
     98        if (equal(keyword, Keyword.AUTO))
    9099            return AUTO_LABEL_COMPOSITION_STRATEGY;
    91         else
    92             return new TagLookupCompositionStrategy(textKW.val);
     100
     101        /*
     102         * Do we have a static text label?
     103         */
     104        String text = c.get("text", null, String.class, true);
     105        if (text != null)
     106            return new StaticLabelCompositionStrategy(text);
     107        return defaultAnnotate ? AUTO_LABEL_COMPOSITION_STRATEGY : null;
    93108    }
    94109
Note: See TracChangeset for help on using the changeset viewer.