public class

DelegatingThumbnailRenderer

extends Object
java.lang.Object
   ↳ com.atlassian.confluence.pages.thumbnail.renderer.DelegatingThumbnailRenderer

Class Overview

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.

Summary

Public Constructors
DelegatingThumbnailRenderer(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(Thumber thumber, AttachmentManager attachmentManager, int rasterSizeThresholdPx)
Create a DelegatingThumbnailRenderer that will use the lower quality stream based rendering if the image exceeds the rasterSizeThresholdPx (height or width in px).
DelegatingThumbnailRenderer(Thumber thumber, AttachmentManager attachmentManager, Predicate<Dimensions> rasterBasedRenderingThreshold)
Create a DelegatingThumbnailRenderer that will use the rasterBasedRenderingThreshold 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).
Public Methods
Thumbnail retrieveOrCreateThumbNail(Attachment attachment, File thumbnailFile, String imageType, int maxWidth, int minWidth, int height)
creates a thumbnail or returns an existing thumbnail for this attachment
Thumbnail retrieveOrCreateThumbNail(Attachment attachment, File thumbnailFile, int maxWidth, int maxHeight)
Create a new or return an existing Thumbnail for this attachment.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public DelegatingThumbnailRenderer (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).

public DelegatingThumbnailRenderer (Thumber thumber, AttachmentManager attachmentManager, int rasterSizeThresholdPx)

Create a DelegatingThumbnailRenderer that will use the lower quality stream based rendering if the image exceeds the rasterSizeThresholdPx (height or width in px).

public DelegatingThumbnailRenderer (Thumber thumber, AttachmentManager attachmentManager, Predicate<Dimensions> rasterBasedRenderingThreshold)

Create a DelegatingThumbnailRenderer that will use the rasterBasedRenderingThreshold 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 use
attachmentManager The attachment manager that will be used to retrieve the image data
rasterBasedRenderingThreshold Predicate used to determine if the raster or stream based image rendering should be used. The apply(T) method should return true for the given Dimensions if the raster based (memory intensive) rendering approach can be used.

Public Methods

public Thumbnail retrieveOrCreateThumbNail (Attachment attachment, File thumbnailFile, String imageType, int maxWidth, int minWidth, int height)

creates a thumbnail or returns an existing thumbnail for this attachment

public Thumbnail retrieveOrCreateThumbNail (Attachment attachment, File thumbnailFile, int maxWidth, int maxHeight)

Create a new or return an existing Thumbnail for this attachment. Thumbnails will always be PNG thumbnails!

Parameters
attachment - The attachment that contains the image data
thumbnailFile - The thumbnail file that will be used to store the rendered thumbnail
maxWidth - The maximum width of the thumbnail - this renderer maintains the aspect ratio of the original image
maxHeight - 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 maxWidthxmaxHeight, never returns null
Throws
ThumbnailRenderException if the thumbnail cannot be created.