Changeset 4162 in josm for trunk/src/org/openstreetmap/josm/data/Preferences.java
- Timestamp:
- 2011-06-24T23:13:02+02:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/Preferences.java
r3938 r4162 30 30 import java.util.Map.Entry; 31 31 import java.util.concurrent.CopyOnWriteArrayList; 32 import java.util.regex.Matcher; 33 import java.util.regex.Pattern; 32 34 33 35 import javax.swing.JOptionPane; … … 72 74 protected final SortedMap<String, String> properties = new TreeMap<String, String>(); 73 75 protected final SortedMap<String, String> defaults = new TreeMap<String, String>(); 76 protected final SortedMap<String, String> colornames = new TreeMap<String, String>(); 74 77 75 78 public interface PreferenceChangeEvent{ … … 526 529 } 527 530 531 /* only for preferences */ 532 synchronized public String getColorName(String o) { 533 try 534 { 535 Matcher m = Pattern.compile("mappaint\\.(.+?)\\.(.+)").matcher(o); 536 m.matches(); 537 return tr("Paint style {0}: {1}", tr(m.group(1)), tr(m.group(2))); 538 } 539 catch (Exception e) {} 540 try 541 { 542 Matcher m = Pattern.compile("layer (.+)").matcher(o); 543 m.matches(); 544 return tr("Layer: {0}", tr(m.group(1))); 545 } 546 catch (Exception e) {} 547 return tr(colornames.containsKey(o) ? colornames.get(o) : o); 548 } 549 528 550 public Color getColor(ColorKey key) { 529 551 return getColor(key.getColorName(), key.getSpecialName(), key.getDefault()); … … 539 561 */ 540 562 synchronized public Color getColor(String colName, String specName, Color def) { 541 putDefault("color."+colName, ColorHelper.color2html(def)); 563 String colKey = colName.toLowerCase().replaceAll("[^a-z0-9]+","."); 564 if(!colKey.equals(colName)) 565 colornames.put(colKey, colName); 566 putDefault("color."+colKey, ColorHelper.color2html(def)); 542 567 String colStr = specName != null ? get("color."+specName) : ""; 543 568 if(colStr.equals("")) { 544 colStr = get("color."+col Name);569 colStr = get("color."+colKey); 545 570 } 546 571 return colStr.equals("") ? def : ColorHelper.html2color(colStr);
Note:
See TracChangeset
for help on using the changeset viewer.