public class Matrix2D
extends java.lang.Object
The following sample sample illustrates how to use Matrix2D in order to calculate absolute positioning for the text on the page.Element element = eb.CreateImage(Image(...)); double deg2rad = 3.1415926535 / 180.0; Matrix2D mtx = Matrix2D(1, 0, 0, 1, 0, 200); // Translate mtx.multiply(Matrix2D(300, 0, 0, 200, 0, 0)); // Scale mtx.multiply(Matrix2D.RotationMatrix( 90 * deg2rad )); // Rotate element.GetGState().SetTransform(mtx); writer.WritePlacedElement(element);
Matrix2D text_mtx = text_element.GetTextMatrix(); double x, y; for (CharIterator itr = text_element.getCharIterator(); itr.HasNext(); itr.Next()) { x = itr.current().x; // character positioning information y = itr.current().y; // Get current transformation matrix (CTM) Matrix2D ctm = text_element.getCTM(); // To get the absolute character positioning information concatenate current // text matrix with CTM and then multiply relative postitioning coordinates with // the resulting matrix. Matrix2D mtx = ctm.multiply(text_mtx); mtx.multPoint(x, y); }
Constructor and Description |
---|
Matrix2D()
Creates an identity matrix
|
Matrix2D(double a,
double b,
double c,
double d,
double h,
double v)
Creates a Matrix object based on six numbers that define an
affine transformation.
|
Modifier and Type | Method and Description |
---|---|
static Matrix2D |
__Create(long impl) |
long |
__GetHandle() |
void |
concat(double a,
double b,
double c,
double d,
double h,
double v)
The Concat method updates this matrix with the product of itself and another matrix
specified through an argument list.
|
void |
destroy()
Frees the native memory of the object.
|
boolean |
equals(java.lang.Object m)
equals determines whether the elements of this matrix are equal to
the elements of another matrix.
|
double |
getA()
Get a, the matrix element in the first row, second column.
|
double |
getB()
Get b, the matrix element in the first row, second column
Matrix2D elements are positioned as follows :
{ a b 0
c d 0
h v 1 }.
|
double |
getC()
Get c, the matrix element in the second row, first column
Matrix2D elements are positioned as follows :
{ a b 0
c d 0
h v 1 }.
|
double |
getD()
Get d, the matrix element in the second row, second column.
|
double |
getH()
Get h, the matrix element in the third row, first column.
|
double |
getV()
Get v, the matrix element in the third row, second column.
|
int |
hashCode() |
static Matrix2D |
identityMatrix()
Create identity matrix (1 0 0 1 0 0).
|
Matrix2D |
inverse()
If this matrix is invertible, the Inverse method returns its inverse matrix.
|
Matrix2D |
multiply(Matrix2D m)
Multiplies this matrix with another matrix and return the result in a new matrix.
|
java.awt.geom.Point2D.Double |
multPoint(double in_x,
double in_y)
Transform/multiply the point (in_out_x, in_out_y) using this matrix.
|
static Matrix2D |
rotationMatrix(double angle)
Rotation matrix.
|
Matrix2D |
scale(double h,
double v)
The Scale method updates this matrix with the product of itself and a scaling matrix.
|
void |
set(double a,
double b,
double c,
double d,
double h,
double v)
The Set method sets the elements of this matrix.
|
void |
setA(double a)
Set a, the matrix element in the first row, first column.
|
void |
setB(double b)
Set b, the matrix element in the first row, second column
Matrix2D elements are positioned as follows :
{ a b 0
c d 0
h v 1 }.
|
void |
setC(double c)
Set c, the matrix element in the second row, first column.
|
void |
setD(double d)
Set d, the matrix element in the second row, second column.
|
void |
setH(double h)
Set h, the matrix element in the third row, first column.
|
void |
setV(double v)
Set v, the matrix element in the third row, second column.
|
Matrix2D |
translate(double h,
double v)
The Translate method updates this matrix with the product of itself and a
translation matrix (i.e.
|
static Matrix2D |
zeroMatrix()
Create zero matrix (0 0 0 0 0 0).
|
public Matrix2D() throws PDFNetException
PDFNetException
public Matrix2D(double a, double b, double c, double d, double h, double v) throws PDFNetException
a
- the ab
- the bc
- the cd
- the dh
- the hv
- the vPDFNetException
public double getA() throws PDFNetException
PDFNetException
public void setA(double a) throws PDFNetException
a
- the new a (the matrix element in the first row, first column)PDFNetException
public double getB() throws PDFNetException
PDFNetException
public void setB(double b) throws PDFNetException
b
- the new b, the matrix element in the first row, second columnPDFNetException
public double getC() throws PDFNetException
PDFNetException
public void setC(double c) throws PDFNetException
c
- the new c, the matrix element in the second row, first column.PDFNetException
public double getD() throws PDFNetException
PDFNetException
public void setD(double d) throws PDFNetException
d
- the new d, the matrix element in the second row, second column.PDFNetException
public double getH() throws PDFNetException
PDFNetException
public void setH(double h) throws PDFNetException
h
- the new h, the matrix element in the third row, first column.PDFNetException
public double getV() throws PDFNetException
PDFNetException
public void setV(double v) throws PDFNetException
v
- the new v, the matrix element in the third row, second column.PDFNetException
public void set(double a, double b, double c, double d, double h, double v) throws PDFNetException
a
- the matrix element in the first row, first column.b
- the matrix element in the first row, second column.c
- the matrix element in the second row, first column.d
- the matrix element in the second row, second column.h
- the matrix element in the third row, first column.v
- the matrix element in the third row, second column.PDFNetException
public void concat(double a, double b, double c, double d, double h, double v) throws PDFNetException
a
- the matrix element in the first row, first column.b
- the matrix element in the first row, second column.c
- the matrix element in the second row, first column.d
- the matrix element in the second row, second column.h
- the matrix element in the third row, first column.v
- the matrix element in the third row, second column.PDFNetException
public Matrix2D multiply(Matrix2D m) throws PDFNetException
m
- another Matrix2D objectPDFNetException
public boolean equals(java.lang.Object m)
equals
in class java.lang.Object
m
- A Matrix object that is compared with this Matrix object.public int hashCode()
hashCode
in class java.lang.Object
public java.awt.geom.Point2D.Double multPoint(double in_x, double in_y) throws PDFNetException
in_x
- x coordinate of the given pointin_y
- y coordinate of the given pointPDFNetException
public Matrix2D inverse() throws PDFNetException
PDFNetException
public Matrix2D translate(double h, double v) throws PDFNetException
h
- the horizontal component of the translation.v
- the vertical component of the translation.PDFNetException
public Matrix2D scale(double h, double v) throws PDFNetException
h
- the horizontal scale factor.v
- the vertical scale factorPDFNetException
public static Matrix2D zeroMatrix() throws PDFNetException
PDFNetException
public static Matrix2D identityMatrix() throws PDFNetException
PDFNetException
public static Matrix2D rotationMatrix(double angle) throws PDFNetException
angle
- the angle of rotation in radians.
Positive values specify clockwise rotation.PDFNetException
public void destroy() throws PDFNetException
PDFNetException
public static Matrix2D __Create(long impl)
public long __GetHandle()