org.geotoolkit.coverage.processing
Class IndexColorOperation

Object
  extended by AbstractOperation
      extended by Operation2D
          extended by IndexColorOperation
All Implemented Interfaces:
Serializable, Operation
Direct Known Subclasses:
Recolor

@Immutable
public abstract class IndexColorOperation
extends Operation2D

Operation applied on the IndexColorModel of the image backing the source grid coverage. The doOperation method extracts the color map of the source coverage as an array of ARGB values, passes that array to transformColormap and creates a new grid coverage using the new colors.

Since:
1.2
Version:
3.14
Author:
Martin Desruisseaux (IRD)
See Also:
Serialized Form
Module:
coverage/geotk-coverage (download)    View source code for this class

Field Summary
 
Fields inherited from class Operation2D
PRIMARY_SOURCE_INDEX, SOURCE_0, SOURCE_1, SOURCE_2
 
Fields inherited from class AbstractOperation
descriptor
 
Constructor Summary
protected IndexColorOperation(DefaultParameterDescriptorGroup descriptor)
          Constructs an operation.
 
Method Summary
protected  Coverage doOperation(ParameterValueGroup parameters, Hints hints)
          Performs the color transformation.
protected  ViewType getComputationView(ParameterValueGroup parameters)
          Returns ViewType.RENDERED as the preferred view for computation purpose.
protected abstract  GridSampleDimension transformColormap(int[] ARGB, int band, GridSampleDimension sampleDimension, ParameterValueGroup parameters)
          Transforms the supplied RGB colors.
 
Methods inherited from class Operation2D
extractSources, extractSources
 
Methods inherited from class AbstractOperation
equals, getDescription, getDocURL, getName, getNumSources, getParameters, getVendor, getVersion, hashCode, toString
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IndexColorOperation

protected IndexColorOperation(DefaultParameterDescriptorGroup descriptor)
Constructs an operation. The operation name will be the same than the parameter descriptor name.

Parameters:
descriptor - The parameters descriptor.
Method Detail

getComputationView

protected ViewType getComputationView(ParameterValueGroup parameters)
Returns ViewType.RENDERED as the preferred view for computation purpose.

Overrides:
getComputationView in class Operation2D
Parameters:
parameters - The parameters supplied by the user to the doOperation method.
Returns:
The view on which computation should be performed.
See Also:
GridCoverage2D.view(ViewType)

doOperation

protected Coverage doOperation(ParameterValueGroup parameters,
                               Hints hints)
                        throws IllegalArgumentException
Performs the color transformation. This method invokes the transformColormap(...) method with the ARGB colors found in the source image, its GridSampleDimension and the parameters supplied to this method. The new colors returned by transformColormap are used for creating a grid coverage backed by and image using a new IndexColorModel.

Specified by:
doOperation in class AbstractOperation
Parameters:
parameters - The parameters.
hints - Rendering hints (ignored in this implementation).
Returns:
The result as a coverage.
Throws:
IllegalArgumentException - if the image do not use an IndexColorModel.

transformColormap

protected abstract GridSampleDimension transformColormap(int[] ARGB,
                                                         int band,
                                                         GridSampleDimension sampleDimension,
                                                         ParameterValueGroup parameters)
Transforms the supplied RGB colors. This method is automatically invoked by doOperation(...) for each band in the source GridCoverage2D. The ARGB array contains the ARGB values from the current source and should be overridden with new ARGB values for the destination image.

This method is usually invoked only once, since images backed by IndexColorModel normally have only one band. However it may happen that an image contains additional "invisible" bands, in which case this method will be invoked for those bands as well.

Parameters:
ARGB - Alpha, Red, Green and Blue components to transform.
band - The band number, from 0 to the number of bands in the image -1.
sampleDimension - The sample dimension of band band.
parameters - The user-supplied parameters.
Returns:
A sample dimension identical to sampleDimension except for the colors. Subclasses may conservatively returns sampleDimension.


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