Changeset 3882 in josm


Ignore:
Timestamp:
Feb 10, 2011 11:41:33 AM (2 years ago)
Author:
bastiK
Message:

mapcss: fix layer handling

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
7 edited

Legend:

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

    r3763 r3882  
    868868            Layer layer = model.getLayer(index); 
    869869            LayerListPopup menu = new LayerListPopup(getModel().getSelectedLayers(), layer); 
    870             menu.show(LayerListDialog.this, p.x, p.y-3); 
     870            menu.show(layerList, p.x, p.y-3); 
    871871        } 
    872872    } 
  • trunk/src/org/openstreetmap/josm/gui/dialogs/MapPaintDialog.java

    r3863 r3882  
    608608            } 
    609609            MapPaintPopup menu = new MapPaintPopup(); 
    610             menu.show(MapPaintDialog.this, p.x, p.y); 
     610            menu.show(tblStyles, p.x, p.y); 
    611611        } 
    612612    } 
  • trunk/src/org/openstreetmap/josm/gui/mappaint/Cascade.java

    r3871 r3882  
    139139            return a; 
    140140        } 
     141        Float f = toFloat(o); 
     142        if (f != null) 
     143            return new float[] { f }; 
    141144        return null; 
    142145    } 
  • trunk/src/org/openstreetmap/josm/gui/mappaint/MultiCascade.java

    r3865 r3882  
    1717    } 
    1818 
    19     public Cascade getCascade(String key) { 
    20         if (key == null) 
     19    /** 
     20     * Return the cascade for the given layer key. If it does not exist, 
     21     * return a new cascade, but do not keep it. 
     22     */ 
     23    public Cascade getCascade(String layer) { 
     24        if (layer == null) 
    2125            throw new IllegalArgumentException(); 
    22         Cascade c = get(key); 
     26        Cascade c = get(layer); 
    2327        if (c == null) { 
    24             c = new Cascade(!key.equals("default")); 
    25             put(key, c); 
     28            c = new Cascade(!layer.equals("default")); 
    2629        } 
    2730        return c; 
  • trunk/src/org/openstreetmap/josm/gui/mappaint/TextElement.java

    r3880 r3882  
    3838 
    3939        Font font = ElemStyle.getFont(c); 
    40         int xOffset = c.get("text-offset-x", 0f, Float.class).intValue(); 
    41         int yOffset = -c.get("text-offset-y", 0f, Float.class).intValue(); 
     40 
     41        float xOffset = 0; 
     42        float yOffset = 0; 
     43        float[] offset = c.get("text-offset", null, float[].class); 
     44        if (offset != null) { 
     45            if (offset.length == 1) { 
     46                yOffset = offset[0]; 
     47            } else if (offset.length >= 2) { 
     48                xOffset = offset[0]; 
     49                yOffset = offset[1]; 
     50            } 
     51        } 
     52        xOffset = c.get("text-offset-x", xOffset, Float.class); 
     53        yOffset = c.get("text-offset-y", yOffset, Float.class); 
     54         
    4255        Color color = c.get("text-color", PaintColors.TEXT.get(), Color.class); 
    43         return new TextElement(textKey, font, xOffset, yOffset, color); 
     56         
     57        return new TextElement(textKey, font, (int) xOffset, (int) yOffset, color); 
    4458    } 
    4559 
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSource.java

    r3865 r3882  
    134134                    } 
    135135 
    136                     if (sub.equals("*")) { // fixme: proper subparts handling 
     136                    if (sub.equals("*")) { 
    137137                        for (Entry<String, Cascade> entry : mc.entrySet()) { 
    138138                            env.layer = entry.getKey(); 
  • trunk/src/org/openstreetmap/josm/gui/mappaint/xml/XmlStyleSource.java

    r3880 r3882  
    278278    @Override 
    279279    public void apply(MultiCascade mc, OsmPrimitive osm, double scale, OsmPrimitive multipolyOuterWay, boolean pretendWayIsClosed) { 
    280         Cascade def = mc.getCascade("default"); 
     280        Cascade def = mc.get("default"); 
     281        if (def == null) { 
     282            def = new Cascade(false); 
     283            mc.put("default", def); 
     284        } 
    281285        boolean useMinMaxScale = Main.pref.getBoolean("mappaint.zoomLevelDisplay", false); 
    282286 
     
    321325                    Cascade c; 
    322326                    if (mod.over) { 
    323                         c = mc.getCascade(String.format("over_%d", numOver)); 
     327                        String layer = String.format("over_%d", numOver); 
     328                        c = mc.get(layer); 
     329                        if (c == null) { 
     330                            c = new Cascade(true); 
     331                            mc.put(layer, c); 
     332                        } 
    324333                        c.put("object-z-index", new Float(numOver)); 
    325334                        ++numOver; 
    326335                    } else { 
    327                         c = mc.getCascade(String.format("under_%d", numUnder)); 
     336                        String layer = String.format("under_%d", numUnder); 
     337                        c = mc.get(layer); 
     338                        if (c == null) { 
     339                            c = new Cascade(true); 
     340                            mc.put(layer, c); 
     341                        } 
    328342                        c.put("object-z-index", new Float(-numUnder)); 
    329343                        ++numUnder; 
Note: See TracChangeset for help on using the changeset viewer.