org.deegree_impl.model.ct
Class AbstractMathTransform

java.lang.Object
  extended byorg.deegree_impl.model.ct.AbstractMathTransform
All Implemented Interfaces:
MathTransform
Direct Known Subclasses:
AbridgedMolodenskiTransform, AbstractMathTransform.Inverse, ConcatenedTransform, GeocentricTransform, MapProjection, MathTransformAdapter, MatrixTransform, PassThroughTransform

public abstract class AbstractMathTransform
extends java.lang.Object
implements MathTransform

Provides a default implementations for most methods required by the MathTransform interface. AbstractMathTransform provides a convenient base class from which other transform classes can be easily derived. In addition, AbstractMathTransform implements methods required by the MathTransform2D interface, but does not implements MathTransform2D. Subclasses must declare implements MathTransform2D themself if they know to maps two-dimensional coordinate systems.

Version:
1.0
Author:
Martin Desruisseaux

Nested Class Summary
protected  class AbstractMathTransform.Inverse
          Default implementation for inverse math transform.
 
Constructor Summary
AbstractMathTransform()
          Construct a math transform.
 
Method Summary
(package private) static void addParameter(java.lang.StringBuffer buffer, java.lang.String key, double value)
          Add the ", PARAMETER["", ]" string to the specified string buffer.
(package private) static void addParameter(java.lang.StringBuffer buffer, java.lang.String key, int value)
          Add the ", PARAMETER["", ]" string to the specified string buffer.
 java.awt.Shape createTransformedShape(java.awt.Shape shape)
          Transform the specified shape.
(package private)  java.awt.Shape createTransformedShape(java.awt.Shape shape, java.awt.geom.AffineTransform preTr, java.awt.geom.AffineTransform postTr, int quadDir)
          Transforme une forme géométrique.
 Matrix derivative(CoordinatePoint point)
          Gets the derivative of this transform at a point.
 Matrix derivative(java.awt.geom.Point2D point)
          Gets the derivative of this transform at a point.
 boolean equals(java.lang.Object object)
          Compares the specified object with this math transform for equality.
protected  java.lang.String getName(java.util.Locale locale)
          Returns a human readable name, if available.
 int hashCode()
          Returns a hash value for this transform.
 MathTransform inverse()
          Creates the inverse transform of this object.
private static Matrix invert(Matrix matrix)
          Invert the specified matrix in place.
(package private) static java.lang.StringBuffer paramMT(java.lang.String classification)
          Returns a string buffer initialized with "PARAM_MT" and a classification name.
(package private)  java.lang.Object toOpenGIS(java.lang.Object adapters)
          Returns an OpenGIS interface for this math transform.
 java.lang.String toString()
          Returns a string représentation of this transform.
 CoordinatePoint transform(CoordinatePoint ptSrc, CoordinatePoint ptDst)
          Transforms the specified ptSrc and stores the result in ptDst.
 void transform(float[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts)
          Transforms a list of coordinate point ordinal values.
 java.awt.geom.Point2D transform(java.awt.geom.Point2D ptSrc, java.awt.geom.Point2D ptDst)
          Transforms the specified ptSrc and stores the result in ptDst.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.deegree_impl.model.ct.MathTransform
getDimSource, getDimTarget, isIdentity, transform
 

Constructor Detail

AbstractMathTransform

public AbstractMathTransform()
Construct a math transform.

Method Detail

getName

protected java.lang.String getName(java.util.Locale locale)
Returns a human readable name, if available. If no name is available in the specified locale, then this method returns a name in an arbitrary locale. If no name is available in any locale, then this method returns null. The default implementation always returns null.

Parameters:
locale - The desired locale, or null for a default locale.
Returns:
The transform name localized in the specified locale if possible, or null if no name is available in any locale.

transform

public java.awt.geom.Point2D transform(java.awt.geom.Point2D ptSrc,
                                       java.awt.geom.Point2D ptDst)
                                throws TransformException
Transforms the specified ptSrc and stores the result in ptDst. The default implementation invokes MathTransform.transform(double[],int,double[],int,int) using a temporary array of doubles.

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 stroring the result in ptDst.
Throws:
MismatchedDimensionException - if this transform doesn't map two-dimensional coordinate systems.
TransformException - if the point can't be transformed.
See Also:
MathTransform2D.transform(Point2D,Point2D)

transform

public CoordinatePoint transform(CoordinatePoint ptSrc,
                                 CoordinatePoint ptDst)
                          throws TransformException
Transforms the specified ptSrc and stores the result in ptDst. The default implementation invokes MathTransform.transform(double[],int,double[],int,int).

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:
TransformException - if the point can't be transformed.

transform

public void transform(float[] srcPts,
                      int srcOff,
                      float[] dstPts,
                      int dstOff,
                      int numPts)
               throws TransformException
Transforms a list of coordinate point ordinal values. The default implementation invokes MathTransform.transform(double[],int,double[],int,int) using a temporary array of doubles.

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.

createTransformedShape

public java.awt.Shape createTransformedShape(java.awt.Shape shape)
                                      throws TransformException
Transform the specified shape. The default implementation compute quadratic curves using three points for each shape's segments.

Parameters:
shape - Shape to transform.
Returns:
Transformed shape, or shape if this transform is the identity transform.
Throws:
java.lang.IllegalStateException - if this transform doesn't map 2D coordinate systems.
TransformException - if a transform failed.
See Also:
MathTransform2D.createTransformedShape(Shape)

createTransformedShape

final java.awt.Shape createTransformedShape(java.awt.Shape shape,
                                            java.awt.geom.AffineTransform preTr,
                                            java.awt.geom.AffineTransform postTr,
                                            int quadDir)
                                     throws TransformException
Transforme une forme géométrique. Cette méthode copie toujours les coordonnées transformées dans un nouvel objet. La plupart du temps, elle produira un objet GeneralPath. Elle peut aussi retourner des objets Line2D ou QuadCurve2D si une telle simplification est possible.

Parameters:
shape - Forme géométrique à transformer.
preTr - Transformation affine à appliquer avant de transformer la forme shape, ou null pour ne pas en appliquer. Cet argument sera surtout utile lors des transformations inverses.
postTr - Transformation affine à appliquer après avoir transformée la forme shape, ou null pour ne pas en appliquer. Cet argument sera surtout utile lors des transformations directes.
quadDir - Direction des courbes quadratiques (Geometry.HORIZONTAL ou Geometry.PARALLEL).
Returns:
La forme géométrique transformée.
Throws:
MismatchedDimensionException - if this transform doesn't map two-dimensional coordinate systems.
TransformException - Si une transformation a échoué.

derivative

public Matrix derivative(java.awt.geom.Point2D point)
                  throws TransformException
Gets the derivative of this transform at a point. The default implementation invokes derivative(CoordinatePoint).

Parameters:
point - The coordinate point where to evaluate the derivative.
Returns:
The derivative at the specified point as a 2x2 matrix.
Throws:
MismatchedDimensionException - if the input dimension is not 2.
TransformException - if the derivative can't be evaluated at the specified point.
See Also:
MathTransform2D.derivative(Point2D)

derivative

public Matrix derivative(CoordinatePoint point)
                  throws TransformException
Gets the derivative of this transform at a point. The default implementation throws an UnsupportedOperationException (note: this default implementation may change in a future version).

Specified by:
derivative in interface MathTransform
Parameters:
point - The coordinate point where to evaluate the derivative.
Returns:
The derivative at the specified point (never null).
Throws:
TransformException - if the derivative can't be evaluated at the specified point.

inverse

public MathTransform inverse()
                      throws NoninvertibleTransformException
Creates the inverse transform of this object. The default implementation returns this if this transform is an identity transform, and throws a NoninvertibleTransformException otherwise. Subclasses should override this method.

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

hashCode

public int hashCode()
Returns a hash value for this transform.


equals

public boolean equals(java.lang.Object object)
Compares the specified object with this math transform for equality. The default implementation checks if object is an instance of the same class than this. Subclasses should override this method in order to compare internal fields.


toString

public java.lang.String toString()
Returns a string représentation of this transform. Subclasses should override this method in order to returns Well Know Text (WKT) instead.


paramMT

static java.lang.StringBuffer paramMT(java.lang.String classification)
Returns a string buffer initialized with "PARAM_MT" and a classification name. This is a convenience method for WKT formatting.


addParameter

static void addParameter(java.lang.StringBuffer buffer,
                         java.lang.String key,
                         double value)
Add the ", PARAMETER["", ]" string to the specified string buffer. This is a convenience method for constructing WKT for "PARAM_MT".


addParameter

static void addParameter(java.lang.StringBuffer buffer,
                         java.lang.String key,
                         int value)
Add the ", PARAMETER["", ]" string to the specified string buffer. This is a convenience method for constructing WKT for "PARAM_MT".


toOpenGIS

java.lang.Object toOpenGIS(java.lang.Object adapters)
Returns an OpenGIS interface for this math transform. The returned object is suitable for RMI use. Note: The returned type is a generic Object in order to avoid too early class loading of OpenGIS interface.


invert

private static Matrix invert(Matrix matrix)
                      throws NoninvertibleTransformException
Invert the specified matrix in place. If the matrix can't be inverted because of a SingularMatrixException, then the exception is wrapped into a NoninvertibleTransformException.

Throws:
NoninvertibleTransformException