Package edu.umd.cs.piccolo.util
Class PAffineTransform
java.lang.Object
java.awt.geom.AffineTransform
edu.umd.cs.piccolo.util.PAffineTransform
- All Implemented Interfaces:
Serializable,Cloneable
PAffineTransform is a subclass of AffineTransform that has been
extended with convenience methods.
- Version:
- 1.0
- Author:
- Jesse Grosjean
- See Also:
-
Field Summary
Fields inherited from class java.awt.geom.AffineTransform
TYPE_FLIP, TYPE_GENERAL_ROTATION, TYPE_GENERAL_SCALE, TYPE_GENERAL_TRANSFORM, TYPE_IDENTITY, TYPE_MASK_ROTATION, TYPE_MASK_SCALE, TYPE_QUADRANT_ROTATION, TYPE_TRANSLATION, TYPE_UNIFORM_SCALE -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new AffineTransform representing the Identity transformation.PAffineTransform(double[] flatmatrix) Constructs a new AffineTransform from an array of double precision values representing either the 4 non-translation entries or the 6 specifiable entries of the 3x3 transformation matrix.PAffineTransform(double m00, double m10, double m01, double m11, double m02, double m12) Constructs a new AffineTransform from 6 double precision values representing the 6 specifiable entries of the 3x3 transformation matrix.PAffineTransform(float[] flatmatrix) Constructs a new AffineTransform from an array of floating point values representing either the 4 non-translation entries or the 6 specifiable entries of the 3x3 transformation matrix.PAffineTransform(float m00, float m10, float m01, float m11, float m02, float m12) Constructs a new AffineTransform from 6 floating point values representing the 6 specifiable entries of the 3x3 transformation matrix.Constructs a new AffineTransform that is a copy of the specified AffineTransform object. -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns the rotation applied to this affine transform in radians.doublegetScale()Returns the scale applied to this transform.inverseTransform(Dimension2D dimSrc, Dimension2D dimDst) Applies the inverse of this transform to the source dimension if possible.inverseTransform(Point2D ptSrc, Point2D ptDst) Applies the inverse of this transform to the source point if possible.inverseTransform(Rectangle2D rectSrc, Rectangle2D rectDst) Applies the inverse of this transform to the source rectangle and stores the result in rectDst.voidscaleAboutPoint(double scale, double x, double y) Scales the transform about the given point by the given scale.voidsetOffset(double tx, double ty) Applies modifies the transform so that it translates by the given offset.voidsetRotation(double theta) Set rotation in radians.voidsetScale(double scale) Sets the scale about to the origin of this transform to the scale provided.transform(Dimension2D dimSrc, Dimension2D dimDst) Applies the transform to the provided dimension.transform(Rectangle2D rectSrc, Rectangle2D rectDst) Applies this transform to the source rectangle and stores the result in rectDst.Methods inherited from class java.awt.geom.AffineTransform
clone, concatenate, createInverse, createTransformedShape, deltaTransform, deltaTransform, equals, getDeterminant, getMatrix, getQuadrantRotateInstance, getQuadrantRotateInstance, getRotateInstance, getRotateInstance, getRotateInstance, getRotateInstance, getScaleInstance, getScaleX, getScaleY, getShearInstance, getShearX, getShearY, getTranslateInstance, getTranslateX, getTranslateY, getType, hashCode, inverseTransform, invert, isIdentity, preConcatenate, quadrantRotate, quadrantRotate, rotate, rotate, rotate, rotate, scale, setToIdentity, setToQuadrantRotation, setToQuadrantRotation, setToRotation, setToRotation, setToRotation, setToRotation, setToScale, setToShear, setToTranslation, setTransform, setTransform, shear, toString, transform, transform, transform, transform, transform, transform, translate
-
Constructor Details
-
PAffineTransform
public PAffineTransform()Constructs a new AffineTransform representing the Identity transformation. -
PAffineTransform
public PAffineTransform(double[] flatmatrix) Constructs a new AffineTransform from an array of double precision values representing either the 4 non-translation entries or the 6 specifiable entries of the 3x3 transformation matrix. The values are retrieved from the array as { m00 m10 m01 m11 [m02 m12]}.- Parameters:
flatmatrix- the double array containing the values to be set in the new AffineTransform object. The length of the array is assumed to be at least 4. If the length of the array is less than 6, only the first 4 values are taken. If the length of the array is greater than 6, the first 6 values are taken.
-
PAffineTransform
public PAffineTransform(float[] flatmatrix) Constructs a new AffineTransform from an array of floating point values representing either the 4 non-translation entries or the 6 specifiable entries of the 3x3 transformation matrix. The values are retrieved from the array as { m00 m10 m01 m11 [m02 m12]}.- Parameters:
flatmatrix- the float array containing the values to be set in the new AffineTransform object. The length of the array is assumed to be at least 4. If the length of the array is less than 6, only the first 4 values are taken. If the length of the array is greater than 6, the first 6 values are taken.
-
PAffineTransform
public PAffineTransform(double m00, double m10, double m01, double m11, double m02, double m12) Constructs a new AffineTransform from 6 double precision values representing the 6 specifiable entries of the 3x3 transformation matrix.- Parameters:
m00- the X coordinate scaling element of the 3x3 matrixm10- the Y coordinate shearing element of the 3x3 matrixm01- the X coordinate shearing element of the 3x3 matrixm11- the Y coordinate scaling element of the 3x3 matrixm02- the X coordinate translation element of the 3x3 matrixm12- the Y coordinate translation element of the 3x3 matrix
-
PAffineTransform
public PAffineTransform(float m00, float m10, float m01, float m11, float m02, float m12) Constructs a new AffineTransform from 6 floating point values representing the 6 specifiable entries of the 3x3 transformation matrix.- Parameters:
m00- the X coordinate scaling element of the 3x3 matrixm10- the Y coordinate shearing element of the 3x3 matrixm01- the X coordinate shearing element of the 3x3 matrixm11- the Y coordinate scaling element of the 3x3 matrixm02- the X coordinate translation element of the 3x3 matrixm12- the Y coordinate translation element of the 3x3 matrix
-
PAffineTransform
Constructs a new AffineTransform that is a copy of the specified AffineTransform object.- Parameters:
tx- transform to copy
-
-
Method Details
-
scaleAboutPoint
public void scaleAboutPoint(double scale, double x, double y) Scales the transform about the given point by the given scale.- Parameters:
scale- to transform the transform byx- x coordinate around which the scale should take placey- y coordinate around which the scale should take place
-
getScale
public double getScale()Returns the scale applied to this transform. Note that it does so by computing the change in length of a unit segment after being passed through the transform. This means that a transform that a transform that doesn't scale the in the x but doubles the y will be reported as 2.- Returns:
- the different in length of a unit segment after being transformed.
-
setScale
public void setScale(double scale) Sets the scale about to the origin of this transform to the scale provided.- Parameters:
scale- The desired resulting scale
-
setOffset
public void setOffset(double tx, double ty) Applies modifies the transform so that it translates by the given offset.- Parameters:
tx- x translation of resulting transformty- y translation of resulting transform
-
getRotation
public double getRotation()Returns the rotation applied to this affine transform in radians. The value returned will be between 0 and 2pi.- Returns:
- rotation in radians
-
setRotation
public void setRotation(double theta) Set rotation in radians. This is not cumulative.- Parameters:
theta- desired rotation in radians.
-
transform
Applies the transform to the provided dimension.- Parameters:
dimSrc- source dimensiondimDst- will be changed to be the transformed dimension, may be null- Returns:
- the transformed dimension
-
inverseTransform
Applies the inverse of this transform to the source point if possible.- Overrides:
inverseTransformin classAffineTransform- Parameters:
ptSrc- point to be transformedptDst- result of transform will be placed in this point- Returns:
- the transformed point
- Since:
- 1.3
-
inverseTransform
Applies the inverse of this transform to the source dimension if possible.- Parameters:
dimSrc- dimension to be transformeddimDst- result of transform will be placed in this dimension- Returns:
- the transformed dimension
-
transform
Applies this transform to the source rectangle and stores the result in rectDst.- Parameters:
rectSrc- rectangle to be transformedrectDst- result of transform will be placed in this rectangle- Returns:
- the transformed rectangle
-
inverseTransform
Applies the inverse of this transform to the source rectangle and stores the result in rectDst.- Parameters:
rectSrc- rectangle to be transformedrectDst- result of transform will be placed in this rectangle- Returns:
- the transformed rectangle
-