Class DisplaySettingUtils

java.lang.Object
qupath.lib.display.settings.DisplaySettingUtils

public class DisplaySettingUtils extends Object
Utility class for working with image display and image display settings objects. The former is used by QuPath to display images, while the latter is used to store the settings in a JSON-friendly form.
  • Constructor Details

    • DisplaySettingUtils

      public DisplaySettingUtils()
  • Method Details

    • displayToSettings

      public static ImageDisplaySettings displayToSettings(ImageDisplay display, String name)
      Create a new image display settings object from the image display. This is typically used to save the settings to a file.
      Parameters:
      display -
      name -
      Returns:
    • settingsCompatibleWithDisplay

      public static boolean settingsCompatibleWithDisplay(ImageDisplay display, ImageDisplaySettings settings)
      Check if the settings are compatible with the display. This is true if the number and names of the channels match.
      Parameters:
      display -
      settings -
      Returns:
    • applySettingsToDisplay

      public static boolean applySettingsToDisplay(ImageDisplay display, ImageDisplaySettings settings)
      Apply the settings to the display, if they are compatible.
      Parameters:
      display -
      settings -
      Returns:
      true if the settings were applied, false otherwise.
    • parseDisplaySettings

      public static Optional<ImageDisplaySettings> parseDisplaySettings(JsonElement element)
      Parse the JSON element into an image display settings object, if possible.
      Parameters:
      element - the JSON element to parse
      Returns:
      an optional containing the settings, or empty if the element is not a valid settings object
      See Also:
    • parseDisplaySettings

      public static ImageDisplaySettings parseDisplaySettings(Path path) throws IOException
      Parse the JSON element into an image display settings object. This assumes that the path is to a JSON file containing a valid JSON representation of an image display settings object, and throws an exception if this is not the case.

      For a more conservative approach, use parseDisplaySettings(JsonElement) instead.

      Parameters:
      path -
      Returns:
      Throws:
      IOException
      See Also:
    • getResourcesForProject

      public static ResourceManager.Manager<ImageDisplaySettings> getResourcesForProject(Project<?> project)
      Get the resource manager for image display settings from a project.
      Parameters:
      project -
      Returns: