us.zuercher.gpx2map.image
Class CompositeImageFactory

java.lang.Object
  extended by us.zuercher.gpx2map.image.CompositeImageFactory
All Implemented Interfaces:
ImageFactory

public class CompositeImageFactory
extends Object
implements ImageFactory

CompositeImageFactory delegates image creation to the NetpbmImageFactory and GenericImageFactory classes.

Author:
Stephan Zuercher

Field Summary
private static List<ImageFormatDescriptor> formatDescriptors
          List of ImageFormatDescriptor objects for our supported formats.
static CompositeImageFactory instance
          The singleton instance of this image factory.
private static List<ImageFactory> subordinates
          List of ImageFactory implmentations that compose this image factory.
 
Constructor Summary
private CompositeImageFactory()
          CompositeImageFactory is a singleton.
 
Method Summary
 boolean canLoad(File imageFile)
          Tests whether the given file can be loaded.
 boolean canLoad(URL imageUrl)
          Tests whether the given URL refers to an image that can be loaded.
 List<ImageFormatDescriptor> getSupportedImageFormats()
          Returns the ImageFormatDescriptors for image formats supported by this factory.
 Image loadImage(File imageFile)
          Loads the given image file.
 Image loadImage(URL imageUrl)
          Loads the given image.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instance

public static final CompositeImageFactory instance
The singleton instance of this image factory.


subordinates

private static final List<ImageFactory> subordinates
List of ImageFactory implmentations that compose this image factory.


formatDescriptors

private static final List<ImageFormatDescriptor> formatDescriptors
List of ImageFormatDescriptor objects for our supported formats.

Constructor Detail

CompositeImageFactory

private CompositeImageFactory()
CompositeImageFactory is a singleton.

See Also:
instance
Method Detail

getSupportedImageFormats

public List<ImageFormatDescriptor> getSupportedImageFormats()
Returns the ImageFormatDescriptors for image formats supported by this factory.

Specified by:
getSupportedImageFormats in interface ImageFactory
Returns:
the ImageFormatDescriptors for image formats supported by this factory.

canLoad

public boolean canLoad(File imageFile)
                throws IOException
Tests whether the given file can be loaded.

Specified by:
canLoad in interface ImageFactory
Parameters:
imageFile - the file to test
Returns:
true if the file is an image in a supported format
Throws:
IOException - if there's an error reading the file

canLoad

public boolean canLoad(URL imageUrl)
                throws IOException
Tests whether the given URL refers to an image that can be loaded.

Specified by:
canLoad in interface ImageFactory
Parameters:
imageUrl - the URL to test
Returns:
true if the URL refers to an image in a supported format
Throws:
IOException - if there's an error reading the URL

loadImage

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

Specified by:
loadImage in interface ImageFactory
Parameters:
imageFile - an image file
Returns:
an Image
Throws:
IOException - if there's an error reading the file
UnknownFormatException - if the file's format is not known

loadImage

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

Specified by:
loadImage in interface ImageFactory
Parameters:
imageUrl - an image URL
Returns:
an Image
Throws:
IOException - if there's an error reading the file
UnknownFormatException - if the file's format is not known