Package swingtree

Class UI.Color

java.lang.Object
java.awt.Color
swingtree.UI.Color
All Implemented Interfaces:
Paint, Transparency, Serializable
Enclosing class:
UI

@Immutable public static final class UI.Color extends Color
This Color class is a refined and more complete/modernized implementation of the Color class which models colors in the default sRGB color space or colors in arbitrary color spaces identified by a ColorSpace.
The original Color class is an immutable and value based class (it overrides equals and hashCode) but it is missing so called with-methods, which are a modern way to create updated copies of an object without having to call the full constructor with all the parameters.

Here a list of the most useful features additionally provided by this class:

With-Methods

Various Color Constants Also note that this class overrides and fixes the Color.darker() and Color.brighter() methods. Not only do they now return a Color type, but also use an implementation which updates the brightness/darkness in terms of the HSB color space.
(The original implementation considers colors like Color.BLUE, Color.RED and Color.GREEN to be the brightest possible colors, which is not true in terms of the much more useful HSB color space modelling.)

Besides the RGB values every fully opaque Color also has an implicit alpha value of 1.0. But you may also construct a Color with an explicit alpha value by using the Color(float, float, float, float) constructor for example. The alpha value defines the transparency of a color and can be represented by a float value in the range 0.0 - 1.0 or 0 - 255. An alpha value of 1.0 or 255 means that the color is completely opaque and an alpha value of 0 or 0.0 means that the color is completely transparent. When constructing a Color with an explicit alpha or getting the color/alpha components of a Color, the color components are never premultiplied by the alpha component.

The default color space for the Java 2D(tm) API is sRGB, a proposed standard RGB color space. For further information on sRGB, see http://www.w3.org/pub/WWW/Graphics/Color/sRGB.html .

