ome.services
Class ThumbnailBean

java.lang.Object
  extended by ome.logic.AbstractLevel2Service
      extended by ome.services.ThumbnailBean
All Implemented Interfaces:
Serializable, ServiceInterface, StatefulServiceInterface, ThumbnailStore, SelfConfigurableService

@Transactional(readOnly=true)
public class ThumbnailBean
extends AbstractLevel2Service
implements ThumbnailStore, Serializable

Provides methods for directly querying object graphs. The service is entirely read/write transactionally because of the requirements of rendering engine lazy object creation where rendering settings are missing.

Since:
3.0
Version:
3.0 (Internal version: $Rev$ $Date$)
Author:
Chris Allan      callan@blackcat.ca
See Also:
Serialized Form

Field Summary
static float DEFAULT_COMPRESSION_QUALITY
          The default compression quality in fractional percent.
static String DEFAULT_MIME_TYPE
          The default MIME type.
static int DEFAULT_X_WIDTH
          The default X-width for a thumbnail.
static int DEFAULT_Y_WIDTH
          The default Y-width for a thumbnail.
 
Fields inherited from class ome.logic.AbstractLevel2Service
iQuery, iUpdate, metadata, queryFactory, sec
 
Constructor Summary
ThumbnailBean()
          default constructor
ThumbnailBean(boolean checking)
          overriden to allow Spring to set boolean
 
Method Summary
 void activate()
          Completely restore this service for active use from whatever passivation it has implemented.
 void close()
          signals the end of the service lifecycle.
 void createThumbnail(Integer sizeX, Integer sizeY)
          Creates a thumbnail for a pixels set using a given set of rendering settings (RenderingDef) in the on-disk cache.
 void createThumbnails()
          Creates thumbnails for a pixels set using a given set of rendering settings (RenderingDef) in the on-disk cache for every sizeX/sizeY combination already cached.
 void createThumbnailsByLongestSideSet(Integer size, Set<Long> pixelsIds)
          Creates thumbnails for a number of pixels sets using a given set of rendering settings (RenderingDef) in the on-disk cache.
protected  void errorIfInvalidState()
           
protected  void errorIfNullPixels()
           
protected  void errorIfNullPixelsAndRenderingDef()
           
protected  void errorIfNullRenderingDef()
           
 EventContext getCurrentEventContext()
          Returns the current EventContext for this instance.
 long getRenderingDefId()
          Return the id of the RenderingDef loaded in this instance.
 Class<? extends ServiceInterface> getServiceInterface()
           
 byte[] getThumbnail(Integer sizeX, Integer sizeY)
          Retrieves a thumbnail for a pixels set using a given set of rendering settings (RenderingDef).
 byte[] getThumbnailByLongestSide(Integer size)
          Retrieves a thumbnail for a pixels set using a given set of rendering settings (RenderingDef).
 byte[] getThumbnailByLongestSideDirect(Integer size)
          Retrieves a thumbnail for a pixels set using a given set of rendering settings (RenderingDef).
 Map<Long,byte[]> getThumbnailByLongestSideSet(Integer size, Set<Long> pixelsIds)
          Retrieves a number of thumbnails for pixels sets using given sets of rendering settings (RenderingDef).
 byte[] getThumbnailDirect(Integer sizeX, Integer sizeY)
          Retrieves a thumbnail for a pixels set using a given set of rendering settings (RenderingDef).
 byte[] getThumbnailForSectionByLongestSideDirect(int theZ, int theT, Integer size)
          Retrieves a thumbnail for a pixels set using a given set of rendering settings (RenderingDef) for a particular section.
 byte[] getThumbnailForSectionDirect(int theZ, int theT, Integer sizeX, Integer sizeY)
          Retrieves a thumbnail for a pixels set using a given set of rendering settings (RenderingDef) for a particular section.
 Map<Long,byte[]> getThumbnailSet(Integer sizeX, Integer sizeY, Set<Long> pixelsIds)
          Retrieves a number of thumbnails for pixels sets using given sets of rendering settings (RenderingDef).
 boolean isDiskSpaceChecking()
           
 void passivate()
          Perform whatever passivation is possible or throw an exception.
 void resetDefaults()
          Resets the rendering definition for the active pixels set to its default settings.
 void setCompressionService(LocalCompress compressionService)
          Compression service Bean injector.
 void setDiskSpaceChecking(boolean diskSpaceChecking)
           
 void setInProgressImageResource(org.springframework.core.io.Resource inProgressImageResource)
          In-progress image resource Bean injector.
 void setIoService(ThumbnailService ioService)
          I/O service (ThumbnailService) Bean injector.
 void setIPixels(IPixels iPixels)
          Pixels service Bean injector.
 void setIRepositoryInfo(IRepositoryInfo iRepositoryInfo)
          Disk Space Usage service Bean injector
 void setPixelDataService(PixelsService pixelDataService)
          Pixels service Bean injector.
 boolean setPixelsId(long id)
          This method manages the state of the service; it must be invoked before using any other methods.
 void setRenderingDefId(long id)
          This method manages the state of the service; it should be invoked directly after setPixelsId.
 void setScaleService(IScale iScale)
          Scale service Bean injector.
 void setSettingsService(IRenderingSettings settingsService)
          Rendering settings service Bean injector.
 boolean thumbnailExists(Integer sizeX, Integer sizeY)
          Checks if a thumbnail of a particular size exists for a pixels set.
 
Methods inherited from class ome.logic.AbstractLevel2Service
getBeanHelper, getExtendedMetadata, getQueryFactory, getSecuritySystem, selfConfigure, setExtendedMetadata, setQueryFactory, setQueryService, setSecuritySystem, setUpdateService
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_X_WIDTH

public static final int DEFAULT_X_WIDTH
The default X-width for a thumbnail.

See Also:
Constant Field Values

DEFAULT_Y_WIDTH

public static final int DEFAULT_Y_WIDTH
The default Y-width for a thumbnail.

See Also:
Constant Field Values

DEFAULT_COMPRESSION_QUALITY

public static final float DEFAULT_COMPRESSION_QUALITY
The default compression quality in fractional percent.

See Also:
Constant Field Values

DEFAULT_MIME_TYPE

public static final String DEFAULT_MIME_TYPE
The default MIME type.

See Also:
Constant Field Values
Constructor Detail

ThumbnailBean

public ThumbnailBean()
default constructor


ThumbnailBean

public ThumbnailBean(boolean checking)
overriden to allow Spring to set boolean

Parameters:
checking -
Method Detail

getServiceInterface

public Class<? extends ServiceInterface> getServiceInterface()
Specified by:
getServiceInterface in interface SelfConfigurableService

passivate

@Transactional(readOnly=true)
public void passivate()
Description copied from interface: StatefulServiceInterface
Perform whatever passivation is possible or throw an exception. A good passivation method will free up as much memory as possible, most likely by storing it to disk. A call to passivate should be safe even if the service is already passivated.

Specified by:
passivate in interface StatefulServiceInterface

activate

@Transactional(readOnly=true)
public void activate()
Description copied from interface: StatefulServiceInterface
Completely restore this service for active use from whatever passivation it has implemented. A call to activate should be safe even if the service is already activated.

Specified by:
activate in interface StatefulServiceInterface

close

public void close()
Description copied from interface: StatefulServiceInterface
signals the end of the service lifecycle. Resources such as Sessions can be released. All further calls will throw an exception.

Specified by:
close in interface StatefulServiceInterface

getRenderingDefId

public long getRenderingDefId()
Description copied from interface: ThumbnailStore
Return the id of the RenderingDef loaded in this instance.

Specified by:
getRenderingDefId in interface ThumbnailStore

getCurrentEventContext

public EventContext getCurrentEventContext()
Description copied from interface: StatefulServiceInterface
Returns the current EventContext for this instance. This is useful for later identifying changes made by this Event.

Specified by:
getCurrentEventContext in interface StatefulServiceInterface

setPixelsId

@Transactional(readOnly=false)
public boolean setPixelsId(long id)
Description copied from interface: ThumbnailStore
This method manages the state of the service; it must be invoked before using any other methods. As the
ThumbnailStore
relies on the
RenderingEngine
, a valid rendering definition must be available for it to work.

Specified by:
setPixelsId in interface ThumbnailStore
Parameters:
id - an Pixels id.
Returns:
true if a RenderingDef exists for the Pixels set, otherwise false

setRenderingDefId

public void setRenderingDefId(long id)
Description copied from interface: ThumbnailStore
This method manages the state of the service; it should be invoked directly after setPixelsId. If it is not invoked with a valid rendering definition ID before using the thumbnail accessor methods execution continues as if renderingDefId were set to null.

Specified by:
setRenderingDefId in interface ThumbnailStore
Parameters:
id - an RenderingDef id. null specifies the user's currently active rendering settings to be used.

setInProgressImageResource

public void setInProgressImageResource(org.springframework.core.io.Resource inProgressImageResource)
In-progress image resource Bean injector.

Parameters:
inProgressImageResource - The in-progress image resource we'll be using for in progress images.

setPixelDataService

public void setPixelDataService(PixelsService pixelDataService)
Pixels service Bean injector.

Parameters:
iPixels - an IPixels.

setIPixels

public void setIPixels(IPixels iPixels)
Pixels service Bean injector.

Parameters:
iPixels - an IPixels.

setScaleService

public void setScaleService(IScale iScale)
Scale service Bean injector.

Parameters:
iScale - an IScale.

setIoService

public void setIoService(ThumbnailService ioService)
I/O service (ThumbnailService) Bean injector.

Parameters:
ioService - a ThumbnailService.

setIRepositoryInfo

public final void setIRepositoryInfo(IRepositoryInfo iRepositoryInfo)
Disk Space Usage service Bean injector

Parameters:
iRepositoryInfo - an IRepositoryInfo

setCompressionService

public void setCompressionService(LocalCompress compressionService)
Compression service Bean injector.

Parameters:
compressionService - an ICompress.

setSettingsService

public void setSettingsService(IRenderingSettings settingsService)
Rendering settings service Bean injector.

Parameters:
settingsService - an IRenderingSettings.

errorIfInvalidState

protected void errorIfInvalidState()

errorIfNullPixelsAndRenderingDef

protected void errorIfNullPixelsAndRenderingDef()

errorIfNullPixels

protected void errorIfNullPixels()

errorIfNullRenderingDef

protected void errorIfNullRenderingDef()

createThumbnail

@Transactional(readOnly=false)
public void createThumbnail(Integer sizeX,
                                          Integer sizeY)
Description copied from interface: ThumbnailStore
Creates a thumbnail for a pixels set using a given set of rendering settings (RenderingDef) in the on-disk cache.

Specified by:
createThumbnail in interface ThumbnailStore
Parameters:
sizeX - the X-axis width of the thumbnail. null specifies the default size of 48.
sizeY - the Y-axis width of the thumbnail. null specifies the default size of 48.
See Also:
getThumb(), getThumbDirect()

createThumbnails

@Transactional(readOnly=false)
public void createThumbnails()
Description copied from interface: ThumbnailStore
Creates thumbnails for a pixels set using a given set of rendering settings (RenderingDef) in the on-disk cache for every sizeX/sizeY combination already cached.

Specified by:
createThumbnails in interface ThumbnailStore
See Also:
getThumb(), getThumbDirect()

createThumbnailsByLongestSideSet

@Transactional(readOnly=false)
public void createThumbnailsByLongestSideSet(Integer size,
                                                           Set<Long> pixelsIds)
Description copied from interface: ThumbnailStore
Creates thumbnails for a number of pixels sets using a given set of rendering settings (RenderingDef) in the on-disk cache. Unlike the other thumbnail creation methods, this method may be called without first calling #setPixelsId(). This method will not reset or modify rendering settings in any way. If rendering settings for a pixels set are not present, thumbnail creation for that pixels set will not be performed.

