Changeset 12987 in josm for trunk/src/org/openstreetmap/josm/gui
- Timestamp:
- 2017-10-12T16:02:15+02:00 (3 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MapScaler.java
r11534 r12987 15 15 import javax.swing.JComponent; 16 16 17 import org.openstreetmap.josm.data.preferences. ColorProperty;17 import org.openstreetmap.josm.data.preferences.NamedColorProperty; 18 18 import org.openstreetmap.josm.gui.help.Helpful; 19 19 … … 29 29 private static final int PADDING_RIGHT = 50; 30 30 31 private static final ColorProperty SCALER_COLOR = newColorProperty(marktr("scale"), Color.WHITE);31 private static final NamedColorProperty SCALER_COLOR = new NamedColorProperty(marktr("scale"), Color.WHITE); 32 32 33 33 /** -
trunk/src/org/openstreetmap/josm/gui/MapStatus.java
r12881 r12987 71 71 import org.openstreetmap.josm.data.preferences.AbstractProperty; 72 72 import org.openstreetmap.josm.data.preferences.BooleanProperty; 73 import org.openstreetmap.josm.data.preferences.ColorProperty;74 73 import org.openstreetmap.josm.data.preferences.DoubleProperty; 74 import org.openstreetmap.josm.data.preferences.NamedColorProperty; 75 75 import org.openstreetmap.josm.gui.help.Helpful; 76 76 import org.openstreetmap.josm.gui.progress.swing.PleaseWaitProgressMonitor; … … 80 80 import org.openstreetmap.josm.gui.widgets.JosmTextField; 81 81 import org.openstreetmap.josm.spi.preferences.Config; 82 import org.openstreetmap.josm.tools.ColorHelper; 82 83 import org.openstreetmap.josm.tools.Destroyable; 83 84 import org.openstreetmap.josm.tools.GBC; … … 110 111 * @since 6789 111 112 */ 112 public static final ColorProperty PROP_BACKGROUND_COLOR = newColorProperty(113 marktr("Status bar background"), "#b8cfe5");113 public static final NamedColorProperty PROP_BACKGROUND_COLOR = new NamedColorProperty( 114 marktr("Status bar background"), ColorHelper.html2color("#b8cfe5")); 114 115 115 116 /** … … 117 118 * @since 6789 118 119 */ 119 public static final ColorProperty PROP_ACTIVE_BACKGROUND_COLOR = newColorProperty(120 marktr("Status bar background: active"), "#aaff5e");120 public static final NamedColorProperty PROP_ACTIVE_BACKGROUND_COLOR = new NamedColorProperty( 121 marktr("Status bar background: active"), ColorHelper.html2color("#aaff5e")); 121 122 122 123 /** … … 124 125 * @since 6789 125 126 */ 126 public static final ColorProperty PROP_FOREGROUND_COLOR = newColorProperty(127 public static final NamedColorProperty PROP_FOREGROUND_COLOR = new NamedColorProperty( 127 128 marktr("Status bar foreground"), Color.black); 128 129 … … 131 132 * @since 6789 132 133 */ 133 public static final ColorProperty PROP_ACTIVE_FOREGROUND_COLOR = newColorProperty(134 public static final NamedColorProperty PROP_ACTIVE_FOREGROUND_COLOR = new NamedColorProperty( 134 135 marktr("Status bar foreground: active"), Color.black); 135 136 -
trunk/src/org/openstreetmap/josm/gui/autofilter/AutoFilterButton.java
r12630 r12987 12 12 13 13 import org.openstreetmap.josm.actions.JosmAction; 14 import org.openstreetmap.josm.data.preferences. ColorProperty;14 import org.openstreetmap.josm.data.preferences.NamedColorProperty; 15 15 import org.openstreetmap.josm.gui.MainApplication; 16 16 … … 21 21 public class AutoFilterButton extends JButton { 22 22 23 private static final ColorProperty PROP_COLOR = newColorProperty("auto.filter.button.color", new Color(0, 160, 160));23 private static final NamedColorProperty PROP_COLOR = new NamedColorProperty("auto.filter.button.color", new Color(0, 160, 160)); 24 24 25 25 private final AutoFilter filter; -
trunk/src/org/openstreetmap/josm/gui/conflict/ConflictColors.java
r10824 r12987 6 6 import java.awt.Color; 7 7 8 import org.openstreetmap.josm.data.preferences. ColorProperty;8 import org.openstreetmap.josm.data.preferences.NamedColorProperty; 9 9 10 10 /** … … 82 82 FGCOLOR_MEMBER_REMOVE(marktr("Conflict foreground: remove member"), Color.black); 83 83 84 private final ColorProperty property;84 private final NamedColorProperty property; 85 85 86 86 ConflictColors(String name, Color defaultColor) { 87 property = new ColorProperty(name, defaultColor);87 property = new NamedColorProperty(name, defaultColor); 88 88 } 89 89 -
trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java
r12809 r12987 52 52 import org.openstreetmap.josm.data.osm.Way; 53 53 import org.openstreetmap.josm.data.osm.visitor.OsmPrimitiveVisitor; 54 import org.openstreetmap.josm.data.preferences. ColorProperty;54 import org.openstreetmap.josm.data.preferences.NamedColorProperty; 55 55 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 56 56 import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec; … … 78 78 public final class ConflictDialog extends ToggleDialog implements ActiveLayerChangeListener, IConflictListener, DataSelectionListener { 79 79 80 private static final ColorProperty CONFLICT_COLOR = newColorProperty(marktr("conflict"), Color.GRAY);81 private static final ColorProperty BACKGROUND_COLOR = newColorProperty(marktr("background"), Color.BLACK);80 private static final NamedColorProperty CONFLICT_COLOR = new NamedColorProperty(marktr("conflict"), Color.GRAY); 81 private static final NamedColorProperty BACKGROUND_COLOR = new NamedColorProperty(marktr("background"), Color.BLACK); 82 82 83 83 /** the collection of conflicts displayed by this conflict dialog */ -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesCellRenderer.java
r11553 r12987 24 24 import org.openstreetmap.josm.data.preferences.BooleanProperty; 25 25 import org.openstreetmap.josm.data.preferences.CachingProperty; 26 import org.openstreetmap.josm.data.preferences. ColorProperty;26 import org.openstreetmap.josm.data.preferences.NamedColorProperty; 27 27 28 28 /** … … 33 33 34 34 private static final CachingProperty<Color> SELECTED_FG 35 = new ColorProperty(marktr("Discardable key: selection Foreground"), Color.GRAY).cached();35 = new NamedColorProperty(marktr("Discardable key: selection Foreground"), Color.GRAY).cached(); 36 36 private static final CachingProperty<Color> SELECTED_BG; 37 37 private static final CachingProperty<Color> NORMAL_FG 38 = new ColorProperty(marktr("Discardable key: foreground"), Color.GRAY).cached();38 = new NamedColorProperty(marktr("Discardable key: foreground"), Color.GRAY).cached(); 39 39 private static final CachingProperty<Color> NORMAL_BG; 40 40 private static final CachingProperty<Boolean> DISCARDABLE … … 42 42 43 43 static { 44 SELECTED_BG = new ColorProperty(marktr("Discardable key: selection Background"),44 SELECTED_BG = new NamedColorProperty(marktr("Discardable key: selection Background"), 45 45 Optional.ofNullable(UIManager.getColor("Table.selectionBackground")).orElse(Color.BLUE)).cached(); 46 NORMAL_BG = new ColorProperty(marktr("Discardable key: background"),46 NORMAL_BG = new NamedColorProperty(marktr("Discardable key: background"), 47 47 Optional.ofNullable(UIManager.getColor("Table.background")).orElse(Color.WHITE)).cached(); 48 48 } -
trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
r12671 r12987 26 26 import org.openstreetmap.josm.data.gpx.GpxTrack; 27 27 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 28 import org.openstreetmap.josm.data.preferences. ColorProperty;28 import org.openstreetmap.josm.data.preferences.NamedColorProperty; 29 29 import org.openstreetmap.josm.data.projection.Projection; 30 30 import org.openstreetmap.josm.gui.MapView; … … 100 100 101 101 @Override 102 protected ColorProperty getBaseColorProperty() {102 protected NamedColorProperty getBaseColorProperty() { 103 103 return GpxDrawHelper.DEFAULT_COLOR; 104 104 } -
trunk/src/org/openstreetmap/josm/gui/layer/Layer.java
r12782 r12987 29 29 import org.openstreetmap.josm.data.preferences.AbstractProperty; 30 30 import org.openstreetmap.josm.data.preferences.AbstractProperty.ValueChangeListener; 31 import org.openstreetmap.josm.data.preferences. ColorProperty;31 import org.openstreetmap.josm.data.preferences.NamedColorProperty; 32 32 import org.openstreetmap.josm.data.projection.Projection; 33 33 import org.openstreetmap.josm.data.projection.ProjectionChangeListener; … … 204 204 */ 205 205 public AbstractProperty<Color> getColorProperty() { 206 ColorProperty base = getBaseColorProperty();206 NamedColorProperty base = getBaseColorProperty(); 207 207 if (base != null) { 208 // cannot cache this - name may change. 209 return base.getChildColor("layer " + getName()); 208 return base.getChildColor(NamedColorProperty.COLOR_CATEGORY_LAYER, getName(), base.getName()); 210 209 } else { 211 210 return null; … … 218 217 * @since 10824 219 218 */ 220 protected ColorProperty getBaseColorProperty() {219 protected NamedColorProperty getBaseColorProperty() { 221 220 return null; 222 221 } -
trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r12846 r12987 81 81 import org.openstreetmap.josm.data.osm.visitor.paint.Rendering; 82 82 import org.openstreetmap.josm.data.osm.visitor.paint.relations.MultipolygonCache; 83 import org.openstreetmap.josm.data.preferences.ColorProperty;84 83 import org.openstreetmap.josm.data.preferences.IntegerProperty; 84 import org.openstreetmap.josm.data.preferences.NamedColorProperty; 85 85 import org.openstreetmap.josm.data.preferences.StringProperty; 86 86 import org.openstreetmap.josm.data.projection.Projection; … … 153 153 public static final StringProperty PROPERTY_SAVE_EXTENSION = new StringProperty("save.extension.osm", "osm"); 154 154 155 private static final ColorProperty PROPERTY_BACKGROUND_COLOR = newColorProperty(marktr("background"), Color.BLACK);156 private static final ColorProperty PROPERTY_OUTSIDE_COLOR = newColorProperty(marktr("outside downloaded area"), Color.YELLOW);155 private static final NamedColorProperty PROPERTY_BACKGROUND_COLOR = new NamedColorProperty(marktr("background"), Color.BLACK); 156 private static final NamedColorProperty PROPERTY_OUTSIDE_COLOR = new NamedColorProperty(marktr("outside downloaded area"), Color.YELLOW); 157 157 158 158 /** List of recent relations */ -
trunk/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java
r12891 r12987 43 43 import org.openstreetmap.josm.data.gpx.GpxData.GpxDataChangeListener; 44 44 import org.openstreetmap.josm.data.gpx.WayPoint; 45 import org.openstreetmap.josm.data.preferences. ColorProperty;45 import org.openstreetmap.josm.data.preferences.NamedColorProperty; 46 46 import org.openstreetmap.josm.gui.MapView; 47 47 import org.openstreetmap.josm.gui.MapViewState; … … 69 69 * @since 10824 70 70 */ 71 public static final ColorProperty DEFAULT_COLOR = newColorProperty(marktr("gps point"), Color.magenta);71 public static final NamedColorProperty DEFAULT_COLOR = new NamedColorProperty(marktr("gps point"), Color.magenta); 72 72 73 73 private final GpxData data; … … 266 266 public Color getColor(String layerName, boolean ignoreCustom) { 267 267 if (ignoreCustom || getColorMode(layerName) == ColorMode.NONE) { 268 return DEFAULT_COLOR.getChildColor(specName(layerName)).get(); 268 return DEFAULT_COLOR.getChildColor( 269 NamedColorProperty.COLOR_CATEGORY_LAYER, 270 layerName, 271 DEFAULT_COLOR.getName()).get(); 269 272 } else { 270 273 return null; -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java
r12846 r12987 38 38 import org.openstreetmap.josm.data.gpx.WayPoint; 39 39 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 40 import org.openstreetmap.josm.data.preferences. ColorProperty;40 import org.openstreetmap.josm.data.preferences.NamedColorProperty; 41 41 import org.openstreetmap.josm.gui.MainApplication; 42 42 import org.openstreetmap.josm.gui.MapView; … … 79 79 80 80 private static final Color DEFAULT_COLOR = Color.magenta; 81 private static final ColorProperty COLOR_PROPERTY = newColorProperty(marktr("gps marker"), DEFAULT_COLOR);81 private static final NamedColorProperty COLOR_PROPERTY = new NamedColorProperty(marktr("gps marker"), DEFAULT_COLOR); 82 82 83 83 /** … … 163 163 164 164 @Override 165 protected ColorProperty getBaseColorProperty() {165 protected NamedColorProperty getBaseColorProperty() { 166 166 return COLOR_PROPERTY; 167 167 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParser.jj
r12620 r12987 18 18 import java.util.Locale; 19 19 20 import org.openstreetmap.josm.data.preferences. ColorProperty;20 import org.openstreetmap.josm.data.preferences.NamedColorProperty; 21 21 import org.openstreetmap.josm.gui.mappaint.Keyword; 22 22 import org.openstreetmap.josm.gui.mappaint.mapcss.Condition; … … 1134 1134 LOOKAHEAD(2) 1135 1135 pref=ident() t=<HEXCOLOR> 1136 { return new ColorProperty("mappaint." + (sheet == null ? "MapCSS" : sheet.title) + "." + pref, t.image).get(); } 1136 { 1137 return new NamedColorProperty( 1138 NamedColorProperty.COLOR_CATEGORY_MAPPAINT, 1139 sheet == null ? "MapCSS" : sheet.title, pref, 1140 ColorHelper.html2color(t.image)).get(); 1141 } 1137 1142 | 1138 1143 t=<IDENT> { return new Keyword(t.image); } -
trunk/src/org/openstreetmap/josm/gui/preferences/advanced/PreferencesTable.java
r12881 r12987 29 29 import javax.swing.table.DefaultTableModel; 30 30 31 import org.openstreetmap.josm.data.preferences. ColorProperty;31 import org.openstreetmap.josm.data.preferences.NamedColorProperty; 32 32 import org.openstreetmap.josm.spi.preferences.ListListSetting; 33 33 import org.openstreetmap.josm.spi.preferences.ListSetting; … … 336 336 static final class SettingCellRenderer extends DefaultTableCellRenderer { 337 337 private final Color backgroundColor = UIManager.getColor("Table.background"); 338 private final Color changedColor = new ColorProperty(338 private final Color changedColor = new NamedColorProperty( 339 339 marktr("Advanced Background: Changed"), 340 340 new Color(200, 255, 200)).get(); 341 private final Color nonDefaultColor = new ColorProperty(341 private final Color nonDefaultColor = new NamedColorProperty( 342 342 marktr("Advanced Background: NonDefault"), 343 343 new Color(255, 255, 200)).get(); -
trunk/src/org/openstreetmap/josm/gui/preferences/display/ColorPreference.java
r12959 r12987 13 13 import java.text.Collator; 14 14 import java.util.ArrayList; 15 import java.util.Collections;16 15 import java.util.HashMap; 17 16 import java.util.List; 18 17 import java.util.Map; 19 18 import java.util.Objects; 19 import java.util.Optional; 20 import java.util.stream.Collectors; 20 21 21 22 import javax.swing.BorderFactory; … … 34 35 35 36 import org.openstreetmap.josm.Main; 37 import org.openstreetmap.josm.data.preferences.ColorInfo; 36 38 import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors; 39 import org.openstreetmap.josm.data.preferences.NamedColorProperty; 37 40 import org.openstreetmap.josm.data.validation.Severity; 38 41 import org.openstreetmap.josm.gui.MapScaler; … … 52 55 import org.openstreetmap.josm.tools.ColorHelper; 53 56 import org.openstreetmap.josm.tools.GBC; 54 import org.openstreetmap.josm.tools. Logging;57 import org.openstreetmap.josm.tools.I18n; 55 58 56 59 /** 57 60 * Color preferences. 61 * 62 * GUI preference to let the user customize named colors. 63 * @see NamedColorProperty 58 64 */ 59 65 public class ColorPreference implements SubPreferenceSetting { … … 78 84 private static class ColorEntry { 79 85 String key; 80 Color color;81 82 ColorEntry(String key, String colorHtml) {86 ColorInfo info; 87 88 ColorEntry(String key, ColorInfo info) { 83 89 CheckParameterUtil.ensureParameterNotNull(key, "key"); 90 CheckParameterUtil.ensureParameterNotNull(info, "info"); 84 91 this.key = key; 85 this.color = ColorHelper.html2color(colorHtml); 86 if (this.color == null) { 87 Logging.warn("Unable to get color from '"+colorHtml+"' for color preference '"+key+'\''); 88 } 89 } 90 92 this.info = info; 93 } 94 95 /** 96 * Get a description of the color based on the given info. 97 * @return a description of the color 98 */ 91 99 public String getDisplay() { 92 return Main.pref.getColorName(key); 100 switch (info.getCategory()) { 101 case NamedColorProperty.COLOR_CATEGORY_LAYER: 102 String v = null; 103 if (info.getSource() != null) { 104 v = info.getSource(); 105 } 106 if (!info.getName().isEmpty()) { 107 if (v == null) { 108 v = tr(I18n.escape(info.getName())); 109 } else { 110 v += " - " + tr(I18n.escape(info.getName())); 111 } 112 } 113 return tr("Layer: {0}", v); 114 case NamedColorProperty.COLOR_CATEGORY_MAPPAINT: 115 if (info.getSource() != null) 116 return tr("Paint style {0}: {1}", tr(I18n.escape(info.getSource())), tr(info.getName())); 117 // fall through 118 default: 119 if (info.getSource() != null) 120 return tr(I18n.escape(info.getSource())) + " - " + tr(I18n.escape(info.getName())); 121 else 122 return tr(I18n.escape(info.getName())); 123 } 124 } 125 126 /** 127 * Get the color value to display. 128 * Either value (if set) or default value. 129 * @return the color value to display 130 */ 131 public Color getDisplayColor() { 132 return Optional.ofNullable(info.getValue()).orElse(info.getDefaultValue()); 133 } 134 135 /** 136 * Check if color has been customized by the user or not. 137 * @return true if the color is at its default value, false if it is customized by the user. 138 */ 139 public boolean isDefault() { 140 return info.getValue() == null || Objects.equals(info.getValue(), info.getDefaultValue()); 141 } 142 143 /** 144 * Convert to a {@link NamedColorProperty}. 145 * @return a {@link NamedColorProperty} 146 */ 147 public NamedColorProperty toProperty() { 148 return new NamedColorProperty(info.getCategory(), info.getSource(), 149 info.getName(), info.getDefaultValue()); 93 150 } 94 151 } … … 143 200 @Override 144 201 public Object getValueAt(int rowIndex, int columnIndex) { 145 return columnIndex == 0 ? data.get(rowIndex) : data.get(rowIndex). color;202 return columnIndex == 0 ? data.get(rowIndex) : data.get(rowIndex).getDisplayColor(); 146 203 } 147 204 … … 159 216 public void setValueAt(Object aValue, int rowIndex, int columnIndex) { 160 217 if (columnIndex == 1 && aValue instanceof Color) { 161 data.get(rowIndex). color = (Color) aValue;218 data.get(rowIndex).info.setValue((Color) aValue); 162 219 fireTableRowsUpdated(rowIndex, rowIndex); 163 220 } 221 } 222 } 223 224 /** 225 * Set the colors to be shown in the preference table. This method creates a table model if 226 * none exists and overwrites all existing values. 227 * @param colorMap the map holding the colors 228 * (key = preference key, value = {@link ColorInfo} instance) 229 */ 230 public void setColors(Map<String, ColorInfo> colorMap) { 231 if (tableModel == null) { 232 tableModel = new ColorTableModel(); 233 } 234 tableModel.clear(); 235 236 // fill model with colors: 237 colorMap.entrySet().stream() 238 .map(e -> new ColorEntry(e.getKey(), e.getValue())) 239 .sorted((e1, e2) -> { 240 int cat = Integer.compare( 241 getCategroyPriority(e1.info.getCategory()), 242 getCategroyPriority(e2.info.getCategory())); 243 if (cat != 0) return cat; 244 return Collator.getInstance().compare(e1.getDisplay(), e2.getDisplay()); 245 }) 246 .forEach(tableModel::addEntry); 247 248 if (this.colors != null) { 249 this.colors.repaint(); 250 } 251 252 } 253 254 private static int getCategroyPriority(String category) { 255 switch (category) { 256 case NamedColorProperty.COLOR_CATEGORY_GENERAL: return 1; 257 case NamedColorProperty.COLOR_CATEGORY_MAPPAINT: return 2; 258 case NamedColorProperty.COLOR_CATEGORY_LAYER: return 3; 259 default: return 4; 164 260 } 165 261 } … … 171 267 * (key = color id (without prefixes, so only <code>background</code>; not <code>color.background</code>), 172 268 * value = html representation of the color. 173 */ 269 * @deprecated (since 12987) replaced by {@link #setColors(java.util.Map)} 270 */ 271 @Deprecated 174 272 public void setColorModel(Map<String, String> colorMap) { 175 if (tableModel == null) { 176 tableModel = new ColorTableModel(); 177 } 178 179 tableModel.clear(); 180 // fill model with colors: 181 List<ColorEntry> colorKeyList = new ArrayList<>(); 182 List<ColorEntry> colorKeyListMappaint = new ArrayList<>(); 183 List<ColorEntry> colorKeyListLayer = new ArrayList<>(); 184 for (Map.Entry<String, String> e : colorMap.entrySet()) { 185 String key = e.getKey(); 186 String html = e.getValue(); 187 if (key.startsWith("layer.")) { 188 colorKeyListLayer.add(new ColorEntry(key, html)); 189 } else if (key.startsWith("mappaint.")) { 190 colorKeyListMappaint.add(new ColorEntry(key, html)); 191 } else { 192 colorKeyList.add(new ColorEntry(key, html)); 193 } 194 } 195 addColorRows(colorKeyList); 196 addColorRows(colorKeyListMappaint); 197 addColorRows(colorKeyListLayer); 198 if (this.colors != null) { 199 this.colors.repaint(); 200 } 201 } 202 203 private void addColorRows(List<ColorEntry> entries) { 204 Collections.sort(entries, (e1, e2) -> Collator.getInstance().compare(e1.getDisplay(), e2.getDisplay())); 205 entries.forEach(tableModel::addEntry); 273 setColors(colorMap.entrySet().stream().collect(Collectors.toMap(e->e.getKey(), e-> 274 new ColorInfo(NamedColorProperty.COLOR_CATEGORY_GENERAL, null, e.getKey(), ColorHelper.html2color(e.getValue()), null)))); 275 } 276 277 /** 278 * Returns a map with the colors in the table (key = preference key, value = color info). 279 * @return a map holding the colors. 280 */ 281 public Map<String, ColorInfo> getColors() { 282 return tableModel.getData().stream().collect(Collectors.toMap(e -> e.key, e -> e.info)); 206 283 } 207 284 … … 209 286 * Returns a map with the colors in the table (key = color name without prefix, value = html color code). 210 287 * @return a map holding the colors. 211 */ 288 * @deprecated replaced by {@link #getColors()} 289 */ 290 @Deprecated 212 291 public Map<String, String> getColorModel() { 213 292 Map<String, String> colorMap = new HashMap<>(); 214 293 for (ColorEntry e : tableModel.getData()) { 215 colorMap.put(e.key, ColorHelper.color2html(e. color));294 colorMap.put(e.key, ColorHelper.color2html(e.getDisplayColor())); 216 295 } 217 296 return colorMap; … … 221 300 public void addGui(final PreferenceTabbedPane gui) { 222 301 fixColorPrefixes(); 223 setColor Model(Main.pref.getAllColors());302 setColors(Main.pref.getAllNamedColors()); 224 303 225 304 colorEdit = new JButton(tr("Choose")); … … 227 306 int sel = colors.getSelectedRow(); 228 307 ColorEntry ce = tableModel.getEntry(sel); 229 JColorChooser chooser = new JColorChooser(ce. color);308 JColorChooser chooser = new JColorChooser(ce.getDisplayColor()); 230 309 int answer = JOptionPane.showConfirmDialog( 231 310 gui, chooser, … … 293 372 ColorEntry e = (ColorEntry) value; 294 373 label.setText(e.getDisplay()); 295 if (! Objects.equals(e.color, Main.pref.getDefaultColor(e.key))) {374 if (!e.isDefault()) { 296 375 label.setFont(label.getFont().deriveFont(Font.BOLD)); 297 376 } else { … … 339 418 340 419 Boolean isRemoveColor(int row) { 341 return tableModel.getEntry(row). key.startsWith("layer.");420 return tableModel.getEntry(row).info.getCategory().equals(NamedColorProperty.COLOR_CATEGORY_LAYER); 342 421 } 343 422 … … 361 440 boolean ret = false; 362 441 for (ColorEntry d : tableModel.getDeleted()) { 363 Main.pref.putColor(d.key, null);442 d.toProperty().remove(); 364 443 } 365 444 for (ColorEntry e : tableModel.getData()) { 366 if (Main.pref.putColor(e.key, e.color) && e.key.startsWith("mappaint.")) { 367 ret = true; 445 if (!e.isDefault()) { 446 if (e.toProperty().put(e.info.getValue()) 447 && e.key.startsWith("mappaint.")) { 448 ret = true; 449 } 368 450 } 369 451 } -
trunk/src/org/openstreetmap/josm/gui/preferences/display/GPXSettingsPanel.java
r12896 r12987 26 26 import org.openstreetmap.josm.actions.ExpertToggleAction; 27 27 import org.openstreetmap.josm.data.PreferencesUtils; 28 import org.openstreetmap.josm.data.preferences.NamedColorProperty; 28 29 import org.openstreetmap.josm.gui.layer.gpx.GpxDrawHelper; 29 30 import org.openstreetmap.josm.gui.layer.markerlayer.Marker; … … 329 330 // ask the GPX draw for the correct color of that layer ( if there is one ) 330 331 if (null != layerName) { 331 color = GpxDrawHelper.DEFAULT_COLOR.getChildColor(layerName).get(); 332 color = GpxDrawHelper.DEFAULT_COLOR.getChildColor( 333 NamedColorProperty.COLOR_CATEGORY_LAYER, layerName, GpxDrawHelper.DEFAULT_COLOR.getName()).get(); 332 334 } else { 333 335 color = GpxDrawHelper.DEFAULT_COLOR.getDefaultValue(); -
trunk/src/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreference.java
r12643 r12987 60 60 import org.openstreetmap.josm.data.imagery.OffsetBookmark; 61 61 import org.openstreetmap.josm.data.imagery.Shape; 62 import org.openstreetmap.josm.data.preferences. ColorProperty;62 import org.openstreetmap.josm.data.preferences.NamedColorProperty; 63 63 import org.openstreetmap.josm.gui.MainApplication; 64 64 import org.openstreetmap.josm.gui.download.DownloadDialog; … … 248 248 private static class ImageryURLTableCellRenderer extends DefaultTableCellRenderer { 249 249 250 private static final ColorProperty IMAGERY_BACKGROUND_COLOR = newColorProperty(250 private static final NamedColorProperty IMAGERY_BACKGROUND_COLOR = new NamedColorProperty( 251 251 marktr("Imagery Background: Default"), 252 252 new Color(200, 255, 200)); -
trunk/src/org/openstreetmap/josm/gui/preferences/shortcut/PrefJPanel.java
r12620 r12987 45 45 import javax.swing.table.TableRowSorter; 46 46 47 import org.openstreetmap.josm.data.preferences. ColorProperty;47 import org.openstreetmap.josm.data.preferences.NamedColorProperty; 48 48 import org.openstreetmap.josm.gui.util.GuiHelper; 49 49 import org.openstreetmap.josm.gui.widgets.JosmComboBox; … … 160 160 private class ShortcutTableCellRenderer extends DefaultTableCellRenderer { 161 161 162 private final transient ColorProperty SHORTCUT_BACKGROUND_USER_COLOR = newColorProperty(162 private final transient NamedColorProperty SHORTCUT_BACKGROUND_USER_COLOR = new NamedColorProperty( 163 163 marktr("Shortcut Background: User"), 164 164 new Color(200, 255, 200)); 165 private final transient ColorProperty SHORTCUT_BACKGROUND_MODIFIED_COLOR = newColorProperty(165 private final transient NamedColorProperty SHORTCUT_BACKGROUND_MODIFIED_COLOR = new NamedColorProperty( 166 166 marktr("Shortcut Background: Modified"), 167 167 new Color(255, 255, 200));
Note: See TracChangeset
for help on using the changeset viewer.