Interface Color

All Known Implementing Classes:
HSVColor, RGBColor

public interface Color
A common interface for different color implementations.
  • Field Details

    • F_BRIGHTEN

      static final float F_BRIGHTEN
      Factor to apply when generating a brighter or darker version of a color.
      See Also:
    • ALICEBLUE

      static final Color ALICEBLUE
      The color ALICEBLUE.
    • ANTIQUEWHITE

      static final Color ANTIQUEWHITE
      The color ANTIQUEWHITE.
    • AQUA

      static final Color AQUA
      The color AQUA.
    • AQUAMARINE

      static final Color AQUAMARINE
      The color AQUAMARINE.
    • AZURE

      static final Color AZURE
      The color AZURE.
    • BEIGE

      static final Color BEIGE
      The color BEIGE.
    • BISQUE

      static final Color BISQUE
      The color BISQUE.
    • BLACK

      static final RGBColor BLACK
      The color BLACK.
    • BLANCHEDALMOND

      static final Color BLANCHEDALMOND
      The color BLANCHEDALMOND.
    • BLUE

      static final Color BLUE
      The color BLUE.
    • BLUEVIOLET

      static final Color BLUEVIOLET
      The color BLUEVIOLET.
    • BROWN

      static final Color BROWN
      The color BROWN.
    • BURLYWOOD

      static final Color BURLYWOOD
      The color BURLYWOOD.
    • CADETBLUE

      static final Color CADETBLUE
      The color CADETBLUE.
    • CHARTREUSE

      static final Color CHARTREUSE
      The color CHARTREUSE.
    • CHOCOLATE

      static final Color CHOCOLATE
      The color CHOCOLATE.
    • CORAL

      static final Color CORAL
      The color CORAL.
    • CORNFLOWERBLUE

      static final Color CORNFLOWERBLUE
      The color CORNFLOWERBLUE.
    • CORNSILK

      static final Color CORNSILK
      The color CORNSILK.
    • CRIMSON

      static final Color CRIMSON
      The color CRIMSON.
    • DARKBLUE

      static final Color DARKBLUE
      The color DARKBLUE.
    • DARKCYAN

      static final Color DARKCYAN
      The color DARKCYAN.
    • DARKGOLDENROD

      static final Color DARKGOLDENROD
      The color DARKGOLDENROD.
    • DARKGRAY

      static final Color DARKGRAY
      The color DARKGRAY.
    • DARKGREEN

      static final Color DARKGREEN
      The color DARKGREEN.
    • DARKGREY

      static final Color DARKGREY
      The color DARKGREY.
    • DARKKHAKI

      static final Color DARKKHAKI
      The color DARKKHAKI.
    • DARKMAGENTA

      static final Color DARKMAGENTA
      The color DARKMAGENTA.
    • DARKOLIVEGREEN

      static final Color DARKOLIVEGREEN
      The color DARKOLIVEGREEN.
    • DARKORANGE

      static final Color DARKORANGE
      The color DARKORANGE.
    • DARKORCHID

      static final Color DARKORCHID
      The color DARKORCHID.
    • DARKRED

      static final Color DARKRED
      The color DARKRED.
    • DARKSALMON

      static final Color DARKSALMON
      The color DARKSALMON.
    • DARKSEAGREEN

      static final Color DARKSEAGREEN
      The color DARKSEAGREEN.
    • DARKSLATEBLUE

      static final Color DARKSLATEBLUE
      The color DARKSLATEBLUE.
    • DARKSLATEGRAY

      static final Color DARKSLATEGRAY
      The color DARKSLATEGRAY.
    • DARKSLATEGREY

      static final Color DARKSLATEGREY
      The color DARKSLATEGREY.
    • DARKTURQUOISE

      static final Color DARKTURQUOISE
      The color DARKTURQUOISE.
    • DARKVIOLET

      static final Color DARKVIOLET
      The color DARKVIOLET.
    • DEEPPINK

      static final Color DEEPPINK
      The color DEEPPINK.
    • DEEPSKYBLUE

      static final Color DEEPSKYBLUE
      The color DEEPSKYBLUE.
    • DIMGRAY

      static final Color DIMGRAY
      The color DIMGRAY.
    • DIMGREY

      static final Color DIMGREY
      The color DIMGREY.
    • DODGERBLUE

      static final Color DODGERBLUE
      The color DODGERBLUE.
    • FIREBRICK

      static final Color FIREBRICK
      The color FIREBRICK.
    • FLORALWHITE

      static final Color FLORALWHITE
      The color FLORALWHITE.
    • FORESTGREEN

      static final Color FORESTGREEN
      The color FORESTGREEN.
    • FUCHSIA

      static final Color FUCHSIA
      The color FUCHSIA.
    • GAINSBORO

      static final Color GAINSBORO
      The color GAINSBORO.
    • GHOSTWHITE

      static final Color GHOSTWHITE
      The color GHOSTWHITE.
    • GOLD

      static final Color GOLD
      The color GOLD.
    • GOLDENROD

      static final Color GOLDENROD
      The color GOLDENROD.
    • GRAY

      static final Color GRAY
      The color GRAY.
    • GREEN

      static final Color GREEN
      The color GREEN.
    • GREENYELLOW

      static final Color GREENYELLOW
      The color GREENYELLOW.
    • GREY

      static final Color GREY
      The color GREY.
    • HONEYDEW

      static final Color HONEYDEW
      The color HONEYDEW.
    • HOTPINK

      static final Color HOTPINK
      The color HOTPINK.
    • INDIANRED

      static final Color INDIANRED
      The color INDIANRED.
    • INDIGO

      static final Color INDIGO
      The color INDIGO.
    • IVORY

      static final Color IVORY
      The color IVORY.
    • KHAKI

      static final Color KHAKI
      The color KHAKI.
    • LAVENDER

      static final Color LAVENDER
      The color LAVENDER.
    • LAVENDERBLUSH

      static final Color LAVENDERBLUSH
      The color LAVENDERBLUSH.
    • LAWNGREEN

      static final Color LAWNGREEN
      The color LAWNGREEN.
    • LEMONCHIFFON

      static final Color LEMONCHIFFON
      The color LEMONCHIFFON.
    • LIGHTBLUE

      static final Color LIGHTBLUE
      The color LIGHTBLUE.
    • LIGHTCORAL

      static final Color LIGHTCORAL
      The color LIGHTCORAL.
    • LIGHTCYAN

      static final Color LIGHTCYAN
      The color LIGHTCYAN.
    • LIGHTGOLDENRODYELLOW

      static final Color LIGHTGOLDENRODYELLOW
      The color LIGHTGOLDENRODYELLOW.
    • LIGHTGRAY

      static final Color LIGHTGRAY
      The color LIGHTGRAY.
    • LIGHTGREEN

      static final Color LIGHTGREEN
      The color LIGHTGREEN.
    • LIGHTGREY

      static final Color LIGHTGREY
      The color LIGHTGREY.
    • LIGHTPINK

      static final Color LIGHTPINK
      The color LIGHTPINK.
    • LIGHTSALMON

      static final Color LIGHTSALMON
      The color LIGHTSALMON.
    • LIGHTSEAGREEN

      static final Color LIGHTSEAGREEN
      The color LIGHTSEAGREEN.
    • LIGHTSKYBLUE

      static final Color LIGHTSKYBLUE
      The color LIGHTSKYBLUE.
    • LIGHTSLATEGRAY

      static final Color LIGHTSLATEGRAY
      The color LIGHTSLATEGRAY.
    • LIGHTSLATEGREY

      static final Color LIGHTSLATEGREY
      The color LIGHTSLATEGREY.
    • LIGHTSTEELBLUE

      static final Color LIGHTSTEELBLUE
      The color LIGHTSTEELBLUE.
    • LIGHTYELLOW

      static final Color LIGHTYELLOW
      The color LIGHTYELLOW.
    • LIME

      static final Color LIME
      The color LIME.
    • LIMEGREEN

      static final Color LIMEGREEN
      The color LIMEGREEN.
    • LINEN

      static final Color LINEN
      The color LINEN.
    • MAROON

      static final Color MAROON
      The color MAROON.
    • MEDIUMAQUAMARINE

      static final Color MEDIUMAQUAMARINE
      The color MEDIUMAQUAMARINE.
    • MEDIUMBLUE

      static final Color MEDIUMBLUE
      The color MEDIUMBLUE.
    • MEDIUMORCHID

      static final Color MEDIUMORCHID
      The color MEDIUMORCHID.
    • MEDIUMPURPLE

      static final Color MEDIUMPURPLE
      The color MEDIUMPURPLE.
    • MEDIUMSEAGREEN

      static final Color MEDIUMSEAGREEN
      The color MEDIUMSEAGREEN.
    • MEDIUMSLATEBLUE

      static final Color MEDIUMSLATEBLUE
      The color MEDIUMSLATEBLUE.
    • MEDIUMSPRINGGREEN

      static final Color MEDIUMSPRINGGREEN
      The color MEDIUMSPRINGGREEN.
    • MEDIUMTURQUOISE

      static final Color MEDIUMTURQUOISE
      The color MEDIUMTURQUOISE.
    • MEDIUMVIOLETRED

      static final Color MEDIUMVIOLETRED
      The color MEDIUMVIOLETRED.
    • MIDNIGHTBLUE

      static final Color MIDNIGHTBLUE
      The color MIDNIGHTBLUE.
    • MINTCREAM

      static final Color MINTCREAM
      The color MINTCREAM.
    • MISTYROSE

      static final Color MISTYROSE
      The color MISTYROSE.
    • MOCCASIN

      static final Color MOCCASIN
      The color MOCCASIN.
    • OLDLACE

      static final Color OLDLACE
      The color OLDLACE.
    • OLIVE

      static final Color OLIVE
      The color OLIVE.
    • OLIVEDRAB

      static final Color OLIVEDRAB
      The color OLIVEDRAB.
    • ORANGE

      static final Color ORANGE
      The color ORANGE.
    • ORANGERED

      static final Color ORANGERED
      The color ORANGERED.
    • ORCHID

      static final Color ORCHID
      The color ORCHID.
    • PALEGOLDENROD

      static final Color PALEGOLDENROD
      The color PALEGOLDENROD.
    • PALEGREEN

      static final Color PALEGREEN
      The color PALEGREEN.
    • PALETURQUOISE

      static final Color PALETURQUOISE
      The color PALETURQUOISE.
    • PALEVIOLETRED

      static final Color PALEVIOLETRED
      The color PALEVIOLETRED.
    • PAPAYAWHIP

      static final Color PAPAYAWHIP
      The color PAPAYAWHIP.
    • PEACHPUFF

      static final Color PEACHPUFF
      The color PEACHPUFF.
    • PERU

      static final Color PERU
      The color PERU.
    • PINK

      static final Color PINK
      The color PINK.
    • PLUM

      static final Color PLUM
      The color PLUM.
    • POWDERBLUE

      static final Color POWDERBLUE
      The color POWDERBLUE.
    • PURPLE

      static final Color PURPLE
      The color PURPLE.
    • REBECCAPURPLE

      static final Color REBECCAPURPLE
      The color REBECCAPURPLE.
    • RED

      static final Color RED
      The color RED.
    • ROSYBROWN

      static final Color ROSYBROWN
      The color ROSYBROWN.
    • ROYALBLUE

      static final Color ROYALBLUE
      The color ROYALBLUE.
    • SADDLEBROWN

      static final Color SADDLEBROWN
      The color SADDLEBROWN.
    • SALMON

      static final Color SALMON
      The color SALMON.
    • SANDYBROWN

      static final Color SANDYBROWN
      The color SANDYBROWN.
    • SEAGREEN

      static final Color SEAGREEN
      The color SEAGREEN.
    • SEASHELL

      static final Color SEASHELL
      The color SEASHELL.
    • SIENNA

      static final Color SIENNA
      The color SIENNA.
    • SILVER

      static final Color SILVER
      The color SILVER.
    • SKYBLUE

      static final Color SKYBLUE
      The color SKYBLUE.
    • SLATEBLUE

      static final Color SLATEBLUE
      The color SLATEBLUE.
    • SLATEGRAY

      static final Color SLATEGRAY
      The color SLATEGRAY.
    • SLATEGREY

      static final Color SLATEGREY
      The color SLATEGREY.
    • SNOW

      static final Color SNOW
      The color SNOW.
    • SPRINGGREEN

      static final Color SPRINGGREEN
      The color SPRINGGREEN.
    • STEELBLUE

      static final Color STEELBLUE
      The color STEELBLUE.
    • TAN

      static final Color TAN
      The color TAN.
    • TEAL

      static final Color TEAL
      The color TEAL.
    • THISTLE

      static final Color THISTLE
      The color THISTLE.
    • TOMATO

      static final Color TOMATO
      The color TOMATO.
    • TURQUOISE

      static final Color TURQUOISE
      The color TURQUOISE.
    • VIOLET

      static final Color VIOLET
      The color VIOLET.
    • WHEAT

      static final Color WHEAT
      The color WHEAT.
    • WHITE

      static final Color WHITE
      The color WHITE.
    • WHITESMOKE

      static final Color WHITESMOKE
      The color WHITESMOKE.
    • YELLOW

      static final Color YELLOW
      The color YELLOW.
    • YELLOWGREEN

      static final Color YELLOWGREEN
      The color YELLOWGREEN.
    • TRANSPARENT_WHITE

      static final Color TRANSPARENT_WHITE
      The color TRANSPARENT.
    • TRANSPARENT_BLACK

      static final Color TRANSPARENT_BLACK
      The color TRANSPARENT.
    • HEX_FORMAT

      static final HexFormat HEX_FORMAT
      A static instance of HexFormat used for formatting and parsing hexadecimal representations of color values.
  • Method Details

    • palette

      static Map<String,Color> palette()
      Get a mapping from color name to Color instance.
      Returns:
      map containing the predefined colors
    • valueOf

      static Color valueOf(String s)
      Convert String to Color. Lookup is tried i these steps:
      1. directly look up the String in the map of predefined colors.
      2. if first character is '#', interpret s as hex representation of the RGB value
      3. if s starts with rgb, s should be something like "rgb(123,210,120)"
      4. otherwise an exception is thrown
      Parameters:
      s - the text
      Returns:
      result of conversion
    • argb

      static RGBColor argb(int argb)
      Create color from ARGB packed integer value.
      Parameters:
      argb - the ARGB packed integer value
      Returns:
      the color
    • rgb

      static RGBColor rgb(int r, int g, int b)
      Create color from RGB values.
      Parameters:
      r - the red component [0 .. 255]
      g - the green component [0 .. 255]
      b - the blue component [0 .. 255]
      Returns:
      the color
    • rgba

      static RGBColor rgba(int r, int g, int b, int a)
      Create color from RGBA values.
      Parameters:
      r - the red component [0 .. 255]
      g - the green component [0 .. 255]
      b - the blue component [0 .. 255]
      a - the alpha value [0 .. 255]
      Returns:
      the color
    • rgbF

      static RGBColor rgbF(float r, float g, float b)
      Create color from RGB values.
      Parameters:
      r - the red component [0 .. 1]
      g - the green component [0 .. 1]
      b - the blue component [0 .. 1]
      Returns:
      the color
    • rgbaF

      static RGBColor rgbaF(float r, float g, float b, float alpha)
      Create color from RGB values.
      Parameters:
      r - the red component [0 .. 1]
      g - the green component [0 .. 1]
      b - the blue component [0 .. 1]
      alpha - the alpha value [0 .. 1]
      Returns:
      the color
    • hsv

      static HSVColor hsv(float h, float s, float v)
      Create color from HSV values.
      Parameters:
      h - the hue [0 .. 360]
      s - the saturation [0 .. 1]
      v - the brightness [0 .. 1]
      Returns:
      the color
    • hsva

      static HSVColor hsva(float h, float s, float v, float alpha)
      Create color from HSV values.
      Parameters:
      h - the hue [0 .. 360]
      s - the saturation [0 .. 1]
      v - the brightness [0 .. 1]
      alpha - the alpha value [0 .. 1]
      Returns:
      the color
    • values

      static Iterable<Color> values()
      Get Iterable over all declared color values.
      Returns:
      Iterable
    • alpha

      float alpha()
      Get the alpha component of this color.
      Returns:
      alpha component
    • a

      int a()
      Get the alpha component of this color as an integer.
      Returns:
      alpha component
    • isOpaque

      boolean isOpaque()
      Test if this color is opaque.
      Returns:
      true, if the color uses the maximum alpha value
    • isTransparent

      boolean isTransparent()
      Test if this color is transparent.
      Returns:
      true, if the color uses an alpha value of 0
    • toArgb

      default String toArgb()
      Get hex-string in ARGB form for this color.
      Returns:
      hex-string
    • toRgba

      default String toRgba()
      Get hex-string in RGBA form for this color.
      Returns:
      hex-string
    • toRGBColor

      default RGBColor toRGBColor()
      Convert this color to RGBColor.
      Returns:
      this color as RGBColor instance
    • toHSVColor

      default HSVColor toHSVColor()
      Convert this color to HSVColor.
      Returns:
      this color as RGBColor instance
    • toCss

      default String toCss()
      Get CSS compatible string representation of this color.

      Opaque colors are represented as three component hex strings, i. e. "#ff0000" for red. Colors using transparency are represented as four component hex strings in rrggbbaa format.

      Returns:
      this color as hex value (in rgb or rgba representation)
    • argb

      int argb()
      Get the color value as an integer in ARGB order.
      Returns:
      this color encoded as an integer value in ARGB order
    • rgba

      default int rgba()
      Get the color value as an integer in RGBA order.
      Returns:
      this color encoded as an integer value
    • toByteArray

      default byte[] toByteArray()
      Get the color components.
      Returns:
      byte array of size 4 containing this color's components in argb order
    • toByteArrayRGB

      default byte[] toByteArrayRGB()
      Get the color components.
      Returns:
      byte array of size 3 containing this color's components in rgb order
    • brighter

      Color brighter()
      Get a brighter color.
      Returns:
      a brighter version of this color
    • darker

      Color darker()
      Get a darker color.
      Returns:
      a darker version of this color