Specified by:
createThumbnailsByLongestSideSet in interface ThumbnailStore
Parameters:
size - the size of the longest side of the thumbnail requested. null specifies the default size of 48.
pixelsIds - the Pixels sets to retrieve thumbnails for.
See Also:
createThumbnail(), ThumbnailStore.createThumbnails()

getThumbnailSet

@Transactional(readOnly=false)
public Map<Long,byte[]> getThumbnailSet(Integer sizeX,
                                                      Integer sizeY,
                                                      Set<Long> pixelsIds)
Description copied from interface: ThumbnailStore
Retrieves a number of thumbnails for pixels sets using given sets of rendering settings (RenderingDef). If the thumbnails exist in the on-disk cache they will be returned directly, otherwise they will be created as in #getThumbDirect(), placed in the on-disk cache and returned. Unlike the other thumbnail retrieval methods, this method may be called without first calling #setPixelsId().

Specified by:
getThumbnailSet in interface ThumbnailStore
Parameters:
sizeX - the X-axis width of the thumbnail. null specifies the default size of 48.
sizeY - the Y-axis width of the thumbnail. null specifies the default size of 48.
pixelsIds - the Pixels sets to retrieve thumbnails for.
Returns:
a Map whose keys are pixels ids and values are JPEG thumbnail byte buffers or null if an exception was thrown while attempting to retrieve the thumbnail for that particular Pixels set.
See Also:
getThumbnail()

getThumbnailByLongestSideSet

@Transactional(readOnly=false)
public Map<Long,byte[]> getThumbnailByLongestSideSet(Integer size,
                                                                   Set<Long> pixelsIds)
Description copied from interface: ThumbnailStore
Retrieves a number of thumbnails for pixels sets using given sets of rendering settings (RenderingDef). If the Thumbnails exist in the on-disk cache they will be returned directly, otherwise they will be created as in ThumbnailStore.getThumbnailByLongestSideDirect(java.lang.Integer). The longest side of the image will be used to calculate the size for the smaller side in order to keep the aspect ratio of the original image. Unlike the other thumbnail retrieval methods, this method may be called without first calling #setPixelsId().

Specified by:
getThumbnailByLongestSideSet in interface ThumbnailStore
Parameters:
size - the size of the longest side of the thumbnail requested. null specifies the default size of 48.
pixelsIds - the Pixels sets to retrieve thumbnails for.
Returns:
a Map whose keys are pixels ids and values are JPEG thumbnail byte buffers or null if an exception was thrown while attempting to retrieve the thumbnail for that particular Pixels set.
See Also:
getThumbnailSet()

getThumbnail

@Transactional(readOnly=false)
public byte[] getThumbnail(Integer sizeX,
                                         Integer sizeY)
Description copied from interface: ThumbnailStore
Retrieves a thumbnail for a pixels set using a given set of rendering settings (RenderingDef). If the thumbnail exists in the on-disk cache it will be returned directly, otherwise it will be created as in #getThumbDirect(), placed in the on-disk cache and returned.

Specified by:
getThumbnail in interface ThumbnailStore
Parameters:
sizeX - the X-axis width of the thumbnail. null specifies the default size of 48.
sizeY - the Y-axis width of the thumbnail. null specifies the default size of 48.
Returns:
a JPEG thumbnail byte buffer.
See Also:
getThumbnailDirect()

getThumbnailByLongestSide

@Transactional(readOnly=false)
public byte[] getThumbnailByLongestSide(Integer size)
Description copied from interface: ThumbnailStore
Retrieves a thumbnail for a pixels set using a given set of rendering settings (RenderingDef). If the thumbnail exists in the on-disk cache it will bereturned directly, otherwise it will be created as in #getThumbDirect(), placed in the on-disk cache and returned. The longest side of the image will be used to calculate the size for the smaller side in order to keep the aspect ratio of the original image.

Specified by:
getThumbnailByLongestSide in interface ThumbnailStore
Parameters:
size - the size of the longest side of the thumbnail requested. null specifies the default size of 48.
Returns:
a JPEG thumbnail byte buffer.
See Also:
getThumbnail()

getThumbnailDirect

public byte[] getThumbnailDirect(Integer sizeX,
                                 Integer sizeY)
Description copied from interface: ThumbnailStore
Retrieves a thumbnail for a pixels set using a given set of rendering settings (RenderingDef). The Thumbnail will always be created directly, ignoring the on-disk cache.

Specified by:
getThumbnailDirect in interface ThumbnailStore
Parameters:
sizeX - the X-axis width of the thumbnail. null specifies the default size of 48.
sizeY - the Y-axis width of the thumbnail. null specifies the default size of 48.
Returns:
a JPEG thumbnail byte buffer.
See Also:
getThumbnail()

getThumbnailForSectionDirect

public byte[] getThumbnailForSectionDirect(int theZ,
                                           int theT,
                                           Integer sizeX,
                                           Integer sizeY)
Description copied from interface: ThumbnailStore
Retrieves a thumbnail for a pixels set using a given set of rendering settings (RenderingDef) for a particular section. The Thumbnail will always be created directly, ignoring the on-disk cache.

Specified by:
getThumbnailForSectionDirect in interface ThumbnailStore
Parameters:
theZ - the optical section (offset across the Z-axis) to use.
theT - the timepoint (offset across the T-axis) to use.
sizeX - the X-axis width of the thumbnail. null specifies the default size of 48.
sizeY - the Y-axis width of the thumbnail. null specifies the default size of 48.
Returns:
a JPEG thumbnail byte buffer.
See Also:
getThumbnail()

getThumbnailByLongestSideDirect

public byte[] getThumbnailByLongestSideDirect(Integer size)
Description copied from interface: ThumbnailStore
Retrieves a thumbnail for a pixels set using a given set of rendering settings (RenderingDef). The Thumbnail will always be created directly, ignoring the on-disk cache. The longest side of the image will be used to calculate the size for the smaller side in order to keep the aspect ratio of the original image.

Specified by:
getThumbnailByLongestSideDirect in interface ThumbnailStore
Parameters:
size - the size of the longest side of the thumbnail requested. null specifies the default size of 48.
Returns:
a JPEG thumbnail byte buffer.
See Also:
getThumbnailDirect()

getThumbnailForSectionByLongestSideDirect

public byte[] getThumbnailForSectionByLongestSideDirect(int theZ,
                                                        int theT,
                                                        Integer size)
Description copied from interface: ThumbnailStore
Retrieves a thumbnail for a pixels set using a given set of rendering settings (RenderingDef) for a particular section. The Thumbnail will always be created directly, ignoring the on-disk cache. The longest side of the image will be used to calculate the size for the smaller side in order to keep the aspect ratio of the original image.

Specified by:
getThumbnailForSectionByLongestSideDirect in interface ThumbnailStore
Parameters:
theZ - the optical section (offset across the Z-axis) to use.
theT - the timepoint (offset across the T-axis) to use.
size - the size of the longest side of the thumbnail requested. null specifies the default size of 48.
Returns:
a JPEG thumbnail byte buffer.
See Also:
getThumbnailDirect()

thumbnailExists

public boolean thumbnailExists(Integer sizeX,
                               Integer sizeY)
Description copied from interface: ThumbnailStore
Checks if a thumbnail of a particular size exists for a pixels set.

Specified by:
thumbnailExists in interface ThumbnailStore
Parameters:
sizeX - the X-axis width of the thumbnail. null specifies use the default size of 48.
sizeY - the Y-axis width of the thumbnail. null specifies user the default size of 48.
See Also:
getThumb(), getThumbDirect()

resetDefaults

@Transactional(readOnly=false)
public void resetDefaults()
Description copied from interface: ThumbnailStore
Resets the rendering definition for the active pixels set to its default settings.

Specified by:
resetDefaults in interface ThumbnailStore

isDiskSpaceChecking

public boolean isDiskSpaceChecking()

setDiskSpaceChecking

public void setDiskSpaceChecking(boolean diskSpaceChecking)


OmeroJava Api

Version: 4.3.3-00d1137e-b2894

Copyright © 2009 The University of Dundee. All Rights Reserved.