org.geotoolkit.image.io.plugin
Class WorldFileImageWriter

Object
  extended by ImageWriter
      extended by SpatialImageWriter
          extended by ImageWriterAdapter
              extended by WorldFileImageWriter
All Implemented Interfaces:
ImageTranscoder, WarningProducer, Disposable, Localized

public class WorldFileImageWriter
extends ImageWriterAdapter

Writer for the World File format. This writer wraps an other image writer for an "ordinary" image format, like TIFF, PNG or JPEG. This WorldFileImageWriter delegates the writing of pixel values to the wrapped writer, and additionally creates two small text files in the same directory than the image file, with the same filename but a different extension:

See WorldFileImageReader for more information about the name, content and encoding of those files.

Since:
3.08 (derived from 3.07)
Version:
3.08
Author:
Martin Desruisseaux (Geomatys)
See Also:
World File Format Description, WorldFileImageReader
Module:
coverage/geotk-coverageio (download)    View source code for this class

Nested Class Summary
static class WorldFileImageWriter.Spi
          Service provider interface (SPI) for WorldFileImageWriters.
 
Field Summary
 
Fields inherited from class ImageWriterAdapter
main
 
Fields inherited from class ImageWriter
availableLocales, locale, originatingProvider, output, progressListeners, warningListeners, warningLocales
 
Fields inherited from interface WarningProducer
LOGGER
 
Constructor Summary
WorldFileImageWriter(WorldFileImageWriter.Spi provider)
          Constructs a new image writer.
WorldFileImageWriter(WorldFileImageWriter.Spi provider, ImageWriter main)
          Constructs a new image writer wrapping the given writer.
 
Method Summary
protected  Object createOutput(String writerID)
          Creates the output to be given to the writer identified by the given argument.
protected  void writeImageMetadata(IIOMetadata metadata, int imageIndex, ImageWriteParam param)
          Invoked by the write methods when image metadata needs to be written.
 
Methods inherited from class ImageWriterAdapter
abort, addIIOWriteProgressListener, addIIOWriteWarningListener, canReplacePixels, canWriteRasters, canWriteSequence, close, dispose, endReplacePixels, endWriteSequence, finalize, getAvailableLocales, getDefaultImageMetadata, getDefaultStreamMetadata, getDefaultWriteParam, getLocale, getNumThumbnailsSupported, getPreferredThumbnailSizes, initialize, prepareReplacePixels, prepareWriteSequence, removeAllIIOWriteProgressListeners, removeAllIIOWriteWarningListeners, removeIIOWriteProgressListener, removeIIOWriteWarningListener, replacePixels, replacePixels, reset, setLocale, write, writeStreamMetadata, writeToSequence
 
Methods inherited from class SpatialImageWriter
computeSize, convertImageMetadata, convertStreamMetadata, createRectIter, getSampleModel, processImageComplete, processImageStarted, processThumbnailComplete, processThumbnailStarted, processWarningOccurred, processWarningOccurred, setOutput, warningOccurred
 
Methods inherited from class ImageWriter
abortRequested, canInsertEmpty, canInsertImage, canRemoveImage, canReplaceImageMetadata, canReplaceStreamMetadata, canWriteEmpty, clearAbortRequest, endInsertEmpty, endWriteEmpty, getOriginatingProvider, getOutput, prepareInsertEmpty, prepareWriteEmpty, processImageProgress, processImageStarted, processThumbnailProgress, processThumbnailStarted, processWarningOccurred, processWarningOccurred, processWriteAborted, removeImage, replaceImageMetadata, replaceStreamMetadata, write, write, writeInsert
 
Methods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WorldFileImageWriter

public WorldFileImageWriter(WorldFileImageWriter.Spi provider)
                     throws IOException
Constructs a new image writer. The provider argument is mandatory for this constructor. If the provider is unknown, use the next constructor below instead.

Parameters:
provider - The ImageWriterSpi that is constructing this object.
Throws:
IOException - If an error occurred while creating the main writer.

WorldFileImageWriter

public WorldFileImageWriter(WorldFileImageWriter.Spi provider,
                            ImageWriter main)
Constructs a new image writer wrapping the given writer.

Parameters:
provider - The ImageWriterSpi that is constructing this object, or null.
main - The writer to use for writing the pixel values.
Method Detail

createOutput

protected Object createOutput(String writerID)
                       throws IOException
Creates the output to be given to the writer identified by the given argument. If the writerID argument is "main" (ignoring case), then this method delegates to the super-class method. Otherwise this method returns an output which is typically a File or URL having the same name than the output of this writer, but a different extension. The new extension is determined from the writerID argument, which can be:

Subclasses can override this method for specifying a different main ("main"), World File ("tfw") or Map Projection ("prj") output. They can also invoke this method with other identifiers than the three above-cited ones, in which case this method uses the given identifier as the extension of the returned output. However the default WorldFileImageWriter implementation uses only "main", "tfw" and "prj".

Overrides:
createOutput in class ImageWriterAdapter
Parameters:
writerID - "main" for the main output, "tfw" for the World File output, or "prj" for the Map Projection output. Other identifiers are allowed but subclass-specific.
Returns:
The given kind of output typically as a File or URL object, or null if there is no output for the given identifier.
Throws:
IOException - If an error occurred while creating the output.
See Also:
WorldFileImageReader.createInput(String)

writeImageMetadata

protected void writeImageMetadata(IIOMetadata metadata,
                                  int imageIndex,
                                  ImageWriteParam param)
                           throws IOException
Invoked by the write methods when image metadata needs to be written. The default implementation writes the World File if an affine transform can be build from the rectified grid domain.

Overrides:
writeImageMetadata in class ImageWriterAdapter
Parameters:
metadata - The stream metadata, or null if none.
imageIndex - The index of the image being written.
param - The user-specified parameter, or null if none.
Throws:
IOException - If an error occurred while writing the metadata.
See Also:
MetadataHelper
TODO:
Needs to write the PRJ file too.


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