Package qupath.lib.color
Class ColorToolsAwt
java.lang.Object
qupath.lib.color.ColorToolsAwt
Helper class for converting between packed RGB colors and Java's AWT representation, as well as creating some ColorModels for BufferedImages.
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic IndexColorModelcreateIndexColorModel(int red, int green, int blue, boolean whiteBackground) Get anIndexColorModelrepresenting a linear LUT based on a RGB color.static ColordarkenColor(Color color) Get a (slightly) darker version of the specified color.static ColorgetCachedColor(int r, int g, int b) Get a Color object, possibly from a shared map (used to avoid creating too many objects unnecessarily).static ColorgetCachedColor(int r, int g, int b, int a) Get a Color object, possibly from a shared map (used to avoid creating too many objects unnecessarily).static ColorgetCachedColor(Integer rgb) Get cached color.static ColorgetCachedColor(Integer rgb, boolean hasAlpha) Get cached color, explicitly stating whether alpha should be included or not.static ColorgetColorWithOpacity(Color color, double opacity) Get a color with a specified opacity, setting the alpha channel accordingly.static ColorgetColorWithOpacity(Integer rgb, double opacity) Get a color with a specified opacity, based on the packed RGB values in an Integer.static IndexColorModelgetIndexColorModel(StainVector stain) Create an IndexColorModel, ranging from white (low values) to a stain vector color (high values).static IndexColorModelgetIndexColorModel(StainVector stain, boolean whiteBackground) Get anIndexColorModelrepresenting a color deconvolution stain.static ColorgetMoreTranslucentColor(Color color) Get a (slightly more) translucent version of the specified color.static ColorgetTranslucentColor(Color color) Get a (slightly) translucent version of the specified color.static ColorscaleColor(Color color, double factor) Get a scaled version of the specified color, where the RGB values are independently scaled by a specified factor.
- 
Field Details- 
TRANSLUCENT_WHITEWhite, with 50% opacity.
- 
TRANSLUCENT_BLACKBlack, with 50% opacity.
 
- 
- 
Constructor Details- 
ColorToolsAwtpublic ColorToolsAwt()
 
- 
- 
Method Details- 
getCachedColorGet a Color object, possibly from a shared map (used to avoid creating too many objects unnecessarily).- Parameters:
- r-
- g-
- b-
- a-
- Returns:
 
- 
getCachedColorGet a Color object, possibly from a shared map (used to avoid creating too many objects unnecessarily).- Parameters:
- r-
- g-
- b-
- Returns:
 
- 
getCachedColorGet cached color. Assumed not to have alpha set, unless the relevant bits are non-zero.- Parameters:
- rgb-
- Returns:
 
- 
getCachedColorGet cached color, explicitly stating whether alpha should be included or not.- Parameters:
- rgb-
- hasAlpha-
- Returns:
 
- 
getIndexColorModelGet anIndexColorModelrepresenting a color deconvolution stain. The color is just an approximation for visualization purposes, it does not perfectly match the stain itself.- Parameters:
- stain- the stain to use
- whiteBackground- if true, the color model will have a white background; if false, it will have a black background
- Returns:
 
- 
createIndexColorModelpublic static IndexColorModel createIndexColorModel(int red, int green, int blue, boolean whiteBackground) Get anIndexColorModelrepresenting a linear LUT based on a RGB color.- Parameters:
- red- the red value of the color for the maximum value
- green- the green value of the color for the maximum value
- blue- the blue value of the color for the maximum value
- whiteBackground- if true, the color model will have a white background; if false, it will have a black background
- Returns:
 
- 
getIndexColorModelCreate an IndexColorModel, ranging from white (low values) to a stain vector color (high values).- Parameters:
- stain-
- Returns:
 
- 
getMoreTranslucentColorGet a (slightly more) translucent version of the specified color.If possible, a cached version will be used. - Parameters:
- color-
- Returns:
- See Also:
 
- 
darkenColorGet a (slightly) darker version of the specified color.If possible, a cached version will be used. - Parameters:
- color-
- Returns:
 
- 
getTranslucentColorGet a (slightly) translucent version of the specified color.If possible, a cached version will be used. - Parameters:
- color-
- Returns:
 
- 
scaleColorGet a scaled version of the specified color, where the RGB values are independently scaled by a specified factor.The alpha value is preserved unchanged. - Parameters:
- color-
- factor-
- Returns:
 
- 
getColorWithOpacityGet a color with a specified opacity, based on the packed RGB values in an Integer.- Parameters:
- rgb-
- opacity-
- Returns:
 
- 
getColorWithOpacityGet a color with a specified opacity, setting the alpha channel accordingly.- Parameters:
- color-
- opacity-
- Returns:
 
 
-