org.geotoolkit.image.io
Class ImageWriterAdapter.Spi

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

public abstract static class ImageWriterAdapter.Spi
extends SpatialImageWriter.Spi

Service provider interface (SPI) for ImageWriterAdapters. The constructor of this class initializes the ImageWriterSpi.outputTypes field to types that can represent a filename, like File or URL, rather than the usual standard output type. The names and MIMETypes fields are set to the values of the wrapped provider, suffixed with the string given at construction time.

Example: An ImageWriterAdapter wrapping the "tiff" image writer with the "-wf" suffix will have the "tiff-wf" format name and the "image/x-tiff-wf" MIME type.

The table below summarizes the initial values. Those values can be modified by subclass constructors.

Field Value
 ImageReaderWriterSpi.names   Same values than the main provider, suffixed by the given string. 
 ImageReaderWriterSpi.suffixes   Same values than the main provider. 
 ImageReaderWriterSpi.MIMETypes   Same values than the main provider, suffixed by the given string. 
 ImageWriterAdapter.outputTypes   String, File, URI, URL, ImageOutputStream 

It is up to subclass constructors to initialize all other instance variables in order to provide working versions of every methods.

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

Field Summary
protected  ImageWriterSpi main
          The provider of the writers to use for writing the pixel values.
 
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
protected ImageWriterAdapter.Spi(ImageWriterSpi main)
          Deprecated. Specify a suffix.
protected ImageWriterAdapter.Spi(ImageWriterSpi main, String formatNameSuffix)
          Creates an ImageWriterAdapter.Spi wrapping the given provider.
protected ImageWriterAdapter.Spi(String format)
          Deprecated. Specify a suffix.
protected ImageWriterAdapter.Spi(String format, String suffix)
          Creates a provider which will use the given format for writing pixel values.
 
Method Summary
 boolean canEncodeImage(ImageTypeSpecifier type)
          Returns true if the writer implementation associated with this service provider is able to encode an image with the given layout.
 boolean canEncodeImage(RenderedImage image)
          Returns true if the writer implementation associated with this service provider is able to encode the given image.
 IIOMetadataFormat getImageMetadataFormat(String formatName)
          Returns a description of the image metadata of the given name.
 Set<InformationType> getModifiedInformation(ImageTypeSpecifier type)
          Returns the kind of information that this wrapper will add or modify compared to the main writer.
 IIOMetadataFormat getStreamMetadataFormat(String formatName)
          Returns a description of the stream metadata of the given name.
 boolean isFormatLossless()
          Returns true if the format that this writer outputs preserves pixel data bit-accurately.
 void onRegistration(ServiceRegistry registry, Class<?> category)
          A callback that will be called exactly once after the Spi class has been instantiated and registered in a ServiceRegistry.
static ImageWriterSpi unwrap(ImageWriterSpi spi)
          If the given provider is an instance of ImageWriterAdapter.Spi, returns the underlying main provider.
 
Methods inherited from class ImageWriterSpi
createWriterInstance, createWriterInstance, getImageReaderSpiNames, getOutputTypes, isOwnWriter
 
Methods inherited from class ImageReaderWriterSpi
getExtraImageMetadataFormatNames, getExtraStreamMetadataFormatNames, getFileSuffixes, getFormatNames, getMIMETypes, getNativeImageMetadataFormatName, getNativeStreamMetadataFormatName, getPluginClassName, isStandardImageMetadataFormatSupported, isStandardStreamMetadataFormatSupported
 
Methods inherited from class IIOServiceProvider
getDescription, getVendorName, getVersion, onDeregistration
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

main

protected final ImageWriterSpi main
The provider of the writers to use for writing the pixel values. This is the provider specified at the construction time.

Constructor Detail

ImageWriterAdapter.Spi

@Deprecated
protected ImageWriterAdapter.Spi(ImageWriterSpi main)
Deprecated. Specify a suffix.


ImageWriterAdapter.Spi

