org.geotoolkit.image.io
Class SpatialImageWriter

Object
  extended by ImageWriter
      extended by SpatialImageWriter
All Implemented Interfaces:
ImageTranscoder, WarningProducer, Disposable, Localized
Direct Known Subclasses:
ImageWriterAdapter, StreamImageWriter

public abstract class SpatialImageWriter
extends ImageWriter
implements WarningProducer, Disposable

Base class for writers of spatial (usually geographic) data. This base class provides the following restrictions or conveniences:

Since:
3.05 (derived from 2.4)
Version:
3.08
Author:
Martin Desruisseaux (IRD, Geomatys)
See Also:
SpatialImageReader
Module:
coverage/geotk-coverageio (download)    View source code for this class

Nested Class Summary
protected static class SpatialImageWriter.Spi
          Service provider interfaces (SPI) for SpatialImageWriters.
 
Field Summary
 
Fields inherited from class ImageWriter
availableLocales, locale, originatingProvider, output, progressListeners, warningListeners, warningLocales
 
Fields inherited from interface WarningProducer
LOGGER
 
Constructor Summary
protected SpatialImageWriter(SpatialImageWriter.Spi provider)
          Constructs a SpatialImageWriter.
 
Method Summary
 boolean canWriteRasters()
          Returns true if the methods that take an IIOImage parameter are capable of dealing with a Raster.
protected static ImageDimension computeSize(IIOImage image, ImageWriteParam parameters)
          Computes the size of the region to be written, taking subsampling in account.
 SpatialMetadata convertImageMetadata(IIOMetadata inData, ImageTypeSpecifier imageType, ImageWriteParam param)
          Returns a metadata object initialized to the specified data for encoding an image of the given type.
 SpatialMetadata convertStreamMetadata(IIOMetadata inData, ImageWriteParam param)
          Returns a metadata object initialized to the specified data for encoding a stream of images.
protected static RectIter createRectIter(IIOImage image, ImageWriteParam parameters)
          Returns an iterator over the pixels of the specified image, taking subsampling in account.
 void dispose()
          Allows any resources held by this writer to be released.
 SpatialMetadata getDefaultImageMetadata(ImageTypeSpecifier imageType, ImageWriteParam param)
          Returns a metadata object containing default values for encoding an image of the given type.
 SpatialMetadata getDefaultStreamMetadata(ImageWriteParam param)
          Returns a metadata object containing default values for encoding a stream of images.
 SpatialImageWriteParam getDefaultWriteParam()
          Returns a default parameter object appropriate for this format.
protected static SampleModel getSampleModel(IIOImage image, ImageWriteParam parameters)
          Returns the sample model to use for the destination image to be written.
protected  void processImageComplete()
          Broadcasts the completion of an image write to all registered listeners.
protected  void processImageStarted()
          Broadcasts the start of an image write to all registered listeners.
protected  void processThumbnailComplete()
          Broadcasts the completion of a thumbnail write to all registered listeners.
protected  void processThumbnailStarted()
          Broadcasts the start of a thumbnail write to all registered listeners.
protected  void processWarningOccurred(String warning)
          Broadcasts a warning message to all registered listeners.
protected  void processWarningOccurred(String baseName, String keyword)
          Broadcasts a warning message to all registered listeners.
 void setOutput(Object output)
          Sets the destination to the given ImageOutputStream or other Object.
 boolean warningOccurred(LogRecord record)
          Invoked when a warning occurred.
 
Methods inherited from class ImageWriter
abort, abortRequested, addIIOWriteProgressListener, addIIOWriteWarningListener, canInsertEmpty, canInsertImage, canRemoveImage, canReplaceImageMetadata, canReplacePixels, canReplaceStreamMetadata, canWriteEmpty, canWriteSequence, clearAbortRequest, endInsertEmpty, endReplacePixels, endWriteEmpty, endWriteSequence, getAvailableLocales, getLocale, getNumThumbnailsSupported, getOriginatingProvider, getOutput, getPreferredThumbnailSizes, prepareInsertEmpty, prepareReplacePixels, prepareWriteEmpty, prepareWriteSequence, processImageProgress, processImageStarted, processThumbnailProgress, processThumbnailStarted, processWarningOccurred, processWarningOccurred, processWriteAborted, removeAllIIOWriteProgressListeners, removeAllIIOWriteWarningListeners, removeIIOWriteProgressListener, removeIIOWriteWarningListener, removeImage, replaceImageMetadata, replacePixels, replacePixels, replaceStreamMetadata, reset, setLocale, write, write, write, writeInsert, writeToSequence
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface Localized
getLocale
 

Constructor Detail

SpatialImageWriter

protected SpatialImageWriter(SpatialImageWriter.Spi provider)
Constructs a SpatialImageWriter.

Parameters:
provider - The ImageWriterSpi that is constructing this object, or null.
Method Detail

setOutput

public void setOutput(Object output)
Sets the destination to the given ImageOutputStream or other Object.

Overrides:
setOutput in class ImageWriter

getDefaultWriteParam

public SpatialImageWriteParam getDefaultWriteParam()
Returns a default parameter object appropriate for this format. The default implementation constructs and returns a new SpatialImageWriteParam.

Overrides:
getDefaultWriteParam in class ImageWriter
Returns:
An ImageWriteParam object which may be used.

getDefaultStreamMetadata

public SpatialMetadata getDefaultStreamMetadata(ImageWriteParam param)
Returns a metadata object containing default values for encoding a stream of images. The default implementation returns an instance of SpatialMetadata using the stream format.

Specified by:
getDefaultStreamMetadata in class ImageWriter
Parameters:
param - Parameters that will be used to encode the image (in cases where it may affect the structure of the metadata), or null.
Returns:
The metadata, or null.

getDefaultImageMetadata

public SpatialMetadata getDefaultImageMetadata(ImageTypeSpecifier imageType,
                                               ImageWriteParam param)
Returns a metadata object containing default values for encoding an image of the given type. The default implementation returns an instance of SpatialMetadata using the image format.

Specified by:
getDefaultImageMetadata in class ImageWriter
Parameters:
imageType - The format of the image to be written later.
param - Parameters that will be used to encode the image (in cases where it may affect the structure of the metadata), or null.
Returns:
The metadata, or null.

convertStreamMetadata

public SpatialMetadata convertStreamMetadata(IIOMetadata inData,
                                             ImageWriteParam param)
Returns a metadata object initialized to the specified data for encoding a stream of images. The default implementation returns the given metadata unchanged if it is an instance of SpatialMetadata using the stream format, or wraps it otherwise.

Specified by:
convertStreamMetadata in interface ImageTranscoder
Specified by:
convertStreamMetadata in class ImageWriter
Parameters:
inData - Stream metadata used to initialize the state of the returned object.
param - Parameters that will be used to encode the image (in cases where it may affect the structure of the metadata), or null.
Returns:
The metadata, or null.

convertImageMetadata

public SpatialMetadata convertImageMetadata(IIOMetadata inData,
                                            ImageTypeSpecifier imageType,
                                            ImageWriteParam param)
Returns a metadata object initialized to the specified data for encoding an image of the given type. The default implementation returns the given metadata unchanged if it is an instance of SpatialMetadata using the image format, or wraps it otherwise.

Specified by:
convertImageMetadata in interface ImageTranscoder
Specified by:
convertImageMetadata in class ImageWriter
Parameters:
inData - Image metadata used to initialize the state of the returned object.
imageType - The format of the image to be written later.
param - Parameters that will be used to encode the image (in cases where it may affect the structure of the metadata), or null.
Returns:
The metadata, or null.

canWriteRasters

public boolean canWriteRasters()
Returns true if the methods that take an IIOImage parameter are capable of dealing with a Raster. The default implementation returns true since it is assumed that subclasses will fetch pixels using the iterator returned by createRectIter.

Overrides:
canWriteRasters in class ImageWriter

getSampleModel

protected static SampleModel getSampleModel(IIOImage image,
                                            ImageWriteParam parameters)
Returns the sample model to use for the destination image to be written. Note that the width and height of the returned sample model are usually not valids, because they have not been adjusted for the source or destination regions.

Parameters:
image - The image or raster to be written.
parameters - The write parameters, or null if the whole image will be written.
Returns:
The sample model of the destination image.
Since:
3.07

createRectIter

protected static RectIter createRectIter(IIOImage image,
                                         ImageWriteParam parameters)
Returns an iterator over the pixels of the specified image, taking subsampling in account.

Parameters:
image - The image or raster to be written.
parameters - The write parameters, or null if the whole image will be written.
Returns:
An iterator over the pixel values of the image to be written.

computeSize

protected static ImageDimension computeSize(IIOImage image,
                                            ImageWriteParam parameters)
Computes the size of the region to be written, taking subsampling in account.

Parameters:
image - The image or raster to be written.
parameters - The write parameters, or null if the whole image will be written.
Returns:
dimension The dimension of the image to be written.

processImageStarted

protected void processImageStarted()
Broadcasts the start of an image write to all registered listeners. The default implementation invokes the super-class method with an image index maintained by this writer.


processImageComplete

protected void processImageComplete()
Broadcasts the completion of an image write to all registered listeners.

Overrides:
processImageComplete in class ImageWriter

processThumbnailStarted

protected void processThumbnailStarted()
Broadcasts the start of a thumbnail write to all registered listeners. The default implementation invokes the super-class method with an image and thumbnail index maintained by this writer.


processThumbnailComplete

protected void processThumbnailComplete()
Broadcasts the completion of a thumbnail write to all registered listeners.

Overrides:
processThumbnailComplete in class ImageWriter

processWarningOccurred

protected void processWarningOccurred(String warning)
Broadcasts a warning message to all registered listeners. The default implementation invokes the super-class method with an image index maintained by this writer.

Parameters:
warning - The warning message to broadcasts.

processWarningOccurred

protected void processWarningOccurred(String baseName,
                                      String keyword)
Broadcasts a warning message to all registered listeners. The default implementation invokes the super-class method with an image index maintained by this writer.

Parameters:
baseName - The base name of a set of ResourceBundles containing localized warning messages.
keyword - The keyword used to index the warning message within the set of ResourceBundles.

warningOccurred

public boolean warningOccurred(LogRecord record)
Invoked when a warning occurred. The default implementation makes the following choice:

Subclasses may override this method if more processing is wanted, or for throwing exception if some warnings should be considered as fatal errors.

Specified by:
warningOccurred in interface WarningProducer
Parameters:
record - The warning record to log.
Returns:
true if the message has been sent to at least one warning listener, or false if it has been sent to the logging system as a fallback.
See Also:
MetadataAccessor.warningOccurred(LogRecord)

dispose

public void dispose()
Allows any resources held by this writer to be released. If an output stream were created by StreamImageWriter or ImageWriterAdapter, it will be closed before to dispose this reader.

Specified by:
dispose in interface Disposable
Overrides:
dispose in class ImageWriter


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