Package ome.services

Class ThumbnailCtx


  • public class ThumbnailCtx
    extends java.lang.Object
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  ThumbnailCtx.NoThumbnail
      Marker exception which is thrown by all methods which wish to tell their callers that for whatever reason the desired Thumbnail is not available, in which case the caller can use a *Direct method instead.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String DEFAULT_MIME_TYPE
      Default thumbnail MIME type.
    • Constructor Summary

      Constructors 
      Constructor Description
      ThumbnailCtx​(ome.api.IQuery queryService, ome.api.IUpdate updateService, ome.api.IPixels pixelsService, ome.api.IRenderingSettings settingsService, ome.io.nio.ThumbnailService thumbnailService, ome.system.OmeroContext applicationContext, SecuritySystem securitySystem, long userId)
      Default constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.awt.Dimension calculateXYWidths​(ome.model.core.Pixels pixels, int longestSide)
      Calculates the ratio of the two sides of a Pixel set and returns the X and Y widths based on the longest side maintaining aspect ratio.
      void createAndPrepareMissingRenderingSettings​(java.util.Set<java.lang.Long> pixelsIds)
      Resets a given set of Pixels rendering settings to the default effectively creating any which do not exist.
      ome.model.display.Thumbnail createThumbnailMetadata​(ome.model.core.Pixels pixels, java.awt.Dimension dimensions)
      Creates metadata for a thumbnail of a given set of pixels set and X-Y dimensions.
      boolean dirtyMetadata​(long pixelsId)
      Whether or not the thumbnail metadata for a given Pixels ID is dirty (the RenderingDef has been updated since the Thumbnail was).
      ome.model.display.Thumbnail getMetadata​(long pixelsId)
      Retrieves the Thumbnail object for a given Pixels ID.
      ome.model.display.Thumbnail getMetadataSimple​(long pixelsId)
      Retrieves the Thumbnail object for a given Pixels ID.
      ome.model.core.Pixels getPixels​(long pixelsId)
      Retrieves the Pixels object for a given Pixels ID.
      ome.model.display.RenderingDef getSettings​(long pixelsId)
      Retrieves the RenderingDef object for a given Pixels ID.
      long getUserId()
      Retrieves the current user ID to use for queries.
      boolean hasMetadata​(long pixelsId)
      Whether or not thumbnail metadata is available for a given Pixels ID.
      boolean hasSettings​(long pixelsId)
      Whether or not settings are available for a given Pixels ID.
      boolean isExtendedGraphCritical​(java.util.Set<java.lang.Long> pixelsIds)
      Whether or not we're extended graph critical for a given set of dimension pools.
      boolean isThumbnailCached​(long pixelsId)
      Checks to see if a thumbnail is in the on disk cache or not.
      java.util.List<ome.model.display.Thumbnail> loadAllMetadata​(long pixelsId)
      Retrieves all thumbnail metadata available in the database for a given Pixels ID.
      void loadAndPrepareMetadata​(java.util.Set<java.lang.Long> pixelsIds, int longestSide)
      Bulk loads and prepares metadata for a group of pixels sets.
      void loadAndPrepareMetadata​(java.util.Set<java.lang.Long> pixelsIds, java.awt.Dimension dimensions)
      Bulk loads and prepares metadata for a group of pixels sets.
      void loadAndPrepareMetadata​(java.util.Set<java.lang.Long> pixelsIds, java.awt.Dimension dimensions, boolean createMissing)
      Bulk loads and prepares metadata for a group of pixels sets.
      void loadAndPrepareRenderingSettings​(long pixelsId, long settingsId)
      Loads and prepares a rendering settings for a Pixels ID and RenderingDef ID.
      void loadAndPrepareRenderingSettings​(java.util.Set<java.lang.Long> pixelsIds)
      Bulk loads a set of rendering settings for a group of pixels sets and prepares our internal data structures.
      void setUserId​(long userId)
      Sets the user ID to use for queries.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_MIME_TYPE

        public static final java.lang.String DEFAULT_MIME_TYPE
        Default thumbnail MIME type.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ThumbnailCtx

        public ThumbnailCtx​(ome.api.IQuery queryService,
                            ome.api.IUpdate updateService,
                            ome.api.IPixels pixelsService,
                            ome.api.IRenderingSettings settingsService,
                            ome.io.nio.ThumbnailService thumbnailService,
                            ome.system.OmeroContext applicationContext,
                            SecuritySystem securitySystem,
                            long userId)
        Default constructor.
        Parameters:
        queryService - OMERO query service to use.
        updateService - OMERO update service to use.
        pixelsService - OMERO pixels service to use.
        settingsService - OMERO rendering settings service to use.
        thumbnailService - OMERO thumbnail service to use.
        applicationContext - OMERO application context
        securitySystem - OMERO security system for this session.
        userId - Current user ID.
    • Method Detail

      • getUserId

        public long getUserId()
        Retrieves the current user ID to use for queries.
        Returns:
        See above.
      • setUserId

        public void setUserId​(long userId)
        Sets the user ID to use for queries.
        Parameters:
        userId - The user ID to use for queries.
      • loadAndPrepareRenderingSettings

        public void loadAndPrepareRenderingSettings​(java.util.Set<java.lang.Long> pixelsIds)
        Bulk loads a set of rendering settings for a group of pixels sets and prepares our internal data structures.
        Parameters:
        pixelsIds - Set of Pixels IDs to prepare rendering settings for.
      • loadAndPrepareRenderingSettings

        public void loadAndPrepareRenderingSettings​(long pixelsId,
                                                    long settingsId)
        Loads and prepares a rendering settings for a Pixels ID and RenderingDef ID.
        Parameters:
        pixelsId - Pixels ID to load.
        settingsId - RenderingDef ID to load an prepare settings for.
      • loadAndPrepareMetadata

        public void loadAndPrepareMetadata​(java.util.Set<java.lang.Long> pixelsIds,
                                           int longestSide)
        Bulk loads and prepares metadata for a group of pixels sets. Calling this method guarantees that metadata are available, creating them if they are not.
        Parameters:
        pixelsIds - Pixels IDs to prepare metadata for.
        longestSide - The longest side of the thumbnails requested.
      • loadAndPrepareMetadata

        public void loadAndPrepareMetadata​(java.util.Set<java.lang.Long> pixelsIds,
                                           java.awt.Dimension dimensions)
        Bulk loads and prepares metadata for a group of pixels sets. Calling this method guarantees that metadata are available, creating them if they are not.
        Parameters:
        pixelsIds - Pixels IDs to prepare metadata for.
        dimensions - X-Y dimensions of the thumbnails requested.
      • loadAndPrepareMetadata

        public void loadAndPrepareMetadata​(java.util.Set<java.lang.Long> pixelsIds,
                                           java.awt.Dimension dimensions,
                                           boolean createMissing)
        Bulk loads and prepares metadata for a group of pixels sets. Calling this method guarantees that metadata are available, creating them if they are not.
        Parameters:
        pixelsIds - Pixels IDs to prepare metadata for.
        dimensions - X-Y dimensions of the thumbnails requested.
      • loadAllMetadata

        public java.util.List<ome.model.display.Thumbnail> loadAllMetadata​(long pixelsId)
        Retrieves all thumbnail metadata available in the database for a given Pixels ID.
        Parameters:
        pixelsId - Pixels ID to retrieve thumbnail metadata for.
        Returns:
        See above.
      • createAndPrepareMissingRenderingSettings

        public void createAndPrepareMissingRenderingSettings​(java.util.Set<java.lang.Long> pixelsIds)
        Resets a given set of Pixels rendering settings to the default effectively creating any which do not exist.
        Parameters:
        pixelsIds - Pixels IDs
      • hasSettings

        public boolean hasSettings​(long pixelsId)
        Whether or not settings are available for a given Pixels ID.
        Parameters:
        pixelsId - Pixels ID to check for availability.
        Returns:
        true if settings are available and false otherwise.
      • hasMetadata

        public boolean hasMetadata​(long pixelsId)
        Whether or not thumbnail metadata is available for a given Pixels ID.
        Parameters:
        pixelsId - Pixels ID to check for availability.
        Returns:
        true if metadata is available and false otherwise.
      • getPixels

        public ome.model.core.Pixels getPixels​(long pixelsId)
        Retrieves the Pixels object for a given Pixels ID.
        Parameters:
        pixelsId - Pixels ID to retrieve the Pixels object for.
        Returns:
        See above.
      • getSettings

        public ome.model.display.RenderingDef getSettings​(long pixelsId)
        Retrieves the RenderingDef object for a given Pixels ID.
        Parameters:
        pixelsId - Pixels ID to retrieve the RenderingDef object for.
        Returns:
        See above.
      • getMetadata

        public ome.model.display.Thumbnail getMetadata​(long pixelsId)
                                                throws ThumbnailCtx.NoThumbnail
        Retrieves the Thumbnail object for a given Pixels ID.
        Parameters:
        pixelsId - Pixels ID to retrieve the Thumbnail object for.
        Returns:
        See above.
        Throws:
        ThumbnailCtx.NoThumbnail
      • getMetadataSimple

        public ome.model.display.Thumbnail getMetadataSimple​(long pixelsId)
                                                      throws ome.conditions.ResourceError
        Retrieves the Thumbnail object for a given Pixels ID.
        Parameters:
        pixelsId - Pixels ID to retrieve the Thumbnail object for.
        Returns:
        returns null if the thumbnail metadata can't be found
        Throws:
        ome.conditions.ResourceError
      • dirtyMetadata

        public boolean dirtyMetadata​(long pixelsId)
        Whether or not the thumbnail metadata for a given Pixels ID is dirty (the RenderingDef has been updated since the Thumbnail was).
        Parameters:
        pixelsId - Pixels ID to check for dirty metadata.
        Returns:
        true if the metadata is dirty false otherwise.
      • isThumbnailCached

        public boolean isThumbnailCached​(long pixelsId)
        Checks to see if a thumbnail is in the on disk cache or not.
        Parameters:
        pixelsId - The Pixels set the thumbnail is for.
        Returns:
        Whether or not the thumbnail is in the on disk cache.
      • calculateXYWidths

        public java.awt.Dimension calculateXYWidths​(ome.model.core.Pixels pixels,
                                                    int longestSide)
        Calculates the ratio of the two sides of a Pixel set and returns the X and Y widths based on the longest side maintaining aspect ratio.
        Parameters:
        pixels - The Pixels set to calculate against.
        longestSide - The size of the longest side of the thumbnail requested.
        Returns:
        The calculated width (X) and height (Y).
      • isExtendedGraphCritical

        public boolean isExtendedGraphCritical​(java.util.Set<java.lang.Long> pixelsIds)
        Whether or not we're extended graph critical for a given set of dimension pools. We're extended graph critical if:
        • isGraphCritical() == true and the Pixels set does not belong to us.
        • isGraphCritical() == false, the Pixels set does not belong to us and the group is READ-ONLY.
        Parameters:
        pixelsIds - Set of Pixels to check if we're graph critical for.
        Returns:
        true if we're graph critical, and false otherwise.
      • createThumbnailMetadata

        public ome.model.display.Thumbnail createThumbnailMetadata​(ome.model.core.Pixels pixels,
                                                                   java.awt.Dimension dimensions)
        Creates metadata for a thumbnail of a given set of pixels set and X-Y dimensions.
        Parameters:
        pixels - The Pixels set to create thumbnail metadata for.
        dimensions - The dimensions of the thumbnail.
        Returns:
        the thumbnail metadata as created.
        See Also:
        getMetadata(long)