Class ImageServerProvider

java.lang.Object
qupath.lib.images.servers.ImageServerProvider

public class ImageServerProvider extends Object
Service provider for creating ImageServers from a given path - which may be a file path or URL.

This class is responsible for hunting through potential ImageServerBuilders, ranked by support level, to find the first that works.

Author:
Pete Bankhead
  • Constructor Details

    • ImageServerProvider

      public ImageServerProvider()
  • Method Details

    • setCache

      public static <T> void setCache(Map<RegionRequest,T> cache, Class<T> cls)
      Set the cache to be used for image tiles of a specific type.
      Type Parameters:
      T -
      Parameters:
      cache -
      cls -
    • getCache

      public static <T> Map<RegionRequest,T> getCache(Class<T> cls)
      Get the cache in use for image tiles of a specific type.
      Type Parameters:
      T -
      Parameters:
      cls -
      Returns:
    • setServiceLoader

      public static void setServiceLoader(ServiceLoader<ImageServerBuilder> newLoader)
      Replace the default service loader with another.

      This can be handy if the ServiceLoader should be using an alternative ClassLoader, e.g. to auto-discover ImageServerBuilders in alternative directories.

      Parameters:
      newLoader -
    • getInstalledImageServerBuilders

      public static List<ImageServerBuilder<?>> getInstalledImageServerBuilders()
      Request all available ImageServerBuilders.
      Returns:
    • getInstalledImageServerBuilders

      public static <T> List<ImageServerBuilder<T>> getInstalledImageServerBuilders(Class<T> imageClass)
      Request all available ImageServerBuilders supporting a given image class.
      Type Parameters:
      T -
      Parameters:
      imageClass -
      Returns:
    • legacyPathToURI

      public static URI legacyPathToURI(String path) throws IOException
      Method to help with converting legacy image paths to URIs. This is intended for compatibility with data files used in QuPath v0.1.2, where servers were represented using paths only (rather than JSON).
      Parameters:
      path -
      Returns:
      a URI parsed from a path, if possible
      Throws:
      IOException
    • getPreferredUriImageSupport

      public static <T> ImageServerBuilder.UriImageSupport<T> getPreferredUriImageSupport(Class<T> cls, String path, String... args) throws IOException
      Get the preferred ImageServerBuilder.UriImageSupport for a specified image path.
      Type Parameters:
      T -
      Parameters:
      cls -
      path -
      args -
      Returns:
      Throws:
      IOException
    • buildServer

      public static <T> ImageServer<T> buildServer(String path, Class<T> cls, String... args) throws IOException
      Attempt to create ImageServer<T> from the specified path and arguments.

      In general, since v0.3 ImageServers.buildServer(URI, String...) is usually preferable to this method because it parses and applies known args (e.g. to reorder RGB channels or rotate the image). Here, all args apart from --classname are passed to builders - which may or may not do anything with them.

      Parameters:
      path - path to an image - typically a URI
      cls - desired generic type for the ImageServer, e.g. BufferedImage.class
      args - optional arguments, which may be used by some builders
      Returns:
      Throws:
      IOException