To create an affine transformation for translation, you first define an
AffineTransform
class. Then, you use the translate
method.
For example, to create an affine transform, transform
, that
translates by one-half of the width and height of a dimension, d
, you write
the following statements:
AffineTransform transform = new AffineTransform(); transform.translate(d.width / 2, d.height / 2);