us.zuercher.gpx2map.image
Interface ImageFactory

All Known Implementing Classes:
CompositeImageFactory, GenericImageFactory, NetpbmImageFactory

public interface ImageFactory

ImageFactory describes the interface to an image factory. By requiring that image factories, such as NetpbmImageFactory, implement this interface, we make it possible to write a single parent image factory that automatically uses the appropriate child image factory to load an Image.

Author:
Stephan Zuercher

Method Summary
 boolean canLoad(File imageFile)
          Tests whether the given image file can be loaded by this ImageFactory.
 boolean canLoad(URL imageUrl)
          Tests whether the given image URL can be loaded by this ImageFactory.
 List<ImageFormatDescriptor> getSupportedImageFormats()
          Returns a List of ImageFormatDescriptors that describe the image formats supported by this ImageFactory.
 Image loadImage(File imageFile)
          Loads an image from the given file.
 Image loadImage(URL imageUrl)
          Loads an image from the given URL.
 

Method Detail

getSupportedImageFormats

List<ImageFormatDescriptor> getSupportedImageFormats()
Returns a List of ImageFormatDescriptors that describe the image formats supported by this ImageFactory.

Returns:
list of format descriptors for this image factory

canLoad

boolean canLoad(File imageFile)
                throws IOException
Tests whether the given image file can be loaded by this ImageFactory.

Parameters:
imageFile - the file to be tested
Returns:
true if the image can be loaded (e.g., the format is recognized and supported); false otherwise
Throws:
IOException - if there's an error reading the file

canLoad

boolean canLoad(URL imageUrl)
                throws IOException
Tests whether the given image URL can be loaded by this ImageFactory.

Parameters:
imageUrl - the URL to be tested
Returns:
true if the image can be loaded (e.g., the format is recognized and supported); false otherwise
Throws:
IOException - if there's an error reading the URL

loadImage

Image loadImage(File imageFile)
                throws IOException,
                       UnknownFormatException
Loads an image from the given file.

Parameters:
imageFile - an image file
Returns:
an image loaded from the given file
Throws:
IOException - if there's an error reading the file
UnknownFormatException - if the format is not supported by this ImageFactory.

loadImage

Image loadImage(URL imageUrl)
                throws IOException,
                       UnknownFormatException
Loads an image from the given URL.

Parameters:
imageUrl - an image URL
Returns:
an image loaded from the given URL
Throws:
IOException - if there's an error reading from the URL
UnknownFormatException - if the format is not supported by this ImageFactory.