org.geotools.renderer.lite.gridcoverage2d
Class LinearColorMap

Object
  extended by AbstractCollection<E>
      extended by AbstractList<LinearColorMapElement>
          extended by LinearColorMap
All Implemented Interfaces:
Iterable<LinearColorMapElement>, Collection<LinearColorMapElement>, List<LinearColorMapElement>, Domain1D<LinearColorMapElement>, PiecewiseTransform1D<LinearColorMapElement>, ColorMapTransform<LinearColorMapElement>, MathTransform, MathTransform1D

public final class LinearColorMap
extends AbstractList<LinearColorMapElement>
implements ColorMapTransform<LinearColorMapElement>

Author:
Simone Giannecchini, GeoSolutions.

Nested Class Summary
static class LinearColorMap.LinearColorMapType
           
 
Field Summary
 
Fields inherited from class AbstractList
modCount
 
Constructor Summary
LinearColorMap(CharSequence name, LinearColorMapElement[] standardElements)
          Constructor which creates a LinearColorMap without a NoDataCategory.
LinearColorMap(CharSequence name, LinearColorMapElement[] standardElements, Color defColor)
           
LinearColorMap(CharSequence name, LinearColorMapElement[] standardElements, LinearColorMapElement[] preFilteringElements, Color defaultColor)
           
