Package qupath.lib.images.servers
Class ImageServerProvider
java.lang.Object
qupath.lib.images.servers.ImageServerProvider
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> ImageServer
<T> buildServer
(String path, Class<T> cls, String... args) Attempt to createImageServer<T>
from the specified path and arguments.static <T> Map
<RegionRequest, T> Get the cache in use for image tiles of a specific type.static List
<ImageServerBuilder<?>> Request all availableImageServerBuilders
.static <T> List
<ImageServerBuilder<T>> getInstalledImageServerBuilders
(Class<T> imageClass) Request all availableImageServerBuilders
supporting a given image class.static <T> ImageServerBuilder.UriImageSupport
<T> getPreferredUriImageSupport
(Class<T> cls, String path, String... args) Get the preferredImageServerBuilder.UriImageSupport
for a specified image path.static URI
legacyPathToURI
(String path) Method to help with converting legacy image paths to URIs.static <T> void
setCache
(Map<RegionRequest, T> cache, Class<T> cls) Set the cache to be used for image tiles of a specific type.static void
setServiceLoader
(ServiceLoader<ImageServerBuilder> newLoader) Replace the default service loader with another.
-
Constructor Details
-
ImageServerProvider
public ImageServerProvider()
-
-
Method Details
-
setCache
Set the cache to be used for image tiles of a specific type.- Type Parameters:
T
-- Parameters:
cache
-cls
-
-
getCache
Get the cache in use for image tiles of a specific type.- Type Parameters:
T
-- Parameters:
cls
-- Returns:
-
setServiceLoader
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
Request all availableImageServerBuilders
.- Returns:
-
getInstalledImageServerBuilders
Request all availableImageServerBuilders
supporting a given image class.- Type Parameters:
T
-- Parameters:
imageClass
-- Returns:
-
legacyPathToURI
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 preferredImageServerBuilder.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 createImageServer<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 URIcls
- desired generic type for the ImageServer, e.g. BufferedImage.classargs
- optional arguments, which may be used by some builders- Returns:
- Throws:
IOException
-