|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.geotools.gp.Operation org.geotools.gp.OperationJAI
Wrap an OperationDescriptor
for interoperability with
Java Advanced Imaging.
This class help to leverage the rich set of JAI operators in an OpenGIS framework.
OperationJAI
inherits operation name and argument types from
OperationDescriptor
, except source argument type which is set to
GridCoverage.class
. If there is only one source argument, il will be
renamed "Source"
for better compliance to OpenGIS usage.
The entry point for applying operation is the usual doOperation
method. The default implementation forward the call to other methods for
different bits of tasks, resulting in the following chain of calls:
doOperation
(the entry point)resampleToCommonGeometry
(reproject all source to the same coordinate system)deriveGridCoverage
(gets the destination properties)deriveSampleDimension(org.geotools.cv.SampleDimension[][], org.geotools.gp.OperationJAI.Parameters)
(gets the destination sample dimensions)deriveCategory(org.geotools.cv.Category[], org.geotools.gp.OperationJAI.Parameters)
(gets the destination categories)deriveUnit(org.geotools.units.Unit[], org.geotools.gp.OperationJAI.Parameters)
(gets the destination units)createRenderedImage(javax.media.jai.ParameterBlockJAI, java.awt.RenderingHints)
(the actual call to JAI.createNS
)
Nested Class Summary | |
protected static class |
OperationJAI.Parameters
A block of parameters for a GridCoverage processed by a OperationJAI .
|
Field Summary | |
protected javax.media.jai.OperationDescriptor |
descriptor
The operation descriptor. |
Fields inherited from class org.geotools.gp.Operation |
MONADIC |
Constructor Summary | |
|
OperationJAI(javax.media.jai.OperationDescriptor descriptor)
Construct an OpenGIS operation from a JAI operation descriptor. |
|
OperationJAI(java.lang.String operationName)
Construct an OpenGIS operation from a JAI operation name. |
protected |
OperationJAI(java.lang.String name,
javax.media.jai.OperationDescriptor operationDescriptor,
javax.media.jai.ParameterListDescriptor paramDescriptor)
Construct an OpenGIS operation backed by a JAI operation. |
Method Summary | |
protected java.awt.image.RenderedImage |
createRenderedImage(javax.media.jai.ParameterBlockJAI parameters,
java.awt.RenderingHints hints)
Apply the JAI operation. |
protected Category |
deriveCategory(Category[] categories,
OperationJAI.Parameters parameters)
Derive the quantitative category for a sample dimension in the destination coverage. |
protected GridCoverage |
deriveGridCoverage(GridCoverage[] sources,
OperationJAI.Parameters parameters)
Apply a JAI operation to a grid coverage. |
protected java.lang.String |
deriveName(GridCoverage source,
OperationJAI.Parameters parameters)
Returns a name for the target grid coverage based on the given source. |
protected SampleDimension[] |
deriveSampleDimension(SampleDimension[][] bandLists,
OperationJAI.Parameters parameters)
Derive the SampleDimension s for the destination image. |
protected Unit |
deriveUnit(Unit[] units,
OperationJAI.Parameters parameters)
Derive the unit of data for a sample dimension in the destination coverage. |
protected GridCoverage |
doOperation(javax.media.jai.ParameterList parameters,
java.awt.RenderingHints hints)
Apply a process operation to a grid coverage. |
boolean |
equals(java.lang.Object object)
Compares the specified object with this operation for equality. |
java.lang.String |
getDescription(java.util.Locale locale)
Returns the description of the processing operation. |
protected static javax.media.jai.JAI |
getJAI(java.awt.RenderingHints hints)
Returns the JAI instance to use for operations on RenderedImage .
|
int |
getNumSources()
Returns the number of source grid coverages required for the operation. |
protected static javax.media.jai.OperationDescriptor |
getOperationDescriptor(java.lang.String name)
Returns the operation descriptor for the specified JAI operation name. |
protected void |
resampleToCommonGeometry(GridCoverage[] sources,
CoordinateSystem coordinateSystem,
MathTransform gridToCS,
java.awt.RenderingHints hints)
Resample all sources grid coverages to the same geometry before to apply an operation. |
Methods inherited from class org.geotools.gp.Operation |
getGridCoverageProcessor, getName, getNumParameters, getParameterInfo, getParameterInfo, getParameterList, getParameterListDescriptor, hashCode, print, toString |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
protected final javax.media.jai.OperationDescriptor descriptor
Constructor Detail |
public OperationJAI(java.lang.String operationName) throws OperationNotFoundException
OperationDescriptor
from the specified operation name using the
default JAI
instance.
operationName
- JAI operation name (e.g. "GradientMagnitude").
OperationNotFoundException
- if no JAI descriptor was found for the given name.public OperationJAI(javax.media.jai.OperationDescriptor descriptor)
descriptor
- The operation descriptor. This descriptor
must supports the "rendered" mode (which is the case
for most JAI operations).protected OperationJAI(java.lang.String name, javax.media.jai.OperationDescriptor operationDescriptor, javax.media.jai.ParameterListDescriptor paramDescriptor)
name
- The operation name for GridCoverageProcessor
registration.
May or may not be the same than the JAI operation name. If null
,
then the JAI operation name is used.operationDescriptor
- The operation descriptor. This descriptor must supports
supports the "rendered" mode (which is the case for most JAI operations).paramDescriptor
- The parameters descriptor. If null
,
then it will be infered from the JAI's parameter descriptor.
java.lang.NullPointerException
- if operationDescriptor
is null.Method Detail |
protected static javax.media.jai.OperationDescriptor getOperationDescriptor(java.lang.String name) throws OperationNotFoundException
JAI
instance and looks for the
"rendered"
mode.
name
- The operation name.
OperationNotFoundException
- if no JAI descriptor was found for the given name.public java.lang.String getDescription(java.util.Locale locale)
null
. The default implementation fetch the description from
the descriptor.
getDescription
in class Operation
locale
- The desired locale, or null
for the default locale.GP_Operation.getDescription()
public int getNumSources()
getNumSources
in class Operation
GP_Operation.getNumSources()
protected GridCoverage doOperation(javax.media.jai.ParameterList parameters, java.awt.RenderingHints hints)
GridCoverage.geophysics
(true)
.
This allow to performs all computation on geophysics values instead of encoded
samples.GridCoverage
s use the same coordinate
system and have the same envelope.deriveGridCoverage(org.geotools.gc.GridCoverage[], org.geotools.gp.OperationJAI.Parameters)
.
The sources in the ParameterBlock
are RenderedImage
objects
obtained from GridCoverage.getRenderedImage()
.GridCoverage
s was not a geophysics view, convert the
result back to the same type with
GridCoverage.geophysics
(false)
.
doOperation
in class Operation
parameters
- List of name value pairs for the parameters required for the operation.hints
- A set of rendering hints, or null
if none.
deriveGridCoverage(org.geotools.gc.GridCoverage[], org.geotools.gp.OperationJAI.Parameters)
protected void resampleToCommonGeometry(GridCoverage[] sources, CoordinateSystem coordinateSystem, MathTransform gridToCS, java.awt.RenderingHints hints) throws InvalidGridGeometryException, CannotReprojectException
sources
- The source grid coverages to resample.
This array is updated in-place as needed.coordinateSystem
- The target coordinate system to use,
or null
for a default one.gridToCS
- The target "grid to coordinate system" transform,
or null
for a default one.hints
- The rendering hints, or null
if none.
InvalidGridGeometryException
- if a source coverage has an unsupported grid geometry.
CannotReprojectException
- if a grid coverage can't be resampled for some other reason.protected GridCoverage deriveGridCoverage(GridCoverage[] sources, OperationJAI.Parameters parameters)
SampleDimension
s for the target images by invoking the
deriveSampleDimension(...)
method.JAI.createNS
(descriptor
.getName(), parameters, hints)
sources
- The source coverages.parameters
- Parameters, rendering hints and coordinate system to use.
doOperation(javax.media.jai.ParameterList, java.awt.RenderingHints)
,
deriveSampleDimension(org.geotools.cv.SampleDimension[][], org.geotools.gp.OperationJAI.Parameters)
,
JAI.createNS(java.lang.String, java.awt.image.renderable.ParameterBlock, java.awt.RenderingHints)
protected SampleDimension[] deriveSampleDimension(SampleDimension[][] bandLists, OperationJAI.Parameters parameters)
SampleDimension
s for the destination image. The
default implementation iterate among all bands and invokes the
deriveCategory
and deriveUnit
methods for each individual band.
bandLists
- SampleDimension
s for each band in each source
GridCoverage
s. For a band (or "sample dimension")
band
in a source coverage source
, the
corresponding SampleDimension
is
bandLists[source][band]
.parameters
- Parameters, rendering hints and coordinate system to use.
SampleDimension
s are unknow,
then this method may returns null
.deriveCategory(org.geotools.cv.Category[], org.geotools.gp.OperationJAI.Parameters)
,
deriveUnit(org.geotools.units.Unit[], org.geotools.gp.OperationJAI.Parameters)
protected Category deriveCategory(Category[] categories, OperationJAI.Parameters parameters)
deriveSampleDimension
method for each band in the
destination image. Subclasses should override this method in order to compute the
destination Category
from the source categories. For example, the
"add
" operation may implements this method as below:
NumberRange r0 = categories[0].getRange(); NumberRange r1 = categories[0].getRange(); double min = r0.getMinimum() + r1.getMinimum(); double min = r0.getMaximum() + r1.getMaximum(); NumberRange newRange = new NumberRange(min, max); return new Category("My category", null, r0, newRange);
categories
- The quantitative categories from every sources. For unary operations
like "GradientMagnitude", this array has a length of 1. For binary
operations like "add" and "multiply", this array has a length of 2.parameters
- Parameters, rendering hints and coordinate system to use.
null
if unknow.protected Unit deriveUnit(Unit[] units, OperationJAI.Parameters parameters)
deriveSampleDimension
method for each band in the
destination image. Subclasses should override this method in order to compute the
destination units from the source units. For example, the "multiply
"
operation may implement this method as below:
if (units[0]!=null && units[1]!=null) { return units[0].multiply
(units[1]); } else { return super.deriveUnit(units, cs, parameters); }
units
- The units from every sources. For unary operations like
"GradientMagnitude", this array has a length of 1.
For binary operations like "add" and "multiply", this array has a length of 2.parameters
- Parameters, rendering hints and coordinate system to use.
null
if unknow.protected java.lang.String deriveName(GridCoverage source, OperationJAI.Parameters parameters)
source
- The source grid coverage.parameters
- Parameters, rendering hints and coordinate system to use.
protected java.awt.image.RenderedImage createRenderedImage(javax.media.jai.ParameterBlockJAI parameters, java.awt.RenderingHints hints)
descriptor
.
The JAI instance to use can be fetch from getJAI(java.awt.RenderingHints)
. The default implementation
invokes JAI.createNS
. Subclasses may overrides this method in order
to invokes a different JAI operation according the parameters.
parameters
- The parameters to be given to JAI.hints
- The rendering hints to be given to JAI.protected static javax.media.jai.JAI getJAI(java.awt.RenderingHints hints)
JAI
instance to use for operations on RenderedImage
.
If no JAI instance is defined for the Hints.JAI_INSTANCE
key, then the
default instance is returned.
hints
- The rendering hints, or null
if none.
null
).public boolean equals(java.lang.Object object)
equals
in class Operation
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |