Class DelegatingThumbnailRenderer
- java.lang.Object
-
- com.atlassian.confluence.impl.pages.thumbnail.renderer.DelegatingThumbnailRenderer
-
public class DelegatingThumbnailRenderer extends Object
Thumbnail renderer that uses different strategies to render a thumbnail.Images will be resized using a high quality renderer if possible and a streaming renderer if they exceed a certain width or height.
-
-
Constructor Summary
Constructors Constructor Description DelegatingThumbnailRenderer(com.atlassian.core.util.thumbnail.Thumber thumber, AttachmentManager attachmentManager)
Create a DelegatingThumbnailRenderer using an adaptive strategy that take the available memory into account to decide if we use the higher quality rendering or the lower quality stream based rendering (less memory consumption).DelegatingThumbnailRenderer(com.atlassian.core.util.thumbnail.Thumber thumber, AttachmentManager attachmentManager, int rasterSizeThresholdPx)
Create a DelegatingThumbnailRenderer that will use the lower quality stream based rendering if the image exceeds therasterSizeThresholdPx
(height or width in px).DelegatingThumbnailRenderer(com.atlassian.core.util.thumbnail.Thumber thumber, AttachmentManager attachmentManager, Predicate<ImageDimensions> rasterBasedRenderingThreshold)
Create a DelegatingThumbnailRenderer that will use therasterBasedRenderingThreshold
Predicate to decide if it's going to use the stream based (lower quality but low memory consumption) or the raster based renderer (higher quality but high memory consumption).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.atlassian.core.util.thumbnail.Thumbnail
retrieveOrCreateThumbNail(@NonNull Attachment attachment, com.atlassian.dc.filestore.api.compat.FilesystemPath thumbnailFile, int maxWidth, int maxHeight)
com.atlassian.core.util.thumbnail.Thumbnail
retrieveOrCreateThumbNail(@NonNull Attachment attachment, File thumbnailFile, int maxWidth, int maxHeight)
Create a new or return an existingThumbnail
for this attachment.
-
-
-
Constructor Detail
-
DelegatingThumbnailRenderer
public DelegatingThumbnailRenderer(com.atlassian.core.util.thumbnail.Thumber thumber, AttachmentManager attachmentManager)
Create a DelegatingThumbnailRenderer using an adaptive strategy that take the available memory into account to decide if we use the higher quality rendering or the lower quality stream based rendering (less memory consumption).
-
DelegatingThumbnailRenderer
public DelegatingThumbnailRenderer(com.atlassian.core.util.thumbnail.Thumber thumber, AttachmentManager attachmentManager, int rasterSizeThresholdPx)
Create a DelegatingThumbnailRenderer that will use the lower quality stream based rendering if the image exceeds therasterSizeThresholdPx
(height or width in px).
-
DelegatingThumbnailRenderer
public DelegatingThumbnailRenderer(com.atlassian.core.util.thumbnail.Thumber thumber, AttachmentManager attachmentManager, Predicate<ImageDimensions> rasterBasedRenderingThreshold)
Create a DelegatingThumbnailRenderer that will use therasterBasedRenderingThreshold
Predicate to decide if it's going to use the stream based (lower quality but low memory consumption) or the raster based renderer (higher quality but high memory consumption).- Parameters:
thumber
- Thumber instance to useattachmentManager
- The attachment manager that will be used to retrieve the image datarasterBasedRenderingThreshold
- Predicate<ImageDimensions> used to determine if the raster or stream based image rendering should be used. ThePredicate.test(Object)
method should return true for the givenDimensions
if the raster based (memory intensive) rendering approach can be used.- Since:
- 7.0.1
-
-
Method Detail
-
retrieveOrCreateThumbNail
public com.atlassian.core.util.thumbnail.Thumbnail retrieveOrCreateThumbNail(@NonNull Attachment attachment, com.atlassian.dc.filestore.api.compat.FilesystemPath thumbnailFile, int maxWidth, int maxHeight) throws ThumbnailRenderException
- Throws:
ThumbnailRenderException
- Since:
- 7.14
-
retrieveOrCreateThumbNail
public com.atlassian.core.util.thumbnail.Thumbnail retrieveOrCreateThumbNail(@NonNull Attachment attachment, File thumbnailFile, int maxWidth, int maxHeight) throws ThumbnailRenderException
Create a new or return an existingThumbnail
for this attachment. Thumbnails will always be PNG thumbnails!- Parameters:
attachment
- - The attachment that contains the image data. Cannot be null.thumbnailFile
- - The thumbnail file that will be used to store the rendered thumbnailmaxWidth
- - The maximum width of the thumbnail - this renderer maintains the aspect ratio of the original imagemaxHeight
- - The maximum height of the thumbnail - this renderer maintains the aspect ratio of the original image- Returns:
- Thumbnail in PNG format that is at most
maxWidth
xmaxHeight
, never returns null - Throws:
ThumbnailRenderException
- if the thumbnail cannot be created.
-
-