Class TextColor.RGB

  • All Implemented Interfaces:
    TextColor, java.io.Serializable
    Enclosing interface:
    TextColor

    public static class TextColor.RGB
    extends java.lang.Object
    implements TextColor
    This class can be used to specify a color in 24-bit color space (RGB with 8-bit resolution per color). Please be aware that only a few terminal support 24-bit color control codes, please avoid using this class unless you know all users will have compatible terminals. For details, please see this commit log. Behavior on terminals that don't support these codes is undefined.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int blue  
      private int green  
      private int red  
    • Constructor Summary

      Constructors 
      Constructor Description
      RGB​(int r, int g, int b)
      This class can be used to specify a color in 24-bit color space (RGB with 8-bit resolution per color).
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)  
      byte[] getBackgroundSGRSequence()
      Returns the byte sequence in between CSI and character 'm' that is used to enable this color as the background color on an ANSI-compatible terminal.
      int getBlue()  
      byte[] getForegroundSGRSequence()
      Returns the byte sequence in between CSI and character 'm' that is used to enable this color as the foreground color on an ANSI-compatible terminal.
      int getGreen()  
      int getRed()  
      int hashCode()  
      java.awt.Color toColor()
      Converts this color to an AWT color object, assuming a standard VGA palette.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • red

        private final int red
      • green

        private final int green
      • blue

        private final int blue
    • Constructor Detail

      • RGB

        public RGB​(int r,
                   int g,
                   int b)
        This class can be used to specify a color in 24-bit color space (RGB with 8-bit resolution per color). Please be aware that only a few terminal support 24-bit color control codes, please avoid using this class unless you know all users will have compatible terminals. For details, please see this commit log. Behavior on terminals that don't support these codes is undefined.
        Parameters:
        r - Red intensity, from 0 to 255
        g - Green intensity, from 0 to 255
        b - Blue intensity, from 0 to 255
    • Method Detail

      • getForegroundSGRSequence

        public byte[] getForegroundSGRSequence()
        Description copied from interface: TextColor
        Returns the byte sequence in between CSI and character 'm' that is used to enable this color as the foreground color on an ANSI-compatible terminal.
        Specified by:
        getForegroundSGRSequence in interface TextColor
        Returns:
        Byte array out data to output in between of CSI and 'm'
      • getBackgroundSGRSequence

        public byte[] getBackgroundSGRSequence()
        Description copied from interface: TextColor
        Returns the byte sequence in between CSI and character 'm' that is used to enable this color as the background color on an ANSI-compatible terminal.
        Specified by:
        getBackgroundSGRSequence in interface TextColor
        Returns:
        Byte array out data to output in between of CSI and 'm'
      • getRed

        public int getRed()
        Specified by:
        getRed in interface TextColor
        Returns:
        Red intensity of this color, from 0 to 255
      • getGreen

        public int getGreen()
        Specified by:
        getGreen in interface TextColor
        Returns:
        Green intensity of this color, from 0 to 255
      • getBlue

        public int getBlue()
        Specified by:
        getBlue in interface TextColor
        Returns:
        Blue intensity of this color, from 0 to 255
      • toColor

        public java.awt.Color toColor()
        Description copied from interface: TextColor
        Converts this color to an AWT color object, assuming a standard VGA palette.
        Specified by:
        toColor in interface TextColor
        Returns:
        TextColor as an AWT Color
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object