本文整理匯總了Java中java.awt.geom.AffineTransform.TYPE_GENERAL_SCALE屬性的典型用法代碼示例。如果您正苦於以下問題:Java AffineTransform.TYPE_GENERAL_SCALE屬性的具體用法?Java AffineTransform.TYPE_GENERAL_SCALE怎麽用?Java AffineTransform.TYPE_GENERAL_SCALE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類java.awt.geom.AffineTransform
的用法示例。
在下文中一共展示了AffineTransform.TYPE_GENERAL_SCALE屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: userSpaceLineWidth
private float userSpaceLineWidth(AffineTransform at, float lw) {
double widthScale;
if ((at.getType() & (AffineTransform.TYPE_GENERAL_TRANSFORM |
AffineTransform.TYPE_GENERAL_SCALE)) != 0) {
widthScale = Math.sqrt(at.getDeterminant());
} else {
/* First calculate the "maximum scale" of this transform. */
double A = at.getScaleX(); // m00
double C = at.getShearX(); // m01
double B = at.getShearY(); // m10
double D = at.getScaleY(); // m11
/*
* Given a 2 x 2 affine matrix [ A B ] such that
* [ C D ]
* v' = [x' y'] = [Ax + Cy, Bx + Dy], we want to
* find the maximum magnitude (norm) of the vector v'
* with the constraint (x^2 + y^2 = 1).
* The equation to maximize is
* |v'| = sqrt((Ax+Cy)^2+(Bx+Dy)^2)
* or |v'| = sqrt((AA+BB)x^2 + 2(AC+BD)xy + (CC+DD)y^2).
* Since sqrt is monotonic we can maximize |v'|^2
* instead and plug in the substitution y = sqrt(1 - x^2).
* Trigonometric equalities can then be used to get
* rid of most of the sqrt terms.
*/
double EA = A*A + B*B; // x^2 coefficient
double EB = 2*(A*C + B*D); // xy coefficient
double EC = C*C + D*D; // y^2 coefficient
/*
* There is a lot of calculus omitted here.
*
* Conceptually, in the interests of understanding the
* terms that the calculus produced we can consider
* that EA and EC end up providing the lengths along
* the major axes and the hypot term ends up being an
* adjustment for the additional length along the off-axis
* angle of rotated or sheared ellipses as well as an
* adjustment for the fact that the equation below
* averages the two major axis lengths. (Notice that
* the hypot term contains a part which resolves to the
* difference of these two axis lengths in the absence
* of rotation.)
*
* In the calculus, the ratio of the EB and (EA-EC) terms
* ends up being the tangent of 2*theta where theta is
* the angle that the long axis of the ellipse makes
* with the horizontal axis. Thus, this equation is
* calculating the length of the hypotenuse of a triangle
* along that axis.
*/
double hypot = Math.sqrt(EB*EB + (EA-EC)*(EA-EC));
/* sqrt omitted, compare to squared limits below. */
double widthsquared = ((EA + EC + hypot)/2.0);
widthScale = Math.sqrt(widthsquared);
}
return (float) (lw / widthScale);
}
示例2: userSpaceLineWidth
private final double userSpaceLineWidth(AffineTransform at, double lw) {
double widthScale;
if (at == null) {
widthScale = 1.0d;
} else if ((at.getType() & (AffineTransform.TYPE_GENERAL_TRANSFORM |
AffineTransform.TYPE_GENERAL_SCALE)) != 0) {
widthScale = Math.sqrt(at.getDeterminant());
} else {
// First calculate the "maximum scale" of this transform.
double A = at.getScaleX(); // m00
double C = at.getShearX(); // m01
double B = at.getShearY(); // m10
double D = at.getScaleY(); // m11
/*
* Given a 2 x 2 affine matrix [ A B ] such that
* [ C D ]
* v' = [x' y'] = [Ax + Cy, Bx + Dy], we want to
* find the maximum magnitude (norm) of the vector v'
* with the constraint (x^2 + y^2 = 1).
* The equation to maximize is
* |v'| = sqrt((Ax+Cy)^2+(Bx+Dy)^2)
* or |v'| = sqrt((AA+BB)x^2 + 2(AC+BD)xy + (CC+DD)y^2).
* Since sqrt is monotonic we can maximize |v'|^2
* instead and plug in the substitution y = sqrt(1 - x^2).
* Trigonometric equalities can then be used to get
* rid of most of the sqrt terms.
*/
double EA = A*A + B*B; // x^2 coefficient
double EB = 2.0d * (A*C + B*D); // xy coefficient
double EC = C*C + D*D; // y^2 coefficient
/*
* There is a lot of calculus omitted here.
*
* Conceptually, in the interests of understanding the
* terms that the calculus produced we can consider
* that EA and EC end up providing the lengths along
* the major axes and the hypot term ends up being an
* adjustment for the additional length along the off-axis
* angle of rotated or sheared ellipses as well as an
* adjustment for the fact that the equation below
* averages the two major axis lengths. (Notice that
* the hypot term contains a part which resolves to the
* difference of these two axis lengths in the absence
* of rotation.)
*
* In the calculus, the ratio of the EB and (EA-EC) terms
* ends up being the tangent of 2*theta where theta is
* the angle that the long axis of the ellipse makes
* with the horizontal axis. Thus, this equation is
* calculating the length of the hypotenuse of a triangle
* along that axis.
*/
double hypot = Math.sqrt(EB*EB + (EA-EC)*(EA-EC));
// sqrt omitted, compare to squared limits below.
double widthsquared = ((EA + EC + hypot) / 2.0d);
widthScale = Math.sqrt(widthsquared);
}
return (lw / widthScale);
}
示例3: userSpaceLineWidth
private final float userSpaceLineWidth(AffineTransform at, float lw) {
float widthScale;
if (at == null) {
widthScale = 1.0f;
} else if ((at.getType() & (AffineTransform.TYPE_GENERAL_TRANSFORM |
AffineTransform.TYPE_GENERAL_SCALE)) != 0) {
widthScale = (float)Math.sqrt(at.getDeterminant());
} else {
// First calculate the "maximum scale" of this transform.
double A = at.getScaleX(); // m00
double C = at.getShearX(); // m01
double B = at.getShearY(); // m10
double D = at.getScaleY(); // m11
/*
* Given a 2 x 2 affine matrix [ A B ] such that
* [ C D ]
* v' = [x' y'] = [Ax + Cy, Bx + Dy], we want to
* find the maximum magnitude (norm) of the vector v'
* with the constraint (x^2 + y^2 = 1).
* The equation to maximize is
* |v'| = sqrt((Ax+Cy)^2+(Bx+Dy)^2)
* or |v'| = sqrt((AA+BB)x^2 + 2(AC+BD)xy + (CC+DD)y^2).
* Since sqrt is monotonic we can maximize |v'|^2
* instead and plug in the substitution y = sqrt(1 - x^2).
* Trigonometric equalities can then be used to get
* rid of most of the sqrt terms.
*/
double EA = A*A + B*B; // x^2 coefficient
double EB = 2.0d * (A*C + B*D); // xy coefficient
double EC = C*C + D*D; // y^2 coefficient
/*
* There is a lot of calculus omitted here.
*
* Conceptually, in the interests of understanding the
* terms that the calculus produced we can consider
* that EA and EC end up providing the lengths along
* the major axes and the hypot term ends up being an
* adjustment for the additional length along the off-axis
* angle of rotated or sheared ellipses as well as an
* adjustment for the fact that the equation below
* averages the two major axis lengths. (Notice that
* the hypot term contains a part which resolves to the
* difference of these two axis lengths in the absence
* of rotation.)
*
* In the calculus, the ratio of the EB and (EA-EC) terms
* ends up being the tangent of 2*theta where theta is
* the angle that the long axis of the ellipse makes
* with the horizontal axis. Thus, this equation is
* calculating the length of the hypotenuse of a triangle
* along that axis.
*/
double hypot = Math.sqrt(EB*EB + (EA-EC)*(EA-EC));
// sqrt omitted, compare to squared limits below.
double widthsquared = ((EA + EC + hypot) / 2.0d);
widthScale = (float)Math.sqrt(widthsquared);
}
return (lw / widthScale);
}