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 @SuppressWarnings("ImmutableEnumChecker") 082 private final NamedColorProperty baseProperty; 083 @SuppressWarnings("ImmutableEnumChecker") 084 private final CachingProperty<Color> property; 085 086 PaintColors(String name, Color defaultColor) { 087 baseProperty = new NamedColorProperty(name, defaultColor); 088 property = baseProperty.cached(); 089 } 090 091 /** 092 * Gets the default value for this color. 093 * @return The default value 094 */ 095 public Color getDefaultValue() { 096 return property.getDefaultValue(); 097 } 098 099 /** 100 * Get the given color 101 * @return The color 102 */ 103 public Color get() { 104 return property.get(); 105 } 106 107 /** 108 * Returns the background color. 109 * @return the background color 110 */ 111 public static Color getBackgroundColor() { 112 return MapPaintStyles.getStyles().getBackgroundColor(); 113 } 114 115 /** 116 * Get the color property 117 * @return The property that is used to access the color. 118 * @since 10874 119 */ 120 public NamedColorProperty getProperty() { 121 return baseProperty; 122 } 123}