|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectImageReader
SpatialImageReader
ImageReaderAdapter
public class ImageReaderAdapter
An ImageReader implementation which use a GridCoverageReader for reading
sample values. This class is the converse of ImageCoverageReader: it takes a high
level construct (GridCoverageReader) and wraps it as a lower level construct
(ImageReader). This is an unusual thing to do - consequently, the only purpose
of this class is to allow usage of an existing GridCoverageReader instance with
API working only with ImageReader instances.
Example
ImageReaderAdapter can be used in order to show the content of a GridCoverageReader
in an ImageFileProperties widget.
Note: An other approach would be to unwrap theImageReaderwhich is wrapped byImageCoverageReader. However the result would not be always the same, because some modules (for example geotk-coverage-sql) define subclasses ofImageCoverageReaderwhich alter the way the image is read. The purpose ofImageReaderAdapteris to get exactly the same image than the one produced by the wrappedGridCoverageReader.
| coverage/geotk-coverageio (download) | View source code for this class |
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class SpatialImageReader |
|---|
SpatialImageReader.Spi |
| Field Summary | |
|---|---|
protected GridCoverageReader |
reader
The coverage reader on which to delegate all ImageReader method invocations. |
| Fields inherited from class ImageReader |
|---|
availableLocales, ignoreMetadata, input, locale, minIndex, originatingProvider, progressListeners, seekForwardOnly, updateListeners, warningListeners, warningLocales |
| Fields inherited from interface WarningProducer |
|---|
LOGGER |
| Constructor Summary | |
|---|---|
ImageReaderAdapter(GridCoverageReader reader)
Creates a new adapter for the given coverage reader. |
|
| Method Summary | |
|---|---|
void |
abort()
Aborts the current reading process. |
protected SpatialMetadata |
createMetadata(int imageIndex)
Fetches the stream metadata or image metadata. |
void |
dispose()
Disposes this image reader and the wrapped GridCoverageReader. |
int |
getDimension(int imageIndex)
Returns the number of dimension of the image at the given index. |
GridEnvelope |
getGridEnvelope(int imageIndex)
Returns the grid envelope of the image at the given index. |
int |
getHeight(int imageIndex)
Returns the height of the image at the given index. |
Iterator<ImageTypeSpecifier> |
getImageTypes(int imageIndex)
Returns the possible image types to which the given image can be decoded. |
int |
getNumBands(int imageIndex)
Returns the number of bands available for the specified image. |
int |
getNumImages(boolean allowSearch)
Returns the number of images in the current input. |
ImageReaderSpi |
getOriginatingProvider()
Returns the ImageReader provider, or null if none. |
protected int |
getRawDataType(int imageIndex)
Returns the data type which most closely represents the "raw" internal data of the image. |
ImageTypeSpecifier |
getRawImageType(int imageIndex)
Returns the raw type of the image at the given index. |
protected Dimension |
getSize(int imageIndex)
Returns the image width and height at the given index. |
int |
getWidth(int imageIndex)
Returns the width of the image at the given index. |
protected GridCoverage |
read(int index,
GridCoverageReadParam param)
Reads the coverage at the given index. |
BufferedImage |
read(int imageIndex,
ImageReadParam param)
Reads the image at the given index. |
RenderedImage |
readAsRenderedImage(int imageIndex,
ImageReadParam param)
Reads the image at the given index. |
void |
setInput(Object input,
boolean seekForwardOnly,
boolean ignoreMetadata)
Sets the input to be read. |
| Methods inherited from class SpatialImageReader |
|---|
checkBandIndex, checkImageIndex, close, collapseNoDataValues, flipVertically, getDefaultReadParam, getDestination, getImageMetadata, getImageType, getStreamMetadata, hasColors, warningOccurred |
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface Localized |
|---|
getLocale |
| Field Detail |
|---|
protected final GridCoverageReader reader
ImageReader method invocations.
| Constructor Detail |
|---|
public ImageReaderAdapter(GridCoverageReader reader)
reader - The coverage reader on which to delegate all
ImageReader method invocations.| Method Detail |
|---|
public ImageReaderSpi getOriginatingProvider()
ImageReader provider, or null if none.
getOriginatingProvider in class ImageReader
public void setInput(Object input,
boolean seekForwardOnly,
boolean ignoreMetadata)
GridCoverageReader, then it is also saved in the inherited ImageReader.input field
for retrieval by ImageReader.getInput().
setInput in class SpatialImageReaderinput - The input object to use for future decoding.seekForwardOnly - If true, images and metadata may only be read
in ascending order from this input source.ignoreMetadata - If true, metadata may be ignored during reads.
public int getNumImages(boolean allowSearch)
throws IOException
GridCoverageReader.getCoverageNames().
getNumImages in class SpatialImageReaderallowSearch - If true, the number of images will be returned
even if a search is required.
allowSearch
is false and a search would be required.
IOException - if an error occurs reading the information from the input source.
public int getNumBands(int imageIndex)
throws IOException
GridCoverageReader.getSampleDimensions(int).
getNumBands in class SpatialImageReaderimageIndex - The image index.
IOException - if an error occurs reading the information from the input source.
public int getDimension(int imageIndex)
throws IOException
GridCoverageReader.getGridGeometry(int).
getDimension in class SpatialImageReaderimageIndex - The image index.
IOException - if an error occurs reading the information from the input source.MultidimensionalImageStore
public GridEnvelope getGridEnvelope(int imageIndex)
throws IOException
GridCoverageReader.getGridGeometry(int).
getGridEnvelope in class SpatialImageReaderimageIndex - The image index.
IOException - if an error occurs reading the information from the input source.MultidimensionalImageStore
protected Dimension getSize(int imageIndex)
throws IOException
GridCoverageReader.getGridGeometry(int).
Subclasses can override this method if they want to compute the size in a different way.
imageIndex - The image index.
IOException - if an error occurs reading the information from the input source.
public final int getWidth(int imageIndex)
throws IOException
getSize(int), which computes the size from the grid geometry.
getWidth in class ImageReaderIOException - if an error occurs reading the information from the input source.
public final int getHeight(int imageIndex)
throws IOException
getSize(int), which computes the size from the grid geometry.
getHeight in class ImageReaderIOException - if an error occurs reading the information from the input source.
protected int getRawDataType(int imageIndex)
throws IOException
getRawImageType(int).
getRawDataType in class SpatialImageReaderimageIndex - The index of the image to be queried.
DataBuffer.TYPE_FLOAT by default).
IOException - if an error occurs reading the information from the input source.SpatialImageReader.getImageType(int, ImageReadParam, SampleConverter[]),
SampleConversionType.SHIFT_SIGNED_INTEGERS
public ImageTypeSpecifier getRawImageType(int imageIndex)
throws IOException
GridCoverageReader.getSampleDimensions(int).
getRawImageType in class SpatialImageReaderimageIndex - The index of the image to be queried.
null).
IOException - if an error occurs reading the information from the input source.SpatialImageReader.getImageType(int, ImageReadParam, SampleConverter[]),
SpatialImageReader.getDefaultReadParam()
public Iterator<ImageTypeSpecifier> getImageTypes(int imageIndex)
throws IOException
getRawDataType(int) in a singleton set.
getImageTypes in class SpatialImageReaderimageIndex - The index of the image to be queried.
IOException - if an error occurs reading the information from the input source.
protected SpatialMetadata createMetadata(int imageIndex)
throws IOException
createMetadata in class SpatialImageReaderimageIndex - -1 for stream metadata, or the image index for image metadata.
null if none.
IOException - if an error occurs reading the information from the input source.
public RenderedImage readAsRenderedImage(int imageIndex,
ImageReadParam param)
throws IOException
GridCoverageReader, then extracts the RenderedImage from
the coverage. Note that the image returned by this method will typically be an instance
of PlanarImage rather than BufferedImage.
readAsRenderedImage in class ImageReaderIOException - if an error occurs reading the information from the input source.
public BufferedImage read(int imageIndex,
ImageReadParam param)
throws IOException
readAsRenderedImage(int, ImageReadParam), then converts the image
to an instance of BufferedImage.
The readAsRenderedImage method should be preferred when the image is
not required to be an instance of BufferedImage.
read in class ImageReaderIOException - if an error occurs reading the information from the input source.
protected GridCoverage read(int index,
GridCoverageReadParam param)
throws IOException
readAsRenderedImage after the image parameters have been converted
to coverage parameters.
The default implementation delegates to
GridCoverageReader.read(int, GridCoverageReadParam). Subclasses can override
this method if they want to perform additional processing before or after the coverage
is read. For example a subclass may invoke GridCoverage2D.view(ViewType.RENDERED)
for a better image rendering.
index - The index of the coverage to be queried.param - Optional parameters used to control the reading process, or null.
GridCoverage at the specified index, or null if abort()
has been invoked in an other thread during the execution of this method.
IOException - If the coverage can not be read.public void abort()
GridCoverageReader, but does not set the ImageReader.abortRequested() flag in
this class (because it is not used).
abort in class ImageReaderpublic void dispose()
GridCoverageReader.
dispose in interface Disposabledispose in class SpatialImageReader
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||