Ignore:
Timestamp:
2012-05-06T21:23:18+02:00 (12 years ago)
Author:
bastiK
Message:

mapcss: change z-index handling

In contrast to previous default z-index of 1000 for nodes and -1000 for areas, the default z-index is
now always 0. An additional "major-z-index" is used to sort elemstyles by category, this property
can be adjusted in the style, so icons can be rendered below lines, if you want to.

File:
1 edited

Legend:

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

    r5054 r5217  
    1515import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings;
    1616import org.openstreetmap.josm.data.osm.visitor.paint.MapPainter;
     17import org.openstreetmap.josm.gui.mappaint.BoxTextElemStyle.BoxProvider;
     18import org.openstreetmap.josm.gui.mappaint.BoxTextElemStyle.SimpleBoxProvider;
    1719import org.openstreetmap.josm.gui.mappaint.MapPaintStyles.IconReference;
    1820import org.openstreetmap.josm.gui.mappaint.StyleCache.StyleList;
    19 import org.openstreetmap.josm.gui.mappaint.BoxTextElemStyle.BoxProvider;
    20 import org.openstreetmap.josm.gui.mappaint.BoxTextElemStyle.SimpleBoxProvider;
    21 import org.openstreetmap.josm.tools.Pair;
    2221import org.openstreetmap.josm.tools.Utils;
    2322
     
    8584        MultiCascade mc = new MultiCascade();
    8685        Cascade c = mc.getOrCreateCascade("default");
    87         SIMPLE_NODE_ELEMSTYLE = create(new Environment(null, mc, "default", null), true);
     86        SIMPLE_NODE_ELEMSTYLE = create(new Environment(null, mc, "default", null), 4.1f, true);
    8887        if (SIMPLE_NODE_ELEMSTYLE == null) throw new AssertionError();
    8988    }
     
    9291    public static final StyleList DEFAULT_NODE_STYLELIST_TEXT = new StyleList(NodeElemStyle.SIMPLE_NODE_ELEMSTYLE, BoxTextElemStyle.SIMPLE_NODE_TEXT_ELEMSTYLE);
    9392
    94     protected NodeElemStyle(Cascade c, MapImage mapImage, Symbol symbol) {
    95         super(c, 1000f);
     93    protected NodeElemStyle(Cascade c, MapImage mapImage, Symbol symbol, float default_major_z_index) {
     94        super(c, default_major_z_index);
    9695        this.mapImage = mapImage;
    9796        this.symbol = symbol;
     
    9998
    10099    public static NodeElemStyle create(Environment env) {
    101         return create(env, false);
    102     }
    103 
    104     private static NodeElemStyle create(Environment env, boolean allowDefault) {
     100        return create(env, 4f, false);
     101    }
     102
     103    private static NodeElemStyle create(Environment env, float default_major_z_index, boolean allowDefault) {
    105104        Cascade c = env.mc.getCascade(env.layer);
    106105
     
    116115        if (!allowDefault && symbol == null && mapImage == null) return null;
    117116
    118         return new NodeElemStyle(c, mapImage, symbol);
     117        return new NodeElemStyle(c, mapImage, symbol, default_major_z_index);
    119118    }
    120119
     
    302301
    303302    public BoxProvider getBoxProvider() {
    304         if (mapImage != null) {
     303        if (mapImage != null)
    305304            return mapImage.getBoxProvider();
    306         } else if (symbol != null) {
     305        else if (symbol != null)
    307306            return new SimpleBoxProvider(new Rectangle(-symbol.size/2, -symbol.size/2, symbol.size, symbol.size));
    308         } else {
     307        else {
    309308            // This is only executed once, so no performance concerns.
    310309            // However, it would be better, if the settings could be changed at runtime.
Note: See TracChangeset for help on using the changeset viewer.