Class ColorToolsFX

java.lang.Object
qupath.lib.gui.tools.ColorToolsFX

public class ColorToolsFX extends Object
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 Details

    • TRANSLUCENT_BLACK_FX

      public static final Color TRANSLUCENT_BLACK_FX
      Black with opacity at 50%.
    • TRANSLUCENT_WHITE_FX

      public static final Color TRANSLUCENT_WHITE_FX
      White with opacity at 50%.
  • Constructor Details

    • ColorToolsFX

      public ColorToolsFX()
  • Method Details

    • getCachedColor

      public 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).
      Parameters:
      r -
      g -
      b -
      a -
      Returns:
    • getCachedColor

      public 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).
      Parameters:
      r -
      g -
      b -
      Returns:
    • getCachedColor

      public static Color getCachedColor(Integer rgb)
      Get cached color. Assumed not to have alpha set, unless the relevant bits are non-zero.
      Parameters:
      rgb -
      Returns:
    • getCachedColor

      public static Color getCachedColor(Integer rgb, boolean hasAlpha)
      Get cached color, explicitly stating whether alpha should be included or not.
      Parameters:
      rgb -
      hasAlpha -
      Returns:
    • getRGB

      public static int getRGB(Color color)
      Get a packed int (ARGB) representation of a Color object, omitting the alpha component.
      Parameters:
      color -
      Returns:
    • getARGB

      public static int getARGB(Color color)
      Get a packed int (ARGB) representation of a Color object.
      Parameters:
      color -
      Returns:
    • getDisplayedColor

      public static Color getDisplayedColor(PathObject pathObject)
      Get a Color appropriate for displaying an object.
      Parameters:
      pathObject -
      Returns:
      See Also:
    • getPathClassColor

      public static Color getPathClassColor(PathClass pathClass)
      Get a Color appropriate for displaying a PathClass.
      Parameters:
      pathClass -
      Returns:
    • getColorWithOpacityFX

      public static Color getColorWithOpacityFX(Integer rgb, double opacity)
      Get a Color from a packed RGB value, setting the alpha component to match the desired opacity.
      Parameters:
      rgb -
      opacity -
      Returns:
    • getColorWithOpacity

      public static Color getColorWithOpacity(Color color, double opacity)
      Derived a Color from an existing one, setting the alpha component to match the desired opacity.
      Parameters:
      color -
      opacity -
      Returns:
    • getDisplayedColorARGB

      public static Integer getDisplayedColorARGB(PathObject pathObject)
      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: