001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.data.osm.visitor.paint; 003 004import static org.openstreetmap.josm.tools.I18n.marktr; 005 006import java.awt.Color; 007 008import org.openstreetmap.josm.data.preferences.CachingProperty; 009import org.openstreetmap.josm.data.preferences.NamedColorProperty; 010import org.openstreetmap.josm.gui.mappaint.MapPaintStyles; 011 012/** 013 * The colors used to paint the map, especially with the wireframe renderer 014 * <p> 015 * This enum stores the colors to be set in the preferences 016 */ 017public enum PaintColors { 018 019 /** 020 * Inactive objects 021 */ 022 INACTIVE(marktr("inactive"), Color.darkGray), 023 /** 024 * Currently selected objects 025 */ 026 SELECTED(marktr("selected"), Color.red), 027 /** 028 * Objects that are part of a selected relation 029 */ 030 RELATIONSELECTED(marktr("Relation: selected"), Color.magenta), 031 /** 032 * Normal nodes 033 */ 034 NODE(marktr("Node: standard"), Color.yellow), 035 /** 036 * Connected nodes 037 */ 038 CONNECTION(marktr("Node: connection"), Color.yellow), 039 /** 040 * A tagged node 041 */ 042 TAGGED(marktr("Node: tagged"), new Color(204, 255, 255)), // light cyan 043 /** 044 * Default way color 045 */ 046 DEFAULT_WAY(marktr("way"), new Color(0, 0, 128)), // dark blue 047 /** 048 * Relation color 049 */ 050 RELATION(marktr("relation"), new Color(0, 128, 128)), // teal 051 /** 052 * Color for untagged way 053 */ 054 UNTAGGED_WAY(marktr("untagged way"), new Color(0, 128, 0)), // dark green 055 /** 056 * Background of the map 057 */ 058 BACKGROUND(marktr("background"), Color.BLACK), 059 /** 060 * Highlight around a selected node/way, MapCSS renderer 061 */ 062 HIGHLIGHT(marktr("highlight"), SELECTED.get()), 063 /** 064 * Highlight around a selected node/way, Wireframe renderer 065 */ 066 HIGHLIGHT_WIREFRAME(marktr("highlight wireframe"), Color.orange), 067 068 /** 069 * Untagged way 070 */ 071 UNTAGGED(marktr("untagged"), Color.GRAY), 072 /** 073 * Default text color 074 */ 075 TEXT(marktr("text"), Color.WHITE), 076 /** 077 * Default text color for areas 078 */ 079 AREA_TEXT(marktr("areatext"), Color.LIGHT_GRAY); 080 081 /** 082 * The name of the color 083 */ 084 private final String name; 085 private final Color defaultColor; 086 private final NamedColorProperty baseProperty; 087 private final CachingProperty<Color> property; 088 089 PaintColors(String name, Color defaultColor) { 090 baseProperty = new NamedColorProperty(name, defaultColor); 091 property = baseProperty.cached(); 092 this.name = name; 093 this.defaultColor = defaultColor; 094 } 095 096 /** 097 * Gets the default value for this color. 098 * @return The default value 099 */ 100 public Color getDefaultValue() { 101 return property.getDefaultValue(); 102 } 103 104 /** 105 * Get the given color 106 * @return The color 107 */ 108 public Color get() { 109 return property.get(); 110 } 111 112 /** 113 * Returns the background color. 114 * @return the background color 115 */ 116 public static Color getBackgroundColor() { 117 return MapPaintStyles.getStyles().getBackgroundColor(); 118 } 119 120 /** 121 * Get the color property 122 * @return The property that is used to access the color. 123 * @since 10874 124 */ 125 public NamedColorProperty getProperty() { 126 return baseProperty; 127 } 128}