Class Colors

java.lang.Object
org.apache.sis.io.wkt.Colors
All Implemented Interfaces:
Serializable, Cloneable

public class Colors extends Object implements Cloneable, Serializable
The colors to use for formatting Well Known Text (WKT) objects. Colors are identified by their names and can be mapped to ElementKind. The currently supported color names are:
  • "red", "green", "yellow", "blue", "magenta", "cyan", "gray".
The above list may be expanded in any future SIS version.
Since:
0.4
Version:
0.4
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      For cross-version compatibility.
      See Also:
    • DEFAULT

      public static final Colors DEFAULT
      The default colors used by FormattableObject.print(). Those colors give better results on a Console with black background. This map is immutable.
      See Also:
    • NAMING

      public static final Colors NAMING
      Emphases on identification information (name and identifiers) only. This map is immutable.
    • map

      private EnumMap<ElementKind,X364> map
      The map of colors. Consider this field as final — it is modified only by clone().
    • isImmutable

      private boolean isImmutable
      true if this instance shall be considered as immutable.
  • Constructor Details

    • Colors

      public Colors()
      Creates a new, initially empty, set of colors.
    • Colors

      public Colors(Colors colors)
      Creates a new set of colors initialized to a copy of the given one.
      Parameters:
      colors - the set of colors to copy.
  • Method Details

    • setName

      public void setName(ElementKind key, String color) throws IllegalArgumentException
      Sets the color of the given syntactic element from a color name. The color names supported in the current implementation are "red", "green", "yellow", "blue", "magenta", "cyan" and "gray", case-insensitive.
      Parameters:
      key - the syntactic element for which to set the color.
      color - the color to give to the specified element, or null if none.
      Throws:
      IllegalArgumentException - if the given color name is not recognized.
      UnsupportedOperationException - if this Colors instance is immutable.
    • getName

      public final String getName(ElementKind key)
      Returns the color for the given syntactic element.
      Parameters:
      key - the syntactic element for which to get the color.
      Returns:
      the color of the specified element, or null if none.
    • getAnsiSequence

      final String getAnsiSequence(ElementKind key)
      Returns the ANSI sequence for the given syntactic element, or null if none.
    • immutable

      final Colors immutable()
      Returns an immutable copy of this set of colors, or this if this instance is already immutable.
    • clone

      public Colors clone()
      Returns a clone of this Colors.
      Overrides:
      clone in class Object
      Returns:
      a clone of this Colors.
    • equals

      public boolean equals(Object other)
      Compares this Colors with the given object for equality.
      Overrides:
      equals in class Object
      Parameters:
      other - the object to compare with this Colors.
      Returns:
      true if both objects are equal.
    • hashCode

      public int hashCode()
      Returns a hash code value for this object.
      Overrides:
      hashCode in class Object
      Returns:
      a hash code value.
    • readResolve

      final Object readResolve() throws ObjectStreamException
      Replaces the deserialized instance by DEFAULT one if possible.
      Returns:
      the object to use after deserialization.
      Throws:
      ObjectStreamException - required by specification but should never be thrown.