org.geotools.image.io
Class RawBinaryImageReader.Spi

java.lang.Object
  extended byjavax.imageio.spi.IIOServiceProvider
      extended byjavax.imageio.spi.ImageReaderWriterSpi
          extended byjavax.imageio.spi.ImageReaderSpi
              extended byorg.geotools.image.io.RawBinaryImageReader.Spi
All Implemented Interfaces:
javax.imageio.spi.RegisterableService
Enclosing class:
RawBinaryImageReader

public static class RawBinaryImageReader.Spi
extends javax.imageio.spi.ImageReaderSpi

Service provider interface (SPI) for RawBinaryImageReaders. This SPI provides all necessary implementations for creating default RawBinaryImageReader. Subclasses only have to set some fields at construction time, e.g.:

 public final class CustomBinaryImageReaderSpi extends RawBinaryImageReader.Spi
 {
     public CustomBinaryImageReaderSpi()
     {
         super("MyRAW", "image/raw-perso");
         vendorName = "Institut de Recherche pour le D?veloppement";
         version    = "1.0";
         dataType   = DataBuffer.TYPE_SHORT;
         imageSize  = new Dimension(400,600);
         padValue   = 9999;
     }
 }
 
(Note: fields vendorName and version are only informatives). There is no need to override any method in this example. However, developers can gain more control by creating subclasses of RawBinaryImageReader and Spi and overriding some of their methods.

Version:
$Id: RawBinaryImageReader.java 17672 2006-01-19 00:25:55Z desruisseaux $
Author:
Martin Desruisseaux

Field Summary
protected  int dataType
          The default data type.
protected  java.awt.Dimension imageSize
          The expected image size, or null if unknow.
protected  double padValue
          The pad value.
 
Fields inherited from class javax.imageio.spi.ImageReaderSpi
inputTypes, STANDARD_INPUT_TYPE, writerSpiNames
 
Fields inherited from class javax.imageio.spi.ImageReaderWriterSpi
extraImageMetadataFormatClassNames, extraImageMetadataFormatNames, extraStreamMetadataFormatClassNames, extraStreamMetadataFormatNames, MIMETypes, names, nativeImageMetadataFormatClassName, nativeImageMetadataFormatName, nativeStreamMetadataFormatClassName, nativeStreamMetadataFormatName, pluginClassName, suffixes, supportsStandardImageMetadataFormat, supportsStandardStreamMetadataFormat
 
Fields inherited from class javax.imageio.spi.IIOServiceProvider
vendorName, version
 
Constructor Summary
RawBinaryImageReader.Spi()
          Construct a new SPI with name "raw" and MIME type "image/raw".
RawBinaryImageReader.Spi(java.lang.String name, java.lang.String mime)
          Construct a new SPI for RawBinaryImageReader.
 
Method Summary
 boolean canDecodeInput(java.lang.Object source)
          Returns false, since "raw" format can potentially attempt to read nearly any stream.
 javax.imageio.ImageReader createReaderInstance()
          Returns an instance of the image reader implementation associated with this service provider.
 javax.imageio.ImageReader createReaderInstance(java.lang.Object extension)
          Returns an instance of the ImageReader implementation associated with this service provider.
 java.lang.String getDescription(java.util.Locale locale)
          Returns a brief, human-readable description of this service provider and its associated implementation.
 
Methods inherited from class javax.imageio.spi.ImageReaderSpi
getImageWriterSpiNames, getInputTypes, isOwnReader
 
Methods inherited from class javax.imageio.spi.ImageReaderWriterSpi
getExtraImageMetadataFormatNames, getExtraStreamMetadataFormatNames, getFileSuffixes, getFormatNames, getImageMetadataFormat, getMIMETypes, getNativeImageMetadataFormatName, getNativeStreamMetadataFormatName, getPluginClassName, getStreamMetadataFormat, isStandardImageMetadataFormatSupported, isStandardStreamMetadataFormatSupported
 
Methods inherited from class javax.imageio.spi.IIOServiceProvider
getVendorName, getVersion, onDeregistration, onRegistration
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

imageSize

protected java.awt.Dimension imageSize
The expected image size, or null if unknow. Setting this field to a non-null value allow RawBinaryImageReader.getWidth(int) and RawBinaryImageReader.getHeight(int) to returns this size. This size will be compared with RawBinaryImageReadParam.getStreamImageSize() at reading time, if such a parameter is specified. An IIOException exception will be thrown if sizes don't match, in order to ensure consistency with getWidth(int) and getHeight(int) methods.


padValue

protected double padValue
The pad value. This field is initially set to Double.NaN. This default value is actually redundant since NaN is always considered as a pad value, no matter the padValue setting. Subclasses should set a new value at construction time if an other pad value is needed in addition to Double.NaN. If a single pad value is not enough, more control can be gained by overriding RawBinaryImageReader.transform(double).


dataType

protected int dataType
The default data type. It should be a constant from DataBuffer. Common types are DataBuffer.TYPE_INT, DataBuffer.TYPE_FLOAT and DataBuffer.TYPE_DOUBLE. The default value is TYPE_FLOAT.

Constructor Detail

RawBinaryImageReader.Spi

public RawBinaryImageReader.Spi()
Construct a new SPI with name "raw" and MIME type "image/raw".


RawBinaryImageReader.Spi

public RawBinaryImageReader.Spi(java.lang.String name,
                                java.lang.String mime)
Construct a new SPI for RawBinaryImageReader. This constructor initialize the following fields to default values:

Parameters:
name - Format name, or null to let ImageReaderWriterSpi.names unset.
mime - MIME type, or null to let ImageReaderWriterSpi.MIMETypes unset.
Method Detail

getDescription

public java.lang.String getDescription(java.util.Locale locale)
Returns a brief, human-readable description of this service provider and its associated implementation. The resulting string should be localized for the supplied locale, if possible.

Parameters:
locale - A Locale for which the return value should be localized.
Returns:
A String containing a description of this service provider.

canDecodeInput

public boolean canDecodeInput(java.lang.Object source)
                       throws java.io.IOException
Returns false, since "raw" format can potentially attempt to read nearly any stream.

Parameters:
source - The input source to be decoded.
Returns:
false in order to avoid being invoked in preference to a closer match.
Throws:
java.io.IOException - if an I/O error occurs while reading the stream.

createReaderInstance

public javax.imageio.ImageReader createReaderInstance()
                                               throws java.io.IOException
Returns an instance of the image reader implementation associated with this service provider. The default implementation returns a new RawBinaryImageReader instance. Subclasses should override this method instead of createReaderInstance(Object) for constructing RawBinaryImageReader subclass.

Returns:
An image reader instance.
Throws:
java.io.IOException - if the attempt to instantiate the reader fails.

createReaderInstance

public javax.imageio.ImageReader createReaderInstance(java.lang.Object extension)
                                               throws java.io.IOException
Returns an instance of the ImageReader implementation associated with this service provider. The optional extension argument may be one of the following classes: The default implementation call createReaderInstance() and set the resulting object's internal fields according the extension argument.

Parameters:
extension - An optional extension object, which may be null.
Returns:
An image reader instance.
Throws:
java.io.IOException - if the attempt to instantiate the reader fails.


Copyright © GeoTools. All Rights Reserved.