Class CSSColor

java.lang.Object
com.codename1.ui.CSSColor

public final class CSSColor extends Object

Parses the CSS color forms into a packed 0xAARRGGBB integer: #rgb, #rgba, #rrggbb, #rrggbbaa, rgb(...) / rgba(...) with integer or percentage components, and the CSS named-color subset.

This is the single home for CSS color-string parsing in the framework. The runtime CSS gradient parser and the vector map style engine both delegate here so the grammar -- and the named-color table -- lives in exactly one place.

  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    parse(String value)
    Parses a CSS color string into 0xAARRGGBB, throwing IllegalArgumentException when the value is not a recognised color so the caller can choose between a default and a propagated failure.
    static int
    parse(String value, int defaultColor)
    Parses a CSS color string into 0xAARRGGBB, returning defaultColor when the value is null or not a recognised color.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • parse

      public static int parse(String value)
      Parses a CSS color string into 0xAARRGGBB, throwing IllegalArgumentException when the value is not a recognised color so the caller can choose between a default and a propagated failure.
    • parse

      public static int parse(String value, int defaultColor)
      Parses a CSS color string into 0xAARRGGBB, returning defaultColor when the value is null or not a recognised color. The lenient variant for styling input that should degrade gracefully rather than fail.