Class Matrix
- All Implemented Interfaces:
Proxy
PangoMatrix specifies a transformation between user-space
and device coordinates.
The transformation is given by
x_device = x_user * matrix->xx + y_user * matrix->xy + matrix->x0;
y_device = x_user * matrix->yx + y_user * matrix->yy + matrix->y0;
- Since:
- 1.6
-
Constructor Summary
ConstructorsConstructorDescriptionMatrix()Allocate a new Matrix.Matrix(double xx, double xy, double yx, double yy, double x0, double y0) Allocate a new Matrix with the fields set to the provided values.Allocate a new Matrix with the fields set to the provided values.Allocate a new Matrix.Matrix(MemorySegment address) Create a Matrix proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionvoidChanges the transformation represented by this Matrix to be the transformation given by first applying transformation given bynewMatrixthen applying the original transformation.@Nullable Matrixcopy()Copies aPangoMatrix.voidfree()Free aPangoMatrix.doubleReturns the scale factor of a matrix on the height of the font.voidgetFontScaleFactors(@Nullable Out<Double> xscale, @Nullable Out<Double> yscale) Calculates the scale factor of a matrix on the width and height of the font.static MemoryLayoutThe memory layout of the native struct.doubleGets the slant ratio of a matrix.static @Nullable TypegetType()Get the GType of the Matrix classdoublereadX0()Read the value of the fieldx0.doublereadXx()Read the value of the fieldxx.doublereadXy()Read the value of the fieldxy.doublereadY0()Read the value of the fieldy0.doublereadYx()Read the value of the fieldyx.doublereadYy()Read the value of the fieldyy.voidrotate(double degrees) Changes the transformation represented by this Matrix to be the transformation given by first rotating bydegreesdegrees counter-clockwise then applying the original transformation.voidscale(double scaleX, double scaleY) Changes the transformation represented by this Matrix to be the transformation given by first scaling bysxin the X direction andsyin the Y direction then applying the original transformation.voidtransformDistance(Out<Double> dx, Out<Double> dy) Transforms the distance vector (dy)bymatrix.voidtransformPixelRectangle(@Nullable Rectangle rect) First transforms therectusingmatrix,then calculates the bounding box of the transformed rectangle.voidtransformPoint(Out<Double> x, Out<Double> y) Transforms the point (x,y)bymatrix.voidtransformRectangle(@Nullable Rectangle rect) First transformsrectusingmatrix,then calculates the bounding box of the transformed rectangle.voidtranslate(double tx, double ty) Changes the transformation represented by this Matrix to be the transformation given by first translating by (tx,ty)then applying the original transformation.voidwriteX0(double x0) Write a value in the fieldx0.voidwriteXx(double xx) Write a value in the fieldxx.voidwriteXy(double xy) Write a value in the fieldxy.voidwriteY0(double y0) Write a value in the fieldy0.voidwriteYx(double yx) Write a value in the fieldyx.voidwriteYy(double yy) Write a value in the fieldyy.Methods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Matrix
Create a Matrix proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
Matrix
Allocate a new Matrix.- Parameters:
arena- to control the memory allocation scope
-
Matrix
public Matrix()Allocate a new Matrix. The memory is allocated withArena.ofAuto(). -
Matrix
Allocate a new Matrix with the fields set to the provided values.- Parameters:
xx- value for the fieldxxxy- value for the fieldxyyx- value for the fieldyxyy- value for the fieldyyx0- value for the fieldx0y0- value for the fieldy0arena- to control the memory allocation scope
-
Matrix
public Matrix(double xx, double xy, double yx, double yy, double x0, double y0) Allocate a new Matrix with the fields set to the provided values. The memory is allocated withArena.ofAuto().- Parameters:
xx- value for the fieldxxxy- value for the fieldxyyx- value for the fieldyxyy- value for the fieldyyx0- value for the fieldx0y0- value for the fieldy0
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
readXx
public double readXx()Read the value of the fieldxx.- Returns:
- The value of the field
xx
-
writeXx
public void writeXx(double xx) Write a value in the fieldxx.- Parameters:
xx- The new value for the fieldxx
-
readXy
public double readXy()Read the value of the fieldxy.- Returns:
- The value of the field
xy
-
writeXy
public void writeXy(double xy) Write a value in the fieldxy.- Parameters:
xy- The new value for the fieldxy
-
readYx
public double readYx()Read the value of the fieldyx.- Returns:
- The value of the field
yx
-
writeYx
public void writeYx(double yx) Write a value in the fieldyx.- Parameters:
yx- The new value for the fieldyx
-
readYy
public double readYy()Read the value of the fieldyy.- Returns:
- The value of the field
yy
-
writeYy
public void writeYy(double yy) Write a value in the fieldyy.- Parameters:
yy- The new value for the fieldyy
-
readX0
public double readX0()Read the value of the fieldx0.- Returns:
- The value of the field
x0
-
writeX0
public void writeX0(double x0) Write a value in the fieldx0.- Parameters:
x0- The new value for the fieldx0
-
readY0
public double readY0()Read the value of the fieldy0.- Returns:
- The value of the field
y0
-
writeY0
public void writeY0(double y0) Write a value in the fieldy0.- Parameters:
y0- The new value for the fieldy0
-
concat
Changes the transformation represented by this Matrix to be the transformation given by first applying transformation given bynewMatrixthen applying the original transformation.- Parameters:
newMatrix- aPangoMatrix- Since:
- 1.6
-
copy
Copies aPangoMatrix.- Returns:
- the newly allocated
PangoMatrix - Since:
- 1.6
-
free
public void free()Free aPangoMatrix.- Since:
- 1.6
-
getFontScaleFactor
public double getFontScaleFactor()Returns the scale factor of a matrix on the height of the font.That is, the scale factor in the direction perpendicular to the vector that the X coordinate is mapped to. If the scale in the X coordinate is needed as well, use
getFontScaleFactors(org.javagi.base.Out<java.lang.Double>, org.javagi.base.Out<java.lang.Double>).- Returns:
- the scale factor of this Matrix on the height of the font,
or 1.0 if this Matrix is
null. - Since:
- 1.12
-
getFontScaleFactors
Calculates the scale factor of a matrix on the width and height of the font.That is,
xscaleis the scale factor in the direction of the X coordinate, andyscaleis the scale factor in the direction perpendicular to the vector that the X coordinate is mapped to.Note that output numbers will always be non-negative.
- Parameters:
xscale- output scale factor in the x directionyscale- output scale factor perpendicular to the x direction- Since:
- 1.38
-
getSlantRatio
public double getSlantRatio()Gets the slant ratio of a matrix.For a simple shear matrix in the form:
1 λ 0 1
this is simply λ.
- Returns:
- the slant ratio of this Matrix
- Since:
- 1.50
-
rotate
public void rotate(double degrees) Changes the transformation represented by this Matrix to be the transformation given by first rotating bydegreesdegrees counter-clockwise then applying the original transformation.- Parameters:
degrees- degrees to rotate counter-clockwise- Since:
- 1.6
-
scale
public void scale(double scaleX, double scaleY) Changes the transformation represented by this Matrix to be the transformation given by first scaling bysxin the X direction andsyin the Y direction then applying the original transformation.- Parameters:
scaleX- amount to scale by in X directionscaleY- amount to scale by in Y direction- Since:
- 1.6
-
transformDistance
Transforms the distance vector (dy)bymatrix.This is similar to
transformPoint(org.javagi.base.Out<java.lang.Double>, org.javagi.base.Out<java.lang.Double>), except that the translation components of the transformation are ignored. The calculation of the returned vector is as follows:dx2 = dx1 * xx + dy1 * xy; dy2 = dx1 * yx + dy1 * yy;Affine transformations are position invariant, so the same vector always transforms to the same vector. If (
y1)transforms to (y2)then (dy1)will transform to (dy2)for all values ofx1andx2.- Parameters:
dx- in/out X component of a distance vectordy- in/out Y component of a distance vector- Since:
- 1.16
-
transformPixelRectangle
First transforms therectusingmatrix,then calculates the bounding box of the transformed rectangle.This function is useful for example when you want to draw a rotated
PangoLayoutto an image buffer, and want to know how large the image should be and how much you should shift the layout when rendering.For better accuracy, you should use
transformRectangle(org.gnome.pango.Rectangle)on original rectangle in Pango units and convert to pixels afterward usingPango.extentsToPixels(org.gnome.pango.Rectangle, org.gnome.pango.Rectangle)'s first argument.- Parameters:
rect- in/out bounding box in device units- Since:
- 1.16
-
transformPoint
-
transformRectangle
First transformsrectusingmatrix,then calculates the bounding box of the transformed rectangle.This function is useful for example when you want to draw a rotated
PangoLayoutto an image buffer, and want to know how large the image should be and how much you should shift the layout when rendering.If you have a rectangle in device units (pixels), use
transformPixelRectangle(org.gnome.pango.Rectangle).If you have the rectangle in Pango units and want to convert to transformed pixel bounding box, it is more accurate to transform it first (using this function) and pass the result to pango_extents_to_pixels(), first argument, for an inclusive rounded rectangle. However, there are valid reasons that you may want to convert to pixels first and then transform, for example when the transformed coordinates may overflow in Pango units (large matrix translation for example).
- Parameters:
rect- in/out bounding box in Pango units- Since:
- 1.16
-
translate
public void translate(double tx, double ty) Changes the transformation represented by this Matrix to be the transformation given by first translating by (tx,ty)then applying the original transformation.- Parameters:
tx- amount to translate in the X directionty- amount to translate in the Y direction- Since:
- 1.6
-