Changeset 1221 in josm for trunk/src/org/openstreetmap/josm/data/Preferences.java
- Timestamp:
- 2009-01-09T09:42:46+01:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/Preferences.java
r1180 r1221 183 183 } 184 184 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 185 202 synchronized public Map<String, String> getDefaults() { 186 203 return defaults; … … 345 362 */ 346 363 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); 353 365 } 354 366 … … 362 374 */ 363 375 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) : ""; 365 378 if(colStr.equals("")) 366 {367 379 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); 375 381 } 376 382
Note:
See TracChangeset
for help on using the changeset viewer.