Class NamedColorProperty


  • public class NamedColorProperty
    extends AbstractToStringProperty<java.awt.Color>
    A property containing a Color value with additional information associated to it. The additional information is used to describe the color in the ColorPreference, so it can be recognized and customized by the user.
    Since:
    12987
    • Constructor Detail

      • NamedColorProperty

        public NamedColorProperty​(java.lang.String category,
                                  java.lang.String source,
                                  java.lang.String name,
                                  java.awt.Color defaultValue)
        Construct a new NamedColorProperty. The priority for getting the color is: 1. a set property, 2. UIManager.getColor(java.lang.Object), 3. the given defaultValue
        Parameters:
        category - a category, can be any identifier, but the following values are recognized by the GUI preferences: COLOR_CATEGORY_GENERAL and COLOR_CATEGORY_MAPPAINT
        source - a filename or similar associated with the color, can be null if not applicable
        name - a short description of the color
        defaultValue - the default value, can be null
      • NamedColorProperty

        public NamedColorProperty​(java.lang.String name,
                                  java.awt.Color defaultValue)
        Construct a new NamedColorProperty.
        Parameters:
        name - a short description of the color
        defaultValue - the default value, can be null
    • Method Detail

      • getKey

        private static java.lang.String getKey​(java.lang.String category,
                                               java.lang.String source,
                                               java.lang.String name)
      • getUIColor

        private static java.awt.Color getUIColor​(java.lang.String uiKey,
                                                 java.awt.Color defaultValue)
      • isSet

        public boolean isSet()
        Description copied from class: AbstractProperty
        Determines if this property is currently set in JOSM preferences.
        Overrides:
        isSet in class AbstractProperty<java.awt.Color>
        Returns:
        true if getPreferences() contains this property.
      • getCategory

        public java.lang.String getCategory()
        Get the category for this color.
        Returns:
        the category
      • getSource

        public java.lang.String getSource()
        Get the source, i.e. a filename or layer name associated with the color. May return null if not applicable.
        Returns:
        the source
      • getName

        public java.lang.String getName()
        Get the color name (a short description of the color).
        Returns:
        the color name
      • getValuePref

        private static java.util.List<java.lang.String> getValuePref​(java.awt.Color color,
                                                                     java.lang.String category,
                                                                     java.lang.String source,
                                                                     java.lang.String name)
      • put

        public boolean put​(java.awt.Color value)
        Description copied from class: AbstractProperty
        Sets this property to the specified value.
        Overrides:
        put in class AbstractToStringProperty<java.awt.Color>
        Parameters:
        value - The new value of this property
        Returns:
        true if something has changed (i.e. value is different than before)
      • getChildColor

        public FallbackProperty<java.awt.Color> getChildColor​(java.lang.String category,
                                                              java.lang.String source,
                                                              java.lang.String name)
        Return a more specialized color, that will fall back to this color, if not set explicitly.
        Parameters:
        category - the category of the specialized color
        source - the source of the specialized color
        name - the name of the specialized color
        Returns:
        a FallbackProperty that will the return the specialized color, if set, but fall back to this property as default value
      • getChildColor

        public FallbackProperty<java.awt.Color> getChildColor​(java.lang.String name)
        Return a more specialized color, that will fall back to this color, if not set explicitly.
        Parameters:
        name - the name of the specialized color
        Returns:
        a FallbackProperty that will the return the specialized color, if set, but fall back to this property as default value
      • toString

        protected java.lang.String toString​(java.awt.Color color)
        Description copied from class: AbstractToStringProperty
        Converts the string to an object of the given type.
        Specified by:
        toString in class AbstractToStringProperty<java.awt.Color>
        Parameters:
        color - The object.
        Returns:
        The string representing the object