See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final UI.Color
    The color alice blue with an RGB value of #F0F8FF
    static final UI.Color
    The color antique white with an RGB value of #FAEBD7
    static final UI.Color
    The color aqua with an RGB value of #00FFFF
    static final UI.Color
    The color aquamarine with an RGB value of #7FFFD4
    static final UI.Color
    The color azure with an RGB value of #F0FFFF
    static final UI.Color
    The color beige with an RGB value of #F5F5DC
    static final UI.Color
    The color bisque with an RGB value of #FFE4C4
    static final UI.Color
    The color black with an RGB value of #000000
    static final UI.Color
    The color blanched almond with an RGB value of #FFEBCD
    static final UI.Color
    The color blue with an RGB value of #0000FF
    static final UI.Color
    The color blue violet with an RGB value of #8A2BE2
    static final UI.Color
    The color brown with an RGB value of #A52A2A
    static final UI.Color
    The color burly wood with an RGB value of #DEB887
    static final UI.Color
    The color cadet blue with an RGB value of #5F9EA0
    static final UI.Color
    The color chartreuse with an RGB value of #7FFF00
    static final UI.Color
    The color chocolate with an RGB value of #D2691E
    static final UI.Color
    The color coral with an RGB value of #FF7F50
    static final UI.Color
    The color cornflower blue with an RGB value of #6495ED
    static final UI.Color
    The color cornsilk with an RGB value of #FFF8DC
    static final UI.Color
    The color crimson with an RGB value of #DC143C
    static final UI.Color
    The color cyan with an RGB value of #00FFFF
    static final UI.Color
    The color dark blue with an RGB value of #00008B
    static final UI.Color
    The color dark cyan with an RGB value of #008B8B
    static final UI.Color
    The color dark goldenrod with an RGB value of #B8860B
    static final UI.Color
    The color dark gray with an RGB value of #A9A9A9
    static final UI.Color
    The color dark green with an RGB value of #006400
    static final UI.Color
    The color dark grey with an RGB value of #A9A9A9
    static final UI.Color
    The color dark khaki with an RGB value of #BDB76B
    static final UI.Color
    The color dark magenta with an RGB value of #8B008B
    static final UI.Color
    The color dark olive green with an RGB value of #556B2F
    static final UI.Color
    The color dark orange with an RGB value of #FF8C00
    static final UI.Color
    The color dark orchid with an RGB value of #9932CC
    static final UI.Color
    The color dark red with an RGB value of #8B0000
    static final UI.Color
    The color dark salmon with an RGB value of #E9967A
    static final UI.Color
    The color dark sea green with an RGB value of #8FBC8F
    static final UI.Color
    The color dark slate blue with an RGB value of #483D8B
    static final UI.Color
    The color dark slate gray with an RGB value of #2F4F4F
    static final UI.Color
    The color dark slate grey with an RGB value of #2F4F4F
    static final UI.Color
    The color dark turquoise with an RGB value of #00CED1
    static final UI.Color
    The color dark violet with an RGB value of #9400D3
    static final UI.Color
    The color deep pink with an RGB value of #FF1493
    static final UI.Color
    The color deep sky blue with an RGB value of #00BFFF
    static final UI.Color
    The color dim gray with an RGB value of #696969
    static final UI.Color
    The color dim grey with an RGB value of #696969
    static final UI.Color
    The color dodger blue with an RGB value of #1E90FF
    static final UI.Color
    The color firebrick with an RGB value of #B22222
    static final UI.Color
    The color floral white with an RGB value of #FFFAF0
    static final UI.Color
    The color forest green with an RGB value of #228B22
    static final UI.Color
    The color fuchsia with an RGB value of #FF00FF
    static final UI.Color
    The color gainsboro with an RGB value of #DCDCDC
    static final UI.Color
    The color ghost white with an RGB value of #F8F8FF
    static final UI.Color
    The color gold with an RGB value of #FFD700
    static final UI.Color
    The color goldenrod with an RGB value of #DAA520
    static final UI.Color
    The color gray with an RGB value of #808080
    static final UI.Color
    The color green with an RGB value of #008000
    static final UI.Color
    The color green yellow with an RGB value of #ADFF2F
    static final UI.Color
    The color grey with an RGB value of #808080
    static final UI.Color
    The color honeydew with an RGB value of #F0FFF0
    static final UI.Color
    The color hot pink with an RGB value of #FF69B4
    static final UI.Color
    The color indian red with an RGB value of #CD5C5C
    static final UI.Color
    The color indigo with an RGB value of #4B0082
    static final UI.Color
    The color ivory with an RGB value of #FFFFF0
    static final UI.Color
    The color khaki with an RGB value of #F0E68C
    static final UI.Color
    The color lavender with an RGB value of #E6E6FA
    static final UI.Color
    The color lavender blush with an RGB value of #FFF0F5
    static final UI.Color
    The color lawn green with an RGB value of #7CFC00
    static final UI.Color
    The color lemon chiffon with an RGB value of #FFFACD
    static final UI.Color
    The color light blue with an RGB value of #ADD8E6
    static final UI.Color
    The color light coral with an RGB value of #F08080
    static final UI.Color
    The color light cyan with an RGB value of #E0FFFF
    static final UI.Color
    The color light goldenrod yellow with an RGB value of #FAFAD2
    static final UI.Color
    The color light gray with an RGB value of #D3D3D3
    static final UI.Color
    The color light green with an RGB value of #90EE90
    static final UI.Color
    The color light grey with an RGB value of #D3D3D3
    static final UI.Color
    The color light pink with an RGB value of #FFB6C1
    static final UI.Color
    The color light salmon with an RGB value of #FFA07A
    static final UI.Color
    The color light sea green with an RGB value of #20B2AA
    static final UI.Color
    The color light sky blue with an RGB value of #87CEFA
    static final UI.Color
    The color light slate gray with an RGB value of #778899
    static final UI.Color
    The color light slate grey with an RGB value of #778899
    static final UI.Color
    The color light steel blue with an RGB value of #B0C4DE
    static final UI.Color
    The color light yellow with an RGB value of #FFFFE0
    static final UI.Color
    The color lime with an RGB value of #00FF00
    static final UI.Color
    The color lime green with an RGB value of #32CD32
    static final UI.Color
    The color linen with an RGB value of #FAF0E6
    static final UI.Color
    The color magenta with an RGB value of #FF00FF
    static final UI.Color
    The color maroon with an RGB value of #800000
    static final UI.Color
    The color medium aquamarine with an RGB value of #66CDAA
    static final UI.Color
    The color medium blue with an RGB value of #0000CD
    static final UI.Color
    The color medium orchid with an RGB value of #BA55D3
    static final UI.Color
    The color medium purple with an RGB value of #9370DB
    static final UI.Color
    The color medium sea green with an RGB value of #3CB371
    static final UI.Color
    The color medium slate blue with an RGB value of #7B68EE
    static final UI.Color
    The color medium spring green with an RGB value of #00FA9A
    static final UI.Color
    The color medium turquoise with an RGB value of #48D1CC
    static final UI.Color
    The color medium violet red with an RGB value of #C71585
    static final UI.Color
    The color midnight blue with an RGB value of #191970
    static final UI.Color
    The color mint cream with an RGB value of #F5FFFA
    static final UI.Color
    The color misty rose with an RGB value of #FFE4E1
    static final UI.Color
    The color moccasin with an RGB value of #FFE4B5
    static final UI.Color
    The color navajo white with an RGB value of #FFDEAD
    static final UI.Color
    The color navy with an RGB value of #000080
    static final UI.Color
    The color "oak".
    static final UI.Color
    The color old lace with an RGB value of #FDF5E6
    static final UI.Color
    The color olive with an RGB value of #808000
    static final UI.Color
    The color olive drab with an RGB value of #6B8E23
    static final UI.Color
    The color orange with an RGB value of #FFA500
    static final UI.Color
    The color orange red with an RGB value of #FF4500
    static final UI.Color
    The color orchid with an RGB value of #DA70D6
    static final UI.Color
    The color pale goldenrod with an RGB value of #EEE8AA
    static final UI.Color
    The color pale green with an RGB value of #98FB98
    static final UI.Color
    The color pale turquoise with an RGB value of #AFEEEE
    static final UI.Color
    The color pale violet red with an RGB value of #DB7093
    static final UI.Color
    The color papaya whip with an RGB value of #FFEFD5
    static final UI.Color
    The color peach puff with an RGB value of #FFDAB9
    static final UI.Color
    The color peru with an RGB value of #CD853F
    static final UI.Color
    The color pink with an RGB value of #FFC0CB
    static final UI.Color
    The color plum with an RGB value of #DDA0DD
    static final UI.Color
    The color powder blue with an RGB value of #B0E0E6
    static final UI.Color
    The color purple with an RGB value of #800080
    static final UI.Color
    The color red with an RGB value of #FF0000
    static final UI.Color
    The color rosy brown with an RGB value of #BC8F8F
    static final UI.Color
    The color royal blue with an RGB value of #4169E1
    static final UI.Color
    The color saddle brown with an RGB value of #8B4513
    static final UI.Color
    The color salmon with an RGB value of #FA8072
    static final UI.Color
    The color sandy brown with an RGB value of #F4A460
    static final UI.Color
    The color sea green with an RGB value of #2E8B57
    static final UI.Color
    The color sea shell with an RGB value of #FFF5EE
    static final UI.Color
    The color sienna with an RGB value of #A0522D
    static final UI.Color
    The color silver with an RGB value of #C0C0C0
    static final UI.Color
    The color sky blue with an RGB value of #87CEEB
    static final UI.Color
    The color slate blue with an RGB value of #6A5ACD
    static final UI.Color
    The color slate gray with an RGB value of #708090
    static final UI.Color
    The color slate grey with an RGB value of #708090
    static final UI.Color
    The color snow with an RGB value of #FFFAFA
    static final UI.Color
    The color spring green with an RGB value of #00FF7F
    static final UI.Color
    The color steel blue with an RGB value of #4682B4
    static final UI.Color
    The color tan with an RGB value of #D2B48C
    static final UI.Color
    The color teal with an RGB value of #008080
    static final UI.Color
    The color thistle with an RGB value of #D8BFD8
    static final UI.Color
    The color tomato with an RGB value of #FF6347
    static final UI.Color
    A fully transparent color with an ARGB value of #00000000.
    static final UI.Color
    The color turquoise with an RGB value of #40E0D0
    static final UI.Color
    This constant is a UI.Color object with all of its rgba values set to 0.
    static final UI.Color
    The color violet with an RGB value of #EE82EE
    static final UI.Color
    The color wheat with an RGB value of #F5DEB3
    static final UI.Color
    The color white with an RGB value of #FFFFFF
    static final UI.Color
    The color white smoke with an RGB value of #F5F5F5
    static final UI.Color
    The color yellow with an RGB value of #FFFF00
    static final UI.Color
    The color yellow green with an RGB value of #9ACD32

    Fields inherited from class java.awt.Color

    black, blue, cyan, DARK_GRAY, darkGray, gray, green, LIGHT_GRAY, lightGray, magenta, orange, pink, red, white, yellow

    Fields inherited from interface java.awt.Transparency

    BITMASK, OPAQUE, TRANSLUCENT
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    The blue component of the Color, in the range 0.0-1.0.
    Creates a new color that is a brighter version of this color.
    brighterBy(double percentage)
    Creates an updated color whose brightness is increased by the specified factor.
    double
    Gets the brightness component of this Color.
    Creates a new color that is a darker version of this color.
    darkerBy(double percentage)
    Creates an updated color whose brightness is decreased by the specified percentage factor.
    Creates a new color that is a less saturated version of this color.
    desaturateBy(double percentage)
    Creates a color which is desaturated by the specified percentage factor.
    Creates an updated color that is grayscale equivalent of this color.
    double
    The green component of the Color, in the range 0.0-1.0.
    double
    hue()
    Gets the hue component of this Color.
    Creates a new color that is inversion of this color.
    static UI.Color
    of(double red, double green, double blue)
    Creates an opaque sRGB color with the specified red, green and blue values in the range 0.0-1.0.
    static UI.Color
    of(double red, double green, double blue, double opacity)
    Creates an sRGB color with the specified RGB values in the range 0-255, and a given opacity.
    static UI.Color
    of(float red, float green, float blue)
    Creates an opaque sRGB color with the specified red, green and blue values in the range 0.0-1.0.
    static UI.Color
    of(float red, float green, float blue, float opacity)
    Creates an sRGB color with the specified RGB values in the range 0-255, and a given opacity.
    static UI.Color
    of(Color color)
    Creates a UI.Color object from a Color object.
    static UI.Color
    of(ColorSpace cspace, float[] components, float alpha)
    Creates a color in the specified ColorSpace with the color components specified in the float array and the specified alpha.
    static UI.Color
    of(String colorString)
     
    static UI.Color
    ofGray(double gray)
    Creates an opaque grey color.
    static UI.Color
    ofGray(double gray, double opacity)
    Creates a grey color.
    static UI.Color
    ofGrayRgb(int gray)
    This is a shortcut for rgb(gray, gray, gray).
    static UI.Color
    ofGrayRgb(int gray, double opacity)
    This is a shortcut for rgb(gray, gray, gray, opacity).
    static UI.Color
    ofHsb(double hue, double saturation, double brightness, double opacity)
    Creates a Color based on the specified values in the HSB color model, and a given opacity.
    static UI.Color
    ofRgb(int rgb)
    Creates an opaque sRGB color with the specified combined RGB value consisting of the red component in bits 16-23, the green component in bits 8-15, and the blue component in bits 0-7.
    static UI.Color
    ofRgb(int rgba, boolean hasalpha)
    Creates an sRGB color with the specified combined RGBA value consisting of the alpha component in bits 24-31, the red component in bits 16-23, the green component in bits 8-15, and the blue component in bits 0-7.
    static UI.Color
    ofRgb(int red, int green, int blue)
    Creates an opaque sRGB color with the specified RGB values in the range 0-255.
    static UI.Color
    ofRgb(int red, int green, int blue, double opacity)
    Creates an sRGB color with the specified RGB values in the range 0-255, and a given opacity.
    static UI.Color
    ofRgba(int r, int g, int b, int a)
    Creates an sRGB color with the specified red, green, blue, and alpha values in the range (0 - 255).
    double
    The opacity of the Color, in the range 0.0-1.0.
    double
    red()
    The red component of the Color, in the range 0.0-1.0.
    Provides an updated color that is a more saturated version of this color.
    saturateBy(double percentage)
    Creates a color which is saturated by the specified percentage factor.
    double
    Gets the saturation component of this Color.
    withAlpha(int alpha)
    Creates and returns an updated version of this color with the alpha component changed to the specified value in the range 0-255.
    withBlue(double blue)
    Returns an updated version of this color with the blue component changed to the specified value in the range 0.0-1.0.
    withBrightness(double brightness)
    Returns an updated version of this color with the brightness changed to the specified value in the range 0.0-1.0.
    withGreen(double green)
    Returns an updated version of this color with the green component changed to the specified value in the range 0.0-1.0.
    withHue(double hue)
    Returns an updated version of this color with the hue changed to the specified value in the range 0.0-360.0.
    withOpacity(double opacity)
    Returns an updated version of this color with the opacity changed to the specified value in the range 0.0-1.0.
    withRed(double red)
    Returns an updated version of this color with the red component changed to the specified value in the range 0.0-1.0.
    withSaturation(double saturation)
    Returns an updated version of this color with the saturation changed to the specified value in the range 0.0-1.0.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • UNDEFINED

      public static final UI.Color UNDEFINED
      This constant is a UI.Color object with all of its rgba values set to 0. Its identity is used to represent the absence of a color being specified, and it is used as a safe replacement for null, meaning that when the style engine of a component encounters it, it will pass it onto the Component.setBackground(java.awt.Color) and Component.setForeground(java.awt.Color) methods as null. Passing null to these methods means that the look and feel determines the coloring.
    • TRANSPARENT

      public static final UI.Color TRANSPARENT
      A fully transparent color with an ARGB value of #00000000.
    • ALICEBLUE

      public static final UI.Color ALICEBLUE
      The color alice blue with an RGB value of #F0F8FF
    • ANTIQUEWHITE

      public static final UI.Color ANTIQUEWHITE
      The color antique white with an RGB value of #FAEBD7
    • AQUA

      public static final UI.Color AQUA
      The color aqua with an RGB value of #00FFFF
    • AQUAMARINE

      public static final UI.Color AQUAMARINE
      The color aquamarine with an RGB value of #7FFFD4
    • AZURE

      public static final UI.Color AZURE
      The color azure with an RGB value of #F0FFFF
    • BEIGE

      public static final UI.Color BEIGE
      The color beige with an RGB value of #F5F5DC
    • BISQUE

      public static final UI.Color BISQUE
      The color bisque with an RGB value of #FFE4C4
    • BLACK

      public static final UI.Color BLACK
      The color black with an RGB value of #000000
    • BLANCHEDALMOND

      public static final UI.Color BLANCHEDALMOND
      The color blanched almond with an RGB value of #FFEBCD
    • BLUE

      public static final UI.Color BLUE
      The color blue with an RGB value of #0000FF
    • BLUEVIOLET

      public static final UI.Color BLUEVIOLET
      The color blue violet with an RGB value of #8A2BE2
    • BROWN

      public static final UI.Color BROWN
      The color brown with an RGB value of #A52A2A
    • BURLYWOOD

      public static final UI.Color BURLYWOOD
      The color burly wood with an RGB value of #DEB887
    • CADETBLUE

      public static final UI.Color CADETBLUE
      The color cadet blue with an RGB value of #5F9EA0
    • CHARTREUSE

      public static final UI.Color CHARTREUSE
      The color chartreuse with an RGB value of #7FFF00
    • CHOCOLATE

      public static final UI.Color CHOCOLATE
      The color chocolate with an RGB value of #D2691E
    • CORAL

      public static final UI.Color CORAL
      The color coral with an RGB value of #FF7F50
    • CORNFLOWERBLUE

      public static final UI.Color CORNFLOWERBLUE
      The color cornflower blue with an RGB value of #6495ED
    • CORNSILK

      public static final UI.Color CORNSILK
      The color cornsilk with an RGB value of #FFF8DC
    • CRIMSON

      public static final UI.Color CRIMSON
      The color crimson with an RGB value of #DC143C
    • CYAN

      public static final UI.Color CYAN
      The color cyan with an RGB value of #00FFFF
    • DARKBLUE

      public static final UI.Color DARKBLUE
      The color dark blue with an RGB value of #00008B
    • DARKCYAN

      public static final UI.Color DARKCYAN
      The color dark cyan with an RGB value of #008B8B
    • DARKGOLDENROD

      public static final UI.Color DARKGOLDENROD
      The color dark goldenrod with an RGB value of #B8860B
    • DARKGRAY

      public static final UI.Color DARKGRAY
      The color dark gray with an RGB value of #A9A9A9
    • DARKGREEN

      public static final UI.Color DARKGREEN
      The color dark green with an RGB value of #006400
    • DARKGREY

      public static final UI.Color DARKGREY
      The color dark grey with an RGB value of #A9A9A9
    • DARKKHAKI

      public static final UI.Color DARKKHAKI
      The color dark khaki with an RGB value of #BDB76B
    • DARKMAGENTA

      public static final UI.Color DARKMAGENTA
      The color dark magenta with an RGB value of #8B008B
    • DARKOLIVEGREEN

      public static final UI.Color DARKOLIVEGREEN
      The color dark olive green with an RGB value of #556B2F
    • DARKORANGE

      public static final UI.Color DARKORANGE
      The color dark orange with an RGB value of #FF8C00
    • DARKORCHID

      public static final UI.Color DARKORCHID
      The color dark orchid with an RGB value of #9932CC
    • DARKRED

      public static final UI.Color DARKRED
      The color dark red with an RGB value of #8B0000
    • DARKSALMON

      public static final UI.Color DARKSALMON
      The color dark salmon with an RGB value of #E9967A
    • DARKSEAGREEN

      public static final UI.Color DARKSEAGREEN
      The color dark sea green with an RGB value of #8FBC8F
    • DARKSLATEBLUE

      public static final UI.Color DARKSLATEBLUE
      The color dark slate blue with an RGB value of #483D8B
    • DARKSLATEGRAY

      public static final UI.Color DARKSLATEGRAY
      The color dark slate gray with an RGB value of #2F4F4F
    • DARKSLATEGREY

      public static final UI.Color DARKSLATEGREY
      The color dark slate grey with an RGB value of #2F4F4F
    • DARKTURQUOISE

      public static final UI.Color DARKTURQUOISE
      The color dark turquoise with an RGB value of #00CED1
    • DARKVIOLET

      public static final UI.Color DARKVIOLET
      The color dark violet with an RGB value of #9400D3
    • DEEPPINK

      public static final UI.Color DEEPPINK
      The color deep pink with an RGB value of #FF1493
    • DEEPSKYBLUE

      public static final UI.Color DEEPSKYBLUE
      The color deep sky blue with an RGB value of #00BFFF
    • DIMGRAY

      public static final UI.Color DIMGRAY
      The color dim gray with an RGB value of #696969
    • DIMGREY

      public static final UI.Color DIMGREY
      The color dim grey with an RGB value of #696969
    • DODGERBLUE

      public static final UI.Color DODGERBLUE
      The color dodger blue with an RGB value of #1E90FF
    • FIREBRICK

      public static final UI.Color FIREBRICK
      The color firebrick with an RGB value of #B22222
    • FLORALWHITE

      public static final UI.Color FLORALWHITE
      The color floral white with an RGB value of #FFFAF0
    • FORESTGREEN

      public static final UI.Color FORESTGREEN
      The color forest green with an RGB value of #228B22
    • FUCHSIA

      public static final UI.Color FUCHSIA
      The color fuchsia with an RGB value of #FF00FF
    • GAINSBORO

      public static final UI.Color GAINSBORO
      The color gainsboro with an RGB value of #DCDCDC
    • GHOSTWHITE

      public static final UI.Color GHOSTWHITE
      The color ghost white with an RGB value of #F8F8FF
    • GOLD

      public static final UI.Color GOLD
      The color gold with an RGB value of #FFD700
    • GOLDENROD

      public static final UI.Color GOLDENROD
      The color goldenrod with an RGB value of #DAA520
    • GRAY

      public static final UI.Color GRAY
      The color gray with an RGB value of #808080
    • GREEN

      public static final UI.Color GREEN
      The color green with an RGB value of #008000
    • GREENYELLOW

      public static final UI.Color GREENYELLOW
      The color green yellow with an RGB value of #ADFF2F
    • GREY

      public static final UI.Color GREY
      The color grey with an RGB value of #808080
    • HONEYDEW

      public static final UI.Color HONEYDEW
      The color honeydew with an RGB value of #F0FFF0
    • HOTPINK

      public static final UI.Color HOTPINK
      The color hot pink with an RGB value of #FF69B4
    • INDIANRED

      public static final UI.Color INDIANRED
      The color indian red with an RGB value of #CD5C5C
    • INDIGO

      public static final UI.Color INDIGO
      The color indigo with an RGB value of #4B0082
    • IVORY

      public static final UI.Color IVORY
      The color ivory with an RGB value of #FFFFF0
    • KHAKI

      public static final UI.Color KHAKI
      The color khaki with an RGB value of #F0E68C
    • LAVENDER

      public static final UI.Color LAVENDER
      The color lavender with an RGB value of #E6E6FA
    • LAVENDERBLUSH

      public static final UI.Color LAVENDERBLUSH
      The color lavender blush with an RGB value of #FFF0F5
    • LAWNGREEN

      public static final UI.Color LAWNGREEN
      The color lawn green with an RGB value of #7CFC00
    • LEMONCHIFFON

      public static final UI.Color LEMONCHIFFON
      The color lemon chiffon with an RGB value of #FFFACD
    • LIGHTBLUE

      public static final UI.Color LIGHTBLUE
      The color light blue with an RGB value of #ADD8E6
    • LIGHTCORAL

      public static final UI.Color LIGHTCORAL
      The color light coral with an RGB value of #F08080
    • LIGHTCYAN

      public static final UI.Color LIGHTCYAN
      The color light cyan with an RGB value of #E0FFFF
    • LIGHTGOLDENRODYELLOW

      public static final UI.Color LIGHTGOLDENRODYELLOW
      The color light goldenrod yellow with an RGB value of #FAFAD2
    • LIGHTGRAY

      public static final UI.Color LIGHTGRAY
      The color light gray with an RGB value of #D3D3D3
    • LIGHTGREEN

      public static final UI.Color LIGHTGREEN
      The color light green with an RGB value of #90EE90
    • LIGHTGREY

      public static final UI.Color LIGHTGREY
      The color light grey with an RGB value of #D3D3D3
    • LIGHTPINK

      public static final UI.Color LIGHTPINK
      The color light pink with an RGB value of #FFB6C1
    • LIGHTSALMON

      public static final UI.Color LIGHTSALMON
      The color light salmon with an RGB value of #FFA07A
    • LIGHTSEAGREEN

      public static final UI.Color LIGHTSEAGREEN
      The color light sea green with an RGB value of #20B2AA
    • LIGHTSKYBLUE

      public static final UI.Color LIGHTSKYBLUE
      The color light sky blue with an RGB value of #87CEFA
    • LIGHTSLATEGRAY

      public static final UI.Color LIGHTSLATEGRAY
      The color light slate gray with an RGB value of #778899
    • LIGHTSLATEGREY

      public static final UI.Color LIGHTSLATEGREY
      The color light slate grey with an RGB value of #778899
    • LIGHTSTEELBLUE

      public static final UI.Color LIGHTSTEELBLUE
      The color light steel blue with an RGB value of #B0C4DE
    • LIGHTYELLOW

      public static final UI.Color LIGHTYELLOW
      The color light yellow with an RGB value of #FFFFE0
    • LIME

      public static final UI.Color LIME
      The color lime with an RGB value of #00FF00
    • LIMEGREEN

      public static final UI.Color LIMEGREEN
      The color lime green with an RGB value of #32CD32
    • LINEN

      public static final UI.Color LINEN
      The color linen with an RGB value of #FAF0E6
    • MAGENTA

      public static final UI.Color MAGENTA
      The color magenta with an RGB value of #FF00FF
    • MAROON

      public static final UI.Color MAROON
      The color maroon with an RGB value of #800000
    • MEDIUMAQUAMARINE

      public static final UI.Color MEDIUMAQUAMARINE
      The color medium aquamarine with an RGB value of #66CDAA
    • MEDIUMBLUE

      public static final UI.Color MEDIUMBLUE
      The color medium blue with an RGB value of #0000CD
    • MEDIUMORCHID

      public static final UI.Color MEDIUMORCHID
      The color medium orchid with an RGB value of #BA55D3
    • MEDIUMPURPLE

      public static final UI.Color MEDIUMPURPLE
      The color medium purple with an RGB value of #9370DB
    • MEDIUMSEAGREEN

      public static final UI.Color MEDIUMSEAGREEN
      The color medium sea green with an RGB value of #3CB371
    • MEDIUMSLATEBLUE

      public static final UI.Color MEDIUMSLATEBLUE
      The color medium slate blue with an RGB value of #7B68EE
    • MEDIUMSPRINGGREEN

      public static final UI.Color MEDIUMSPRINGGREEN
      The color medium spring green with an RGB value of #00FA9A
    • MEDIUMTURQUOISE

      public static final UI.Color MEDIUMTURQUOISE
      The color medium turquoise with an RGB value of #48D1CC
    • MEDIUMVIOLETRED

      public static final UI.Color MEDIUMVIOLETRED
      The color medium violet red with an RGB value of #C71585
    • MIDNIGHTBLUE

      public static final UI.Color MIDNIGHTBLUE
      The color midnight blue with an RGB value of #191970
    • MINTCREAM

      public static final UI.Color MINTCREAM
      The color mint cream with an RGB value of #F5FFFA
    • MISTYROSE

      public static final UI.Color MISTYROSE
      The color misty rose with an RGB value of #FFE4E1
    • MOCCASIN

      public static final UI.Color MOCCASIN
      The color moccasin with an RGB value of #FFE4B5
    • OAK

      public static final UI.Color OAK
      The color "oak".
    • OLDLACE

      public static final UI.Color OLDLACE
      The color old lace with an RGB value of #FDF5E6
    • OLIVE

      public static final UI.Color OLIVE
      The color olive with an RGB value of #808000
    • OLIVEDRAB

      public static final UI.Color OLIVEDRAB
      The color olive drab with an RGB value of #6B8E23
    • ORANGE

      public static final UI.Color ORANGE
      The color orange with an RGB value of #FFA500
    • ORANGERED

      public static final UI.Color ORANGERED
      The color orange red with an RGB value of #FF4500
    • ORCHID

      public static final UI.Color ORCHID
      The color orchid with an RGB value of #DA70D6
    • PALEGOLDENROD

      public static final UI.Color PALEGOLDENROD
      The color pale goldenrod with an RGB value of #EEE8AA
    • PALEGREEN

      public static final UI.Color PALEGREEN
      The color pale green with an RGB value of #98FB98
    • PALETURQUOISE

      public static final UI.Color PALETURQUOISE
      The color pale turquoise with an RGB value of #AFEEEE
    • PALEVIOLETRED

      public static final UI.Color PALEVIOLETRED
      The color pale violet red with an RGB value of #DB7093
    • PAPAYAWHIP

      public static final UI.Color PAPAYAWHIP
      The color papaya whip with an RGB value of #FFEFD5
    • PEACHPUFF

      public static final UI.Color PEACHPUFF
      The color peach puff with an RGB value of #FFDAB9
    • PERU

      public static final UI.Color PERU
      The color peru with an RGB value of #CD853F
    • PINK

      public static final UI.Color PINK
      The color pink with an RGB value of #FFC0CB
    • PLUM

      public static final UI.Color PLUM
      The color plum with an RGB value of #DDA0DD
    • POWDERBLUE

      public static final UI.Color POWDERBLUE
      The color powder blue with an RGB value of #B0E0E6
    • PURPLE

      public static final UI.Color PURPLE
      The color purple with an RGB value of #800080
    • RED

      public static final UI.Color RED
      The color red with an RGB value of #FF0000
    • ROSYBROWN

      public static final UI.Color ROSYBROWN
      The color rosy brown with an RGB value of #BC8F8F
    • ROYALBLUE

      public static final UI.Color ROYALBLUE
      The color royal blue with an RGB value of #4169E1
    • SADDLEBROWN

      public static final UI.Color SADDLEBROWN
      The color saddle brown with an RGB value of #8B4513
    • SALMON

      public static final UI.Color SALMON
      The color salmon with an RGB value of #FA8072
    • SANDYBROWN

      public static final UI.Color SANDYBROWN
      The color sandy brown with an RGB value of #F4A460
    • SEAGREEN

      public static final UI.Color SEAGREEN
      The color sea green with an RGB value of #2E8B57
    • SEASHELL

      public static final UI.Color SEASHELL
      The color sea shell with an RGB value of #FFF5EE
    • SIENNA

      public static final UI.Color SIENNA
      The color sienna with an RGB value of #A0522D
    • SILVER

      public static final UI.Color SILVER
      The color silver with an RGB value of #C0C0C0
    • SKYBLUE

      public static final UI.Color SKYBLUE
      The color sky blue with an RGB value of #87CEEB
    • SLATEBLUE

      public static final UI.Color SLATEBLUE
      The color slate blue with an RGB value of #6A5ACD
    • SLATEGRAY

      public static final UI.Color SLATEGRAY
      The color slate gray with an RGB value of #708090
    • SLATEGREY

      public static final UI.Color SLATEGREY
      The color slate grey with an RGB value of #708090
    • SNOW

      public static final UI.Color SNOW
      The color snow with an RGB value of #FFFAFA
    • SPRINGGREEN

      public static final UI.Color SPRINGGREEN
      The color spring green with an RGB value of #00FF7F
    • STEELBLUE

      public static final UI.Color STEELBLUE
      The color steel blue with an RGB value of #4682B4
    • TAN

      public static final UI.Color TAN
      The color tan with an RGB value of #D2B48C
    • TEAL

      public static final UI.Color TEAL
      The color teal with an RGB value of #008080
    • THISTLE

      public static final UI.Color THISTLE
      The color thistle with an RGB value of #D8BFD8
    • TOMATO

      public static final UI.Color TOMATO
      The color tomato with an RGB value of #FF6347
    • TURQUOISE

      public static final UI.Color TURQUOISE
      The color turquoise with an RGB value of #40E0D0
    • VIOLET

      public static final UI.Color VIOLET
      The color violet with an RGB value of #EE82EE
    • WHEAT

      public static final UI.Color WHEAT
      The color wheat with an RGB value of #F5DEB3
    • WHITE

      public static final UI.Color WHITE
      The color white with an RGB value of #FFFFFF
    • WHITESMOKE

      public static final UI.Color WHITESMOKE
      The color white smoke with an RGB value of #F5F5F5
    • YELLOW

      public static final UI.Color YELLOW
      The color yellow with an RGB value of #FFFF00
    • YELLOWGREEN

      public static final UI.Color YELLOWGREEN
      The color yellow green with an RGB value of #9ACD32
  • Method Details

    • of

      public static UI.Color of(Color color)
      Creates a UI.Color object from a Color object.
      Parameters:
      color - The color to convert to a color.
      Returns:
      The color object.
    • ofRgb

      public static UI.Color ofRgb(int red, int green, int blue)
      Creates an opaque sRGB color with the specified RGB values in the range 0-255.
      Parameters:
      red - the red component, in the range 0-255
      green - the green component, in the range 0-255
      blue - the blue component, in the range 0-255
      Returns:
      the Color
      Throws:
      IllegalArgumentException - if any value is out of range
    • ofRgba

      public static UI.Color ofRgba(int r, int g, int b, int a)
      Creates an sRGB color with the specified red, green, blue, and alpha values in the range (0 - 255).
      Parameters:
      r - the red component
      g - the green component
      b - the blue component
      a - the alpha component
      Throws:
      IllegalArgumentException - if r, g, b or a are outside of the range 0 to 255, inclusive
      See Also:
    • ofRgb

      public static UI.Color ofRgb(int rgb)
      Creates an opaque sRGB color with the specified combined RGB value consisting of the red component in bits 16-23, the green component in bits 8-15, and the blue component in bits 0-7. The actual color used in rendering depends on finding the best match given the color space available for a particular output device. Alpha is defaulted to 255.
      Parameters:
      rgb - the combined RGB components
      See Also:
    • ofRgb

      public static UI.Color ofRgb(int rgba, boolean hasalpha)
      Creates an sRGB color with the specified combined RGBA value consisting of the alpha component in bits 24-31, the red component in bits 16-23, the green component in bits 8-15, and the blue component in bits 0-7. If the hasalpha argument is false, alpha is defaulted to 255.
      Parameters:
      rgba - the combined RGBA components
      hasalpha - true if the alpha bits are valid; false otherwise
      See Also:
    • of

      public static UI.Color of(double red, double green, double blue)
      Creates an opaque sRGB color with the specified red, green and blue values in the range 0.0-1.0.
      Parameters:
      red - the red component, in the range 0.0-1.0
      green - the green component, in the range 0.0-1.0
      blue - the blue component, in the range 0.0-1.0
      Returns:
      the Color
      Throws:
      IllegalArgumentException - if any value is out of range
      See Also:
    • of

      public static UI.Color of(float red, float green, float blue)
      Creates an opaque sRGB color with the specified red, green and blue values in the range 0.0-1.0.
      Parameters:
      red - the red component, in the range 0.0-1.0
      green - the green component, in the range 0.0-1.0
      blue - the blue component, in the range 0.0-1.0
      Returns:
      the Color
      Throws:
      IllegalArgumentException - if any value is out of range
      See Also:
    • of

      public static UI.Color of(double red, double green, double blue, double opacity)
      Creates an sRGB color with the specified RGB values in the range 0-255, and a given opacity.
      Parameters:
      red - the red component, in the range 0-255
      green - the green component, in the range 0-255
      blue - the blue component, in the range 0-255
      opacity - the opacity component, in the range 0.0-1.0
      Returns:
      the Color
      Throws:
      IllegalArgumentException - if any value is out of range
      See Also:
    • of

      public static UI.Color of(float red, float green, float blue, float opacity)
      Creates an sRGB color with the specified RGB values in the range 0-255, and a given opacity.
      Parameters:
      red - the red component, in the range 0-255
      green - the green component, in the range 0-255
      blue - the blue component, in the range 0-255
      opacity - the opacity component, in the range 0.0-1.0
      Returns:
      the Color
      Throws:
      IllegalArgumentException - if any value is out of range
      See Also:
    • of

      public static UI.Color of(ColorSpace cspace, float[] components, float alpha)
      Creates a color in the specified ColorSpace with the color components specified in the float array and the specified alpha. The number of components is determined by the type of the ColorSpace. For example, RGB requires 3 components, but CMYK requires 4 components.
      Parameters:
      cspace - the ColorSpace to be used to interpret the components
      components - an arbitrary number of color components that is compatible with the ColorSpace
      alpha - alpha value
      Throws:
      IllegalArgumentException - if any of the values in the components array or alpha is outside of the range 0.0 to 1.0
      See Also:
    • ofRgb

      public static UI.Color ofRgb(int red, int green, int blue, double opacity)
      Creates an sRGB color with the specified RGB values in the range 0-255, and a given opacity.
      Parameters:
      red - the red component, in the range 0-255
      green - the green component, in the range 0-255
      blue - the blue component, in the range 0-255
      opacity - the opacity component, in the range 0.0-1.0
      Returns:
      the Color
      Throws:
      IllegalArgumentException - if any value is out of range
    • ofGrayRgb

      public static UI.Color ofGrayRgb(int gray)
      This is a shortcut for rgb(gray, gray, gray).
      Parameters:
      gray - the gray component, in the range 0-255
      Returns:
      the Color
    • ofGrayRgb

      public static UI.Color ofGrayRgb(int gray, double opacity)
      This is a shortcut for rgb(gray, gray, gray, opacity).
      Parameters:
      gray - the gray component, in the range 0-255
      opacity - the opacity component, in the range 0.0-1.0
      Returns:
      the Color
    • ofGray

      public static UI.Color ofGray(double gray, double opacity)
      Creates a grey color.
      Parameters:
      gray - color on gray scale in the range 0.0 (black) - 1.0 (white).
      opacity - the opacity component, in the range 0.0-1.0
      Returns:
      the Color
      Throws:
      IllegalArgumentException - if any value is out of range
    • ofGray

      public static UI.Color ofGray(double gray)
      Creates an opaque grey color.
      Parameters:
      gray - color on gray scale in the range 0.0 (black) - 1.0 (white).
      Returns:
      the Color
      Throws:
      IllegalArgumentException - if any value is out of range
    • ofHsb

      public static UI.Color ofHsb(double hue, double saturation, double brightness, double opacity)
      Creates a Color based on the specified values in the HSB color model, and a given opacity.
      Parameters:
      hue - the hue, in degrees
      saturation - the saturation, 0.0 to 1.0
      brightness - the brightness, 0.0 to 1.0
      opacity - the opacity, 0.0 to 1.0
      Returns:
      the Color
      Throws:
      IllegalArgumentException - if saturation, brightness or opacity are out of range
    • of

      public static UI.Color of(String colorString)
    • red

      public double red()
      The red component of the Color, in the range 0.0-1.0. If you want to get the red component in the range 0-255, use the Color.getRed() method.
      Returns:
      the red component of the Color, in the range 0.0-1.0
      See Also:
    • green

      public double green()
      The green component of the Color, in the range 0.0-1.0. If you want to get the green component in the range 0-255, use the Color.getGreen() method.
      Returns:
      the green component of the Color, in the range 0.0-1.0
      See Also:
    • blue

      public double blue()
      The blue component of the Color, in the range 0.0-1.0. If you want to get the blue component in the range 0-255, use the Color.getBlue() method.
      Returns:
      the blue component of the Color, in the range 0.0-1.0
      See Also:
    • opacity

      public double opacity()
      The opacity of the Color, in the range 0.0-1.0. If you want to get the opacity in the form of the alpha component in the range 0-255, use the Color.getAlpha() method.
      Returns:
      the opacity of the Color, in the range 0.0-1.0
      See Also:
    • hue

      public double hue()
      Gets the hue component of this Color.
      Returns:
      Hue value in the range in the range 0.0-360.0.
    • saturation

      public double saturation()
      Gets the saturation component of this Color.
      Returns:
      Saturation value in the range in the range 0.0-1.0.
    • brightness

      public double brightness()
      Gets the brightness component of this Color.
      Returns:
      Brightness value in the range in the range 0.0-1.0.
    • brighter

      public UI.Color brighter()
      Creates a new color that is a brighter version of this color.
      Overrides:
      brighter in class Color
      Returns:
      A color that is a brighter version of this color.
    • brighterBy

      public UI.Color brighterBy(double percentage)
      Creates an updated color whose brightness is increased by the specified factor.
      Parameters:
      percentage - The factor by which to increase the brightness.
    • darker

      public UI.Color darker()
      Creates a new color that is a darker version of this color.
      Overrides:
      darker in class Color
      Returns:
      a color that is a darker version of this color
    • darkerBy

      public UI.Color darkerBy(double percentage)
      Creates an updated color whose brightness is decreased by the specified percentage factor.
      Parameters:
      percentage - The factor by which to decrease the brightness.
    • saturate

      public UI.Color saturate()
      Provides an updated color that is a more saturated version of this color. The color will be 30% more saturated than the original color.
      Returns:
      A color that is a more saturated version of this color.
    • saturateBy

      public UI.Color saturateBy(double percentage)
      Creates a color which is saturated by the specified percentage factor. So the value 0.0 will return the same color and the value and the value 1.0 will return a fully saturated color.
      Parameters:
      percentage - The percentage factor by which to increase the saturation.
    • desaturate

      public UI.Color desaturate()
      Creates a new color that is a less saturated version of this color. The color will be 30% less saturated than the original color.
      Returns:
      A color that is a less saturated version of this color.
    • desaturateBy

      public UI.Color desaturateBy(double percentage)
      Creates a color which is desaturated by the specified percentage factor. So the value 0.0 will return the same color and the value and the value 1.0 will return a fully desaturated color.
      Parameters:
      percentage - The percentage factor by which to decrease the saturation.
    • grayscale

      public UI.Color grayscale()
      Creates an updated color that is grayscale equivalent of this color. Opacity is preserved.
      Returns:
      A color that is grayscale equivalent of this color
    • invert

      public UI.Color invert()
      Creates a new color that is inversion of this color. Opacity is preserved.
      Returns:
      A color that is inversion of this color.
    • withRed

      public UI.Color withRed(double red)
      Returns an updated version of this color with the red component changed to the specified value in the range 0.0-1.0. The number 0.0 represents no red, and 1.0 represents full red.
      Parameters:
      red - The red component, in the range 0.0-1.0.
      Returns:
      A new Color object with the red component changed.
      Throws:
      IllegalArgumentException - If the value is out of range (0.0-1.0)
      See Also:
    • withGreen

      public UI.Color withGreen(double green)
      Returns an updated version of this color with the green component changed to the specified value in the range 0.0-1.0. A number of 0.0 represents no green, and 1.0 represents green to the maximum extent.
      Parameters:
      green - The green component, in the range 0.0-1.0
      Returns:
      A new Color object with the green component changed
      Throws:
      IllegalArgumentException - If the value is out of range (0.0-1.0)
      See Also:
    • withBlue

      public UI.Color withBlue(double blue)
      Returns an updated version of this color with the blue component changed to the specified value in the range 0.0-1.0. A value closer to 0.0 represents no blue, and closer to 1.0 represents blue to the maximum extent possible.
      Parameters:
      blue - The blue component, in the range 0.0-1.0
      Returns:
      A new Color object with the blue component changed
      Throws:
      IllegalArgumentException - If the value is out of range (0.0-1.0)
      See Also:
    • withOpacity

      public UI.Color withOpacity(double opacity)
      Returns an updated version of this color with the opacity changed to the specified value in the range 0.0-1.0. A value closer to 0.0 represents a fully transparent color, and closer to 1.0 represents a fully opaque color.
      Parameters:
      opacity - The opacity component, in the range 0.0-1.0
      Returns:
      A new Color object with the opacity changed
      Throws:
      IllegalArgumentException - If the value is out of range (0.0-1.0)
      See Also:
    • withAlpha

      public UI.Color withAlpha(int alpha)
      Creates and returns an updated version of this color with the alpha component changed to the specified value in the range 0-255. A value closer to 0 represents a fully transparent color, and closer to 255 represents a fully opaque color.
      Parameters:
      alpha - The alpha component, in the range 0-255.
      Returns:
      A new Color object with the alpha component changed
    • withHue

      public UI.Color withHue(double hue)
      Returns an updated version of this color with the hue changed to the specified value in the range 0.0-360.0. A value closer to 0.0 represents red, and closer to 360.0 represents red again.
      Parameters:
      hue - The hue component, in the range 0.0-360.0
      Returns:
      A new Color object with the hue changed
      Throws:
      IllegalArgumentException - If the value is out of range (0.0-360.0)
      See Also:
    • withSaturation

      public UI.Color withSaturation(double saturation)
      Returns an updated version of this color with the saturation changed to the specified value in the range 0.0-1.0. A value closer to 0.0 represents a shade of grey, and closer to 1.0 represents a fully saturated color.
      Parameters:
      saturation - The saturation component, in the range 0.0-1.0
      Returns:
      A new Color object with the saturation changed
      Throws:
      IllegalArgumentException - If the value is out of range (0.0-1.0)
      See Also:
    • withBrightness

      public UI.Color withBrightness(double brightness)
      Returns an updated version of this color with the brightness changed to the specified value in the range 0.0-1.0. A value closer to 0.0 represents black, and closer to 1.0 represents white.
      Parameters:
      brightness - The brightness component, in the range 0.0-1.0
      Returns:
      A new Color object with the brightness changed
      Throws:
      IllegalArgumentException - If the value is out of range (0.0-1.0)
      See Also: