Ignore:
Timestamp:
2009-01-09T09:42:46+01:00 (15 years ago)
Author:
stoecker
Message:

cleanup color handling

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r1180 r1221  
    183183    }
    184184
     185    synchronized public TreeMap<String, String> getAllColors() {
     186        final TreeMap<String,String> all = new TreeMap<String,String>();
     187        for (final Entry<String,String> e : defaults.entrySet())
     188            if (e.getKey().startsWith("color."))
     189                all.put(e.getKey().substring(6), e.getValue());
     190        for (final Entry<String,String> e : properties.entrySet())
     191            if (e.getKey().startsWith("color."))
     192                all.put(e.getKey().substring(6), e.getValue());
     193        for (final Entry<String,String> e : override.entrySet())
     194            if (e.getKey().startsWith("color."))
     195                if (e.getValue() == null)
     196                    all.remove(e.getKey().substring(6));
     197                else
     198                    all.put(e.getKey().substring(6), e.getValue());
     199        return all;
     200    }
     201
    185202    synchronized public Map<String, String> getDefaults() {
    186203        return defaults;
     
    345362     */
    346363    synchronized public Color getColor(String colName, Color def) {
    347         String colStr = get("color."+colName);
    348         if (colStr.equals("")) {
    349             put("color."+colName, ColorHelper.color2html(def));
    350             return def;
    351         }
    352         return ColorHelper.html2color(colStr);
     364        return getColor(colName, null, def);
    353365    }
    354366
     
    362374     */
    363375    synchronized public Color getColor(String colName, String specName, Color def) {
    364         String colStr = get("color."+specName);
     376        putDefault("color."+colName, ColorHelper.color2html(def));
     377        String colStr = specName != null ? get("color."+specName) : "";
    365378        if(colStr.equals(""))
    366         {
    367379            colStr = get("color."+colName);
    368             if (colStr.equals("")) {
    369                 put("color."+colName, ColorHelper.color2html(def));
    370                 return def;
    371             }
    372         }
    373         putDefault("color."+colName, ColorHelper.color2html(def));
    374         return ColorHelper.html2color(colStr);
     380        return colStr.equals("") ? def : ColorHelper.html2color(colStr);
    375381    }
    376382
Note: See TracChangeset for help on using the changeset viewer.