Enum TextColor.ANSI

  • All Implemented Interfaces:
    TextColor, java.io.Serializable, java.lang.Comparable<TextColor.ANSI>
    Enclosing interface:
    TextColor

    public static enum TextColor.ANSI
    extends java.lang.Enum<TextColor.ANSI>
    implements TextColor
    This class represent classic ANSI colors that are likely to be very compatible with most terminal implementations. It is limited to 8 colors (plus the 'default' color) but as a norm, using bold mode (SGR code) will slightly alter the color, giving it a bit brighter tone, so in total this will give you 16 (+1) colors.

    For more information, see http://en.wikipedia.org/wiki/File:Ansi.png

    • Field Detail

      • bright

        private final boolean bright
      • red

        private final int red
      • green

        private final int green
      • blue

        private final int blue
      • foregroundSGR

        private final byte[] foregroundSGR
      • backgroundSGR

        private final byte[] backgroundSGR
    • Constructor Detail

      • ANSI

        private ANSI​(int index,
                     int red,
                     int green,
                     int blue)
      • ANSI

        private ANSI​(int index,
                     boolean bright,
                     int red,
                     int green,
                     int blue)
    • Method Detail

      • values

        public static TextColor.ANSI[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (TextColor.ANSI c : TextColor.ANSI.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static TextColor.ANSI valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • 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'
      • isBright

        public boolean isBright()
      • 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