Package qupath.lib.gui.tools
Class ColorToolsFX
java.lang.Object
qupath.lib.gui.tools.ColorToolsFX
Helper class for converting between packed RGB colors and Java's AWT representation, as well as creating some ColorModels for BufferedImages.
- Author:
- Pete Bankhead
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
Get a packed int (ARGB) representation of a Color object.static Color
getCachedColor
(int r, int g, int b) Get a Color object, possibly from a shared map (used to avoid creating too many objects unnecessarily).static Color
getCachedColor
(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 Color
getCachedColor
(Integer rgb) Get cached color.static Color
getCachedColor
(Integer rgb, boolean hasAlpha) Get cached color, explicitly stating whether alpha should be included or not.static Color
getColorWithOpacity
(Color color, double opacity) Derived a Color from an existing one, setting the alpha component to match the desired opacity.static Color
getColorWithOpacityFX
(Integer rgb, double opacity) Get a Color from a packed RGB value, setting the alpha component to match the desired opacity.static Color
getDisplayedColor
(PathObject pathObject) Get a Color appropriate for displaying an object.static Integer
getDisplayedColorARGB
(PathObject pathObject) Get the color with which an object should be displayed, as a packaged ARGB integer.static Color
getPathClassColor
(PathClass pathClass) Get a Color appropriate for displaying aPathClass
.static int
Get a packed int (ARGB) representation of a Color object, omitting the alpha component.
-
Field Details
-
TRANSLUCENT_BLACK_FX
Black with opacity at 50%. -
TRANSLUCENT_WHITE_FX
White with opacity at 50%.
-
-
Constructor Details
-
ColorToolsFX
public ColorToolsFX()
-
-
Method Details
-
getCachedColor
Get a Color object, possibly from a shared map (used to avoid creating too many objects unnecessarily).- Parameters:
r
-g
-b
-a
-- Returns:
-
getCachedColor
Get a Color object, possibly from a shared map (used to avoid creating too many objects unnecessarily).- Parameters:
r
-g
-b
-- Returns:
-
getCachedColor
Get cached color. Assumed not to have alpha set, unless the relevant bits are non-zero.- Parameters:
rgb
-- Returns:
-
getCachedColor
Get cached color, explicitly stating whether alpha should be included or not.- Parameters:
rgb
-hasAlpha
-- Returns:
-
getRGB
Get a packed int (ARGB) representation of a Color object, omitting the alpha component.- Parameters:
color
-- Returns:
-
getARGB
Get a packed int (ARGB) representation of a Color object.- Parameters:
color
-- Returns:
-
getDisplayedColor
Get a Color appropriate for displaying an object.- Parameters:
pathObject
-- Returns:
- See Also:
-
getPathClassColor
Get a Color appropriate for displaying aPathClass
.- Parameters:
pathClass
-- Returns:
-
getColorWithOpacityFX
Get a Color from a packed RGB value, setting the alpha component to match the desired opacity.- Parameters:
rgb
-opacity
-- Returns:
-
getColorWithOpacity
Derived a Color from an existing one, setting the alpha component to match the desired opacity.- Parameters:
color
-opacity
-- Returns:
-
getDisplayedColorARGB
Get the color with which an object should be displayed, as a packaged ARGB integer. This could be stored internally, or obtained from its PathClass. If neither of these produces a result, a default color will be returned based on PathPrefs for the specific (Java) class of the PathObject. Assuming PathPrefs does not contain any nulls, this will therefore not return nulls either.- Parameters:
pathObject
-- Returns:
-