org.geotoolkit.image.io.plugin
Class WorldFileImageReader.Spi

Object
  extended by IIOServiceProvider
      extended by ImageReaderWriterSpi
          extended by ImageReaderSpi
              extended by SpatialImageReader.Spi
                  extended by ImageReaderAdapter.Spi
                      extended by WorldFileImageReader.Spi
All Implemented Interfaces:
RegisterableService
Enclosing class:
WorldFileImageReader

public static class WorldFileImageReader.Spi
extends ImageReaderAdapter.Spi

Service provider interface (SPI) for WorldFileImageReaders. This provider wraps an other provider (typically for the TIFF, JPEG or PNG formats), which shall be specified at construction time. The legal input types are String, File, URI and URL in order to allow the image reader to infer the World File (".tfw") and Map Projection (".prj") files from the image input file.


Plugins registration
At the difference of other ImageReader plugins, the WorldFileImageReader plugin is not automatically registered in the JVM. This is because there is many plugins to register (one instance of this Spi class for each format to wrap), and because attempts to get an ImageReader to wrap while IIORegistry is scanning the classpath for services cause an infinite loop. To enable the World File plugins, users must invoke registerDefaults(ServiceRegistry) explicitly.

Since:
3.08 (derived from 3.07)
Version:
3.20
Author:
Martin Desruisseaux (Geomatys)
See Also:
WorldFileImageWriter.Spi
Module:
coverage/geotk-coverageio (download)    View source code for this class

Field Summary
 
Fields inherited from class ImageReaderAdapter.Spi
main
 
Fields inherited from class ImageReaderSpi
inputTypes, STANDARD_INPUT_TYPE, writerSpiNames
 
Fields inherited from class ImageReaderWriterSpi
extraImageMetadataFormatClassNames, extraImageMetadataFormatNames, extraStreamMetadataFormatClassNames, extraStreamMetadataFormatNames, MIMETypes, names, nativeImageMetadataFormatClassName, nativeImageMetadataFormatName, nativeStreamMetadataFormatClassName, nativeStreamMetadataFormatName, pluginClassName, suffixes, supportsStandardImageMetadataFormat, supportsStandardStreamMetadataFormat
 
Fields inherited from class IIOServiceProvider
vendorName, version
 
Constructor Summary
WorldFileImageReader.Spi(ImageReaderSpi main)
          Creates a provider which will use the given format for reading pixel values.
WorldFileImageReader.Spi(String format)
          Creates a provider which will use the given format for reading pixel values.
 
Method Summary
 boolean canDecodeInput(Object source)
          Returns true if the supplied source object appears to be of the format supported by this reader.
 ImageReader createReaderInstance(Object extension)
          Creates a new World File reader.
 String getDescription(Locale locale)
          Returns a brief, human-readable description of this service provider.
 Set<InformationType> getModifiedInformation(Object source)
          Returns the kind of information that this wrapper will add or modify compared to the ImageReaderAdapter.main reader.
static void registerDefaults(ServiceRegistry registry)
          Registers a default set of World File formats.
static void unregisterDefaults(ServiceRegistry registry)
          Unregisters the providers registered by registerDefaults(ServiceRegistry).
 
Methods inherited from class ImageReaderAdapter.Spi
getImageMetadataFormat, getStreamMetadataFormat, onRegistration, unwrap
 
Methods inherited from class ImageReaderSpi
createReaderInstance, getImageWriterSpiNames, getInputTypes, isOwnReader
 
Methods inherited from class ImageReaderWriterSpi
getExtraImageMetadataFormatNames, getExtraStreamMetadataFormatNames, getFileSuffixes, getFormatNames, getMIMETypes, getNativeImageMetadataFormatName, getNativeStreamMetadataFormatName, getPluginClassName, isStandardImageMetadataFormatSupported, isStandardStreamMetadataFormatSupported
 
Methods inherited from class IIOServiceProvider
getVendorName, getVersion, onDeregistration
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WorldFileImageReader.Spi

public WorldFileImageReader.Spi(ImageReaderSpi main)
Creates a provider which will use the given format for reading pixel values.

Parameters:
main - The provider of the readers to use for reading the pixel values.

WorldFileImageReader.Spi

public WorldFileImageReader.Spi(String format)
                         throws IllegalArgumentException
Creates a provider which will use the given format for reading pixel values. This is a convenience constructor for the above constructor with a provider fetched from the given format name.

Parameters:
format - The name of the provider to use for reading the pixel values.
Throws:
IllegalArgumentException - If no provider is found for the given format.
Method Detail

getDescription

public String getDescription(Locale locale)
Returns a brief, human-readable description of this service provider.

Specified by:
getDescription in class IIOServiceProvider
Parameters:
locale - The locale for which the return value should be localized.
Returns:
A description of this service provider.

canDecodeInput

public boolean canDecodeInput(Object source)
                       throws IOException
Returns true if the supplied source object appears to be of the format supported by this reader. The default implementation checks if at least one of the ".tfw (actual extension may vary) or ".prj" file is presents, then delegates to the super-class method.

Overrides:
canDecodeInput in class ImageReaderAdapter.Spi
Parameters:
source - The input (typically a File) to be decoded.
Returns:
true if it is likely that the file can be decoded.
Throws:
IOException - If an error occurred while reading the file.

getModifiedInformation

public Set<InformationType> getModifiedInformation(Object source)
                                            throws IOException
Returns the kind of information that this wrapper will add or modify compared to the ImageReaderAdapter.main reader.

Overrides:
getModifiedInformation in class ImageReaderAdapter.Spi
Parameters:
source - The input (typically a File) to be decoded.
Returns:
The set of information to be read or modified by this adapter.
Throws:
IOException - If an error occurred while reading the file.
Since:
3.20

createReaderInstance

public ImageReader createReaderInstance(Object extension)
                                 throws IOException
Creates a new World File reader. The extension argument is forwarded to the main provider with no change.

Specified by:
createReaderInstance in class ImageReaderSpi
Parameters:
extension - A plug-in specific extension object, or null.
Returns:
A new reader.
Throws:
IOException - If the reader can not be created.

registerDefaults

@Configuration
public static void registerDefaults(ServiceRegistry registry)
Registers a default set of World File formats. This method shall be invoked at least once by client application before to use Image I/O library if they wish to decode World File images. This method can also be invoked more time if the PNG, TIFF or other standard readers changed, and this change needs to be taken in account by the World File readers. See the System initialization section in the package description for more information.

The current implementation registers plugins for the TIFF, JPEG, PNG, GIF, BMP, matrix and ASCII-Grid (".prj" file only) formats, but this list can be augmented in any future Geotk version.

Parameters:
registry - The registry where to register the formats, or null for the default registry.
See Also:
Registry.setDefaultCodecPreferences(), Setup

unregisterDefaults

@Configuration
public static void unregisterDefaults(ServiceRegistry registry)
Unregisters the providers registered by registerDefaults(ServiceRegistry).

Parameters:
registry - The registry from which to unregister the formats, or null for the default registry.
See Also:
Setup


Copyright © 2009-2012 Geotoolkit.org. All Rights Reserved.