本文整理汇总了Java中java.awt.geom.AffineTransform.isIdentity方法的典型用法代码示例。如果您正苦于以下问题:Java AffineTransform.isIdentity方法的具体用法?Java AffineTransform.isIdentity怎么用?Java AffineTransform.isIdentity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.geom.AffineTransform
的用法示例。
在下文中一共展示了AffineTransform.isIdentity方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setGlyphTransform
import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
public void setGlyphTransform(int ix, AffineTransform newTX) {
if (ix < 0 || ix >= glyphs.length) {
throw new IndexOutOfBoundsException("ix = " + ix);
}
if (gti == null) {
if (newTX == null || newTX.isIdentity()) {
return;
}
gti = new GlyphTransformInfo(this);
}
gti.setGlyphTransform(ix, newTX); // sets flags
if (gti.transformCount() == 0) {
gti = null;
}
}
示例2: transformShape
import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
protected static Shape transformShape(AffineTransform tx, Shape clip) {
if (clip == null) {
return null;
}
if (clip instanceof Rectangle2D &&
(tx.getType() & NON_RECTILINEAR_TRANSFORM_MASK) == 0)
{
Rectangle2D rect = (Rectangle2D) clip;
double matrix[] = new double[4];
matrix[0] = rect.getX();
matrix[1] = rect.getY();
matrix[2] = matrix[0] + rect.getWidth();
matrix[3] = matrix[1] + rect.getHeight();
tx.transform(matrix, 0, matrix, 0, 2);
fixRectangleOrientation(matrix, rect);
return new Rectangle2D.Double(matrix[0], matrix[1],
matrix[2] - matrix[0],
matrix[3] - matrix[1]);
}
if (tx.isIdentity()) {
return cloneShape(clip);
}
return tx.createTransformedShape(clip);
}
示例3: isIntegerTranslation
import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
/**
* 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;
}
示例4: setTransform
import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
public void setTransform(AffineTransform f) {
this.transform = (f == null || f.isIdentity())
? DEFAULT.transform
: new AffineTransform(f);
updateDerivedTransforms();
update(ETRANSFORM);
}
示例5: transformBounds
import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
protected Rectangle transformBounds(Rectangle rect,
AffineTransform tx) {
if (tx.isIdentity()) {
return rect;
}
Shape s = transformShape(tx, rect);
return s.getBounds();
}
示例6: init
import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
public void init(TestEnvironment env, Result result) {
// graphics
graphics = env.getGraphics();
// text
String sname = (String)env.getModifier(tscriptList);
int slen = env.getIntValue(tlengthList);
text = getString(sname, slen);
// chars
chars = text.toCharArray();
// font
String fname = (String)env.getModifier(fnameList);
if ("Physical".equals(fname)) {
fname = physicalFontNameFor(sname, slen, text);
}
int fstyle = env.getIntValue(fstyleList);
float fsize = ((Float)env.getModifier(fsizeList)).floatValue();
AffineTransform ftx = (AffineTransform)env.getModifier(ftxList);
font = new Font(fname, fstyle, (int)fsize);
if (hasGraphics2D) {
if (fsize != Math.floor(fsize)) {
font = font.deriveFont(fsize);
}
if (!ftx.isIdentity()) {
font = font.deriveFont(ftx);
}
}
// graphics
if (hasGraphics2D) {
Graphics2D g2d = (Graphics2D)graphics;
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
env.getModifier(taaList));
g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
env.isEnabled(tfmTog)
? RenderingHints.VALUE_FRACTIONALMETRICS_ON
: RenderingHints.VALUE_FRACTIONALMETRICS_OFF);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
env.isEnabled(gaaTog)
? RenderingHints.VALUE_ANTIALIAS_ON
: RenderingHints.VALUE_ANTIALIAS_OFF);
g2d.transform((AffineTransform)env.getModifier(gtxList));
}
// set result
result.setUnits(text.length());
result.setUnitName("char");
}
示例7: FontRenderContext
import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
/**
* Constructs a {@code FontRenderContext} object from an
* optional {@link AffineTransform} and two {@code boolean}
* values that determine if the newly constructed object has
* anti-aliasing or fractional metrics.
* In each case the boolean values {@code true} and {@code false}
* correspond to the rendering hint values {@code ON} and
* {@code OFF} respectively.
* <p>
* To specify other hint values, use the constructor which
* specifies the rendering hint values as parameters :
* {@link #FontRenderContext(AffineTransform, Object, Object)}.
* @param tx the transform which is used to scale typographical points
* to pixels in this {@code FontRenderContext}. If null, an
* identity transform is used.
* @param isAntiAliased determines if the newly constructed object
* has anti-aliasing.
* @param usesFractionalMetrics determines if the newly constructed
* object has fractional metrics.
*/
public FontRenderContext(AffineTransform tx,
boolean isAntiAliased,
boolean usesFractionalMetrics) {
if (tx != null && !tx.isIdentity()) {
this.tx = new AffineTransform(tx);
}
if (isAntiAliased) {
aaHintValue = VALUE_TEXT_ANTIALIAS_ON;
} else {
aaHintValue = VALUE_TEXT_ANTIALIAS_OFF;
}
if (usesFractionalMetrics) {
fmHintValue = VALUE_FRACTIONALMETRICS_ON;
} else {
fmHintValue = VALUE_FRACTIONALMETRICS_OFF;
}
}
示例8: drawImage
import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
/**
* Draw an image, applying a transform from image space into user space
* before drawing.
* The transformation from user space into device space is done with
* the current transform in the Graphics2D.
* The given transformation is applied to the image before the
* transform attribute in the Graphics2D state is applied.
* The rendering attributes applied include the clip, transform,
* paint or color and composite attributes. Note that the result is
* undefined, if the given transform is non-invertible.
* @param img The image to be drawn.
* @param xform The transformation from image space into user space.
* @param observer The image observer to be notified on the image producing
* progress.
* @see #transform
* @see #setComposite
* @see #setClip
*/
public boolean drawImage(Image img,
AffineTransform xform,
ImageObserver observer) {
if (img == null) {
return true;
}
if (xform == null || xform.isIdentity()) {
return drawImage(img, 0, 0, null, observer);
}
if (isHiDPIImage(img)) {
final int w = img.getWidth(null);
final int h = img.getHeight(null);
final AffineTransform tx = new AffineTransform(transform);
transform(xform);
boolean result = drawHiDPIImage(img, 0, 0, w, h, 0, 0, w, h, null,
observer);
transform.setTransform(tx);
invalidateTransform();
return result;
}
try {
return imagepipe.transformImage(this, img, xform, observer);
} catch (InvalidPipeException e) {
try {
revalidateAll();
return imagepipe.transformImage(this, img, xform, observer);
} catch (InvalidPipeException e2) {
// Still catching the exception; we are not yet ready to
// validate the surfaceData correctly. Fail for now and
// try again next time around.
return false;
}
} finally {
surfaceData.markDirty();
}
}
示例9: FontRenderContext
import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
/**
* Constructs a <code>FontRenderContext</code> object from an
* optional {@link AffineTransform} and two <code>boolean</code>
* values that determine if the newly constructed object has
* anti-aliasing or fractional metrics.
* In each case the boolean values <CODE>true</CODE> and <CODE>false</CODE>
* correspond to the rendering hint values <CODE>ON</CODE> and
* <CODE>OFF</CODE> respectively.
* <p>
* To specify other hint values, use the constructor which
* specifies the rendering hint values as parameters :
* {@link #FontRenderContext(AffineTransform, Object, Object)}.
* @param tx the transform which is used to scale typographical points
* to pixels in this <code>FontRenderContext</code>. If null, an
* identity transform is used.
* @param isAntiAliased determines if the newly constructed object
* has anti-aliasing.
* @param usesFractionalMetrics determines if the newly constructed
* object has fractional metrics.
*/
public FontRenderContext(AffineTransform tx,
boolean isAntiAliased,
boolean usesFractionalMetrics) {
if (tx != null && !tx.isIdentity()) {
this.tx = new AffineTransform(tx);
}
if (isAntiAliased) {
aaHintValue = VALUE_TEXT_ANTIALIAS_ON;
} else {
aaHintValue = VALUE_TEXT_ANTIALIAS_OFF;
}
if (usesFractionalMetrics) {
fmHintValue = VALUE_FRACTIONALMETRICS_ON;
} else {
fmHintValue = VALUE_FRACTIONALMETRICS_OFF;
}
}
示例10: TransformAttribute
import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
/**
* Wraps the specified transform. The transform is cloned and a
* reference to the clone is kept. The original transform is unchanged.
* If null is passed as the argument, this constructor behaves as though
* it were the identity transform. (Note that it is preferable to use
* {@link #IDENTITY} in this case.)
* @param transform the specified {@link AffineTransform} to be wrapped,
* or null.
*/
public TransformAttribute(AffineTransform transform) {
if (transform != null && !transform.isIdentity()) {
this.transform = new AffineTransform(transform);
}
}