- java.lang.Object
-
- ij.plugin.Colors
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String[]colors
-
Constructor Summary
Constructors Constructor Description Colors()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.StringcolorToString(java.awt.Color color)Converts a Color into a lowercase string ("red", "green", "#aa55ff", etc.).static java.lang.StringcolorToString2(java.awt.Color color)Converts a Color into a string ("Red", "Green", #aa55ff, etc.).static java.awt.Colordecode(java.lang.String hexColor)Converts a String with the color name or the hexadecimal representation of a color with 6 or 8 hex digits to a Color.static java.awt.Colordecode(java.lang.String hexColor, java.awt.Color defaultColor)Converts a String with the color name or the hexadecimal representation of a color with 6 or 8 hex digits to a Color.static intgetBlue(java.lang.String hexColor)static java.awt.ColorgetColor(java.lang.String name, java.awt.Color defaultColor)For named colors, converts the name String to the corresponding color.static java.lang.StringgetColorName(java.awt.Color c, java.lang.String defaultName)For named colors, returns the name, or 'defaultName' if not a named color.static java.lang.String[]getColors(java.lang.String... moreColors)Returns an array of the color Strings in the argument(s) and the 13 predefined color names "Red", "Green", ...static intgetGreen(java.lang.String hexColor)static intgetRed(java.lang.String hexColor)static java.lang.StringhexToColor(java.lang.String hex)Converts a hex color (e.g., "ffff00") into "red", "green", "yellow", etc.static java.lang.StringhexToColor2(java.lang.String hex)Converts a hex color (e.g., "ffff00" or "#ffff00") into a color name "Red", "Green", "Yellow", etc.voiditemStateChanged(java.awt.event.ItemEvent e)Callback listener for Choice modifications in the dialogvoidrun(java.lang.String arg)This method is called when the plugin is loaded.static java.awt.ColortoColor(int red, int green, int blue)Returns an opaque color with the specified red, green, and blue values.
-
-
-
Method Detail
-
run
public void run(java.lang.String arg)
Description copied from interface:PlugInThis method is called when the plugin is loaded. 'arg', which may be blank, is the argument specified for this plugin in IJ_Props.txt.
-
getColorName
public static java.lang.String getColorName(java.awt.Color c, java.lang.String defaultName)For named colors, returns the name, or 'defaultName' if not a named color. If 'defaultName' is non-null and starts with an uppercase character, the returned name is capitalized (first character uppercase). Use colorToString or colorToString2 to get a String representation (hexadecimal) also for unnamed colors.
-
getColor
public static java.awt.Color getColor(java.lang.String name, java.awt.Color defaultColor)For named colors, converts the name String to the corresponding color. Returns 'defaultColor' if the color has no name. Use 'decode' to also decode hex color names like "#ffff00"
-
decode
public static java.awt.Color decode(java.lang.String hexColor)
Converts a String with the color name or the hexadecimal representation of a color with 6 or 8 hex digits to a Color. With 8 hex digits, the first two digits are the alpha. With 6 hex digits, the color is opaque (alpha = hex ff). A hex String may be preceded by '#' such as "#80ff00". When the string does not include a valid color name or hex code, returns Color.GRAY.
-
decode
public static java.awt.Color decode(java.lang.String hexColor, java.awt.Color defaultColor)Converts a String with the color name or the hexadecimal representation of a color with 6 or 8 hex digits to a Color. With 8 hex digits, the first two digits are the alpha. With 6 hex digits, the color is opaque (alpha = hex ff). A hex String may be preceded by "#" such as "#80ff00" or "0x". When the string does not include a valid color name or hex code, returns 'defaultColor'.
-
getRed
public static int getRed(java.lang.String hexColor)
-
getGreen
public static int getGreen(java.lang.String hexColor)
-
getBlue
public static int getBlue(java.lang.String hexColor)
-
hexToColor
public static java.lang.String hexToColor(java.lang.String hex)
Converts a hex color (e.g., "ffff00") into "red", "green", "yellow", etc. Returns null if the hex color does not have a name. Unused in ImageJ, for compatibility only.
-
hexToColor2
public static java.lang.String hexToColor2(java.lang.String hex)
Converts a hex color (e.g., "ffff00" or "#ffff00") into a color name "Red", "Green", "Yellow", etc. Returns null if the hex color does not have a name. Unused in ImageJ, for compatibility only.
-
colorToString
public static java.lang.String colorToString(java.awt.Color color)
Converts a Color into a lowercase string ("red", "green", "#aa55ff", etc.). Ifcolorisnull, returns the String "none".
-
colorToString2
public static java.lang.String colorToString2(java.awt.Color color)
Converts a Color into a string ("Red", "Green", #aa55ff, etc.). Ifcolorisnull, returns the String "None".
-
toColor
public static java.awt.Color toColor(int red, int green, int blue)Returns an opaque color with the specified red, green, and blue values. Values is outside the 0-255 range are replaced by the nearest valid number (0 or 255)
-
itemStateChanged
public void itemStateChanged(java.awt.event.ItemEvent e)
Callback listener for Choice modifications in the dialog- Specified by:
itemStateChangedin interfacejava.awt.event.ItemListener
-
getColors
public static java.lang.String[] getColors(java.lang.String... moreColors)
Returns an array of the color Strings in the argument(s) and the 13 predefined color names "Red", "Green", ... "Pink". The Strings arguments must be either "None" or hex codes starting with "#". Any null arguments are ignored.
-
-