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