org.meshcms.core
Class ResizedThumbnail

java.lang.Object
  extended byorg.meshcms.core.AbstractThumbnail
      extended byorg.meshcms.core.ResizedThumbnail

public class ResizedThumbnail
extends AbstractThumbnail

Creates a thumbnail by simply resizing the image. The way the thumbnail is created can be controlled with some parameters (see the various setters for details).


Field Summary
static int DEFAULT_SIZE
          Default thumbnail size.
static java.lang.String MODE_CROP
          Used to scale the image and crop it to have a thumbnail of the required size.
static java.lang.String MODE_PADDING
          Like MODE_SCALE, but adds a padding to reach the required size.
static java.lang.String MODE_SCALE
          Used to scale the image maintaining proportions.
static java.lang.String MODE_STRETCH
          Used to resize the image without maintaining proportions.
static java.lang.String WHITE
          Default padding color.
 
Fields inherited from class org.meshcms.core.AbstractThumbnail
DEFAULT_BORDER_COLOR
 
Constructor Summary
ResizedThumbnail()
           
 
Method Summary
protected  boolean createThumbnail(java.io.File imageFile, java.io.File thumbnailFile)
          Creates the thumbnail. Called only if needed.
 java.lang.String getColor()
           
 int getHeight()
           
 java.lang.String getMode()
           
 java.lang.String getSuggestedFileName()
          Returns the recommended file name for the current thumbnail.
 int getWidth()
           
 boolean isHighQuality()
          Returns the quality setting.
 void setColor(java.lang.String color)
          Sets the padding color (used only when mode is MODE_PADDING).
 void setHeight(int height)
          Sets the maximum image height.
 void setHighQuality(boolean highQuality)
          Enables or disables better quality for image resizing.
 void setMode(java.lang.String mode)
          Sets the scaling mode.
 void setWidth(int width)
          Sets the maximum image width.
 
Methods inherited from class org.meshcms.core.AbstractThumbnail
averageResize, checkAndCreate, drawResizedImage, linearResize, resize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MODE_SCALE

public static final java.lang.String MODE_SCALE
Used to scale the image maintaining proportions.

See Also:
Constant Field Values

MODE_CROP

public static final java.lang.String MODE_CROP
Used to scale the image and crop it to have a thumbnail of the required size.

See Also:
Constant Field Values

MODE_PADDING

public static final java.lang.String MODE_PADDING
Like MODE_SCALE, but adds a padding to reach the required size.

See Also:
Constant Field Values

MODE_STRETCH

public static final java.lang.String MODE_STRETCH
Used to resize the image without maintaining proportions.

See Also:
Constant Field Values

WHITE

public static final java.lang.String WHITE
Default padding color.

See Also:
Constant Field Values

DEFAULT_SIZE

public static final int DEFAULT_SIZE
Default thumbnail size.

See Also:
Constant Field Values
Constructor Detail

ResizedThumbnail

public ResizedThumbnail()
Method Detail

getSuggestedFileName

public java.lang.String getSuggestedFileName()
Description copied from class: AbstractThumbnail
Returns the recommended file name for the current thumbnail.

Specified by:
getSuggestedFileName in class AbstractThumbnail

createThumbnail

protected boolean createThumbnail(java.io.File imageFile,
                                  java.io.File thumbnailFile)
Description copied from class: AbstractThumbnail
Creates the thumbnail. Called only if needed.

Specified by:
createThumbnail in class AbstractThumbnail
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

isHighQuality

public boolean isHighQuality()
Returns the quality setting.


setHighQuality

public void setHighQuality(boolean highQuality)
Enables or disables better quality for image resizing.


getWidth

public int getWidth()

setWidth

public void setWidth(int width)
Sets the maximum image width.


getHeight

public int getHeight()

setHeight

public void setHeight(int height)
Sets the maximum image height.


getMode

public java.lang.String getMode()

setMode

public void setMode(java.lang.String mode)
Sets the scaling mode. Possible values are MODE_SCALE (default), MODE_CROP, MODE_PADDING and MODE_STRETCH.


getColor

public java.lang.String getColor()

setColor

public void setColor(java.lang.String color)
Sets the padding color (used only when mode is MODE_PADDING). The color must be supplied in hexadecimal format, with or without a # sign (e.g. #ffcc00 or 123ABC).