Ignore:
Timestamp:
2016-01-03T15:50:53+01:00 (8 years ago)
Author:
bastiK
Message:

move ElemStyle classes to new package, rename to (Style)Element

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
1 added
5 edited
10 moved

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDialog.java

    r9078 r9278  
    3939import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    4040import org.openstreetmap.josm.gui.mappaint.Cascade;
    41 import org.openstreetmap.josm.gui.mappaint.ElemStyle;
     41import org.openstreetmap.josm.gui.mappaint.styleelement.StyleElement;
    4242import org.openstreetmap.josm.gui.mappaint.ElemStyles;
    4343import org.openstreetmap.josm.gui.mappaint.MapPaintStyles;
     
    363363                txtMappaint.append(tr("\n\nList of generated Styles:\n"));
    364364                StyleList sl = elemstyles.get(osm, scale, nc);
    365                 for (ElemStyle s : sl) {
     365                for (StyleElement s : sl) {
    366366                    txtMappaint.append(" * ").append(s).append('\n');
    367367                }
  • trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java

    r9239 r9278  
    2323import org.openstreetmap.josm.gui.mappaint.StyleCache.StyleList;
    2424import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource;
     25import org.openstreetmap.josm.gui.mappaint.styleelement.AreaElement;
     26import org.openstreetmap.josm.gui.mappaint.styleelement.BoxTextElement;
     27import org.openstreetmap.josm.gui.mappaint.styleelement.LineElement;
     28import org.openstreetmap.josm.gui.mappaint.styleelement.LineTextElement;
     29import org.openstreetmap.josm.gui.mappaint.styleelement.NodeElement;
     30import org.openstreetmap.josm.gui.mappaint.styleelement.RepeatImageElement;
     31import org.openstreetmap.josm.gui.mappaint.styleelement.StyleElement;
     32import org.openstreetmap.josm.gui.mappaint.styleelement.TextLabel;
    2533import org.openstreetmap.josm.gui.util.GuiHelper;
    2634import org.openstreetmap.josm.tools.Pair;
     
    97105        if (osm instanceof Node && isDefaultNodes()) {
    98106            if (p.a.isEmpty()) {
    99                 if (TextElement.AUTO_LABEL_COMPOSITION_STRATEGY.compose(osm) != null) {
    100                     p.a = NodeElemStyle.DEFAULT_NODE_STYLELIST_TEXT;
     107                if (TextLabel.AUTO_LABEL_COMPOSITION_STRATEGY.compose(osm) != null) {
     108                    p.a = NodeElement.DEFAULT_NODE_STYLELIST_TEXT;
    101109                } else {
    102                     p.a = NodeElemStyle.DEFAULT_NODE_STYLELIST;
     110                    p.a = NodeElement.DEFAULT_NODE_STYLELIST;
    103111                }
    104112            } else {
    105113                boolean hasNonModifier = false;
    106114                boolean hasText = false;
    107                 for (ElemStyle s : p.a) {
    108                     if (s instanceof BoxTextElemStyle) {
     115                for (StyleElement s : p.a) {
     116                    if (s instanceof BoxTextElement) {
    109117                        hasText = true;
    110118                    } else {
     
    115123                }
    116124                if (!hasNonModifier) {
    117                     p.a = new StyleList(p.a, NodeElemStyle.SIMPLE_NODE_ELEMSTYLE);
     125                    p.a = new StyleList(p.a, NodeElement.SIMPLE_NODE_ELEMSTYLE);
    118126                    if (!hasText) {
    119                         if (TextElement.AUTO_LABEL_COMPOSITION_STRATEGY.compose(osm) != null) {
    120                             p.a = new StyleList(p.a, BoxTextElemStyle.SIMPLE_NODE_TEXT_ELEMSTYLE);
     127                        if (TextLabel.AUTO_LABEL_COMPOSITION_STRATEGY.compose(osm) != null) {
     128                            p.a = new StyleList(p.a, BoxTextElement.SIMPLE_NODE_TEXT_ELEMSTYLE);
    121129                        }
    122130                    }
     
    125133        } else if (osm instanceof Way && isDefaultLines()) {
    126134            boolean hasProperLineStyle = false;
    127             for (ElemStyle s : p.a) {
     135            for (StyleElement s : p.a) {
    128136                if (s.isProperLineStyle()) {
    129137                    hasProperLineStyle = true;
     
    132140            }
    133141            if (!hasProperLineStyle) {
    134                 AreaElemStyle area = Utils.find(p.a, AreaElemStyle.class);
    135                 LineElemStyle line = area == null ? LineElemStyle.UNTAGGED_WAY : LineElemStyle.createSimpleLineStyle(area.color, true);
     142                AreaElement area = Utils.find(p.a, AreaElement.class);
     143                LineElement line = area == null ? LineElement.UNTAGGED_WAY : LineElement.createSimpleLineStyle(area.color, true);
    136144                p.a = new StyleList(p.a, line);
    137145            }
     
    197205                    boolean hasIndependentLineStyle = false;
    198206                    if (!isOuterWayOfSomeMP) { // do this only one time
    199                         List<ElemStyle> tmp = new ArrayList<>(p.a.size());
    200                         for (ElemStyle s : p.a) {
    201                             if (s instanceof AreaElemStyle) {
    202                                 wayColor = ((AreaElemStyle) s).color;
     207                        List<StyleElement> tmp = new ArrayList<>(p.a.size());
     208                        for (StyleElement s : p.a) {
     209                            if (s instanceof AreaElement) {
     210                                wayColor = ((AreaElement) s).color;
    203211                            } else {
    204212                                tmp.add(s);
     
    217225                            mpElemStyles = getStyleCacheWithRange(r, scale, nc);
    218226                        }
    219                         ElemStyle mpLine = null;
    220                         for (ElemStyle s : mpElemStyles.a) {
     227                        StyleElement mpLine = null;
     228                        for (StyleElement s : mpElemStyles.a) {
    221229                            if (s.isProperLineStyle()) {
    222230                                mpLine = s;
     
    229237                            break;
    230238                        } else if (wayColor == null && isDefaultLines()) {
    231                             AreaElemStyle mpArea = Utils.find(mpElemStyles.a, AreaElemStyle.class);
     239                            AreaElement mpArea = Utils.find(mpElemStyles.a, AreaElement.class);
    232240                            if (mpArea != null) {
    233241                                wayColor = mpArea.color;
     
    240248                if (isDefaultLines()) {
    241249                    boolean hasLineStyle = false;
    242                     for (ElemStyle s : p.a) {
     250                    for (StyleElement s : p.a) {
    243251                        if (s.isProperLineStyle()) {
    244252                            hasLineStyle = true;
     
    247255                    }
    248256                    if (!hasLineStyle) {
    249                         p.a = new StyleList(p.a, LineElemStyle.createSimpleLineStyle(wayColor, true));
     257                        p.a = new StyleList(p.a, LineElement.createSimpleLineStyle(wayColor, true));
    250258                    }
    251259                }
     
    265273                    p = generateStyles(osm, scale, false);
    266274                    boolean hasIndependentElemStyle = false;
    267                     for (ElemStyle s : p.a) {
    268                         if (s.isProperLineStyle() || s instanceof AreaElemStyle) {
     275                    for (StyleElement s : p.a) {
     276                        if (s.isProperLineStyle() || s instanceof AreaElement) {
    269277                            hasIndependentElemStyle = true;
    270278                            break;
     
    277285                            mpElemStyles = get(ref, scale, nc);
    278286                        }
    279                         for (ElemStyle mpS : mpElemStyles) {
    280                             if (mpS instanceof AreaElemStyle) {
    281                                 mpColor = ((AreaElemStyle) mpS).color;
     287                        for (StyleElement mpS : mpElemStyles) {
     288                            if (mpS instanceof AreaElement) {
     289                                mpColor = ((AreaElement) mpS).color;
    282290                                break;
    283291                            }
    284292                        }
    285                         p.a = new StyleList(p.a, LineElemStyle.createSimpleLineStyle(mpColor, true));
     293                        p.a = new StyleList(p.a, LineElement.createSimpleLineStyle(mpColor, true));
    286294                    }
    287295                    return p;
     
    292300            Pair<StyleList, Range> p = generateStyles(osm, scale, true);
    293301            if (drawMultipolygon && ((Relation) osm).isMultipolygon()) {
    294                 if (!Utils.exists(p.a, AreaElemStyle.class) && Main.pref.getBoolean("multipolygon.deprecated.outerstyle", true)) {
     302                if (!Utils.exists(p.a, AreaElement.class) && Main.pref.getBoolean("multipolygon.deprecated.outerstyle", true)) {
    295303                    // look at outer ways to find area style
    296304                    Multipolygon multipolygon = MultipolygonCache.getInstance().get(nc, (Relation) osm);
     
    298306                        Pair<StyleList, Range> wayStyles = generateStyles(w, scale, false);
    299307                        p.b = Range.cut(p.b, wayStyles.b);
    300                         ElemStyle area = Utils.find(wayStyles.a, AreaElemStyle.class);
     308                        StyleElement area = Utils.find(wayStyles.a, AreaElement.class);
    301309                        if (area != null) {
    302310                            p.a = new StyleList(p.a, area);
     
    326334    public Pair<StyleList, Range> generateStyles(OsmPrimitive osm, double scale, boolean pretendWayIsClosed) {
    327335
    328         List<ElemStyle> sl = new ArrayList<>();
     336        List<StyleElement> sl = new ArrayList<>();
    329337        MultiCascade mc = new MultiCascade();
    330338        Environment env = new Environment(osm, mc, null, null);
     
    342350            env.layer = e.getKey();
    343351            if (osm instanceof Way) {
    344                 addIfNotNull(sl, AreaElemStyle.create(env));
    345                 addIfNotNull(sl, RepeatImageElemStyle.create(env));
    346                 addIfNotNull(sl, LineElemStyle.createLine(env));
    347                 addIfNotNull(sl, LineElemStyle.createLeftCasing(env));
    348                 addIfNotNull(sl, LineElemStyle.createRightCasing(env));
    349                 addIfNotNull(sl, LineElemStyle.createCasing(env));
    350                 addIfNotNull(sl, LineTextElemStyle.create(env));
     352                addIfNotNull(sl, AreaElement.create(env));
     353                addIfNotNull(sl, RepeatImageElement.create(env));
     354                addIfNotNull(sl, LineElement.createLine(env));
     355                addIfNotNull(sl, LineElement.createLeftCasing(env));
     356                addIfNotNull(sl, LineElement.createRightCasing(env));
     357                addIfNotNull(sl, LineElement.createCasing(env));
     358                addIfNotNull(sl, LineTextElement.create(env));
    351359            } else if (osm instanceof Node) {
    352                 NodeElemStyle nodeStyle = NodeElemStyle.create(env);
     360                NodeElement nodeStyle = NodeElement.create(env);
    353361                if (nodeStyle != null) {
    354362                    sl.add(nodeStyle);
    355                     addIfNotNull(sl, BoxTextElemStyle.create(env, nodeStyle.getBoxProvider()));
     363                    addIfNotNull(sl, BoxTextElement.create(env, nodeStyle.getBoxProvider()));
    356364                } else {
    357                     addIfNotNull(sl, BoxTextElemStyle.create(env, NodeElemStyle.SIMPLE_NODE_ELEMSTYLE_BOXPROVIDER));
     365                    addIfNotNull(sl, BoxTextElement.create(env, NodeElement.SIMPLE_NODE_ELEMSTYLE_BOXPROVIDER));
    358366                }
    359367            } else if (osm instanceof Relation) {
    360368                if (((Relation) osm).isMultipolygon()) {
    361                     addIfNotNull(sl, AreaElemStyle.create(env));
    362                     addIfNotNull(sl, RepeatImageElemStyle.create(env));
    363                     addIfNotNull(sl, LineElemStyle.createLine(env));
    364                     addIfNotNull(sl, LineElemStyle.createCasing(env));
    365                     addIfNotNull(sl, LineTextElemStyle.create(env));
     369                    addIfNotNull(sl, AreaElement.create(env));
     370                    addIfNotNull(sl, RepeatImageElement.create(env));
     371                    addIfNotNull(sl, LineElement.createLine(env));
     372                    addIfNotNull(sl, LineElement.createCasing(env));
     373                    addIfNotNull(sl, LineTextElement.create(env));
    366374                } else if ("restriction".equals(osm.get("type"))) {
    367                     addIfNotNull(sl, NodeElemStyle.create(env));
     375                    addIfNotNull(sl, NodeElement.create(env));
    368376                }
    369377            }
     
    448456
    449457    /**
    450      * Returns the first AreaElemStyle for a given primitive.
     458     * Returns the first AreaElement for a given primitive.
    451459     * @param p the OSM primitive
    452460     * @param pretendWayIsClosed For styles that require the way to be closed,
    453461     * we pretend it is. This is useful for generating area styles from the (segmented)
    454462     * outer ways of a multipolygon.
    455      * @return first AreaElemStyle found or {@code null}.
    456      */
    457     public static AreaElemStyle getAreaElemStyle(OsmPrimitive p, boolean pretendWayIsClosed) {
     463     * @return first AreaElement found or {@code null}.
     464     */
     465    public static AreaElement getAreaElemStyle(OsmPrimitive p, boolean pretendWayIsClosed) {
    458466        MapCSSStyleSource.STYLE_SOURCE_LOCK.readLock().lock();
    459467        try {
    460468            if (MapPaintStyles.getStyles() == null)
    461469                return null;
    462             for (ElemStyle s : MapPaintStyles.getStyles().generateStyles(p, 1.0, pretendWayIsClosed).a) {
    463                 if (s instanceof AreaElemStyle)
    464                     return (AreaElemStyle) s;
     470            for (StyleElement s : MapPaintStyles.getStyles().generateStyles(p, 1.0, pretendWayIsClosed).a) {
     471                if (s instanceof AreaElement)
     472                    return (AreaElement) s;
    465473            }
    466474            return null;
     
    471479
    472480    /**
    473      * Determines whether primitive has an AreaElemStyle.
     481     * Determines whether primitive has an AreaElement.
    474482     * @param p the OSM primitive
    475483     * @param pretendWayIsClosed For styles that require the way to be closed,
    476484     * we pretend it is. This is useful for generating area styles from the (segmented)
    477485     * outer ways of a multipolygon.
    478      * @return {@code true} if primitive has an AreaElemStyle
     486     * @return {@code true} if primitive has an AreaElement
    479487     */
    480488    public static boolean hasAreaElemStyle(OsmPrimitive p, boolean pretendWayIsClosed) {
     
    483491
    484492    /**
    485      * Determines whether primitive has <b>only</b> an AreaElemStyle.
     493     * Determines whether primitive has <b>only</b> an AreaElement.
    486494     * @param p the OSM primitive
    487      * @return {@code true} if primitive has only an AreaElemStyle
     495     * @return {@code true} if primitive has only an AreaElement
    488496     * @since 7486
    489497     */
     
    497505                return false;
    498506            }
    499             for (ElemStyle s : styles) {
    500                 if (!(s instanceof AreaElemStyle)) {
     507            for (StyleElement s : styles) {
     508                if (!(s instanceof AreaElement)) {
    501509                    return false;
    502510                }
  • trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java

    r9239 r9278  
    2929import org.openstreetmap.josm.gui.mappaint.StyleCache.StyleList;
    3030import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource;
     31import org.openstreetmap.josm.gui.mappaint.styleelement.MapImage;
     32import org.openstreetmap.josm.gui.mappaint.styleelement.NodeElement;
     33import org.openstreetmap.josm.gui.mappaint.styleelement.StyleElement;
    3134import org.openstreetmap.josm.gui.mappaint.xml.XmlStyleSource;
    3235import org.openstreetmap.josm.gui.preferences.SourceEntry;
     
    192195            }
    193196            if (styleList != null) {
    194                 for (ElemStyle style : styleList) {
    195                     if (style instanceof NodeElemStyle) {
    196                         MapImage mapImage = ((NodeElemStyle) style).mapImage;
     197                for (StyleElement style : styleList) {
     198                    if (style instanceof NodeElement) {
     199                        MapImage mapImage = ((NodeElement) style).mapImage;
    197200                        if (mapImage != null) {
    198201                            if (includeDeprecatedIcon || mapImage.name == null || !"misc/deprecated.png".equals(mapImage.name)) {
  • trunk/src/org/openstreetmap/josm/gui/mappaint/StyleCache.java

    r9239 r9278  
    1010
    1111import org.openstreetmap.josm.data.osm.Storage;
     12import org.openstreetmap.josm.gui.mappaint.styleelement.StyleElement;
    1213import org.openstreetmap.josm.tools.Pair;
    1314
     
    1617 * Splits the range of possible scale values (0 &lt; scale &lt; +Infinity) into multiple
    1718 * subranges, for each scale range it keeps a list of styles.
    18  * Immutable class, equals &amp; hashCode is required (the same for StyleList, ElemStyle
    19  * and its subclasses).
     19 * Immutable class, equals &amp; hashCode is required (the same for StyleList, StyleElement
     20 and its subclasses).
    2021 */
    2122public final class StyleCache {
     
    4647     * List of Styles, immutable
    4748     */
    48     public static class StyleList implements Iterable<ElemStyle> {
    49         private final List<ElemStyle> lst;
     49    public static class StyleList implements Iterable<StyleElement> {
     50        private final List<StyleElement> lst;
    5051
    5152        /**
     
    5657        }
    5758
    58         public StyleList(ElemStyle... init) {
     59        public StyleList(StyleElement... init) {
    5960            lst = new ArrayList<>(Arrays.asList(init));
    6061        }
    6162
    62         public StyleList(Collection<ElemStyle> sl) {
     63        public StyleList(Collection<StyleElement> sl) {
    6364            lst = new ArrayList<>(sl);
    6465        }
    6566
    66         public StyleList(StyleList sl, ElemStyle s) {
     67        public StyleList(StyleList sl, StyleElement s) {
    6768            lst = new ArrayList<>(sl.lst);
    6869            lst.add(s);
     
    7071
    7172        @Override
    72         public Iterator<ElemStyle> iterator() {
     73        public Iterator<StyleElement> iterator() {
    7374            return lst.iterator();
    7475        }
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSource.java

    r8882 r9278  
    3838import org.openstreetmap.josm.gui.mappaint.Cascade;
    3939import org.openstreetmap.josm.gui.mappaint.Environment;
    40 import org.openstreetmap.josm.gui.mappaint.LineElemStyle;
    4140import org.openstreetmap.josm.gui.mappaint.MultiCascade;
    4241import org.openstreetmap.josm.gui.mappaint.Range;
     
    5655import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.ParseException;
    5756import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.TokenMgrError;
     57import org.openstreetmap.josm.gui.mappaint.styleelement.LineElement;
    5858import org.openstreetmap.josm.gui.preferences.SourceEntry;
    5959import org.openstreetmap.josm.io.CachedFile;
     
    113113            }
    114114        }
    115         for (LineElemStyle.LineType lt : LineElemStyle.LineType.values()) {
     115        for (LineElement.LineType lt : LineElement.LineType.values()) {
    116116            SUPPORTED_KEYS.add(lt.prefix + StyleKeys.COLOR);
    117117            SUPPORTED_KEYS.add(lt.prefix + StyleKeys.DASHES);
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/AreaElement.java

    r9275 r9278  
    11// License: GPL. For details, see LICENSE file.
    2 package org.openstreetmap.josm.gui.mappaint;
     2package org.openstreetmap.josm.gui.mappaint.styleelement;
    33
    44import java.awt.Color;
     
    1212import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors;
    1313import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer;
     14import org.openstreetmap.josm.gui.mappaint.Cascade;
     15import org.openstreetmap.josm.gui.mappaint.Environment;
     16import org.openstreetmap.josm.gui.mappaint.Keyword;
    1417import org.openstreetmap.josm.gui.mappaint.MapPaintStyles.IconReference;
    1518import org.openstreetmap.josm.tools.CheckParameterUtil;
    1619import org.openstreetmap.josm.tools.Utils;
    1720
    18 public class AreaElemStyle extends ElemStyle {
     21public class AreaElement extends StyleElement {
    1922
    2023    /**
     
    2427    public Color color;
    2528    public MapImage fillImage;
    26     public TextElement text;
     29    public TextLabel text;
    2730    public Float extent;
    2831    public Float extentThreshold;
    2932
    30     protected AreaElemStyle(Cascade c, Color color, MapImage fillImage, Float extent, Float extentThreshold, TextElement text) {
     33    protected AreaElement(Cascade c, Color color, MapImage fillImage, Float extent, Float extentThreshold, TextLabel text) {
    3134        super(c, 1f);
    3235        CheckParameterUtil.ensureParameterNotNull(color);
     
    3841    }
    3942
    40     public static AreaElemStyle create(final Environment env) {
     43    public static AreaElement create(final Environment env) {
    4144        final Cascade c = env.mc.getCascade(env.layer);
    4245        MapImage fillImage = null;
     
    7679        }
    7780
    78         TextElement text = null;
     81        TextLabel text = null;
    7982        Keyword textPos = c.get(TEXT_POSITION, null, Keyword.class);
    8083        if (textPos == null || "center".equals(textPos.val)) {
    81             text = TextElement.create(env, PaintColors.AREA_TEXT.get(), true);
     84            text = TextLabel.create(env, PaintColors.AREA_TEXT.get(), true);
    8285        }
    8386
     
    8689
    8790        if (color != null)
    88             return new AreaElemStyle(c, color, fillImage, extent, extentThreshold, text);
     91            return new AreaElement(c, color, fillImage, extent, extentThreshold, text);
    8992        else
    9093            return null;
     
    118121        if (!super.equals(obj))
    119122            return false;
    120         AreaElemStyle other = (AreaElemStyle) obj;
     123        AreaElement other = (AreaElement) obj;
    121124        // we should get the same image object due to caching
    122125        if (!Objects.equals(fillImage, other.fillImage))
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/BoxTextElement.java

    r9275 r9278  
    11// License: GPL. For details, see LICENSE file.
    2 package org.openstreetmap.josm.gui.mappaint;
     2package org.openstreetmap.josm.gui.mappaint.styleelement;
    33
    44import java.awt.Color;
     
    1010import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors;
    1111import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer;
     12import org.openstreetmap.josm.gui.mappaint.Cascade;
     13import org.openstreetmap.josm.gui.mappaint.Environment;
     14import org.openstreetmap.josm.gui.mappaint.Keyword;
     15import org.openstreetmap.josm.gui.mappaint.MultiCascade;
    1216import org.openstreetmap.josm.tools.CheckParameterUtil;
    1317
     
    1519 * Text style attached to a style with a bounding box, like an icon or a symbol.
    1620 */
    17 public class BoxTextElemStyle extends ElemStyle {
     21public class BoxTextElement extends StyleElement {
    1822
    1923    public enum HorizontalTextAlignment { LEFT, CENTER, RIGHT }
     
    8589    public static final Rectangle ZERO_BOX = new Rectangle(0, 0, 0, 0);
    8690
    87     public TextElement text;
     91    public TextLabel text;
    8892    // Either boxProvider or box is not null. If boxProvider is different from
    8993    // null, this means, that the box can still change in future, otherwise
     
    9498    public VerticalTextAlignment vAlign;
    9599
    96     public BoxTextElemStyle(Cascade c, TextElement text, BoxProvider boxProvider, Rectangle box,
     100    public BoxTextElement(Cascade c, TextLabel text, BoxProvider boxProvider, Rectangle box,
    97101            HorizontalTextAlignment hAlign, VerticalTextAlignment vAlign) {
    98102        super(c, 5f);
     
    107111    }
    108112
    109     public static BoxTextElemStyle create(Environment env, BoxProvider boxProvider) {
     113    public static BoxTextElement create(Environment env, BoxProvider boxProvider) {
    110114        return create(env, boxProvider, null);
    111115    }
    112116
    113     public static BoxTextElemStyle create(Environment env, Rectangle box) {
     117    public static BoxTextElement create(Environment env, Rectangle box) {
    114118        return create(env, null, box);
    115119    }
    116120
    117     public static BoxTextElemStyle create(Environment env, BoxProvider boxProvider, Rectangle box) {
     121    public static BoxTextElement create(Environment env, BoxProvider boxProvider, Rectangle box) {
    118122        initDefaultParameters();
    119123        Cascade c = env.mc.getCascade(env.layer);
    120124
    121         TextElement text = TextElement.create(env, DEFAULT_TEXT_COLOR, false);
     125        TextLabel text = TextLabel.create(env, DEFAULT_TEXT_COLOR, false);
    122126        if (text == null) return null;
    123127        // Skip any primitives that don't have text to draw. (Styles are recreated for any tag change.)
    124128        // The concrete text to render is not cached in this object, but computed for each
    125         // repaint. This way, one BoxTextElemStyle object can be used by multiple primitives (to save memory).
     129        // repaint. This way, one BoxTextElement object can be used by multiple primitives (to save memory).
    126130        if (text.labelCompositionStrategy.compose(env.osm) == null) return null;
    127131
     
    154158        }
    155159
    156         return new BoxTextElemStyle(c, text, boxProvider, box, hAlign, vAlign);
     160        return new BoxTextElement(c, text, boxProvider, box, hAlign, vAlign);
    157161    }
    158162
     
    169173    }
    170174
    171     public static final BoxTextElemStyle SIMPLE_NODE_TEXT_ELEMSTYLE;
     175    public static final BoxTextElement SIMPLE_NODE_TEXT_ELEMSTYLE;
    172176    static {
    173177        MultiCascade mc = new MultiCascade();
     
    176180        Node n = new Node();
    177181        n.put("name", "dummy");
    178         SIMPLE_NODE_TEXT_ELEMSTYLE = create(new Environment(n, mc, "default", null), NodeElemStyle.SIMPLE_NODE_ELEMSTYLE.getBoxProvider());
     182        SIMPLE_NODE_TEXT_ELEMSTYLE = create(new Environment(n, mc, "default", null), NodeElement.SIMPLE_NODE_ELEMSTYLE.getBoxProvider());
    179183        if (SIMPLE_NODE_TEXT_ELEMSTYLE == null) throw new AssertionError();
    180184    }
     
    207211        if (obj == null || getClass() != obj.getClass())
    208212            return false;
    209         final BoxTextElemStyle other = (BoxTextElemStyle) obj;
     213        final BoxTextElement other = (BoxTextElement) obj;
    210214        if (!text.equals(other.text)) return false;
    211215        if (boxProvider != null) {
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/LabelCompositionStrategy.java

    r9275 r9278  
    11// License: GPL. For details, see LICENSE file.
    2 package org.openstreetmap.josm.gui.mappaint;
     2package org.openstreetmap.josm.gui.mappaint.styleelement;
    33
    44import java.util.ArrayList;
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/LineElement.java

    r9275 r9278  
    11// License: GPL. For details, see LICENSE file.
    2 package org.openstreetmap.josm.gui.mappaint;
     2package org.openstreetmap.josm.gui.mappaint.styleelement;
    33
    44import java.awt.BasicStroke;
     
    1414import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors;
    1515import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer;
     16import org.openstreetmap.josm.gui.mappaint.Cascade;
     17import org.openstreetmap.josm.gui.mappaint.Environment;
     18import org.openstreetmap.josm.gui.mappaint.Keyword;
     19import org.openstreetmap.josm.gui.mappaint.MultiCascade;
    1620import org.openstreetmap.josm.gui.mappaint.mapcss.Instruction.RelativeFloat;
    1721import org.openstreetmap.josm.tools.Utils;
    1822
    19 public class LineElemStyle extends ElemStyle {
    20 
    21     public static LineElemStyle createSimpleLineStyle(Color color, boolean isAreaEdge) {
     23public class LineElement extends StyleElement {
     24
     25    public static LineElement createSimpleLineStyle(Color color, boolean isAreaEdge) {
    2226        MultiCascade mc = new MultiCascade();
    2327        Cascade c = mc.getOrCreateCascade("default");
     
    3135    }
    3236
    33     public static final LineElemStyle UNTAGGED_WAY = createSimpleLineStyle(null, false);
     37    public static final LineElement UNTAGGED_WAY = createSimpleLineStyle(null, false);
    3438
    3539    private BasicStroke line;
     
    5660    }
    5761
    58     protected LineElemStyle(Cascade c, float default_major_z_index, BasicStroke line, Color color, BasicStroke dashesLine,
     62    protected LineElement(Cascade c, float default_major_z_index, BasicStroke line, Color color, BasicStroke dashesLine,
    5963            Color dashesBackground, float offset, float realWidth) {
    6064        super(c, default_major_z_index);
     
    6771    }
    6872
    69     public static LineElemStyle createLine(Environment env) {
     73    public static LineElement createLine(Environment env) {
    7074        return createImpl(env, LineType.NORMAL);
    7175    }
    7276
    73     public static LineElemStyle createLeftCasing(Environment env) {
    74         LineElemStyle leftCasing = createImpl(env, LineType.LEFT_CASING);
     77    public static LineElement createLeftCasing(Environment env) {
     78        LineElement leftCasing = createImpl(env, LineType.LEFT_CASING);
    7579        if (leftCasing != null) {
    7680            leftCasing.isModifier = true;
     
    7983    }
    8084
    81     public static LineElemStyle createRightCasing(Environment env) {
    82         LineElemStyle rightCasing = createImpl(env, LineType.RIGHT_CASING);
     85    public static LineElement createRightCasing(Environment env) {
     86        LineElement rightCasing = createImpl(env, LineType.RIGHT_CASING);
    8387        if (rightCasing != null) {
    8488            rightCasing.isModifier = true;
     
    8791    }
    8892
    89     public static LineElemStyle createCasing(Environment env) {
    90         LineElemStyle casing = createImpl(env, LineType.CASING);
     93    public static LineElement createCasing(Environment env) {
     94        LineElement casing = createImpl(env, LineType.CASING);
    9195        if (casing != null) {
    9296            casing.isModifier = true;
     
    9599    }
    96100
    97     private static LineElemStyle createImpl(Environment env, LineType type) {
     101    private static LineElement createImpl(Environment env, LineType type) {
    98102        Cascade c = env.mc.getCascade(env.layer);
    99103        Cascade c_def = env.mc.getCascade("default");
     
    260264        }
    261265
    262         return new LineElemStyle(c, type.defaultMajorZIndex, line, color, dashesLine, dashesBackground, offset, realWidth);
     266        return new LineElement(c, type.defaultMajorZIndex, line, color, dashesLine, dashesBackground, offset, realWidth);
    263267    }
    264268
     
    332336        if (!super.equals(obj))
    333337            return false;
    334         final LineElemStyle other = (LineElemStyle) obj;
     338        final LineElement other = (LineElement) obj;
    335339        return Objects.equals(line, other.line) &&
    336340            Objects.equals(color, other.color) &&
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/LineTextElement.java

    r9275 r9278  
    11// License: GPL. For details, see LICENSE file.
    2 package org.openstreetmap.josm.gui.mappaint;
     2package org.openstreetmap.josm.gui.mappaint.styleelement;
    33
    44import java.util.Objects;
     
    99import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors;
    1010import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer;
     11import org.openstreetmap.josm.gui.mappaint.Cascade;
     12import org.openstreetmap.josm.gui.mappaint.Environment;
     13import org.openstreetmap.josm.gui.mappaint.Keyword;
    1114
    12 public class LineTextElemStyle extends ElemStyle {
     15public class LineTextElement extends StyleElement {
    1316
    14     private final TextElement text;
     17    private final TextLabel text;
    1518
    16     protected LineTextElemStyle(Cascade c, TextElement text) {
     19    protected LineTextElement(Cascade c, TextLabel text) {
    1720        super(c, 4.9f);
    1821        this.text = text;
    1922    }
    2023
    21     public static LineTextElemStyle create(final Environment env) {
     24    public static LineTextElement create(final Environment env) {
    2225        final Cascade c = env.mc.getCascade(env.layer);
    2326
     
    2629            return null;
    2730
    28         TextElement text = TextElement.create(env, PaintColors.TEXT.get(), false);
     31        TextLabel text = TextLabel.create(env, PaintColors.TEXT.get(), false);
    2932        if (text == null)
    3033            return null;
    31         return new LineTextElemStyle(c, text);
     34        return new LineTextElement(c, text);
    3235    }
    3336
     
    4548        if (!super.equals(obj))
    4649            return false;
    47         final LineTextElemStyle other = (LineTextElemStyle) obj;
     50        final LineTextElement other = (LineTextElement) obj;
    4851        return Objects.equals(text, other.text);
    4952    }
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/MapImage.java

    r9275 r9278  
    11// License: GPL. For details, see LICENSE file.
    2 package org.openstreetmap.josm.gui.mappaint;
     2package org.openstreetmap.josm.gui.mappaint.styleelement;
    33
    44import java.awt.Graphics;
     
    1111
    1212import org.openstreetmap.josm.Main;
    13 import org.openstreetmap.josm.gui.mappaint.BoxTextElemStyle.BoxProvider;
    14 import org.openstreetmap.josm.gui.mappaint.BoxTextElemStyle.BoxProviderResult;
     13import org.openstreetmap.josm.gui.mappaint.MapPaintStyles;
     14import org.openstreetmap.josm.gui.mappaint.StyleSource;
     15import org.openstreetmap.josm.gui.mappaint.styleelement.BoxTextElement.BoxProvider;
     16import org.openstreetmap.josm.gui.mappaint.styleelement.BoxTextElement.BoxProviderResult;
    1517import org.openstreetmap.josm.gui.util.GuiHelper;
    1618import org.openstreetmap.josm.tools.ImageProvider;
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/NodeElement.java

    r9275 r9278  
    11// License: GPL. For details, see LICENSE file.
    2 package org.openstreetmap.josm.gui.mappaint;
     2package org.openstreetmap.josm.gui.mappaint.styleelement;
    33
    44import java.awt.BasicStroke;
     
    1414import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings;
    1515import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer;
    16 import org.openstreetmap.josm.gui.mappaint.BoxTextElemStyle.BoxProvider;
    17 import org.openstreetmap.josm.gui.mappaint.BoxTextElemStyle.SimpleBoxProvider;
     16import org.openstreetmap.josm.gui.mappaint.Cascade;
     17import org.openstreetmap.josm.gui.mappaint.Environment;
     18import org.openstreetmap.josm.gui.mappaint.Keyword;
    1819import org.openstreetmap.josm.gui.mappaint.MapPaintStyles.IconReference;
     20import org.openstreetmap.josm.gui.mappaint.MultiCascade;
    1921import org.openstreetmap.josm.gui.mappaint.StyleCache.StyleList;
     22import org.openstreetmap.josm.gui.mappaint.styleelement.BoxTextElement.BoxProvider;
     23import org.openstreetmap.josm.gui.mappaint.styleelement.BoxTextElement.SimpleBoxProvider;
    2024import org.openstreetmap.josm.gui.util.RotationAngle;
    2125import org.openstreetmap.josm.tools.Utils;
     
    2428 * applies for Nodes and turn restriction relations
    2529 */
    26 public class NodeElemStyle extends ElemStyle implements StyleKeys {
     30public class NodeElement extends StyleElement {
    2731    public final MapImage mapImage;
    2832    public final RotationAngle mapImageAngle;
     
    8185    }
    8286
    83     public static final NodeElemStyle SIMPLE_NODE_ELEMSTYLE;
     87    public static final NodeElement SIMPLE_NODE_ELEMSTYLE;
    8488    public static final BoxProvider SIMPLE_NODE_ELEMSTYLE_BOXPROVIDER;
    8589    static {
     
    9195    }
    9296
    93     public static final StyleList DEFAULT_NODE_STYLELIST = new StyleList(NodeElemStyle.SIMPLE_NODE_ELEMSTYLE);
    94     public static final StyleList DEFAULT_NODE_STYLELIST_TEXT = new StyleList(NodeElemStyle.SIMPLE_NODE_ELEMSTYLE,
    95             BoxTextElemStyle.SIMPLE_NODE_TEXT_ELEMSTYLE);
    96 
    97     protected NodeElemStyle(Cascade c, MapImage mapImage, Symbol symbol, float default_major_z_index, RotationAngle rotationAngle) {
     97    public static final StyleList DEFAULT_NODE_STYLELIST = new StyleList(NodeElement.SIMPLE_NODE_ELEMSTYLE);
     98    public static final StyleList DEFAULT_NODE_STYLELIST_TEXT = new StyleList(NodeElement.SIMPLE_NODE_ELEMSTYLE,
     99            BoxTextElement.SIMPLE_NODE_TEXT_ELEMSTYLE);
     100
     101    protected NodeElement(Cascade c, MapImage mapImage, Symbol symbol, float default_major_z_index, RotationAngle rotationAngle) {
    98102        super(c, default_major_z_index);
    99103        this.mapImage = mapImage;
     
    102106    }
    103107
    104     public static NodeElemStyle create(Environment env) {
     108    public static NodeElement create(Environment env) {
    105109        return create(env, 4f, false);
    106110    }
    107111
    108     private static NodeElemStyle create(Environment env, float default_major_z_index, boolean allowDefault) {
     112    private static NodeElement create(Environment env, float default_major_z_index, boolean allowDefault) {
    109113        Cascade c = env.mc.getCascade(env.layer);
    110114
     
    140144        if (!allowDefault && symbol == null && mapImage == null) return null;
    141145
    142         return new NodeElemStyle(c, mapImage, symbol, default_major_z_index, rotationAngle);
     146        return new NodeElement(c, mapImage, symbol, default_major_z_index, rotationAngle);
    143147    }
    144148
     
    374378            return false;
    375379
    376         final NodeElemStyle other = (NodeElemStyle) obj;
     380        final NodeElement other = (NodeElement) obj;
    377381        // we should get the same image object due to caching
    378382        if (!Objects.equals(mapImage, other.mapImage))
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/RepeatImageElement.java

    r9275 r9278  
    11// License: GPL. For details, see LICENSE file.
    2 package org.openstreetmap.josm.gui.mappaint;
     2package org.openstreetmap.josm.gui.mappaint.styleelement;
    33
    44import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    66import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings;
    77import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer;
     8import org.openstreetmap.josm.gui.mappaint.Cascade;
     9import org.openstreetmap.josm.gui.mappaint.Environment;
     10import org.openstreetmap.josm.gui.mappaint.Keyword;
    811import org.openstreetmap.josm.tools.CheckParameterUtil;
    912
    10 public class RepeatImageElemStyle extends ElemStyle implements StyleKeys {
     13public class RepeatImageElement extends StyleElement {
    1114
    1215    public enum LineImageAlignment { TOP, CENTER, BOTTOM }
     
    1821    public LineImageAlignment align;
    1922
    20     public RepeatImageElemStyle(Cascade c, MapImage pattern, float offset, float spacing, float phase, LineImageAlignment align) {
     23    public RepeatImageElement(Cascade c, MapImage pattern, float offset, float spacing, float phase, LineImageAlignment align) {
    2124        super(c, 2.9f);
    2225        CheckParameterUtil.ensureParameterNotNull(pattern);
     
    2932    }
    3033
    31     public static RepeatImageElemStyle create(Environment env) {
    32         MapImage pattern = NodeElemStyle.createIcon(env, REPEAT_IMAGE_KEYS);
     34    public static RepeatImageElement create(Environment env) {
     35        MapImage pattern = NodeElement.createIcon(env, REPEAT_IMAGE_KEYS);
    3336        if (pattern == null)
    3437            return null;
     
    4649        }
    4750
    48         return new RepeatImageElemStyle(c, pattern, offset, spacing, phase, align);
     51        return new RepeatImageElement(c, pattern, offset, spacing, phase, align);
    4952    }
    5053
     
    6770        if (!super.equals(obj))
    6871            return false;
    69         final RepeatImageElemStyle other = (RepeatImageElemStyle) obj;
     72        final RepeatImageElement other = (RepeatImageElement) obj;
    7073        if (!this.pattern.equals(other.pattern)) return false;
    7174        if (this.offset != other.offset) return false;
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/StyleElement.java

    r9275 r9278  
    11// License: GPL. For details, see LICENSE file.
    2 package org.openstreetmap.josm.gui.mappaint;
     2package org.openstreetmap.josm.gui.mappaint.styleelement;
    33
    44import java.awt.Font;
     
    1010import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings;
    1111import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer;
     12import org.openstreetmap.josm.gui.mappaint.Cascade;
     13import org.openstreetmap.josm.gui.mappaint.Keyword;
     14import org.openstreetmap.josm.gui.mappaint.StyleKeys;
    1215import org.openstreetmap.josm.gui.mappaint.mapcss.Instruction.RelativeFloat;
    1316
    14 public abstract class ElemStyle implements StyleKeys {
     17public abstract class StyleElement implements StyleKeys {
    1518
    1619    protected static final int ICON_IMAGE_IDX = 0;
     
    3033    // primitive; true, if it is a highlight or modifier
    3134
    32     public ElemStyle(float major_z_index, float z_index, float object_z_index, boolean isModifier) {
     35    public StyleElement(float major_z_index, float z_index, float object_z_index, boolean isModifier) {
    3336        this.majorZIndex = major_z_index;
    3437        this.zIndex = z_index;
     
    3740    }
    3841
    39     protected ElemStyle(Cascade c, float default_major_z_index) {
     42    protected StyleElement(Cascade c, float default_major_z_index) {
    4043        majorZIndex = c.get(MAJOR_Z_INDEX, default_major_z_index, Float.class);
    4144        zIndex = c.get(Z_INDEX, 0f, Float.class);
     
    208211    @Override
    209212    public boolean equals(Object o) {
    210         if (!(o instanceof ElemStyle))
     213        if (!(o instanceof StyleElement))
    211214            return false;
    212         ElemStyle s = (ElemStyle) o;
     215        StyleElement s = (StyleElement) o;
    213216        return isModifier == s.isModifier &&
    214217                majorZIndex == s.majorZIndex &&
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/TextLabel.java

    r9275 r9278  
    11// License: GPL. For details, see LICENSE file.
    2 package org.openstreetmap.josm.gui.mappaint;
     2package org.openstreetmap.josm.gui.mappaint.styleelement;
    33
    44import java.awt.Color;
     
    77
    88import org.openstreetmap.josm.data.osm.OsmPrimitive;
    9 import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.DeriveLabelFromNameTagsCompositionStrategy;
    10 import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.StaticLabelCompositionStrategy;
    11 import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.TagLookupCompositionStrategy;
     9import org.openstreetmap.josm.gui.mappaint.Cascade;
     10import org.openstreetmap.josm.gui.mappaint.Environment;
     11import org.openstreetmap.josm.gui.mappaint.Keyword;
    1212import org.openstreetmap.josm.gui.mappaint.MapPaintStyles.TagKeyReference;
     13import org.openstreetmap.josm.gui.mappaint.StyleKeys;
     14import org.openstreetmap.josm.gui.mappaint.styleelement.LabelCompositionStrategy.DeriveLabelFromNameTagsCompositionStrategy;
     15import org.openstreetmap.josm.gui.mappaint.styleelement.LabelCompositionStrategy.StaticLabelCompositionStrategy;
     16import org.openstreetmap.josm.gui.mappaint.styleelement.LabelCompositionStrategy.TagLookupCompositionStrategy;
    1317import org.openstreetmap.josm.tools.CheckParameterUtil;
    1418import org.openstreetmap.josm.tools.Utils;
     
    1822 * @since 3880
    1923 */
    20 public class TextElement implements StyleKeys {
     24public class TextLabel implements StyleKeys {
    2125    public static final LabelCompositionStrategy AUTO_LABEL_COMPOSITION_STRATEGY = new DeriveLabelFromNameTagsCompositionStrategy();
    2226
     
    4549     * @param haloColor halo color
    4650     */
    47     public TextElement(LabelCompositionStrategy strategy, Font font, int xOffset, int yOffset, Color color, Float haloRadius, Color haloColor) {
     51    public TextLabel(LabelCompositionStrategy strategy, Font font, int xOffset, int yOffset, Color color, Float haloRadius, Color haloColor) {
    4852        CheckParameterUtil.ensureParameterNotNull(font);
    4953        CheckParameterUtil.ensureParameterNotNull(color);
     
    6266     * @param other the other element.
    6367     */
    64     public TextElement(TextElement other) {
     68    public TextLabel(TextLabel other) {
    6569        this.labelCompositionStrategy = other.labelCompositionStrategy;
    6670        this.font = other.font;
     
    116120     * @throws IllegalArgumentException if {@code defaultTextColor} is null
    117121     */
    118     public static TextElement create(Environment env, Color defaultTextColor, boolean defaultAnnotate) {
     122    public static TextLabel create(Environment env, Color defaultTextColor, boolean defaultAnnotate) {
    119123        CheckParameterUtil.ensureParameterNotNull(defaultTextColor);
    120124        Cascade c = env.mc.getCascade(env.layer);
     
    124128        String s = strategy.compose(env.osm);
    125129        if (s == null) return null;
    126         Font font = ElemStyle.getFont(c, s);
     130        Font font = StyleElement.getFont(c, s);
    127131
    128132        float xOffset = 0;
     
    157161        }
    158162
    159         return new TextElement(strategy, font, (int) xOffset, -(int) yOffset, color, haloRadius, haloColor);
     163        return new TextLabel(strategy, font, (int) xOffset, -(int) yOffset, color, haloRadius, haloColor);
    160164    }
    161165
     
    212216        if (obj == null || getClass() != obj.getClass())
    213217            return false;
    214         final TextElement other = (TextElement) obj;
     218        final TextLabel other = (TextLabel) obj;
    215219        return Objects.equals(labelCompositionStrategy, other.labelCompositionStrategy) &&
    216220        Objects.equals(font, other.font) &&
Note: See TracChangeset for help on using the changeset viewer.