LinearColorMap(String string, LinearColorMapElement[] linearColorMapElements, LinearColorMapElement[] linearColorMapElements2)
           
 
Method Summary
 Matrix derivative(DirectPosition point)
          Gets the derivative of this transform at a point.
 double derivative(double value)
          Gets the derivative of this function at a value.
 boolean equals(Object o)
           
 LinearColorMapElement findDomainElement(double sample)
          Returns the DomainElement1D of the specified sample value.
 LinearColorMapElement get(int index)
           
 NumberRange<?> getApproximateDomainRange()
          Returns the range of values in this Domain1D.
 IndexColorModel getColorModel()
          Returns a color model for this category list.
 double getDefaultValue()
          The default value which will be returned when asked to transform a value outside the valid domain elements.
 LinearColorMapElement[] getDomainElements()
           
 InternationalString getName()
          Returns the name of this object.
 SampleModel getSampleModel(int width, int height)
          Creates a SampleModel compatible with the underlying ColorModel having the specified width and height.
 int getSourceDimensions()
          Gets the dimension of input points.
 int getTargetDimensions()
          Gets the dimension of output points.
 boolean hasDefaultValue()
          Indicates whether or not this PiecewiseTransform1D has a default value which will be returned when asked to transform a value outside the valid domain elements.
 boolean hasGaps()
          Tell us if there is a gap in this Domain1D which means a range where no DomainElement1D is defined.
 int hashCode()
           
 MathTransform1D inverse()
          Creates the inverse transform of this object.
 boolean isIdentity()
          Tests whether this transform does not move any points.
 int size()
           
 String toWKT()
          Returns a Well Known Text (WKT) for this object.
 DirectPosition transform(DirectPosition ptSrc, DirectPosition ptDst)
          Transforms the specified ptSrc and stores the result in ptDst.
 double transform(double value)
          Transforms the specified value.
 void transform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts)
          Transforms a list of coordinate point ordinal values.
 void transform(double[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts)
          Transforms a list of coordinate point ordinal values.
 void transform(float[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts)
          Transforms a list of coordinate point ordinal values.
 void transform(float[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts)
          Transforms a list of coordinate point ordinal values.
 
Methods inherited from class AbstractList
add, add, addAll, clear, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
 
Methods inherited from class AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface List
add, add, addAll, addAll, clear, contains, containsAll, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, subList, toArray, toArray
 

Constructor Detail

LinearColorMap

public LinearColorMap(CharSequence name,
                      LinearColorMapElement[] standardElements)
Constructor which creates a LinearColorMap without a NoDataCategory. Keep in mind that if the list has gaps, if you try to transform a value that falls into a gap you'll get a nice TransformException!

Parameters:
categories - the array of a categories to use for this LinearColorMap.

LinearColorMap

public LinearColorMap(CharSequence name,
                      LinearColorMapElement[] standardElements,
                      Color defColor)

LinearColorMap

public LinearColorMap(CharSequence name,
                      LinearColorMapElement[] standardElements,
                      LinearColorMapElement[] preFilteringElements,
                      Color defaultColor)

LinearColorMap

public LinearColorMap(String string,
                      LinearColorMapElement[] linearColorMapElements,
                      LinearColorMapElement[] linearColorMapElements2)
Method Detail

getColorModel

public IndexColorModel getColorModel()
Returns a color model for this category list. This method builds up the color model from each category's colors (as returned by #getColors ).

Specified by:
getColorModel in interface ColorMapTransform<LinearColorMapElement>
Parameters:
visibleBand - The band to be made visible (usually 0). All other bands, if any will be ignored.
numBands - The number of bands for the color model (usually 1). The returned color model will renderer only the visibleBand and ignore the others, but the existence of all numBands will be at least tolerated. Supplemental bands, even invisible, are useful for processing with Java Advanced Imaging.
Returns:
The requested color model, suitable for RenderedImage objects with values in the #getRange range.
UML property:
name="colorModel"

getSampleModel

public SampleModel getSampleModel(int width,
                                  int height)
Creates a SampleModel compatible with the underlying ColorModel having the specified width and height.

Specified by:
getSampleModel in interface ColorMapTransform<LinearColorMapElement>
Parameters:
width - represents the width for the final SampleModel
height - represents the height for the final SampleModel
Returns:

get

public LinearColorMapElement get(int index)
Specified by:
get in interface List<LinearColorMapElement>
Specified by:
get in class AbstractList<LinearColorMapElement>

size

public int size()
Specified by:
size in interface Collection<LinearColorMapElement>
Specified by:
size in interface List<LinearColorMapElement>
Specified by:
size in class AbstractCollection<LinearColorMapElement>

getDefaultValue

public double getDefaultValue()
Description copied from interface: PiecewiseTransform1D
The default value which will be returned when asked to transform a value outside the valid domain elements.

In case PiecewiseTransform1D.hasDefaultValue() return false this value has no meaning.

Specified by:
getDefaultValue in interface PiecewiseTransform1D<LinearColorMapElement>
Returns:
The default value which will be returned when asked to transform a value outside the valid domain elements.

hasDefaultValue

public boolean hasDefaultValue()
Description copied from interface: PiecewiseTransform1D
Indicates whether or not this PiecewiseTransform1D has a default value which will be returned when asked to transform a value outside the valid domain elements.

Specified by:
hasDefaultValue in interface PiecewiseTransform1D<LinearColorMapElement>
Returns:
a boolean to indicate whether or not this PiecewiseTransform1D has a default value.

getApproximateDomainRange

public NumberRange<?> getApproximateDomainRange()
Description copied from interface: Domain1D
Returns the range of values in this Domain1D. This is the union of the range of values of every Domain1D.

Specified by:
getApproximateDomainRange in interface Domain1D<LinearColorMapElement>
Returns:
The range of values.

findDomainElement

public LinearColorMapElement findDomainElement(double sample)
Description copied from interface: Domain1D
Returns the DomainElement1D of the specified sample value. If no DomainElement1D fits, then this method returns null.

Specified by:
findDomainElement in interface Domain1D<LinearColorMapElement>
Parameters:
sample - The value.
Returns:
The domain element of the supplied value, or null.

getDomainElements

public LinearColorMapElement[] getDomainElements()

getName

public InternationalString getName()
Description copied from interface: Domain1D
Returns the name of this object. The default implementation returns the name of what seems to be the "main" domain element (i.e. the domain element with the widest range of values).

Specified by:
getName in interface Domain1D<LinearColorMapElement>
Returns:
UML property:
name="name"

hasGaps

public boolean hasGaps()
Description copied from interface: Domain1D
Tell us if there is a gap in this Domain1D which means a range where no DomainElement1D is defined.

Specified by:
hasGaps in interface Domain1D<LinearColorMapElement>
Returns:
true in case a gap exists, false otherwise.

derivative

public double derivative(double value)
                  throws TransformException
Description copied from interface: MathTransform1D
Gets the derivative of this function at a value. The derivative is the 1×1 matrix of the non-translating portion of the approximate affine map at the value.

Specified by:
derivative in interface MathTransform1D
Parameters:
value - The value where to evaluate the derivative.
Returns:
The derivative at the specified point.
Throws:
TransformException - if the derivative can't be evaluated at the specified point.

transform

public double transform(double value)
                 throws TransformException
Description copied from interface: MathTransform1D
Transforms the specified value.

Specified by:
transform in interface MathTransform1D
Parameters:
value - The value to transform.
Returns:
the transformed value.
Throws:
TransformException - if the value can't be transformed.

derivative

public Matrix derivative(DirectPosition point)
                  throws MismatchedDimensionException,
                         TransformException
Description copied from interface: MathTransform
Gets the derivative of this transform at a point. The derivative is the matrix of the non-translating portion of the approximate affine map at the point. The matrix will have dimensions corresponding to the source and target coordinate systems. If the input dimension is M, and the output dimension is N, then the matrix will have size N×M. The elements of the matrix {en,m : n=0..(N-1)} form a vector in the output space which is parallel to the displacement caused by a small change in the m'th ordinate in the input space.

For example, if the input dimension is 4 and the output dimension is 3, then a small displacement (x0, x1, x2, x3) in the input space will result in a displacement (y0, y1, y2) in the output space computed as below (en,m are the matrix's elements):

 [ y0 ]     [ e00  e01  e02  e03 ] [ x0 ]
 [ y1 ]  =  [ e10  e11  e12  e13 ] [ x1 ]
 [ y2 ]     [ e20  e21  e22  e23 ] [ x2 ]
                                   [ x3 ]
 

Specified by:
derivative in interface MathTransform
Parameters:
point - The coordinate point where to evaluate the derivative. Null value is accepted only if the derivative is the same everywhere. For example affine transform accept null value since they produces identical derivative no matter the coordinate value. But most map projection will requires a non-null value.
Returns:
The derivative at the specified point (never null). This method never returns an internal object: changing the matrix will not change the state of this math transform.
Throws:
MismatchedDimensionException - if point doesn't have the expected dimension.
TransformException - if the derivative can't be evaluated at the specified point.

getSourceDimensions

public int getSourceDimensions()
Description copied from interface: MathTransform
Gets the dimension of input points.

Specified by:
getSourceDimensions in interface MathTransform
Returns:
The dimension of input points.

getTargetDimensions

public int getTargetDimensions()
Description copied from interface: MathTransform
Gets the dimension of output points.

Specified by:
getTargetDimensions in interface MathTransform
Returns:
The dimension of output points.

inverse

public MathTransform1D inverse()
                        throws NoninvertibleTransformException
Description copied from interface: MathTransform1D
Creates the inverse transform of this object.

Specified by:
inverse in interface MathTransform
Specified by:
inverse in interface MathTransform1D
Returns:
The inverse transform.
Throws:
NoninvertibleTransformException - if the transform can't be inversed.

isIdentity

public boolean isIdentity()
Description copied from interface: MathTransform
Tests whether this transform does not move any points.

Specified by:
isIdentity in interface MathTransform
Returns:
true if this MathTransform is an identity transform; false otherwise.

toWKT

public String toWKT()
             throws UnsupportedOperationException
Description copied from interface: MathTransform
Returns a Well Known Text (WKT) for this object. Well know text are defined in extended Backus Naur form. This operation may fails if an object is too complex for the WKT format capability.

Specified by:
toWKT in interface MathTransform
Returns:
The Well Known Text (WKT) for this object.
Throws:
UnsupportedOperationException - If this object can't be formatted as WKT.

transform

public DirectPosition transform(DirectPosition ptSrc,
                                DirectPosition ptDst)
                         throws MismatchedDimensionException,
                                TransformException
Description copied from interface: MathTransform
Transforms the specified ptSrc and stores the result in ptDst. If ptDst is null, a new DirectPosition object is allocated and then the result of the transformation is stored in this object. In either case, ptDst, which contains the transformed point, is returned for convenience. If ptSrc and ptDst are the same object, the input point is correctly overwritten with the transformed point.

Specified by:
transform in interface MathTransform
Parameters:
ptSrc - the specified coordinate point to be transformed.
ptDst - the specified coordinate point that stores the result of transforming ptSrc, or null.
Returns:
the coordinate point after transforming ptSrc and storing the result in ptDst, or a newly created point if ptDst was null.
Throws:
MismatchedDimensionException - if ptSrc or ptDst doesn't have the expected dimension.
TransformException - if the point can't be transformed.

transform

public void transform(double[] srcPts,
                      int srcOff,
                      double[] dstPts,
                      int dstOff,
                      int numPts)
               throws TransformException
Description copied from interface: MathTransform
Transforms a list of coordinate point ordinal values. This method is provided for efficiently transforming many points. The supplied array of ordinal values will contain packed ordinal values. For example, if the source dimension is 3, then the ordinals will be packed in this order: (x0,y0,z0, x1,y1,z1 ...).

Specified by:
transform in interface MathTransform
Parameters:
srcPts - the array containing the source point coordinates.
srcOff - the offset to the first point to be transformed in the source array.
dstPts - the array into which the transformed point coordinates are returned. May be the same than srcPts.
dstOff - the offset to the location of the first transformed point that is stored in the destination array.
numPts - the number of point objects to be transformed.
Throws:
TransformException - if a point can't be transformed. Some implementations will stop at the first failure, wile some other implementations will fill the untransformable points with NaN values, continue and throw the exception only at end. Implementations that fall in the later case should set the last completed transform to this.

transform

public void transform(float[] srcPts,
                      int srcOff,
                      float[] dstPts,
                      int dstOff,
                      int numPts)
               throws TransformException
Description copied from interface: MathTransform
Transforms a list of coordinate point ordinal values. This method is provided for efficiently transforming many points. The supplied array of ordinal values will contain packed ordinal values. For example, if the source dimension is 3, then the ordinals will be packed in this order: (x0,y0,z0, x1,y1,z1 ...).

Specified by:
transform in interface MathTransform
Parameters:
srcPts - the array containing the source point coordinates.
srcOff - the offset to the first point to be transformed in the source array.
dstPts - the array into which the transformed point coordinates are returned. May be the same than srcPts.
dstOff - the offset to the location of the first transformed point that is stored in the destination array.
numPts - the number of point objects to be transformed.
Throws:
TransformException - if a point can't be transformed. Some implementations will stop at the first failure, wile some other implementations will fill the untransformable points with NaN values, continue and throw the exception only at end. Implementations that fall in the later case should set the last completed transform to this.

transform

public void transform(float[] srcPts,
                      int srcOff,
                      double[] dstPts,
                      int dstOff,
                      int numPts)
               throws TransformException
Description copied from interface: MathTransform
Transforms a list of coordinate point ordinal values. This method is provided for efficiently transforming many points. The supplied array of ordinal values will contain packed ordinal values. For example, if the source dimension is 3, then the ordinals will be packed in this order: (x0,y0,z0, x1,y1,z1 ...).

Specified by:
transform in interface MathTransform
Parameters:
srcPts - the array containing the source point coordinates.
srcOff - the offset to the first point to be transformed in the source array.
dstPts - the array into which the transformed point coordinates are returned.
dstOff - the offset to the location of the first transformed point that is stored in the destination array.
numPts - the number of point objects to be transformed.
Throws:
TransformException - if a point can't be transformed. Some implementations will stop at the first failure, wile some other implementations will fill the untransformable points with NaN values, continue and throw the exception only at end. Implementations that fall in the later case should set the last completed transform to this.

transform

public void transform(double[] srcPts,
                      int srcOff,
                      float[] dstPts,
                      int dstOff,
                      int numPts)
               throws TransformException
Description copied from interface: MathTransform
Transforms a list of coordinate point ordinal values. This method is provided for efficiently transforming many points. The supplied array of ordinal values will contain packed ordinal values. For example, if the source dimension is 3, then the ordinals will be packed in this order: (x0,y0,z0, x1,y1,z1 ...).

Specified by:
transform in interface MathTransform
Parameters:
srcPts - the array containing the source point coordinates.
srcOff - the offset to the first point to be transformed in the source array.
dstPts - the array into which the transformed point coordinates are returned.
dstOff - the offset to the location of the first transformed point that is stored in the destination array.
numPts - the number of point objects to be transformed.
Throws:
TransformException - if a point can't be transformed. Some implementations will stop at the first failure, wile some other implementations will fill the untransformable points with NaN values, continue and throw the exception only at end. Implementations that fall in the later case should set the last completed transform to this.

equals

public boolean equals(Object o)
Specified by:
equals in interface Collection<LinearColorMapElement>
Specified by:
equals in interface List<LinearColorMapElement>
Overrides:
equals in class AbstractList<LinearColorMapElement>

hashCode

public int hashCode()
Specified by:
hashCode in interface Collection<LinearColorMapElement>
Specified by:
hashCode in interface List<LinearColorMapElement>
Overrides:
hashCode in class AbstractList<LinearColorMapElement>


Copyright © 1996-2014 Geotools. All Rights Reserved.