Ignore:
Timestamp:
2012-07-15T14:59:10+02:00 (14 years ago)
Author:
Don-vip
Message:

mappaint: fix "real width" painting, broken since r5212 because of a typo error on "real-width" key. Introduction of a StyleKeys interface centralizing key definitions at the same place to avoid same mistake in the future.

File:
1 edited

Legend:

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

    r5144 r5342  
    2323import org.openstreetmap.josm.gui.mappaint.MultiCascade;
    2424import org.openstreetmap.josm.gui.mappaint.Range;
     25import org.openstreetmap.josm.gui.mappaint.StyleKeys;
    2526import org.openstreetmap.josm.gui.mappaint.StyleSource;
    2627import org.openstreetmap.josm.gui.preferences.SourceEntry;
     
    3132import org.xml.sax.SAXParseException;
    3233
    33 public class XmlStyleSource extends StyleSource {
     34public class XmlStyleSource extends StyleSource implements StyleKeys {
    3435
    3536    protected final HashMap<String, IconPrototype> icons = new HashMap<String, IconPrototype>();
     
    286287            IconPrototype icon = getNode(osm, (useMinMaxScale ? scale : null), mc);
    287288            if (icon != null) {
    288                 def.put("icon-image", icon.icon);
     289                def.put(ICON_IMAGE, icon.icon);
    289290                if (osm instanceof Node) {
    290291                    if (icon.annotate != null) {
    291292                        if (icon.annotate) {
    292                             def.put("text", Keyword.AUTO);
     293                            def.put(TEXT, Keyword.AUTO);
    293294                        } else {
    294                             def.remove("text");
     295                            def.remove(TEXT);
    295296                        }
    296297                    }
     
    301302            get(osm, pretendWayIsClosed || !(osm instanceof Way) || ((Way) osm).isClosed(), p, (useMinMaxScale ? scale : null), mc);
    302303            if (p.line != null) {
    303                 def.put("width", new Float(p.line.getWidth()));
    304                 def.putOrClear("real-width", p.line.realWidth != null ? new Float(p.line.realWidth) : null);
    305                 def.putOrClear("color", p.line.color);
     304                def.put(WIDTH, new Float(p.line.getWidth()));
     305                def.putOrClear(REAL_WIDTH, p.line.realWidth != null ? new Float(p.line.realWidth) : null);
     306                def.putOrClear(COLOR, p.line.color);
    306307                if (p.line.color != null) {
    307308                    int alpha = p.line.color.getAlpha();
    308309                    if (alpha != 255) {
    309                         def.put("opacity", Utils.color_int2float(alpha));
     310                        def.put(OPACITY, Utils.color_int2float(alpha));
    310311                    }
    311312                }
    312                 def.putOrClear("dashes", p.line.getDashed());
    313                 def.putOrClear("dashes-background-color", p.line.dashedColor);
    314             }
    315             Float refWidth = def.get("width", null, Float.class);
     313                def.putOrClear(DASHES, p.line.getDashed());
     314                def.putOrClear(DASHES_BACKGROUND_COLOR, p.line.dashedColor);
     315            }
     316            Float refWidth = def.get(WIDTH, null, Float.class);
    316317            if (refWidth != null && p.linemods != null) {
    317318                int numOver = 0, numUnder = 0;
     
    325326                        String layer = String.format("over_%d", numOver);
    326327                        c = mc.getOrCreateCascade(layer);
    327                         c.put("object-z-index", new Float(numOver));
     328                        c.put(OBJECT_Z_INDEX, new Float(numOver));
    328329                        ++numOver;
    329330                    } else {
    330331                        String layer = String.format("under_%d", numUnder);
    331332                        c = mc.getOrCreateCascade(layer);
    332                         c.put("object-z-index", new Float(-numUnder));
     333                        c.put(OBJECT_Z_INDEX, new Float(-numUnder));
    333334                        ++numUnder;
    334335                    }
    335                     c.put("width", new Float(mod.getWidth(refWidth)));
    336                     c.putOrClear("color", mod.color);
     336                    c.put(WIDTH, new Float(mod.getWidth(refWidth)));
     337                    c.putOrClear(COLOR, mod.color);
    337338                    if (mod.color != null) {
    338339                        int alpha = mod.color.getAlpha();
    339340                        if (alpha != 255) {
    340                             c.put("opacity", Utils.color_int2float(alpha));
     341                            c.put(OPACITY, Utils.color_int2float(alpha));
    341342                        }
    342343                    }
    343                     c.putOrClear("dashes", mod.getDashed());
    344                     c.putOrClear("dashes-background-color", mod.dashedColor);
     344                    c.putOrClear(DASHES, mod.getDashed());
     345                    c.putOrClear(DASHES_BACKGROUND_COLOR, mod.dashedColor);
    345346                }
    346347            }
     
    353354            }
    354355            if (p.area != null) {
    355                 def.putOrClear("fill-color", p.area.color);
    356                 def.putOrClear("text-position", Keyword.CENTER);
    357                 def.putOrClear("text", Keyword.AUTO);
    358                 def.remove("fill-image");
     356                def.putOrClear(FILL_COLOR, p.area.color);
     357                def.putOrClear(TEXT_POSITION, Keyword.CENTER);
     358                def.putOrClear(TEXT, Keyword.AUTO);
     359                def.remove(FILL_IMAGE);
    359360            }
    360361        }
Note: See TracChangeset for help on using the changeset viewer.