se.datadosen.util
Class FileFilters

java.lang.Object
  extended by se.datadosen.util.FileFilters

public class FileFilters
extends java.lang.Object

Handle image loading and saving and decide if a certain file is supported by JAlbum


Nested Class Summary
static class FileFilters.BasicImageInfo
           
static class FileFilters.FileType
           
 
Field Summary
static java.lang.String AUDIO_FILE
           
static java.lang.String FLASH_VIDEO
           
static java.lang.String MEDIA_FILE
           
 
Constructor Summary
FileFilters()
           
 
Method Summary
static int calculateSubsamplingByScale(java.io.File file, java.awt.Dimension imageDim)
          Calculate subsampling variable for an image.
static int calculateSubsamplingByScale(java.io.File file, java.awt.Dimension imageDim, int scaleModifier)
          Calculate subsampling variable for an image.
static FileFilters.BasicImageInfo getBasicImageInfo(java.io.File f)
           
static java.lang.String getExtensionOf(java.io.File f)
          Deprecated. Also lowers case of extension. Use IO.extension
static java.lang.String getFileCategory(java.io.File f)
          Return file category (from filetypes.xml) or null if not category found
static FileFilters.FileType getFileType(java.io.File f)
           
static java.io.File getIconFor(java.io.File f)
          Deprecated. Use getIconFor(File f, AlbumBean engine) instead
static java.io.File getIconFor(java.io.File f, AlbumBean engine)
          Get icon for given file.
static boolean hasIcon(java.io.File file)
           
static boolean isFileSupported(java.io.File file)
          Tell if the extension of a specific file is supported by FileFilters.
static boolean isMediaFile(java.io.File file)
          Deprecated. Use hasIcon() instead
static java.awt.image.BufferedImage loadImage(java.io.File file)
          Load an image from file.
static java.awt.image.BufferedImage loadImage(java.io.File file, AlbumBean engine)
          Deprecated. Use loadImage(File file) instead.
static java.awt.image.BufferedImage loadImage(java.io.File file, int subsampling)
          Load an image from file.
static void saveJPEG(java.awt.image.BufferedImage img, java.io.File file, AlbumBean engine)
           
static void saveJPEG(java.awt.image.BufferedImage img, java.io.File file, AlbumBean engine, javax.imageio.metadata.IIOMetadata metaData)
           
static byte[] saveJPEG(java.awt.image.BufferedImage img, java.io.File file, AlbumBean engine, javax.imageio.metadata.IIOMetadata metaData, float compressionQuality)
          Save image to JPEG file Since jAlbum 8.9: If null is passed as file, then the JPEG image is returned as a byte array instead
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MEDIA_FILE

public static final java.lang.String MEDIA_FILE
See Also:
Constant Field Values

FLASH_VIDEO

public static final java.lang.String FLASH_VIDEO
See Also:
Constant Field Values

AUDIO_FILE

public static final java.lang.String AUDIO_FILE
See Also:
Constant Field Values
Constructor Detail

FileFilters

public FileFilters()
Method Detail

saveJPEG

public static void saveJPEG(java.awt.image.BufferedImage img,
                            java.io.File file,
                            AlbumBean engine)
                     throws java.io.IOException,
                            com.sun.image.codec.jpeg.ImageFormatException
Throws:
java.io.IOException
com.sun.image.codec.jpeg.ImageFormatException

saveJPEG

public static void saveJPEG(java.awt.image.BufferedImage img,
                            java.io.File file,
                            AlbumBean engine,
                            javax.imageio.metadata.IIOMetadata metaData)
                     throws java.io.IOException,
                            com.sun.image.codec.jpeg.ImageFormatException
Throws:
java.io.IOException
com.sun.image.codec.jpeg.ImageFormatException

saveJPEG

public static byte[] saveJPEG(java.awt.image.BufferedImage img,
                              java.io.File file,
                              AlbumBean engine,
                              javax.imageio.metadata.IIOMetadata metaData,
                              float compressionQuality)
                       throws java.io.IOException,
                              com.sun.image.codec.jpeg.ImageFormatException
Save image to JPEG file Since jAlbum 8.9: If null is passed as file, then the JPEG image is returned as a byte array instead

Parameters:
img -
file - If null, encoded JPEG image will be returned as byte array
engine -
metaData -
compressionQuality -
Returns:
null, or byte array of JPEG encoded image if file is null
Throws:
java.io.IOException
com.sun.image.codec.jpeg.ImageFormatException

isFileSupported

public static boolean isFileSupported(java.io.File file)
Tell if the extension of a specific file is supported by FileFilters.

Returns:
True if extension is supported, otherwise false.

isMediaFile

public static boolean isMediaFile(java.io.File file)
Deprecated. Use hasIcon() instead


getFileCategory

public static java.lang.String getFileCategory(java.io.File f)
Return file category (from filetypes.xml) or null if not category found

Since:
v8

getFileType

public static FileFilters.FileType getFileType(java.io.File f)

hasIcon

public static boolean hasIcon(java.io.File file)

getIconFor

public static java.io.File getIconFor(java.io.File f)
Deprecated. Use getIconFor(File f, AlbumBean engine) instead


getIconFor

public static java.io.File getIconFor(java.io.File f,
                                      AlbumBean engine)
Get icon for given file. Icons defined in the skin specific res directory have presedence over icons defined in the global res directory


getExtensionOf

public static java.lang.String getExtensionOf(java.io.File f)
Deprecated. Also lowers case of extension. Use IO.extension


getBasicImageInfo

public static FileFilters.BasicImageInfo getBasicImageInfo(java.io.File f)
                                                    throws java.io.IOException
Throws:
java.io.IOException

loadImage

public static java.awt.image.BufferedImage loadImage(java.io.File file,
                                                     AlbumBean engine)
                                              throws java.io.IOException,
                                                     com.sun.image.codec.jpeg.ImageFormatException
Deprecated. Use loadImage(File file) instead.

Load JPEG, GIF and PNG images and others supported by Jimi.

Throws:
java.io.IOException
com.sun.image.codec.jpeg.ImageFormatException

loadImage

public static java.awt.image.BufferedImage loadImage(java.io.File file)
                                              throws java.io.IOException
Load an image from file.

Parameters:
file - Image file.
Returns:
BufferedImage representing the image file.
Throws:
java.io.IOException - If image load fails.

loadImage

public static java.awt.image.BufferedImage loadImage(java.io.File file,
                                                     int subsampling)
                                              throws java.io.IOException
Load an image from file.

Parameters:
file - Image file.
subsampling - Sumbsampling variable, use calculateSubsamplingByScale() to calculate it.
Returns:
BufferedImage representing the inage file.
Throws:
java.io.IOException - If image load fails.

calculateSubsamplingByScale

public static int calculateSubsamplingByScale(java.io.File file,
                                              java.awt.Dimension imageDim)
                                       throws java.io.IOException
Calculate subsampling variable for an image.

Parameters:
file - Image file.
imageDim - Intended output image dimension.
Returns:
Calculated subsampling variable.
Throws:
java.io.IOException - If calculation fails.

calculateSubsamplingByScale

public static int calculateSubsamplingByScale(java.io.File file,
                                              java.awt.Dimension imageDim,
                                              int scaleModifier)
                                       throws java.io.IOException
Calculate subsampling variable for an image.

Parameters:
file - Image file.
imageDim - Intended output image dimension.
scaleModifier - Variable used to control image quality (higher value gives higher quality but slower processing).
Returns:
Calculated subsampling variable.
Throws:
java.io.IOException - If calculation fails.