本文整理匯總了Java中java.awt.geom.AffineTransform.TYPE_TRANSLATION屬性的典型用法代碼示例。如果您正苦於以下問題:Java AffineTransform.TYPE_TRANSLATION屬性的具體用法?Java AffineTransform.TYPE_TRANSLATION怎麽用?Java AffineTransform.TYPE_TRANSLATION使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類java.awt.geom.AffineTransform
的用法示例。
在下文中一共展示了AffineTransform.TYPE_TRANSLATION屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isIntegerTranslation
/**
* Returns true if the given AffineTransform is an integer
* translation.
*/
private static boolean isIntegerTranslation(AffineTransform xform) {
if (xform.isIdentity()) {
return true;
}
if (xform.getType() == AffineTransform.TYPE_TRANSLATION) {
double tx = xform.getTranslateX();
double ty = xform.getTranslateY();
return (tx == (int)tx && ty == (int)ty);
}
return false;
}
示例2: getNativePointSize
private int getNativePointSize() {
/* Make a copy of the glyphTX in which we will store the
* font transform, inverting the devTx if necessary
*/
double[] mat = new double[4];
desc.glyphTx.getMatrix(mat);
fontTx = new AffineTransform(mat);
/* Now work backwards to get the font transform */
if (!desc.devTx.isIdentity() &&
desc.devTx.getType() != AffineTransform.TYPE_TRANSLATION) {
try {
invertDevTx = desc.devTx.createInverse();
fontTx.concatenate(invertDevTx);
} catch (NoninvertibleTransformException e) {
e.printStackTrace();
}
}
/* At this point the fontTx may be a simple +ve scale, or it
* may be something more complex.
*/
Point2D.Float pt = new Point2D.Float(1f,1f);
fontTx.deltaTransform(pt, pt);
double ptSize = Math.abs(pt.y);
int ttype = fontTx.getType();
if ((ttype & ~AffineTransform.TYPE_UNIFORM_SCALE) != 0 ||
fontTx.getScaleY() <= 0) {
/* We need to create an inverse transform that doesn't
* include the point size (strictly the uniform scale)
*/
fontTx.scale(1/ptSize, 1/ptSize);
} else {
fontTx = null; // no need
}
return (int)ptSize;
}
示例3: invalidateTransform
protected void invalidateTransform() {
int type = transform.getType();
int origTransformState = transformState;
if (type == AffineTransform.TYPE_IDENTITY) {
transformState = TRANSFORM_ISIDENT;
transX = transY = 0;
} else if (type == AffineTransform.TYPE_TRANSLATION) {
double dtx = transform.getTranslateX();
double dty = transform.getTranslateY();
transX = (int) Math.floor(dtx + 0.5);
transY = (int) Math.floor(dty + 0.5);
if (dtx == transX && dty == transY) {
transformState = TRANSFORM_INT_TRANSLATE;
} else {
transformState = TRANSFORM_ANY_TRANSLATE;
}
} else if ((type & (AffineTransform.TYPE_FLIP |
AffineTransform.TYPE_MASK_ROTATION |
AffineTransform.TYPE_GENERAL_TRANSFORM)) == 0)
{
transformState = TRANSFORM_TRANSLATESCALE;
transX = transY = 0;
} else {
transformState = TRANSFORM_GENERIC;
transX = transY = 0;
}
if (transformState >= TRANSFORM_TRANSLATESCALE ||
origTransformState >= TRANSFORM_TRANSLATESCALE)
{
/* Its only in this case that the previous or current transform
* was more than a translate that font info is invalidated
*/
cachedFRC = null;
this.validFontInfo = false;
this.fontMetrics = null;
this.glyphVectorFontInfo = null;
if (transformState != origTransformState) {
invalidatePipe();
}
}
if (strokeState != STROKE_CUSTOM) {
validateBasicStroke((BasicStroke) stroke);
}
}