Class Colors
java.lang.Object
ij.plugin.Colors
- All Implemented Interfaces:
PlugIn, ItemListener, EventListener
This plugin implements most of the Edit/Options/Colors command.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcolorToString(Color color) Converts a Color into a lowercase string ("red", "green", "#aa55ff", etc.).static StringcolorToString2(Color color) Converts a Color into a string ("Red", "Green", #aa55ff, etc.).static ColorConverts a String with the color name or the hexadecimal representation of a color with 6 or 8 hex digits to a Color.static ColorConverts a String with the color name or the hexadecimal representation of a color with 6 or 8 hex digits to a Color.static intstatic ColorFor named colors, converts the name String to the corresponding color.static StringgetColorName(Color c, String defaultName) For named colors, returns the name, or 'defaultName' if not a named color.static String[]Returns an array of the color Strings in the argument(s) and the 13 predefined color names "Red", "Green", ...static intstatic intstatic StringhexToColor(String hex) Converts a hex color (e.g., "ffff00") into "red", "green", "yellow", etc.static StringhexToColor2(String hex) Converts a hex color (e.g., "ffff00" or "#ffff00") into a color name "Red", "Green", "Yellow", etc.voidCallback listener for Choice modifications in the dialogvoidThis method is called when the plugin is loaded.static ColortoColor(int red, int green, int blue) Returns an opaque color with the specified red, green, and blue values.static ColorwavelengthToColor(double wl) Converts a wavelength (380-750 nm) to color.
-
Field Details
-
colors
-
-
Constructor Details
-
Colors
public Colors()
-
-
Method Details
-
run
-
getColorName
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
-
decode
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
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
-
getGreen
-
getBlue
-
hexToColor
-
hexToColor2
-
colorToString
-
colorToString2
-
toColor
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
Callback listener for Choice modifications in the dialog- Specified by:
itemStateChangedin interfaceItemListener
-
getColors
-
wavelengthToColor
Converts a wavelength (380-750 nm) to color. Based on the wavelength_to_rgb.R program at https://gist.github.com/friendly/67a7df339aa999e2bcfcfec88311abfc, which in turn is based on a FORTRAN program at http://www.physics.sfasu.edu/astro/color.html.
-