Class CSSRGB

java.lang.Object
com.helger.css.decl.CSSRGB
All Implemented Interfaces:
com.helger.commons.lang.ICloneable<CSSRGB>, ICSSColor, ICSSWriteable

@NotThreadSafe public class CSSRGB extends Object implements ICSSWriteable, ICSSColor, com.helger.commons.lang.ICloneable<CSSRGB>
Represents a single RGB color value (red, green, blue)
Author:
Philip Helger
  • Constructor Details

    • CSSRGB

      public CSSRGB(@Nonnull CSSRGB aOther)
      Copy constructor
      Parameters:
      aOther - The object to copy the data from. May not be null.
    • CSSRGB

      public CSSRGB(int nRed, int nGreen, int nBlue)
      Constructor
      Parameters:
      nRed - Red part. Is fitted to a value between 0 and 255.
      nGreen - Green part. Is fitted to a value between 0 and 255.
      nBlue - Blue part. Is fitted to a value between 0 and 255.
    • CSSRGB

      public CSSRGB(@Nonnull @Nonempty String sRed, @Nonnull @Nonempty String sGreen, @Nonnull @Nonempty String sBlue)
      Constructor
      Parameters:
      sRed - Red part.
      sGreen - Green part.
      sBlue - Blue part.
  • Method Details

    • getRed

      @Nonnull @Nonempty public final String getRed()
      Returns:
      red part
    • setRed

      @Nonnull public final CSSRGB setRed(@Nonnull @Nonempty String sRed)
    • getGreen

      @Nonnull @Nonempty public final String getGreen()
      Returns:
      green part
    • setGreen

      @Nonnull public final CSSRGB setGreen(@Nonnull @Nonempty String sGreen)
    • getBlue

      @Nonnull @Nonempty public final String getBlue()
      Returns:
      blue part
    • setBlue

      @Nonnull public final CSSRGB setBlue(@Nonnull @Nonempty String sBlue)
    • getAsRGBA

      @Nonnull public CSSRGBA getAsRGBA(float fOpacity)
      Convert this value to an RGBA value.
      Parameters:
      fOpacity - Opacity part. Is fitted to a value between 0 and 1.
      Returns:
      This value as RGBA value with the passed opacity. Never null.
      Since:
      3.8.3
    • getAsRGBA

      @Nonnull public CSSRGBA getAsRGBA(@Nonnull @Nonempty String sOpacity)
      Convert this value to an RGBA value.
      Parameters:
      sOpacity - Opacity part. May neither be null nor empty.
      Returns:
      This value as RGBA value with the passed opacity. Never null.
      Since:
      3.8.3
    • getAsString

      @Nonnull @Nonempty public String getAsString()
      Specified by:
      getAsString in interface ICSSColor
      Returns:
      The textual representation of the color.
      Since:
      3.8.3
    • getAsCSSString

      @Nonnull @Nonempty public String getAsCSSString(@Nonnull ICSSWriterSettings aSettings, @Nonnegative int nIndentLevel)
      Description copied from interface: ICSSWriteable
      Get the contents of this object as a serialized CSS string for writing to an output.
      Specified by:
      getAsCSSString in interface ICSSWriteable
      Parameters:
      aSettings - The settings to be used to format the output. May not be null.
      nIndentLevel - The current indentation level
      Returns:
      The content of this object as CSS string. Never null.
    • getClone

      @Nonnull public CSSRGB getClone()
      Specified by:
      getClone in interface com.helger.commons.lang.ICloneable<CSSRGB>
      Since:
      3.8.3
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object