Class AffineTransform

  • AffineTransform uses a 3x3 matrix to transform source coordinates into destination coordinates.

  • The transformation involves scaling, shearing, and translation of coordinates.

  • The class provides methods to retrieve the individual scaling, shearing, and translation elements.

  • An AffineTransform object can be used to create a new AffineTransformBuilder.

AffineTransform

A 3x3 matrix used to transform source coordinates (x1, y1) into destination coordinates (x2, y2)according to matrix multiplication:

[ x2 ]   [ scaleX shearX translateX ] [ x1 ][ y2 ] = [ shearY scaleY translateY ] [ y1 ][ 1  ]   [   0      0        1      ] [ 1  ]

After transformation,

x2 = scaleX * x1 + shearX * y1 + translateX;y2 = scaleY * y1 + shearY * x1 + translateY;

Methods

MethodReturn typeBrief description
getScaleX()NumberGets the X coordinate scaling element.
getScaleY()NumberGets the Y coordinate scaling element.
getShearX()NumberGets the X coordinate shearing element.
getShearY()NumberGets the Y coordinate shearing element.
getTranslateX()NumberGets the X coordinate translation element in points.
getTranslateY()NumberGets the Y coordinate translation element in points.
toBuilder()AffineTransformBuilderReturns a newAffineTransformBuilder based on this transform.

Detailed documentation

getScaleX()

Gets the X coordinate scaling element.

Return

Number


getScaleY()

Gets the Y coordinate scaling element.

Return

Number


getShearX()

Gets the X coordinate shearing element.

Return

Number


getShearY()

Gets the Y coordinate shearing element.

Return

Number


getTranslateX()

Gets the X coordinate translation element in points.

Return

Number


getTranslateY()

Gets the Y coordinate translation element in points.

Return

Number


toBuilder()

Returns a newAffineTransformBuilder based on this transform.

Return

AffineTransformBuilder

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-11 UTC.