Class WColor


  • public class WColor
    extends java.lang.Object
    A class that specifies a color. A color corresponds to a CSS color. You can specify a color either using its red/green/blue components, or from a valid CSS name. The color supports an alpha channel, which determines the degree of transparency. An alpha value of 0 is completely transparent (and thus invisible), while a value of 255 is completely opaque.
    • Constructor Summary

      Constructors 
      Constructor Description
      WColor()
      Construct a default color.
      WColor​(int r, int g, int b)
      Construct a color with given red/green/blue components.
      WColor​(int r, int g, int b, int a)
      Construct a color with given red/green/blue/alpha components.
      WColor​(StandardColor c)
      Construct a color from a StandardColor.
      WColor​(java.lang.CharSequence name)
      Construct a color from a CSS name.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(WColor other)
      Indicates whether some other object is "equal to" this one.
      static WColor fromHSL​(double h, double s, double l, int alpha)  
      int getAlpha()
      Returns the alpha component.
      int getBlue()
      Returns the blue component.
      java.lang.String getCssText()  
      java.lang.String getCssText​(boolean withAlpha)  
      int getGreen()
      Returns the green component.
      WString getName()
      Get CSS name.
      int getRed()
      Returns the red component.
      boolean isDefault()
      Returns if the color is the default color.
      void setName​(java.lang.CharSequence name)
      Set the CSS name.
      void setRgb​(int red, int green, int blue)
      Set the red/green/blue components and a 255 for the alpha component.
      void setRgb​(int red, int green, int blue, int alpha)
      Set the red/green/blue/alpha components.
      void toHSL​(double[] hsl)  
      • Methods inherited from class java.lang.Object

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

      • white

        public static WColor white
        White WColor object.
      • black

        public static WColor black
        Black WColor object.
      • red

        public static WColor red
        Red WColor object.
      • darkRed

        public static WColor darkRed
        Dark red WColor object.
      • green

        public static WColor green
        Green WColor object.
      • darkGreen

        public static WColor darkGreen
        Dark green WColor object.
      • blue

        public static WColor blue
        Blue WColor object.
      • darkBlue

        public static WColor darkBlue
        Dark blue WColor object.
      • cyan

        public static WColor cyan
        Cyan WColor object.
      • darkCyan

        public static WColor darkCyan
        Dark cyan WColor object.
      • magenta

        public static WColor magenta
        White Magenta object.
      • darkMagenta

        public static WColor darkMagenta
        Dark magenta WColor object.
      • yellow

        public static WColor yellow
        Yellow WColor object.
      • darkYellow

        public static WColor darkYellow
        Dark yellow WColor object.
      • gray

        public static WColor gray
        Gray WColor object.
      • darkGray

        public static WColor darkGray
        Dark gray WColor object.
      • lightGray

        public static WColor lightGray
        Light gray WColor object.
      • transparent

        public static WColor transparent
        Transparant WColor object.
    • Constructor Detail

      • WColor

        public WColor()
        Construct a default color. The default color is depending on the context, another color (for example from a hierarchical parent in a widget tree), or a completely transparent color.
      • WColor

        public WColor​(StandardColor c)
        Construct a color from a StandardColor.
      • WColor

        public WColor​(int r,
                      int g,
                      int b,
                      int a)
        Construct a color with given red/green/blue/alpha components. All four components must be specified with a value in the range (0 - 255). The alpha channel determines the degree of transparency. An alpha value of 0 is completely transparent (and thus invisible), while a value of 255 is completely opaque.
        See Also:
        setRgb(int red, int green, int blue, int alpha)
      • WColor

        public WColor​(int r,
                      int g,
                      int b)
        Construct a color with given red/green/blue components. All three components must be specified with a value in the range (0 - 255). The alpha channel is defaulted to completely opaque (255).
        See Also:
        setRgb(int, int, int)
    • Method Detail

      • setRgb

        public void setRgb​(int red,
                           int green,
                           int blue,
                           int alpha)
        Set the red/green/blue/alpha components. All four components must be specified with a value in the range (0 - 255). The alpha channel determines the degree of transparency. An alpha value of 0 is completely transparent (and thus invisible), while a value of 255 is completely opaque.
      • setRgb

        public final void setRgb​(int red,
                                 int green,
                                 int blue)
        Set the red/green/blue components and a 255 for the alpha component.
        See Also:
        setRgb(int, int, int, int)
      • isDefault

        public boolean isDefault()
        Returns if the color is the default color.
        See Also:
        WColor()
      • getRed

        public int getRed()
        Returns the red component. Only available when the color was specified in terms of the RGB components using setRgb(int, int, int, int) or WColor(int, int, int, int).
      • getGreen

        public int getGreen()
        Returns the green component. Only available when the color was specified in terms of the RGB components using setRgb(int, int, int, int) or WColor(int, int, int, int).
      • getBlue

        public int getBlue()
        Returns the blue component. Only available when the color was specified in terms of the RGB components using setRgb(int, int, int, int) or WColor(int, int, int, int).
      • getAlpha

        public int getAlpha()
        Returns the alpha component. Only available when the color was specified in terms of the RGB components using setRgb(int, int, int, int) or WColor(int, int, int, int).
      • equals

        public boolean equals​(WColor other)
        Indicates whether some other object is "equal to" this one. Returns true if the two colors were defined in exactly the same way. It may return false although they actually represent the same color.
      • getCssText

        public final java.lang.String getCssText​(boolean withAlpha)
      • getCssText

        public final java.lang.String getCssText()
      • toHSL

        public final void toHSL​(double[] hsl)
      • fromHSL

        public static WColor fromHSL​(double h,
                                     double s,
                                     double l,
                                     int alpha)