|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectus.zuercher.gpx2map.image.generic.GenericImageFactory
public class GenericImageFactory
GenericImageFactory is a factory for GenericImage
objects. Its
generic insofar as it depends entirely on Toolkit
to
load images and only supports the image formats that the toolkit supports
(GIF, JPEG, and PNG).
Nested Class Summary | |
---|---|
private static class |
GenericImageFactory.DrawingObserver
DrawingObserver is an ImageObserver that allows callers to
wait for the drawing of an image to complete. |
private static class |
GenericImageFactory.Observer
Observer provides a base class for size and drawing observations. |
private static class |
GenericImageFactory.SizeObserver
SizeObserver is an ImageObserver that can be waited upon
to determine when an image's size data has been loaded. |
Field Summary | |
---|---|
private static byte |
_00
0x00 as a byte. |
private static byte |
_FF
0xFF pre-cast as a byte. |
private static List<ImageFormatDescriptor> |
formatDescriptors
List of ImageFormatDescriptor objects for our supported
formats. |
private static byte[][] |
gifHeaders
GIF file header. |
static GenericImageFactory |
instance
The singleton instance of this image factory. |
private static byte[][] |
jpegHeaders
JPEG file header. |
private static int |
minimumFileSize
Minimum number of bytes from an image file necessary to determine the file's type. |
private static byte[][] |
pngHeaders
PNG file header. |
private static byte[][][] |
supportedHeaders
Array of supported header data. |
private static Toolkit |
toolkit
Graphics toolkit used for loading images. |
Constructor Summary | |
---|---|
private |
GenericImageFactory()
GenericImageFactory is a singleton. |
Method Summary | |
---|---|
boolean |
canLoad(File imageFile)
Tests whether the given file contains an image in a format supported by this factory. |
private boolean |
canLoad(InputStream imageStream)
Test the given input stream's format and return an indication of whether the format is supported or not. |
boolean |
canLoad(URL imageUrl)
Tests whether the given URL refers to an image in a format supported by this factory. |
private static GenericImage |
createImage(Image javaImage)
|
List<ImageFormatDescriptor> |
getSupportedImageFormats()
Returns the ImageFormatDescriptors for
image formats supported by this factory. |
GenericImage |
loadImage(File imageFile)
Load an image from the given file name. |
GenericImage |
loadImage(URL imageUrl)
Load an image from the given URL. |
private void |
testFormat(InputStream stream)
Test the given input stream's format and throw an UnknownFormatException if it's not in a supported format. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final GenericImageFactory instance
private static final Toolkit toolkit
private static final byte _FF
private static final byte _00
private static final byte[][] pngHeaders
private static final byte[][] gifHeaders
private static final byte[][] jpegHeaders
private static final byte[][][] supportedHeaders
private static final int minimumFileSize
private static final List<ImageFormatDescriptor> formatDescriptors
ImageFormatDescriptor
objects for our supported
formats.
Constructor Detail |
---|
private GenericImageFactory()
instance
Method Detail |
---|
public List<ImageFormatDescriptor> getSupportedImageFormats()
ImageFormatDescriptors
for
image formats supported by this factory.
getSupportedImageFormats
in interface ImageFactory
public boolean canLoad(File imageFile) throws IOException
canLoad
in interface ImageFactory
imageFile
- the file to test
IOException
- if the file cannot be readpublic boolean canLoad(URL imageUrl) throws IOException
canLoad
in interface ImageFactory
imageUrl
- the URL to test
IOException
- if the URL cannot be readpublic GenericImage loadImage(File imageFile) throws IOException, UnknownFormatException
loadImage
in interface ImageFactory
imageFile
- the image to load
GenericImage
IOException
- if there's an error reading the file
UnknownFormatException
- if the file format is not knownpublic GenericImage loadImage(URL imageUrl) throws IOException
loadImage
in interface ImageFactory
imageUrl
- the image to load
GenericImage
IOException
- if there's an error reading the file
UnknownFormatException
- if the file format is not knownprivate void testFormat(InputStream stream) throws IOException, UnknownFormatException
stream
- the stream to test
IOException
- if there's an error reading the stream
UnknownFormatException
- if the stream's format is not supportedprivate boolean canLoad(InputStream imageStream) throws IOException
imageStream
- the stream to test
IOException
- if there's an error reading the streamprivate static GenericImage createImage(Image javaImage) throws IOException
IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |