Package com.coswald.jtalker.gui
Class ANSIColorConstants
- java.lang.Object
-
- com.coswald.jtalker.gui.ANSIColorConstants
-
public final class ANSIColorConstants extends Object
A set of descriptions for specific color constants within the ANSI standard. This is a transcription class that allows for Java to understand ANSI color code. For specific values, we use the standards defined within the Windows console version of the ANSI color codes (because it is fairly algorithmic and understandable). This class also provides a method for allowing the transcription of an escape string to a Java
Colorvia thegetANSIColormethod.We only allow two types of ANSI color codes: dark colors and bold dark colors (i. e. 30 - 37, 40 - 47 and 1;30 - 1:37, 1;40 - 1;47). We did not feel it was necessary or worth our time to include the whole standard; this is subject to change.
- Since:
- JTalker 0.1.5
- Version:
- 0.0.1
- Author:
- C. William Oswald
-
-
Field Summary
Fields Modifier and Type Field Description static ColorBACKGROUND_RESETThe reset color dictated by ANSI code 0 (this dictates the background) It is currently set to RGB values (16, 16, 16).static ColorBRIGHT_BLACKThe bright black color that is described by ANSI code 1;30 (or 1;40 for backgrounds).static ColorBRIGHT_BLUEThe bright blue color that is described by ANSI code 1;34 (or 1;44 for backgrounds).static ColorBRIGHT_CYANThe bright cyan color that is described by ANSI code 1;36 (or 1;46 for backgrounds).static ColorBRIGHT_GREENThe bright green color that is described by ANSI code 1;32 (or 1;42 for backgrounds).static ColorBRIGHT_MAGENTAThe bright magenta color that is described by ANSI code 1;35 (or 1;45 for backgrounds).static ColorBRIGHT_REDThe bright red color that is described by ANSI code 1;31 (or 1;41 for backgrounds).static ColorBRIGHT_WHITEThe bright white color that is described by ANSI code 1;37 (or 1;47 for backgrounds).static ColorBRIGHT_YELLOWThe bright yellow color that is described by ANSI code 1;33 (or 1;43 for backgrounds).static ColorCOLOR_RESETThe reset color dictated by ANSI code 0 (this dictates the foreground).static ColorDARK_BLACKThe dark black color that is described by ANSI code 30 (or 40 for backgrounds).static ColorDARK_BLUEThe dark blue color that is described by ANSI code 34 (or 44 for backgrounds).static ColorDARK_CYANThe dark cyan color that is described by ANSI code 36 (or 46 for backgrounds).static ColorDARK_GREENThe dark green color that is described by ANSI code 32 (or 42 for backgrounds).static ColorDARK_MAGENTAThe dark magenta color that is described by ANSI code 35 (or 45 for backgrounds).static ColorDARK_REDThe dark red color that is described by ANSI code 31 (or 41 for backgrounds).static ColorDARK_WHITEThe dark white color that is described by ANSI code 37 (or 47 for backgrounds).static ColorDARK_YELLOWThe dark yellow color that is described by ANSI code 33 (or 33 for backgrounds).static StringESCAPE_TEXTThe escape character.static StringESCAPE_TEXT_ENDThe end of the escape sequence.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ColorgetANSIColor(String ansiColor)Transforms a character code as a string into an actualColor.static booleanisBackgroundEscape(String ansiColor)Determines whether a given escape code is a background color escape code.static booleanisEscape(String test)Tests whether the given string is an escape sequence that we recognize.static booleanisReset(String ansiColor)Determines whether a given escape code is the reset escape code.
-
-
-
Field Detail
-
DARK_BLACK
public static final Color DARK_BLACK
The dark black color that is described by ANSI code 30 (or 40 for backgrounds). This has the RGB value of (0, 0, 0).
-
DARK_RED
public static final Color DARK_RED
The dark red color that is described by ANSI code 31 (or 41 for backgrounds). This has the RGB value of (128, 0, 0).
-
DARK_GREEN
public static final Color DARK_GREEN
The dark green color that is described by ANSI code 32 (or 42 for backgrounds). This has the RGB value of (0, 128, 0).
-
DARK_YELLOW
public static final Color DARK_YELLOW
The dark yellow color that is described by ANSI code 33 (or 33 for backgrounds). This has the RGB value of (128, 128, 0).
-
DARK_BLUE
public static final Color DARK_BLUE
The dark blue color that is described by ANSI code 34 (or 44 for backgrounds). This has the RGB value of (0, 0, 128).
-
DARK_MAGENTA
public static final Color DARK_MAGENTA
The dark magenta color that is described by ANSI code 35 (or 45 for backgrounds). This has the RGB value of (128, 0, 128).
-
DARK_CYAN
public static final Color DARK_CYAN
The dark cyan color that is described by ANSI code 36 (or 46 for backgrounds). This has the RGB value of (0, 128, 128).
-
DARK_WHITE
public static final Color DARK_WHITE
The dark white color that is described by ANSI code 37 (or 47 for backgrounds). This has the RGB value of (192, 192, 192).
-
BRIGHT_BLACK
public static final Color BRIGHT_BLACK
The bright black color that is described by ANSI code 1;30 (or 1;40 for backgrounds). This has the RGB value of (128, 128, 128).
-
BRIGHT_RED
public static final Color BRIGHT_RED
The bright red color that is described by ANSI code 1;31 (or 1;41 for backgrounds). This has the RGB value of (255, 0, 0).
-
BRIGHT_GREEN
public static final Color BRIGHT_GREEN
The bright green color that is described by ANSI code 1;32 (or 1;42 for backgrounds). This has the RGB value of (0, 255, 0).
-
BRIGHT_YELLOW
public static final Color BRIGHT_YELLOW
The bright yellow color that is described by ANSI code 1;33 (or 1;43 for backgrounds). This has the RGB value of (255, 255, 0).
-
BRIGHT_BLUE
public static final Color BRIGHT_BLUE
The bright blue color that is described by ANSI code 1;34 (or 1;44 for backgrounds). This has the RGB value of (0, 0, 255).
-
BRIGHT_MAGENTA
public static final Color BRIGHT_MAGENTA
The bright magenta color that is described by ANSI code 1;35 (or 1;45 for backgrounds). This has the RGB value of (255, 0, 255).
-
BRIGHT_CYAN
public static final Color BRIGHT_CYAN
The bright cyan color that is described by ANSI code 1;36 (or 1;46 for backgrounds). This has the RGB value of (0, 255, 255).
-
BRIGHT_WHITE
public static final Color BRIGHT_WHITE
The bright white color that is described by ANSI code 1;37 (or 1;47 for backgrounds). This has the RGB value of (255, 255, 255).
-
COLOR_RESET
public static final Color COLOR_RESET
The reset color dictated by ANSI code 0 (this dictates the foreground). It is currently set to RGB values (255, 255, 255).
-
BACKGROUND_RESET
public static final Color BACKGROUND_RESET
The reset color dictated by ANSI code 0 (this dictates the background) It is currently set to RGB values (16, 16, 16).
-
ESCAPE_TEXT
public static final String ESCAPE_TEXT
The escape character. This character is present before each escape sequence and ensures that we can understand the ANSI code after it.- See Also:
- Constant Field Values
-
ESCAPE_TEXT_END
public static final String ESCAPE_TEXT_END
The end of the escape sequence. This is also known as "m".- See Also:
- Constant Field Values
-
-
Method Detail
-
isEscape
public static boolean isEscape(String test)
Tests whether the given string is an escape sequence that we recognize.- Parameters:
test- The string to test.- Returns:
trueif it is an escape sequence we know,falseotherwise.
-
getANSIColor
public static Color getANSIColor(String ansiColor)
Transforms a character code as a string into an actualColor. This is done by exact comparison: the parameter given must only be the escape code. By default,whitewill be returned.- Parameters:
ansiColor- The color code.- Returns:
- A color represented by the given ANSI color code.
-
isBackgroundEscape
public static boolean isBackgroundEscape(String ansiColor)
Determines whether a given escape code is a background color escape code. This is done by exact comparison: the parameter given must only be the escape code. If no ANSI escape code is given as a parameter, thenfalseis returned.- Parameters:
ansiColor- The color code.- Returns:
- Whether a given color code is a background code.
-
isReset
public static boolean isReset(String ansiColor)
Determines whether a given escape code is the reset escape code. This is done by exact comparison: the parameter given must only the the escape code. If a given string is not an ANSI escape code, this method will returnfalse- Parameters:
ansiColor- The color code.- Returns:
- Whether a given code is the escape code.
- See Also:
COLOR_RESET,BACKGROUND_RESET
-
-