org.opengis.example.referencing
Class AffineTransform2D

Object
  extended by AffineTransform
      extended by AffineTransform2D
All Implemented Interfaces:
Serializable, Cloneable, MathTransform, MathTransform2D

public class AffineTransform2D
extends AffineTransform
implements MathTransform2D

A MathTransform2D backed by the Java2D AffineTransform.

Affine transforms are very commons in GIS - they can be used for scaling, flipping the y axis, applying unit conversions, etc.. The standard Java2D library provides an efficient general-purpose implementation of affine transform. This class extends the Java2D class for efficiency and for inter-operability with Java2D.

This affine transform is a special case of ProjectiveTransform restricted to the following cases:

Since:
3.1
See Also:
Serialized Form

Field Summary
 
Fields inherited from class AffineTransform
TYPE_FLIP, TYPE_GENERAL_ROTATION, TYPE_GENERAL_SCALE, TYPE_GENERAL_TRANSFORM, TYPE_IDENTITY, TYPE_MASK_ROTATION, TYPE_MASK_SCALE, TYPE_QUADRANT_ROTATION, TYPE_TRANSLATION, TYPE_UNIFORM_SCALE
 
Constructor Summary
AffineTransform2D()
          Creates a new transform initialized to the identity transform.
AffineTransform2D(AffineTransform tr)
          Creates a new transform initialized to the values of the given transform.
 
Method Summary
 Matrix derivative(DirectPosition point)
          Gets the derivative of this transform at a point.
 Matrix derivative(Point2D point)
          Gets the derivative of this transform at a point.
 int getSourceDimensions()
          Returns the source dimension, which is 2.
 int getTargetDimensions()
          Returns the target dimension, which is 2.
 MathTransform2D inverse()
          Returns the inverse of this affine transform.
 void setTransform(Matrix matrix)
          Sets this affine transform to the values of the given matrix.
 String toWKT()
          Unsupported operation.
 DirectPosition transform(DirectPosition ptSrc, DirectPosition ptDst)
          Transforms the specified ptSrc and stores the result in ptDst.
 
Methods inherited from class AffineTransform
clone, concatenate, createInverse, createTransformedShape, deltaTransform, deltaTransform, equals, getDeterminant, getMatrix, getQuadrantRotateInstance, getQuadrantRotateInstance, getRotateInstance, getRotateInstance, getRotateInstance, getRotateInstance, getScaleInstance, getScaleX, getScaleY, getShearInstance, getShearX, getShearY, getTranslateInstance, getTranslateX, getTranslateY, getType, hashCode, inverseTransform, inverseTransform, invert, isIdentity, preConcatenate, quadrantRotate, quadrantRotate, rotate, rotate, rotate, rotate, scale, setToIdentity, setToQuadrantRotation, setToQuadrantRotation, setToRotation, setToRotation, setToRotation, setToRotation, setToScale, setToShear, setToTranslation, setTransform, setTransform, shear, toString, transform, transform, transform, transform, transform, transform, translate
 
Methods inherited from class Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface MathTransform2D
createTransformedShape, transform
 
Methods inherited from interface MathTransform
isIdentity, transform, transform, transform, transform
 

Constructor Detail

AffineTransform2D

public AffineTransform2D()
Creates a new transform initialized to the identity transform.


AffineTransform2D

public AffineTransform2D(AffineTransform tr)
Creates a new transform initialized to the values of the given transform.

Parameters:
tr - The transform to copy.
Method Detail

setTransform

public void setTransform(Matrix matrix)
                  throws IllegalArgumentException
Sets this affine transform to the values of the given matrix. The matrix size must be 3×3 and the last row shall contains the [0 0 1] values.

Parameters:
matrix - The matrix to copy in this affine transform.
Throws:
IllegalArgumentException - If the matrix size is not 3×3, or the transform is not affine.

getSourceDimensions

public final int getSourceDimensions()
Returns the source dimension, which is 2. This number of dimensions can not be changed.

Specified by:
getSourceDimensions in interface MathTransform

getTargetDimensions

public final int getTargetDimensions()
Returns the target dimension, which is 2. This number of dimensions can not be changed.

Specified by:
getTargetDimensions in interface MathTransform

transform

public DirectPosition transform(DirectPosition ptSrc,
                                DirectPosition ptDst)
                         throws MismatchedDimensionException
Transforms the specified ptSrc and stores the result in ptDst. This method delegates its work to AffineTransform.transform(Point2D, Point2D).

Specified by:
transform in interface MathTransform
Parameters:
ptSrc - the coordinate point to be transformed.
ptDst - the coordinate point that stores the transform result, 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 exactly 2 dimensions.

derivative

public Matrix derivative(DirectPosition point)
                  throws MismatchedDimensionException
Gets the derivative of this transform at a point. This method delegates its work to derivative(Point2D).

Specified by:
derivative in interface MathTransform
Parameters:
point - Ignored (except for the dimension, which is checked as a matter of principle).
Returns:
The derivative (never null).
Throws:
MismatchedDimensionException - if point doesn't have the expected dimension.

derivative

public Matrix derivative(Point2D point)
Gets the derivative of this transform at a point. The derivative of an affine transform is constant everywhere.

Specified by:
derivative in interface MathTransform2D
Parameters:
point - Ignored - may be null.
Returns:
The derivative (never null).

inverse

public MathTransform2D inverse()
                        throws NoninvertibleTransformException
Returns the inverse of this affine transform.

Specified by:
inverse in interface MathTransform
Specified by:
inverse in interface MathTransform2D
Throws:
NoninvertibleTransformException

toWKT

public String toWKT()
             throws UnsupportedOperationException
Unsupported operation.

Specified by:
toWKT in interface MathTransform
Throws:
UnsupportedOperationException


Copyright © 1994–2014 Open Geospatial Consortium. All rights reserved.