Methods Summary |
---|
public java.lang.Object | clone()
try {
return super.clone();
} catch (CloneNotSupportedException e) {
throw new InternalError();
}
|
public void | concatenate(java.awt.geom.AffineTransform t)Applies the given AffineTransform to this AffineTransform via matrix
multiplication.
setTransform(multiply(t, this));
|
public java.awt.geom.AffineTransform | createInverse()Creates an AffineTransform that is the inverse of this transform.
double det = getDeterminant();
if (Math.abs(det) < ZERO) {
// awt.204=Determinant is zero
throw new NoninvertibleTransformException(Messages.getString("awt.204")); //$NON-NLS-1$
}
return new AffineTransform(m11 / det, // m00
-m10 / det, // m10
-m01 / det, // m01
m00 / det, // m11
(m01 * m12 - m11 * m02) / det, // m02
(m10 * m02 - m00 * m12) / det // m12
);
|
public java.awt.Shape | createTransformedShape(java.awt.Shape src)Creates a new shape whose data is given by applying this AffineTransform
to the specified shape.
if (src == null) {
return null;
}
if (src instanceof GeneralPath) {
return ((GeneralPath)src).createTransformedShape(this);
}
PathIterator path = src.getPathIterator(this);
GeneralPath dst = new GeneralPath(path.getWindingRule());
dst.append(path, false);
return dst;
|
public java.awt.geom.Point2D | deltaTransform(java.awt.geom.Point2D src, java.awt.geom.Point2D dst)Transforms the point according to the linear transformation part of this
AffineTransformation (without applying the translation).
if (dst == null) {
if (dst instanceof Point2D.Double) {
dst = new Point2D.Double();
} else {
dst = new Point2D.Float();
}
}
double x = src.getX();
double y = src.getY();
dst.setLocation(x * m00 + y * m01, x * m10 + y * m11);
return dst;
|
public void | deltaTransform(double[] src, int srcOff, double[] dst, int dstOff, int length)Applies the linear transformation part of this AffineTransform (ignoring
the translation part) to a set of points given as an array of double
values where every two values in the array give the coordinates of a
point; the even-indexed values giving the x coordinates and the
odd-indexed values giving the y coordinates.
while (--length >= 0) {
double x = src[srcOff++];
double y = src[srcOff++];
dst[dstOff++] = x * m00 + y * m01;
dst[dstOff++] = x * m10 + y * m11;
}
|
public boolean | equals(java.lang.Object obj)
if (obj == this) {
return true;
}
if (obj instanceof AffineTransform) {
AffineTransform t = (AffineTransform)obj;
return m00 == t.m00 && m01 == t.m01 && m02 == t.m02 && m10 == t.m10 && m11 == t.m11
&& m12 == t.m12;
}
return false;
|
public double | getDeterminant()Gets the determinant of the linear transformation matrix.
return m00 * m11 - m01 * m10;
|
public void | getMatrix(double[] matrix)Writes the values of the transformation matrix into the given array of
doubles. If the array has length 4, only the linear transformation part
will be written into it. If it has length greater than 4, the translation
vector will be included as well.
matrix[0] = m00;
matrix[1] = m10;
matrix[2] = m01;
matrix[3] = m11;
if (matrix.length > 4) {
matrix[4] = m02;
matrix[5] = m12;
}
|
public static java.awt.geom.AffineTransform | getRotateInstance(double angle)Creates a new AffineTransformation that is a rotation alone. The new
transformation's type is TYPE_IDENTITY if the
AffineTransformation is the identity transformation, otherwise it's
TYPE_UNKNOWN .
AffineTransform t = new AffineTransform();
t.setToRotation(angle);
return t;
|
public static java.awt.geom.AffineTransform | getRotateInstance(double angle, double x, double y)Creates a new AffineTransformation that is a rotation followed by a
translation. Sets the type to TYPE_UNKNOWN .
AffineTransform t = new AffineTransform();
t.setToRotation(angle, x, y);
return t;
|
public static java.awt.geom.AffineTransform | getScaleInstance(double scx, double scY)Creates a new AffineTransformation that is a scale alone. The new
transformation's type is TYPE_IDENTITY if the
AffineTransformation is the identity transformation, otherwise it's
TYPE_UNKNOWN .
AffineTransform t = new AffineTransform();
t.setToScale(scx, scY);
return t;
|
public double | getScaleX()Gets the scale x entry of the transformation matrix (the upper left
matrix entry).
return m00;
|
public double | getScaleY()Gets the scale y entry of the transformation matrix (the lower right
entry of the linear transformation).
return m11;
|
public static java.awt.geom.AffineTransform | getShearInstance(double shx, double shy)Creates a new AffineTransformation that is a shear alone. The new
transformation's type is TYPE_IDENTITY if the
AffineTransformation is the identity transformation, otherwise it's
TYPE_UNKNOWN .
AffineTransform m = new AffineTransform();
m.setToShear(shx, shy);
return m;
|
public double | getShearX()Gets the shear x entry of the transformation matrix (the upper right
entry of the linear transformation).
return m01;
|
public double | getShearY()Gets the shear y entry of the transformation matrix (the lower left entry
of the linear transformation).
return m10;
|
public static java.awt.geom.AffineTransform | getTranslateInstance(double mx, double my)Creates a new AffineTransformation that is a translation alone with the
translation vector given by the values sent as parameters. The new
transformation's type is TYPE_IDENTITY if the
AffineTransformation is the identity transformation, otherwise it's
TYPE_TRANSLATION .
AffineTransform t = new AffineTransform();
t.setToTranslation(mx, my);
return t;
|
public double | getTranslateX()Gets the x coordinate of the translation vector.
return m02;
|
public double | getTranslateY()Gets the y coordinate of the translation vector.
return m12;
|
public int | getType()Returns type of the affine transformation.
The type is computed as follows: Label the entries of the transformation
matrix as three rows (m00, m01), (m10, m11), and (m02, m12). Then if the
original basis vectors are (1, 0) and (0, 1), the new basis vectors after
transformation are given by (m00, m01) and (m10, m11), and the
translation vector is (m02, m12).
The types are classified as follows: TYPE_IDENTITY - no change
TYPE_TRANSLATION - The translation vector isn't zero
TYPE_UNIFORM_SCALE - The new basis vectors have equal length
TYPE_GENERAL_SCALE - The new basis vectors dont' have equal length
TYPE_FLIP - The new basis vector orientation differs from the original
one TYPE_QUADRANT_ROTATION - The new basis is a rotation of the
original by 90, 180, 270, or 360 degrees TYPE_GENERAL_ROTATION - The
new basis is a rotation of the original by an arbitrary angle
TYPE_GENERAL_TRANSFORM - The transformation can't be inverted.
Note that multiple types are possible, thus the types can be combined
using bitwise combinations.
if (type != TYPE_UNKNOWN) {
return type;
}
int type = 0;
if (m00 * m01 + m10 * m11 != 0.0) {
type |= TYPE_GENERAL_TRANSFORM;
return type;
}
if (m02 != 0.0 || m12 != 0.0) {
type |= TYPE_TRANSLATION;
} else if (m00 == 1.0 && m11 == 1.0 && m01 == 0.0 && m10 == 0.0) {
type = TYPE_IDENTITY;
return type;
}
if (m00 * m11 - m01 * m10 < 0.0) {
type |= TYPE_FLIP;
}
double dx = m00 * m00 + m10 * m10;
double dy = m01 * m01 + m11 * m11;
if (dx != dy) {
type |= TYPE_GENERAL_SCALE;
} else if (dx != 1.0) {
type |= TYPE_UNIFORM_SCALE;
}
if ((m00 == 0.0 && m11 == 0.0) || (m10 == 0.0 && m01 == 0.0 && (m00 < 0.0 || m11 < 0.0))) {
type |= TYPE_QUADRANT_ROTATION;
} else if (m01 != 0.0 || m10 != 0.0) {
type |= TYPE_GENERAL_ROTATION;
}
return type;
|
public int | hashCode()
HashCode hash = new HashCode();
hash.append(m00);
hash.append(m01);
hash.append(m02);
hash.append(m10);
hash.append(m11);
hash.append(m12);
return hash.hashCode();
|
public java.awt.geom.Point2D | inverseTransform(java.awt.geom.Point2D src, java.awt.geom.Point2D dst)Transforms the point according to the inverse of this
AffineTransformation.
double det = getDeterminant();
if (Math.abs(det) < ZERO) {
// awt.204=Determinant is zero
throw new NoninvertibleTransformException(Messages.getString("awt.204")); //$NON-NLS-1$
}
if (dst == null) {
if (src instanceof Point2D.Double) {
dst = new Point2D.Double();
} else {
dst = new Point2D.Float();
}
}
double x = src.getX() - m02;
double y = src.getY() - m12;
dst.setLocation((x * m11 - y * m01) / det, (y * m00 - x * m10) / det);
return dst;
|
public void | inverseTransform(double[] src, int srcOff, double[] dst, int dstOff, int length)Applies the inverse of this AffineTransform to a set of points given as
an array of double values where every two values in the array give the
coordinates of a point; the even-indexed values giving the x coordinates
and the odd-indexed values giving the y coordinates.
double det = getDeterminant();
if (Math.abs(det) < ZERO) {
// awt.204=Determinant is zero
throw new NoninvertibleTransformException(Messages.getString("awt.204")); //$NON-NLS-1$
}
while (--length >= 0) {
double x = src[srcOff++] - m02;
double y = src[srcOff++] - m12;
dst[dstOff++] = (x * m11 - y * m01) / det;
dst[dstOff++] = (y * m00 - x * m10) / det;
}
|
public boolean | isIdentity()Checks if the AffineTransformation is the identity.
return getType() == TYPE_IDENTITY;
|
java.awt.geom.AffineTransform | multiply(java.awt.geom.AffineTransform t1, java.awt.geom.AffineTransform t2)Multiplies the matrix representations of two AffineTransform objects.
return new AffineTransform(t1.m00 * t2.m00 + t1.m10 * t2.m01, // m00
t1.m00 * t2.m10 + t1.m10 * t2.m11, // m01
t1.m01 * t2.m00 + t1.m11 * t2.m01, // m10
t1.m01 * t2.m10 + t1.m11 * t2.m11, // m11
t1.m02 * t2.m00 + t1.m12 * t2.m01 + t2.m02, // m02
t1.m02 * t2.m10 + t1.m12 * t2.m11 + t2.m12);// m12
|
public void | preConcatenate(java.awt.geom.AffineTransform t)Changes the current AffineTransform the one obtained by taking the
transform t and applying this AffineTransform to it.
setTransform(multiply(this, t));
|
private void | readObject(java.io.ObjectInputStream stream)Read the AffineTransform object from the input stream.
stream.defaultReadObject();
type = TYPE_UNKNOWN;
|
public void | rotate(double angle)Applies a rotation transformation to this AffineTransformation.
concatenate(AffineTransform.getRotateInstance(angle));
|
public void | rotate(double angle, double px, double py)Applies a rotation and translation transformation to this
AffineTransformation.
concatenate(AffineTransform.getRotateInstance(angle, px, py));
|
public void | scale(double scx, double scy)Applies a scaling transformation to this AffineTransformation.
concatenate(AffineTransform.getScaleInstance(scx, scy));
|
public void | setToIdentity()Sets the transform to the identity transform.
type = TYPE_IDENTITY;
m00 = m11 = 1.0;
m10 = m01 = m02 = m12 = 0.0;
|
public void | setToRotation(double angle)Sets the transformation to being a rotation alone, eliminating shearing,
scaling, and translation elements. Sets the type to
TYPE_IDENTITY if the resulting AffineTransformation is the
identity transformation, otherwise sets it to TYPE_UNKNOWN .
double sin = Math.sin(angle);
double cos = Math.cos(angle);
if (Math.abs(cos) < ZERO) {
cos = 0.0;
sin = sin > 0.0 ? 1.0 : -1.0;
} else if (Math.abs(sin) < ZERO) {
sin = 0.0;
cos = cos > 0.0 ? 1.0 : -1.0;
}
m00 = m11 = cos;
m01 = -sin;
m10 = sin;
m02 = m12 = 0.0;
type = TYPE_UNKNOWN;
|
public void | setToRotation(double angle, double px, double py)Sets the transformation to being a rotation followed by a translation.
Sets the type to TYPE_UNKNOWN .
setToRotation(angle);
m02 = px * (1.0 - m00) + py * m10;
m12 = py * (1.0 - m00) - px * m10;
type = TYPE_UNKNOWN;
|
public void | setToScale(double scx, double scy)Sets the transformation to being a scale alone, eliminating rotation,
shear, and translation elements. Sets the type to
TYPE_IDENTITY if the resulting AffineTransformation is the
identity transformation, otherwise sets it to TYPE_UNKNOWN .
m00 = scx;
m11 = scy;
m10 = m01 = m02 = m12 = 0.0;
if (scx != 1.0 || scy != 1.0) {
type = TYPE_UNKNOWN;
} else {
type = TYPE_IDENTITY;
}
|
public void | setToShear(double shx, double shy)Sets the transformation to being a shear alone, eliminating rotation,
scaling, and translation elements. Sets the type to
TYPE_IDENTITY if the resulting AffineTransformation is the
identity transformation, otherwise sets it to TYPE_UNKNOWN .
m00 = m11 = 1.0;
m02 = m12 = 0.0;
m01 = shx;
m10 = shy;
if (shx != 0.0 || shy != 0.0) {
type = TYPE_UNKNOWN;
} else {
type = TYPE_IDENTITY;
}
|
public void | setToTranslation(double mx, double my)Sets the transformation to a translation alone. Sets the linear part of
the transformation to identity and the translation vector to the values
sent as parameters. Sets the type to TYPE_IDENTITY if the
resulting AffineTransformation is the identity transformation, otherwise
sets it to TYPE_TRANSLATION .
m00 = m11 = 1.0;
m01 = m10 = 0.0;
m02 = mx;
m12 = my;
if (mx == 0.0 && my == 0.0) {
type = TYPE_IDENTITY;
} else {
type = TYPE_TRANSLATION;
}
|
public void | setTransform(double m00, double m10, double m01, double m11, double m02, double m12)Sets the transform in terms of a list of double values.
this.type = TYPE_UNKNOWN;
this.m00 = m00;
this.m10 = m10;
this.m01 = m01;
this.m11 = m11;
this.m02 = m02;
this.m12 = m12;
|
public void | setTransform(java.awt.geom.AffineTransform t)Sets the transform's data to match the data of the transform sent as a
parameter.
type = t.type;
setTransform(t.m00, t.m10, t.m01, t.m11, t.m02, t.m12);
|
public void | shear(double shx, double shy)Applies a shearing transformation to this AffineTransformation.
concatenate(AffineTransform.getShearInstance(shx, shy));
|
public java.lang.String | toString()
return getClass().getName() + "[[" + m00 + ", " + m01 + ", " + m02 + "], [" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ m10 + ", " + m11 + ", " + m12 + "]]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
public java.awt.geom.Point2D | transform(java.awt.geom.Point2D src, java.awt.geom.Point2D dst)Apply the current AffineTransform to the point.
if (dst == null) {
if (src instanceof Point2D.Double) {
dst = new Point2D.Double();
} else {
dst = new Point2D.Float();
}
}
double x = src.getX();
double y = src.getY();
dst.setLocation(x * m00 + y * m01 + m02, x * m10 + y * m11 + m12);
return dst;
|
public void | transform(java.awt.geom.Point2D[] src, int srcOff, java.awt.geom.Point2D[] dst, int dstOff, int length)Applies this AffineTransform to an array of points.
while (--length >= 0) {
Point2D srcPoint = src[srcOff++];
double x = srcPoint.getX();
double y = srcPoint.getY();
Point2D dstPoint = dst[dstOff];
if (dstPoint == null) {
if (srcPoint instanceof Point2D.Double) {
dstPoint = new Point2D.Double();
} else {
dstPoint = new Point2D.Float();
}
}
dstPoint.setLocation(x * m00 + y * m01 + m02, x * m10 + y * m11 + m12);
dst[dstOff++] = dstPoint;
}
|
public void | transform(double[] src, int srcOff, double[] dst, int dstOff, int length)Applies this AffineTransform to a set of points given as an array of
double values where every two values in the array give the coordinates of
a point; the even-indexed values giving the x coordinates and the
odd-indexed values giving the y coordinates.
int step = 2;
if (src == dst && srcOff < dstOff && dstOff < srcOff + length * 2) {
srcOff = srcOff + length * 2 - 2;
dstOff = dstOff + length * 2 - 2;
step = -2;
}
while (--length >= 0) {
double x = src[srcOff + 0];
double y = src[srcOff + 1];
dst[dstOff + 0] = x * m00 + y * m01 + m02;
dst[dstOff + 1] = x * m10 + y * m11 + m12;
srcOff += step;
dstOff += step;
}
|
public void | transform(float[] src, int srcOff, float[] dst, int dstOff, int length)Applies this AffineTransform to a set of points given as an array of
float values where every two values in the array give the coordinates of
a point; the even-indexed values giving the x coordinates and the
odd-indexed values giving the y coordinates.
int step = 2;
if (src == dst && srcOff < dstOff && dstOff < srcOff + length * 2) {
srcOff = srcOff + length * 2 - 2;
dstOff = dstOff + length * 2 - 2;
step = -2;
}
while (--length >= 0) {
float x = src[srcOff + 0];
float y = src[srcOff + 1];
dst[dstOff + 0] = (float)(x * m00 + y * m01 + m02);
dst[dstOff + 1] = (float)(x * m10 + y * m11 + m12);
srcOff += step;
dstOff += step;
}
|
public void | transform(float[] src, int srcOff, double[] dst, int dstOff, int length)Applies this AffineTransform to a set of points given as an array of
float values where every two values in the array give the coordinates of
a point; the even-indexed values giving the x coordinates and the
odd-indexed values giving the y coordinates. The destination coordinates
are given as values of type double .
while (--length >= 0) {
float x = src[srcOff++];
float y = src[srcOff++];
dst[dstOff++] = x * m00 + y * m01 + m02;
dst[dstOff++] = x * m10 + y * m11 + m12;
}
|
public void | transform(double[] src, int srcOff, float[] dst, int dstOff, int length)Applies this AffineTransform to a set of points given as an array of
double values where every two values in the array give the coordinates of
a point; the even-indexed values giving the x coordinates and the
odd-indexed values giving the y coordinates. The destination coordinates
are given as values of type float .
while (--length >= 0) {
double x = src[srcOff++];
double y = src[srcOff++];
dst[dstOff++] = (float)(x * m00 + y * m01 + m02);
dst[dstOff++] = (float)(x * m10 + y * m11 + m12);
}
|
public void | translate(double mx, double my)Applies a translation to this AffineTransformation.
concatenate(AffineTransform.getTranslateInstance(mx, my));
|
private void | writeObject(java.io.ObjectOutputStream stream)Writes the AffineTrassform object to the output steam.
stream.defaultWriteObject();
|