org.meshcms.core
Class AbstractThumbnail

java.lang.Object
  extended byorg.meshcms.core.AbstractThumbnail
Direct Known Subclasses:
FileManagerThumbnail, GalleryThumbnail, ResizedThumbnail

public abstract class AbstractThumbnail
extends java.lang.Object


Field Summary
static java.awt.Color DEFAULT_BORDER_COLOR
          Default color for thumbnail borders.
 
Constructor Summary
AbstractThumbnail()
           
 
Method Summary
static java.awt.image.BufferedImage averageResize(java.awt.image.BufferedImage in, int width, int height)
          Resizes an image using a simple area average (suitable to create images that are much smaller than the original).
 Path checkAndCreate(WebSite webSite, Path imagePath, java.lang.String thumbnailFileName)
          Checks the current thumbnail, and creates it if not available or too old.
protected abstract  boolean createThumbnail(java.io.File imageFile, java.io.File thumbnailFile)
          Creates the thumbnail. Called only if needed.
static void drawResizedImage(java.awt.Graphics g, java.awt.image.BufferedImage image, int x, int y, int width, int height, boolean highQuality)
           
abstract  java.lang.String getSuggestedFileName()
          Returns the recommended file name for the current thumbnail.
static java.awt.image.BufferedImage linearResize(java.awt.image.BufferedImage in, int width, int height)
          Resizes an image using a simple linear interpolation (suitable to resize to a size similar to the original one).
static java.awt.image.BufferedImage resize(java.awt.image.BufferedImage in, int width, int height)
          Resizes an image.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_BORDER_COLOR

public static final java.awt.Color DEFAULT_BORDER_COLOR
Default color for thumbnail borders.

Constructor Detail

AbstractThumbnail

public AbstractThumbnail()
Method Detail

getSuggestedFileName

public abstract java.lang.String getSuggestedFileName()
Returns the recommended file name for the current thumbnail.


createThumbnail

protected abstract boolean createThumbnail(java.io.File imageFile,
                                           java.io.File thumbnailFile)
Creates the thumbnail. Called only if needed.

Parameters:
imageFile - source image file to create thumbnail from
thumbnailFile - destination file
Returns:
true if succeded to create the thumbnail and false if an error(exception) occured

checkAndCreate

public Path checkAndCreate(WebSite webSite,
                           Path imagePath,
                           java.lang.String thumbnailFileName)
Checks the current thumbnail, and creates it if not available or too old.


drawResizedImage

public static void drawResizedImage(java.awt.Graphics g,
                                    java.awt.image.BufferedImage image,
                                    int x,
                                    int y,
                                    int width,
                                    int height,
                                    boolean highQuality)

resize

public static java.awt.image.BufferedImage resize(java.awt.image.BufferedImage in,
                                                  int width,
                                                  int height)
Resizes an image. The method used is chosen according to the ratio between original and new size.


linearResize

public static java.awt.image.BufferedImage linearResize(java.awt.image.BufferedImage in,
                                                        int width,
                                                        int height)
Resizes an image using a simple linear interpolation (suitable to resize to a size similar to the original one).


averageResize

public static java.awt.image.BufferedImage averageResize(java.awt.image.BufferedImage in,
                                                         int width,
                                                         int height)
Resizes an image using a simple area average (suitable to create images that are much smaller than the original).