Class NamedColorSet


  • public abstract class NamedColorSet
    extends java.lang.Object
    Defines a set of colours with associated names. This is quite like a map, but the colours can be retrieved with variant keys (modified spellings, case folding etc). A couple of useful instances are supplied.
    Since:
    23 Feb 2017
    Author:
    Mark Taylor
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static NamedColorSet CSS
      Standard CSS/SVG/HTML/JS list of colours (140 entries).
      static NamedColorSet CSS_DARK
      CSS with all the very light colours (except White) removed.
    • Constructor Summary

      Constructors 
      Constructor Description
      NamedColorSet​(java.util.Map<java.lang.String,​java.awt.Color> map)
      Constructor.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      java.awt.Color getColor​(java.lang.String name)
      Returns the colour for a given name.
      java.util.Map<java.lang.String,​java.awt.Color> getMap()
      Returns the colour map on which this named set is based.
      abstract java.lang.String toKey​(java.lang.String name)
      Normalises a colour name to turn it into a map key.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • NamedColorSet

        public NamedColorSet​(java.util.Map<java.lang.String,​java.awt.Color> map)
        Constructor.
        Parameters:
        map - name->color map
    • Method Detail

      • getMap

        public java.util.Map<java.lang.String,​java.awt.Color> getMap()
        Returns the colour map on which this named set is based.
        Returns:
        map
      • getColor

        public java.awt.Color getColor​(java.lang.String name)
        Returns the colour for a given name. This name is normalised using the toKey(java.lang.String) method before matching.
        Parameters:
        name - approximate name
        Returns:
        colour, or null
      • toKey

        public abstract java.lang.String toKey​(java.lang.String name)
        Normalises a colour name to turn it into a map key.
        Parameters:
        name - approximate name
        Returns:
        name used for matching