Changeset 6624 in josm
- Timestamp:
- 2014-01-04T14:56:55+01:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/Preferences.java
r6617 r6624 852 852 } 853 853 854 /** 855 * Returns the color for the given key. 856 * @param key The color key 857 * @return the color 858 */ 854 859 public Color getColor(ColorKey key) { 855 860 return getColor(key.getColorName(), key.getSpecialName(), key.getDefaultValue()); … … 870 875 } 871 876 String colStr = specName != null ? get("color."+specName) : ""; 872 if (colStr.isEmpty()) {873 colStr = get("color." + colKey, "");877 if (colStr.isEmpty()) { 878 colStr = get("color." + colKey, ColorHelper.color2html(def)); 874 879 } 875 880 return colStr.isEmpty() ? def : ColorHelper.html2color(colStr); -
trunk/src/org/openstreetmap/josm/gui/conflict/ConflictColors.java
r6616 r6624 49 49 private final Color defaultColor; 50 50 51 private static Color backgroundColorCache = null;52 53 51 private ConflictColors(String name, Color defaultColor) { 54 52 this.name = name; … … 71 69 } 72 70 71 /** 72 * Returns the color. 73 * @return the color 74 */ 73 75 public Color get() { 74 76 return Main.pref.getColor(this); 75 77 } 76 78 79 /** 80 * Loads all colors from preferences. 81 */ 77 82 public static void getColors() { 78 for (ConflictColors c :values()) {83 for (ConflictColors c : values()) { 79 84 c.get(); 80 85 } -
trunk/src/org/openstreetmap/josm/gui/preferences/display/ColorPreference.java
r6529 r6624 14 14 import java.util.List; 15 15 import java.util.Map; 16 import java.util.Map.Entry;17 16 import java.util.TreeMap; 18 17 import java.util.Vector; … … 78 77 */ 79 78 public void setColorModel(Map<String, String> colorMap) { 80 if (tableModel == null) {79 if (tableModel == null) { 81 80 tableModel = new DefaultTableModel(); 82 81 tableModel.addColumn(tr("Name")); … … 85 84 86 85 // clear old model: 87 while (tableModel.getRowCount() > 0) {86 while (tableModel.getRowCount() > 0) { 88 87 tableModel.removeRow(0); 89 88 } … … 92 91 Map<String, String> colorKeyList_mappaint = new TreeMap<String, String>(); 93 92 Map<String, String> colorKeyList_layer = new TreeMap<String, String>(); 94 for (String key : colorMap.keySet()) {95 if (key.startsWith("layer ")) {93 for (String key : colorMap.keySet()) { 94 if (key.startsWith("layer ")) { 96 95 colorKeyList_layer.put(getName(key), key); 97 } else if (key.startsWith("mappaint.")) {98 / * use getName(key)+key, as getName() may be ambiguous */96 } else if (key.startsWith("mappaint.")) { 97 // use getName(key)+key, as getName() may be ambiguous 99 98 colorKeyList_mappaint.put(getName(key)+key, key); 100 99 } else { … … 102 101 } 103 102 } 104 for (Entry<String, String> k : colorKeyList.entrySet()) { 103 addColorRows(colorMap, colorKeyList); 104 addColorRows(colorMap, colorKeyList_mappaint); 105 addColorRows(colorMap, colorKeyList_layer); 106 if (this.colors != null) { 107 this.colors.repaint(); 108 } 109 } 110 111 private void addColorRows(Map<String, String> colorMap, Map<String, String> keyMap) { 112 for (String value : keyMap.values()) { 105 113 Vector<Object> row = new Vector<Object>(2); 106 row.add(k.getValue()); 107 row.add(ColorHelper.html2color(colorMap.get(k.getValue()))); 114 String html = colorMap.get(value); 115 Color color = ColorHelper.html2color(html); 116 if (color == null) { 117 Main.warn("Unable to get color from '"+html+"' for color preference '"+value+"'"); 118 } 119 row.add(value); 120 row.add(color); 108 121 tableModel.addRow(row); 109 }110 for (Entry<String, String> k : colorKeyList_mappaint.entrySet()) {111 Vector<Object> row = new Vector<Object>(2);112 row.add(k.getValue());113 row.add(ColorHelper.html2color(colorMap.get(k.getValue())));114 tableModel.addRow(row);115 }116 for (Entry<String, String> k : colorKeyList_layer.entrySet()) {117 Vector<Object> row = new Vector<Object>(2);118 row.add(k.getValue());119 row.add(ColorHelper.html2color(colorMap.get(k.getValue())));120 tableModel.addRow(row);121 }122 if(this.colors != null) {123 this.colors.repaint();124 122 } 125 123 }
Note:
See TracChangeset
for help on using the changeset viewer.