Package com.apogee.dev.CUJaS.UI.utils
Class ANSIColorConstants
java.lang.Object
com.apogee.dev.CUJaS.UI.utils.ANSIColorConstants
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 Color
via the
getANSIColor
method.
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
Modifier and TypeFieldDescriptionprivate static final int
static final Color
The reset color dictated by ANSI code 0 (this dictates the background) It is currently set to RGB values (16, 16, 16).static final Color
The bright black color that is described by ANSI code 1;30 (or 1;40 for backgrounds).static final Color
The bright blue color that is described by ANSI code 1;34 (or 1;44 for backgrounds).static final Color
The bright cyan color that is described by ANSI code 1;36 (or 1;46 for backgrounds).static final Color
The bright green color that is described by ANSI code 1;32 (or 1;42 for backgrounds).static final Color
The bright magenta color that is described by ANSI code 1;35 (or 1;45 for backgrounds).static final Color
The bright red color that is described by ANSI code 1;31 (or 1;41 for backgrounds).static final Color
The bright white color that is described by ANSI code 1;37 (or 1;47 for backgrounds).static final Color
The bright yellow color that is described by ANSI code 1;33 (or 1;43 for backgrounds).static final Color
The reset color dictated by ANSI code 0 (this dictates the foreground).static final Color
The dark black color that is described by ANSI code 30 (or 40 for backgrounds).static final Color
The dark blue color that is described by ANSI code 34 (or 44 for backgrounds).static final Color
The dark cyan color that is described by ANSI code 36 (or 46 for backgrounds).static final Color
The dark green color that is described by ANSI code 32 (or 42 for backgrounds).static final Color
The dark magenta color that is described by ANSI code 35 (or 45 for backgrounds).static final Color
The dark red color that is described by ANSI code 31 (or 41 for backgrounds).static final Color
The dark white color that is described by ANSI code 37 (or 47 for backgrounds).static final Color
The dark yellow color that is described by ANSI code 33 (or 33 for backgrounds).static final String
The escape character.static final String
The end of the escape sequence.private static final int
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Color
getANSIColor
(String ansiColor) Transforms a character code as a string into an actualColor
.private static boolean
static boolean
isBackgroundEscape
(String ansiColor) Determines whether a given escape code is a background color escape code.static boolean
Tests whether the given string is an escape sequence that we recognize.static boolean
Determines whether a given escape code is the reset escape code.
-
Field Details
-
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
The reset color dictated by ANSI code 0 (this dictates the foreground). It is currently set to RGB values (255, 255, 255). -
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
The escape character. This character is present before each escape sequence and ensures that we can understand the ANSI code after it.- See Also:
-
ESCAPE_TEXT_END
The end of the escape sequence. This is also known as "m".- See Also:
-
BACKGROUND_NUMBER
private static final int BACKGROUND_NUMBER- See Also:
-
MAX_ESCAPE_NUMBER
private static final int MAX_ESCAPE_NUMBER- See Also:
-
-
Constructor Details
-
ANSIColorConstants
private ANSIColorConstants()
-
-
Method Details
-
isEscape
Tests whether the given string is an escape sequence that we recognize.- Parameters:
test
- The string to test.- Returns:
true
if it is an escape sequence we know,false
otherwise.
-
getANSIColor
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,white
will be returned.- Parameters:
ansiColor
- The color code.- Returns:
- A color represented by the given ANSI color code.
-
isBackgroundEscape
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, thenfalse
is returned.- Parameters:
ansiColor
- The color code.- Returns:
- Whether a given color code is a background code.
-
isReset
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:
-
innerTest
-