Package ghidra.util
Class WebColors
java.lang.Object
ghidra.util.WebColors
Class for web color support. This class defines many of the colors used by html. This class
includes methods for converting a color to a string (name or hex value) and for converting
those strings back to a color.
Usage Note: Java's HTML rendering engine supports colors in hex form ('#aabb11'). Also, the engine supports many web color names ('silver'). However, not all web color names defined in this file are supported. Thus, when specifying HTML colors, do not rely on these web color names.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
static final Color
-
Method Summary
Modifier and TypeMethodDescriptionstatic Color
Attempts to convert the given string into a color in a most flexible manner.static Color
getColorOrDefault
(String value, Color defaultColor) Tries to find a color for the given String value.static String
toColorName
(Color color) static String
toHexString
(Color color) Returns the hex value string for the given colorstatic String
toRgbString
(Color color) Returns the rgb value string for the given colorstatic String
Converts a color to a string value.static String
Converts a color to a string value.static String
toWebColorName
(Color color) Returns the WebColor name for the given color.
-
Field Details
-
BLACK
-
NAVY
-
DARK_BLUE
-
MEDIUM_BLUE
-
BLUE
-
DARK_GREEN
-
GREEN
-
TEAL
-
DARK_CYAN
-
DEEP_SKY_BLUE
-
DARK_TURQUOSE
-
LIME
-
SPRING_GREEN
-
AQUA
-
CYAN
-
MIDNIGHT_BLUE
-
DOGER_BLUE
-
LIGHT_SEA_GREEN
-
FOREST_GREEN
-
SEA_GREEN
-
DARK_SLATE_GRAY
-
LIME_GREEN
-
TURQUOISE
-
ROYAL_BLUE
-
STEEL_BLUE
-
DARK_SLATE_BLUE
-
INDIGO
-
CADET_BLUE
-
REBECCA_PURPLE
-
DIM_GRAY
-
SLATE_BLUE
-
OLIVE_DRAB
-
SLATE_GRAY
-
LAWN_GREEN
-
CHARTREUSE
-
AQUAMARINE
-
MAROON
-
PURPLE
-
OLIVE
-
GRAY
-
SYY_BLUE
-
LIGHT_SKY_BLUE
-
BLUE_VIOLET
-
DARK_RED
-
DARK_MAGENTA
-
SADDLE_BROWN
-
DARK_SEA_GREEN
-
LIGHT_GREEN
-
MEDIUM_PURPLE
-
DARK_VIOLET
-
PALE_GREEN
-
DARK_ORCHID
-
YELLOW_GREEN
-
SIENNA
-
BROWN
-
DARK_GRAY
-
LIGHT_BLUE
-
GREEN_YELLOW
-
PALE_TURQUOISE
-
POWDER_BLUE
-
FIRE_BRICK
-
DARK_GOLDENROD
-
MEDIUM_ORCHID
-
ROSY_BROWN
-
DARK_KHAKI
-
SILVER
-
INDIAN_RED
-
PERU
-
CHOCOLATE
-
TAN
-
LIGHT_GRAY
-
THISTLE
-
ORCHID
-
GOLDEN_ROD
-
PALE_VIOLET_RED
-
CRIMSON
-
GAINSBORO
-
PLUM
-
BURLYWOOD
-
LIGHT_CYAN
-
LAVENDER
-
DARK_SALMON
-
VIOLET
-
PALE_GOLDENROD
-
LIGHT_CORAL
-
KHAKE
-
ALICE_BLUE
-
HONEY_DEW
-
AZURE
-
SANDY_BROWN
-
WHEAT
-
BEIGE
-
WHITE_SMOKE
-
MINT_CREAM
-
GHOST_WHITE
-
SALMON
-
ANTIQUE_WHITE
-
LINEN
-
OLDLACE
-
RED
-
FUCHSIA
-
MAGENTA
-
DEEP_PINK
-
ORANGE_RED
-
TOMATO
-
HOT_PINK
-
CORAL
-
DARK_ORANGE
-
LIGHT_SALMON
-
ORANGE
-
LIGHT_PINK
-
PINK
-
GOLD
-
PEACH_PUFF
-
NAVAJO_WHITE
-
MOCCASIN
-
BISQUE
-
MISTY_ROSE
-
BLANCHED_ALMOND
-
PAPAYA_WHIP
-
LAVENDER_BLUSH
-
SEASHELL
-
CORNSILK
-
LEMON_CHIFFON
-
FLORAL_WHITE
-
SNOW
-
YELLOW
-
LIGHT_YELLOW
-
IVORY
-
WHITE
-
MEDIUM_SPRING_GREEN
-
LIGHT_GOLDENROD
-
MEDIUM_VIOLET_RED
-
LIGHT_STEEL_BLUE
-
LIGHT_SLATE_GRAY
-
MEDIUM_SLATE_BLUE
-
MEDIUM_SEA_GREEN
-
MEDUM_AQUA_MARINE
-
MEDIUM_TURQOISE
-
DARK_OLIVE_GREEN
-
CORNFLOWER_BLUE
-
-
Method Details
-
getColorOrDefault
Tries to find a color for the given String value. The String value can either be a hex string (seeColor.decode(String)
) or a web color name as defined above- Parameters:
value
- the string value to interpret as a colordefaultColor
- a default color to return if the string can't be converted to a color- Returns:
- a color for the given string value or the default color if the string can't be translated
-
toString
Converts a color to a string value. If there is a defined color for the given color value, the color name will be returned. Otherwise, it will return a hex string for the color as follows. If the color has an non-opaque alpha value, it will be of the form #rrggbb. If it has an alpha value,then the format will be #rrggbbaa.- Parameters:
color
- the color to convert to a string.- Returns:
- the string representation for the given color.
-
toString
Converts a color to a string value. If the color is a WebColor and the useNameIfPossible is true, the name of the color will be returned. OOtherwise, it will return a hex string for the color as follows. If the color has an non-opaque alpha value, it will be of the form #rrggbb. If it has an alpha value ,then the format will be #rrggbbaa.- Parameters:
color
- the color to convert to a string.useNameIfPossible
- if true, the name of the color will be returned if the color is a WebColor- Returns:
- the string representation for the given color.
-
toColorName
-
toHexString
Returns the hex value string for the given color- Parameters:
color
- the color- Returns:
- the string
-
toRgbString
Returns the rgb value string for the given color- Parameters:
color
- the color- Returns:
- the string
-
toWebColorName
Returns the WebColor name for the given color. Returns null if the color is not a WebColor- Parameters:
color
- the color to lookup a WebColor name.- Returns:
- the WebColor name for the given color. Returns null if the color is not a WebColor
-
getColor
Attempts to convert the given string into a color in a most flexible manner. It first checks if the given string matches the name of a known web color as defined above. If so it returns that color. Otherwise it tries to parse the string in any one of the following formats:#rrggbb #rrggbbaa 0xrrggbb 0xrrggbbaa rgb(red, green, blue) rgba(red, green, alpha)
In the hex digit formats, the hex digits "rr", "gg", "bb", "aa" represent the values for red, green, blue, and alpha, respectively. In the "rgb" and "rgba" formats the red, green, and blue values are all integers between 0-255, while the alpha value is a float value from 0.0 to 1.0.- Parameters:
colorString
- the color name- Returns:
- a color for the given string or null
-