@Deprecated
protected ImageWriterAdapter.Spi(String format)
Deprecated. Specify a suffix.


ImageWriterAdapter.Spi

protected ImageWriterAdapter.Spi(ImageWriterSpi main,
                                 String formatNameSuffix)
Creates an ImageWriterAdapter.Spi wrapping the given provider. The fields are initialized as documented in the class javadoc. It is up to the subclass to initialize all other instance variables in order to provide working versions of all methods.

For efficiency reasons, the outputTypes field is initialized to a shared array. Subclasses can assign new arrays, but should not modify the default array content.

Parameters:
main - The provider of the writers to use for writing the pixel values.
formatNameSuffix - The suffix to append to format names and MIME types.
Since:
3.20

ImageWriterAdapter.Spi

protected ImageWriterAdapter.Spi(String format,
                                 String suffix)
                          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.
suffix - The suffix to append to format names and MIME types.
Throws:
IllegalArgumentException - If no provider is found for the given format.
Since:
3.20
Method Detail

getStreamMetadataFormat

public IIOMetadataFormat getStreamMetadataFormat(String formatName)
Returns a description of the stream metadata of the given name. If no description is available, then this method returns null.

Overrides:
getStreamMetadataFormat in class SpatialImageWriter.Spi
Parameters:
formatName - The desired stream metadata format.
Returns:
The stream metadata format of the given name.

getImageMetadataFormat

public IIOMetadataFormat getImageMetadataFormat(String formatName)
Returns a description of the image metadata of the given name. If no description is available, then this method returns null.

Overrides:
getImageMetadataFormat in class SpatialImageWriter.Spi
Parameters:
formatName - The desired image metadata format.
Returns:
The image metadata format of the given name.

isFormatLossless

public boolean isFormatLossless()
Returns true if the format that this writer outputs preserves pixel data bit-accurately. The default implementation delegates to the main provider.

Overrides:
isFormatLossless in class ImageWriterSpi

canEncodeImage

public boolean canEncodeImage(ImageTypeSpecifier type)
Returns true if the writer implementation associated with this service provider is able to encode an image with the given layout. The default implementation delegates to the main provider.

Specified by:
canEncodeImage in class ImageWriterSpi
Parameters:
type - The layout of the image to be written.

canEncodeImage

public boolean canEncodeImage(RenderedImage image)
Returns true if the writer implementation associated with this service provider is able to encode the given image. The default implementation delegates to the main provider.

Overrides:
canEncodeImage in class ImageWriterSpi
Parameters:
image - The image to be written.

getModifiedInformation

public Set<InformationType> getModifiedInformation(ImageTypeSpecifier type)
Returns the kind of information that this wrapper will add or modify compared to the main writer. If this method returns an empty set, then there is no raison to use this adapter instead than the main writer.

The default implementation conservatively returns all of the InformationType enum values. Subclasses should return more accurate information when possible.

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

onRegistration

public void onRegistration(ServiceRegistry registry,
                           Class<?> category)
A callback that will be called exactly once after the Spi class has been instantiated and registered in a ServiceRegistry. The default implementation conservatively gives precedence to the main provider, using the code below:
registry.setOrdering(category, main, this);
The plugin order matter when an image writer is selected by file suffix, because the file suffixes of this adapter are the same than the file suffixes of the main provider by default.

Specified by:
onRegistration in interface RegisterableService
Overrides:
onRegistration in class IIOServiceProvider
See Also:
ServiceRegistry.setOrdering(Class, Object, Object)

unwrap

public static ImageWriterSpi unwrap(ImageWriterSpi spi)
If the given provider is an instance of ImageWriterAdapter.Spi, returns the underlying main provider. Otherwise returns the given provider unchanged.

This method is convenient when the caller is not interested in spatial metadata, in order to ensure that the cost of writing TFW, PRJ or similar files is avoided.

Parameters:
spi - An image writer provider, or null.
Returns:
The wrapped image writer provider, or null.
Since:
3.14


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