Class AffineTransform
- java.lang.Object
-
- com.pdftools.toolbox.internal.NativeBase
-
- com.pdftools.toolbox.geometry.real.AffineTransform
-
public class AffineTransform extends NativeBase
-
-
Constructor Summary
Constructors Constructor Description AffineTransform()
Constructor.AffineTransform(double a, double b, double c, double d, double e, double f)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
concatenate(AffineTransform other)
Concatenate transform with other transform.boolean
equals(java.lang.Object obj)
double
getA()
Getsa
double
getB()
Getsb
double
getC()
Getsc
double
getD()
Getsd
double
getE()
Getse
double
getF()
Getsf
static AffineTransform
getIdentity()
The identity transform (Getter)int
hashCode()
void
invert()
Invert the transformvoid
rotate(double angle, Point center)
Rotate.void
scale(double sx, double sy)
Scale.void
setA(double a)
Setsa
void
setB(double b)
Setsb
void
setC(double c)
Setsc
void
setD(double d)
Setsd
void
setE(double e)
Setse
void
setF(double f)
Setsf
void
skew(double alpha, double beta)
Skew.Point
transformPoint(Point original)
Transforms the given point.Quadrilateral
transformQuadrilateral(Quadrilateral original)
Transform a given quadrilateralQuadrilateral
transformRectangle(Rectangle original)
Transform the given rectanglevoid
translate(double tx, double ty)
Translate.
-
-
-
Field Detail
-
a
public double a
The 'a' matrix element.
This is the 'a' element in the affine transformation matrix [a b 0; c d 0; e f 1]
-
b
public double b
The 'b' matrix element.
This is the 'b' element in the affine transformation matrix [a b 0; c d 0; e f 1]
-
c
public double c
The 'c' matrix element.
This is the 'c' element in the affine transformation matrix [a b 0; c d 0; e f 1]
-
d
public double d
The 'd' matrix element.
This is the 'd' element in the affine transformation matrix [a b 0; c d 0; e f 1]
-
e
public double e
The 'e' matrix element.
This is the 'e' element in the affine transformation matrix [a b 0; c d 0; e f 1]
-
f
public double f
The 'f' matrix element.
This is the 'f' element in the affine transformation matrix [a b 0; c d 0; e f 1]
-
-
Method Detail
-
getA
public double getA()
Getsa
-
setA
public void setA(double a)
Setsa
-
getB
public double getB()
Getsb
-
setB
public void setB(double b)
Setsb
-
getC
public double getC()
Getsc
-
setC
public void setC(double c)
Setsc
-
getD
public double getD()
Getsd
-
setD
public void setD(double d)
Setsd
-
getE
public double getE()
Getse
-
setE
public void setE(double e)
Setse
-
getF
public double getF()
Getsf
-
setF
public void setF(double f)
Setsf
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
translate
public void translate(double tx, double ty)
Translate.
Translations are specified as [1 0 0 1 tx ty], where tx and ty are the distances to translate the origin of the coordinate system in the horizontal and vertical dimensions, respectively.- Parameters:
tx
- horizontal translationty
- vertical translation- Throws:
java.lang.IllegalStateException
- If the affine transform is singular, e.g. default initialized. (UsegetIdentity()
as an initial value.)
-
scale
public void scale(double sx, double sy)
Scale.
Scaling is obtained by [sx 0 0 sy 0 0]. This scales the coordinates so that 1 unit in the horizontal and vertical dimensions of the new coordinate system is the same size as sx and sy units, respectively, in the previous coordinate system.- Parameters:
sx
- horizontal scale factorsy
- vertical scale factor- Throws:
java.lang.IllegalStateException
- If the affine transform is singular, e.g. default initialized. (UsegetIdentity()
as an initial value.)
-
rotate
public void rotate(double angle, Point center)
Rotate.
Rotations are produced by [cos(a) sin(a) -sin(a) cos(a) 0 0], which has the effect of rotating the coordinate system axes by an angle "a" in counterclockwise direction around the origin.
If the given
center
is notnull
, then the rotation is performed around the given center point, which is equivalent to the following sequence:-
translate(double, double)
tocenter
. -
rotate(double, com.pdftools.toolbox.geometry.real.Point)
byangle
around the origin. -
translate(double, double)
"back" to the original origin.
- Parameters:
angle
- The angle of the rotation in degrees.center
- The center of the rotation. Ifnull
then the origin (0/0) is taken as center.- Throws:
java.lang.IllegalStateException
- If the affine transform is singular, e.g. default initialized. (UsegetIdentity()
as an initial value.)
-
-
skew
public void skew(double alpha, double beta)
Skew.
Skew is specified by [1 tan a tan b 1 0 0], which skews the x axis by an angle a and the y axis by an angle b.- Parameters:
alpha
- angle a in degreesbeta
- angle b in degrees- Throws:
java.lang.IllegalStateException
- If the affine transform is singular, e.g. default initialized. (UsegetIdentity()
as an initial value.)java.lang.IllegalArgumentException
- if any of the given angles is too close to 90 + k*180 degrees for k = ..., -2, -1, 0, 1, 2, ...
-
concatenate
public void concatenate(AffineTransform other)
Concatenate transform with other transform.
Concatenating a transform with an other transform is equivalent to left-multiplying the transform's matrix with with the other transform's matrix.- Parameters:
other
- the transform to be concatenated to this transform- Throws:
java.lang.IllegalStateException
- If the affine transform is singular, e.g. default initialized. (UsegetIdentity()
as an initial value.)java.lang.IllegalArgumentException
- If theother
affine transform is singular, e.g. default initialized. (UsegetIdentity()
as an initial value.)java.lang.IllegalArgumentException
- ifother
isnull
-
invert
public void invert()
Invert the transform
A transform usually maps from the transformed coordinate system to the untransformed coordinate system. Use this method to create the reverse transform.- Throws:
java.lang.IllegalStateException
- If the affine transform is singular, e.g. default initialized. (UsegetIdentity()
as an initial value.)
-
transformPoint
public Point transformPoint(Point original)
Transforms the given point.
- Parameters:
original
- the point to be transformed- Returns:
- the transformed point
- Throws:
java.lang.IllegalStateException
- If the affine transform is singular, e.g. default initialized. (UsegetIdentity()
as an initial value.)java.lang.IllegalArgumentException
- iforiginal
isnull
-
transformRectangle
public Quadrilateral transformRectangle(Rectangle original)
Transform the given rectangle
For a general affine transformation, the returnedQuadrilateral
is a parallelogram.- Parameters:
original
- the rectangle to be transformed- Returns:
- the transformed rectangle. For a general affine transform this is a parallelogram.
- Throws:
java.lang.IllegalStateException
- if the affine transform is singular, e.g. default initialized. (UsegetIdentity()
as an initial value.)java.lang.IllegalArgumentException
- iforiginal
isnull
-
transformQuadrilateral
public Quadrilateral transformQuadrilateral(Quadrilateral original)
Transform a given quadrilateral
If the input quadrilateral is a parallelogram, then the output is also a parallelogram.- Parameters:
original
- the quadrilateral to be transformed- Returns:
- the transformed quadrilateral. If the input is a parallelogram then the output is also a parallelogram.
- Throws:
java.lang.IllegalStateException
- if the affine transform is singular, e.g. default initialized. (UsegetIdentity()
as an initial value.)java.lang.IllegalArgumentException
- iforiginal
isnull
-
getIdentity
public static AffineTransform getIdentity()
The identity transform (Getter)
-
-