Class AbstractMathTransform2D
- Object
-
- FormattableObject
-
- AbstractMathTransform
-
- AbstractMathTransform2D
-
- All Implemented Interfaces:
Parameterized
,LenientComparable
,MathTransform
,MathTransform2D
- Direct Known Subclasses:
NormalizedProjection
,ZonedGridSystem
public abstract class AbstractMathTransform2D extends AbstractMathTransform implements MathTransform2D
Base class for math transforms that are known to be two-dimensional in all cases. Two-dimensional math transforms are not required to extend this class, however doing so may simplify their implementation.The simplest way to implement this abstract class is to provide an implementation for the following methods only:
However more performance may be gained by overriding the othertransform
methods as well.Immutability and thread safetyAll Apache SIS implementations ofMathTransform2D
are immutable and thread-safe. It is highly recommended that third-party implementations be immutable and thread-safe too. This means that unless otherwise noted in the javadoc,MathTransform2D
instances can be shared by many objects and passed between threads without synchronization.SerializationMathTransform2D
may or may not be serializable, at implementation choices. Most Apache SIS implementations are serializable, but the serialized objects are not guaranteed to be compatible with future SIS versions. Serialization should be used only for short term storage or RMI between applications running the same SIS version.- Since:
- 0.5
Defined in the
sis-referencing
module
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
AbstractMathTransform2D.Inverse
Base class for implementation of inverse math transforms.
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractMathTransform2D()
Constructor for subclasses.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Shape
createTransformedShape(Shape shape)
Transforms the specified shape.Matrix
derivative(Point2D point)
Gets the derivative of this transform at a point.int
getSourceDimensions()
Returns the dimension of input points, which is always 2.int
getTargetDimensions()
Returns the dimension of output points, which is always 2.MathTransform2D
inverse()
Returns the inverse transform of this object.Point2D
transform(Point2D ptSrc, Point2D ptDst)
Transforms the specifiedptSrc
and stores the result inptDst
.-
Methods inherited from class AbstractMathTransform
computeHashCode, derivative, equals, equals, formatTo, getContextualParameters, getParameterDescriptors, getParameterValues, hashCode, isIdentity, transform, transform, transform, transform, transform, transform, tryConcatenate
-
Methods inherited from class FormattableObject
print, toString, toString, toWKT
-
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface MathTransform
derivative, isIdentity, toWKT, transform, transform, transform, transform, transform
-
-
-
-
Method Detail
-
getSourceDimensions
public final int getSourceDimensions()
Returns the dimension of input points, which is always 2.- Specified by:
getSourceDimensions
in interfaceMathTransform
- Specified by:
getSourceDimensions
in classAbstractMathTransform
- Returns:
- the dimension of input points.
- See Also:
DefaultOperationMethod.getSourceDimensions()
-
getTargetDimensions
public final int getTargetDimensions()
Returns the dimension of output points, which is always 2.- Specified by:
getTargetDimensions
in interfaceMathTransform
- Specified by:
getTargetDimensions
in classAbstractMathTransform
- Returns:
- the dimension of output points.
- See Also:
DefaultOperationMethod.getTargetDimensions()
-
transform
public Point2D transform(Point2D ptSrc, Point2D ptDst) throws TransformException
Transforms the specifiedptSrc
and stores the result inptDst
. The default implementation invokesAbstractMathTransform.transform(double[], int, double[], int, boolean)
using a temporary array of doubles.- Specified by:
transform
in interfaceMathTransform2D
- Parameters:
ptSrc
- the coordinate point to be transformed.ptDst
- the coordinate point that stores the result of transformingptSrc
, ornull
if a new point shall be created.- Returns:
- the coordinate point after transforming
ptSrc
and storing the result inptDst
, or in a new point ifptDst
was null. - Throws:
TransformException
- if the point can not be transformed.- See Also:
MathTransform2D.transform(Point2D, Point2D)
-
createTransformedShape
public Shape createTransformedShape(Shape shape) throws TransformException
Transforms the specified shape. The default implementation computes quadratic curves using three points for each line segment in the shape. The returned object is often aPath2D
, but may also be aLine2D
or aQuadCurve2D
if such simplification is possible.- Specified by:
createTransformedShape
in interfaceMathTransform2D
- Parameters:
shape
- shape to transform.- Returns:
- transformed shape, or
shape
if this transform is the identity transform. - Throws:
TransformException
- if a transform failed.
-
derivative
public Matrix derivative(Point2D point) throws TransformException
Gets the derivative of this transform at a point. The default implementation performs the following steps:- Copy the coordinate in a temporary array and pass that array to the
AbstractMathTransform.transform(double[], int, double[], int, boolean)
method, with thederivate
boolean argument set totrue
. - If the later method returned a non-null matrix, returns that matrix.
Otherwise throws
TransformException
.
- Specified by:
derivative
in interfaceMathTransform2D
- Parameters:
point
- the coordinate point where to evaluate the derivative.- Returns:
- the derivative at the specified point as a 2×2 matrix.
- Throws:
TransformException
- if the derivative can not be evaluated at the specified point.
- Copy the coordinate in a temporary array and pass that array to the
-
inverse
public MathTransform2D inverse() throws NoninvertibleTransformException
Returns the inverse transform of this object. The default implementation returnsthis
if this transform is an identity transform, or throws an exception otherwise. Subclasses should override this method.- Specified by:
inverse
in interfaceMathTransform
- Specified by:
inverse
in interfaceMathTransform2D
- Overrides:
inverse
in classAbstractMathTransform
- Throws:
NoninvertibleTransformException
-
-