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

Object
  extended by IIOServiceProvider
      extended by ImageReaderWriterSpi
          extended by ImageWriterSpi
              extended by SpatialImageWriter.Spi
                  extended by ImageWriterAdapter.Spi
                      extended by WorldFileImageWriter.Spi
All Implemented Interfaces:
RegisterableService
Enclosing class:
WorldFileImageWriter

public static class WorldFileImageWriter.Spi
extends ImageWriterAdapter.Spi

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


Plugins registration
At the difference of other ImageWriter plugins, the WorldFileImageWriter 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 ImageWriter 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:
WorldFileImageReader.Spi
Module:
coverage/geotk-coverageio (download)    View source code for this class

Field Summary
 
Fields inherited from class ImageWriterAdapter.Spi
main
 
Fields inherited from class ImageWriterSpi
outputTypes, readerSpiNames, STANDARD_OUTPUT_TYPE
 
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
WorldFileImageWriter.Spi(ImageWriterSpi main)
          Creates a provider which will use the given format for writing pixel values.
WorldFileImageWriter.Spi(String format)
          Creates a provider which will use the given format for writing pixel values.
 
Method Summary
 ImageWriter createWriterInstance(Object extension)
          Creates a new World File writer.
 String getDescription(Locale locale)
          Returns a brief, human-writable description of this service provider.
 Set<InformationType> getModifiedInformation(ImageTypeSpecifier type)
          Returns the kind of information that this wrapper will add or modify compared to the ImageWriterAdapter.main writer.
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 ImageWriterAdapter.Spi
canEncodeImage, canEncodeImage, getImageMetadataFormat, getStreamMetadataFormat, isFormatLossless, onRegistration, unwrap
 
Methods inherited from class ImageWriterSpi
createWriterInstance, getImageReaderSpiNames, getOutputTypes, isOwnWriter
 
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

WorldFileImageWriter.Spi

public WorldFileImageWriter.Spi(ImageWriterSpi main)
Creates a provider which will use the given format for writing pixel values.

Parameters:
main - The provider of the writers to use for writing the pixel values.

WorldFileImageWriter.Spi

public WorldFileImageWriter.Spi(String format)
                         throws IllegalArgumentException
Creates a provider which will use the given format for writing 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 writing 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-writable 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.

getModifiedInformation

public Set<InformationType> getModifiedInformation(ImageTypeSpecifier type)
Returns the kind of information that this wrapper will add or modify compared to the ImageWriterAdapter.main writer.

Overrides:
getModifiedInformation in class ImageWriterAdapter.Spi
Parameters:
type - The layout of the image to be written.
Returns:
The set of information to be written or modified by this adapter.
Since:
3.20

createWriterInstance

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

Specified by:
createWriterInstance in class ImageWriterSpi
Parameters:
extension - A plug-in specific extension object, or null.
Returns:
A new writer.
Throws:
IOException - If the writer 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 encode World File images. This method can also be invoked more time if the PNG, TIFF or other standard writers changed, and this change needs to be taken in account by the World File writers. 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.