Package com.itextpdf.kernel.geom
Class AffineTransform
- java.lang.Object
-
- com.itextpdf.kernel.geom.AffineTransform
-
- All Implemented Interfaces:
java.lang.Cloneable
public class AffineTransform extends java.lang.Object implements java.lang.Cloneable
-
-
Field Summary
Fields Modifier and Type Field Description (package private) double
m00
The values of transformation matrix(package private) double
m01
(package private) double
m02
(package private) double
m10
(package private) double
m11
(package private) double
m12
(package private) int
type
The transformationtype
static int
TYPE_FLIP
The type of affine transformation.static int
TYPE_GENERAL_ROTATION
The type of affine transformation.static int
TYPE_GENERAL_SCALE
The type of affine transformation.static int
TYPE_GENERAL_TRANSFORM
The type of affine transformation.static int
TYPE_IDENTITY
The type of affine transformation.static int
TYPE_MASK_ROTATION
The type of affine transformation.static int
TYPE_MASK_SCALE
The type of affine transformation.static int
TYPE_QUADRANT_ROTATION
The type of affine transformation.static int
TYPE_TRANSLATION
The type of affine transformation.static int
TYPE_UNIFORM_SCALE
The type of affine transformation.(package private) static int
TYPE_UNKNOWN
TheTYPE_UNKNOWN
is an initial type value.(package private) static double
ZERO
The min value equivalent to zero.
-
Constructor Summary
Constructors Constructor Description AffineTransform()
AffineTransform(double[] matrix)
AffineTransform(double m00, double m10, double m01, double m11, double m02, double m12)
AffineTransform(float[] matrix)
AffineTransform(AffineTransform t)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AffineTransform
clone()
Creates a "deep copy" of this AffineTransform, meaning the object returned by this method will be independent of the object being cloned.void
concatenate(AffineTransform t)
AffineTransform
createInverse()
void
deltaTransform(double[] src, int srcOff, double[] dst, int dstOff, int length)
Point
deltaTransform(Point src, Point dst)
boolean
equals(java.lang.Object o)
double
getDeterminant()
void
getMatrix(double[] matrix)
void
getMatrix(float[] matrix)
static AffineTransform
getRotateInstance(double angle)
Get an affine transformation representing a counter-clockwise rotation over the passed anglestatic AffineTransform
getRotateInstance(double angle, double x, double y)
Get an affine transformation representing a counter-clockwise rotation over the passed angle, using the passed point as the center of rotationstatic AffineTransform
getScaleInstance(double scx, double scY)
double
getScaleX()
double
getScaleY()
static AffineTransform
getShearInstance(double shx, double shy)
double
getShearX()
double
getShearY()
static AffineTransform
getTranslateInstance(double mx, double my)
double
getTranslateX()
double
getTranslateY()
int
getType()
Method returns type of affine transformation.int
hashCode()
void
inverseTransform(double[] src, int srcOff, double[] dst, int dstOff, int length)
void
inverseTransform(float[] src, int srcOff, float[] dst, int dstOff, int length)
Point
inverseTransform(Point src, Point dst)
boolean
isIdentity()
(package private) AffineTransform
multiply(AffineTransform t1, AffineTransform t2)
Multiply matrix of two AffineTransform objectsvoid
preConcatenate(AffineTransform t)
void
rotate(double angle)
Add a counter-clockwise rotation to this transformationvoid
rotate(double angle, double px, double py)
Add a counter-clockwise rotation to this transformation, using the passed point as the center of rotationvoid
scale(double scx, double scy)
void
setToIdentity()
void
setToRotation(double angle)
Set this affine transformation to represent a rotation over the passed anglevoid
setToRotation(double angle, double px, double py)
Set this affine transformation to represent a rotation over the passed angle, using the passed point as the center of rotationvoid
setToScale(double scx, double scy)
void
setToShear(double shx, double shy)
void
setToTranslation(double mx, double my)
void
setTransform(double m00, double m10, double m01, double m11, double m02, double m12)
void
setTransform(float m00, float m10, float m01, float m11, float m02, float m12)
void
setTransform(AffineTransform t)
void
shear(double shx, double shy)
void
transform(double[] src, int srcOff, double[] dst, int dstOff, int length)
void
transform(double[] src, int srcOff, float[] dst, int dstOff, int length)
void
transform(float[] src, int srcOff, double[] dst, int dstOff, int length)
void
transform(float[] src, int srcOff, float[] dst, int dstOff, int length)
void
transform(Point[] src, int srcOff, Point[] dst, int dstOff, int length)
Point
transform(Point src, Point dst)
void
translate(double mx, double my)
-
-
-
Field Detail
-
TYPE_IDENTITY
public static final int TYPE_IDENTITY
The type of affine transformation. SeegetType()
.- See Also:
- Constant Field Values
-
TYPE_TRANSLATION
public static final int TYPE_TRANSLATION
The type of affine transformation. SeegetType()
.- See Also:
- Constant Field Values
-
TYPE_UNIFORM_SCALE
public static final int TYPE_UNIFORM_SCALE
The type of affine transformation. SeegetType()
.- See Also:
- Constant Field Values
-
TYPE_GENERAL_SCALE
public static final int TYPE_GENERAL_SCALE
The type of affine transformation. SeegetType()
.- See Also:
- Constant Field Values
-
TYPE_QUADRANT_ROTATION
public static final int TYPE_QUADRANT_ROTATION
The type of affine transformation. SeegetType()
.- See Also:
- Constant Field Values
-
TYPE_GENERAL_ROTATION
public static final int TYPE_GENERAL_ROTATION
The type of affine transformation. SeegetType()
.- See Also:
- Constant Field Values
-
TYPE_GENERAL_TRANSFORM
public static final int TYPE_GENERAL_TRANSFORM
The type of affine transformation. SeegetType()
.- See Also:
- Constant Field Values
-
TYPE_FLIP
public static final int TYPE_FLIP
The type of affine transformation. SeegetType()
.- See Also:
- Constant Field Values
-
TYPE_MASK_SCALE
public static final int TYPE_MASK_SCALE
The type of affine transformation. SeegetType()
.- See Also:
- Constant Field Values
-
TYPE_MASK_ROTATION
public static final int TYPE_MASK_ROTATION
The type of affine transformation. SeegetType()
.- See Also:
- Constant Field Values
-
TYPE_UNKNOWN
static final int TYPE_UNKNOWN
TheTYPE_UNKNOWN
is an initial type value.- See Also:
- Constant Field Values
-
ZERO
static final double ZERO
The min value equivalent to zero. If absolute value less then ZERO it considered as zero.- See Also:
- Constant Field Values
-
m00
double m00
The values of transformation matrix
-
m10
double m10
-
m01
double m01
-
m11
double m11
-
m02
double m02
-
m12
double m12
-
type
int type
The transformationtype
-
-
Constructor Detail
-
AffineTransform
public AffineTransform()
-
AffineTransform
public AffineTransform(AffineTransform t)
-
AffineTransform
public AffineTransform(double m00, double m10, double m01, double m11, double m02, double m12)
-
AffineTransform
public AffineTransform(float[] matrix)
-
AffineTransform
public AffineTransform(double[] matrix)
-
-
Method Detail
-
getType
public int getType()
Method returns type of affine transformation.Transform matrix is m00 m01 m02 m10 m11 m12
According analytic geometry new basis vectors are (m00, m01) and (m10, m11), translation vector is (m02, m12). Original basis vectors are (1, 0) and (0, 1). Type transformations classification:
TYPE_IDENTITY
- new basis equals original one and zero translationTYPE_TRANSLATION
- translation vector isn't zeroTYPE_UNIFORM_SCALE
- vectors length of new basis equalsTYPE_GENERAL_SCALE
- vectors length of new basis doesn't equalTYPE_FLIP
- new basis vector orientation differ from original oneTYPE_QUADRANT_ROTATION
- new basis is rotated by 90, 180, 270, or 360 degreesTYPE_GENERAL_ROTATION
- new basis is rotated by arbitrary angleTYPE_GENERAL_TRANSFORM
- transformation can't be inversed
- Returns:
- the type of this AffineTransform
-
getScaleX
public double getScaleX()
-
getScaleY
public double getScaleY()
-
getShearX
public double getShearX()
-
getShearY
public double getShearY()
-
getTranslateX
public double getTranslateX()
-
getTranslateY
public double getTranslateY()
-
isIdentity
public boolean isIdentity()
-
getMatrix
public void getMatrix(float[] matrix)
-
getMatrix
public void getMatrix(double[] matrix)
-
getDeterminant
public double getDeterminant()
-
setTransform
public void setTransform(float m00, float m10, float m01, float m11, float m02, float m12)
-
setTransform
public void setTransform(double m00, double m10, double m01, double m11, double m02, double m12)
-
setTransform
public void setTransform(AffineTransform t)
-
setToIdentity
public void setToIdentity()
-
setToTranslation
public void setToTranslation(double mx, double my)
-
setToScale
public void setToScale(double scx, double scy)
-
setToShear
public void setToShear(double shx, double shy)
-
setToRotation
public void setToRotation(double angle)
Set this affine transformation to represent a rotation over the passed angle- Parameters:
angle
- angle to rotate over in radians
-
setToRotation
public void setToRotation(double angle, double px, double py)
Set this affine transformation to represent a rotation over the passed angle, using the passed point as the center of rotation- Parameters:
angle
- angle to rotate over in radianspx
- x-coordinate of center of rotationpy
- y-coordinate of center of rotation
-
getTranslateInstance
public static AffineTransform getTranslateInstance(double mx, double my)
-
getScaleInstance
public static AffineTransform getScaleInstance(double scx, double scY)
-
getShearInstance
public static AffineTransform getShearInstance(double shx, double shy)
-
getRotateInstance
public static AffineTransform getRotateInstance(double angle)
Get an affine transformation representing a counter-clockwise rotation over the passed angle- Parameters:
angle
- angle in radians to rotate over- Returns:
AffineTransform
representing the rotation
-
getRotateInstance
public static AffineTransform getRotateInstance(double angle, double x, double y)
Get an affine transformation representing a counter-clockwise rotation over the passed angle, using the passed point as the center of rotation- Parameters:
angle
- angle in radians to rotate overx
- x-coordinate of center of rotationy
- y-coordinate of center of rotation- Returns:
AffineTransform
representing the rotation
-
translate
public void translate(double mx, double my)
-
scale
public void scale(double scx, double scy)
-
shear
public void shear(double shx, double shy)
-
rotate
public void rotate(double angle)
Add a counter-clockwise rotation to this transformation- Parameters:
angle
- angle in radians to rotate over
-
rotate
public void rotate(double angle, double px, double py)
Add a counter-clockwise rotation to this transformation, using the passed point as the center of rotation- Parameters:
angle
- angle in radians to rotate overpx
- x-coordinate of center of rotationpy
- y-coordinate of center of rotation
-
multiply
AffineTransform multiply(AffineTransform t1, AffineTransform t2)
Multiply matrix of two AffineTransform objects- Parameters:
t1
- - the AffineTransform object is a multiplicandt2
- - the AffineTransform object is a multiplier- Returns:
- an AffineTransform object that is a result of t1 multiplied by matrix t2.
-
concatenate
public void concatenate(AffineTransform t)
-
preConcatenate
public void preConcatenate(AffineTransform t)
-
createInverse
public AffineTransform createInverse() throws NoninvertibleTransformException
- Throws:
NoninvertibleTransformException
-
transform
public void transform(double[] src, int srcOff, double[] dst, int dstOff, int length)
-
transform
public void transform(float[] src, int srcOff, float[] dst, int dstOff, int length)
-
transform
public void transform(float[] src, int srcOff, double[] dst, int dstOff, int length)
-
transform
public void transform(double[] src, int srcOff, float[] dst, int dstOff, int length)
-
deltaTransform
public void deltaTransform(double[] src, int srcOff, double[] dst, int dstOff, int length)
-
inverseTransform
public Point inverseTransform(Point src, Point dst) throws NoninvertibleTransformException
- Throws:
NoninvertibleTransformException
-
inverseTransform
public void inverseTransform(double[] src, int srcOff, double[] dst, int dstOff, int length) throws NoninvertibleTransformException
- Throws:
NoninvertibleTransformException
-
inverseTransform
public void inverseTransform(float[] src, int srcOff, float[] dst, int dstOff, int length) throws NoninvertibleTransformException
- Throws:
NoninvertibleTransformException
-
clone
public AffineTransform clone() throws java.lang.CloneNotSupportedException
Creates a "deep copy" of this AffineTransform, meaning the object returned by this method will be independent of the object being cloned.- Overrides:
clone
in classjava.lang.Object
- Returns:
- the copied AffineTransform.
- Throws:
java.lang.CloneNotSupportedException
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-