public void draw(Graphics2D g){
Color originalColor = g.getColor();
g.setColor(Color.ORANGE);
AffineTransform af = new AffineTransform();
af.translate(x, y);
g.transform(af);
g.fill(shape);
try {
g.transform(af.createInverse());
} catch (NoninvertibleTransformException e) {
e.printStackTrace();
}
g.setColor(originalColor);
}
java类java.awt.geom.NoninvertibleTransformException的实例源码
Paddle.java 文件源码
项目:pong
阅读 18
收藏 0
点赞 0
评论 0
TexturePaintContext.java 文件源码
项目:OpenJSharp
阅读 24
收藏 0
点赞 0
评论 0
TexturePaintContext(ColorModel cm, AffineTransform xform,
int bWidth, int bHeight, int maxw) {
this.colorModel = getInternedColorModel(cm);
this.bWidth = bWidth;
this.bHeight = bHeight;
this.maxWidth = maxw;
try {
xform = xform.createInverse();
} catch (NoninvertibleTransformException e) {
xform.setToScale(0, 0);
}
this.incXAcross = mod(xform.getScaleX(), bWidth);
this.incYAcross = mod(xform.getShearY(), bHeight);
this.incXDown = mod(xform.getShearX(), bWidth);
this.incYDown = mod(xform.getScaleY(), bHeight);
this.xOrg = xform.getTranslateX();
this.yOrg = xform.getTranslateY();
this.colincx = (int) incXAcross;
this.colincy = (int) incYAcross;
this.colincxerr = fractAsInt(incXAcross);
this.colincyerr = fractAsInt(incYAcross);
this.rowincx = (int) incXDown;
this.rowincy = (int) incYDown;
this.rowincxerr = fractAsInt(incXDown);
this.rowincyerr = fractAsInt(incYDown);
}
SunGraphics2D.java 文件源码
项目:OpenJSharp
阅读 25
收藏 0
点赞 0
评论 0
public Shape untransformShape(Shape s) {
if (s == null) {
return null;
}
if (transformState > TRANSFORM_INT_TRANSLATE) {
try {
return transformShape(transform.createInverse(), s);
} catch (NoninvertibleTransformException e) {
return null;
}
} else {
return transformShape(-transX, -transY, s);
}
}
LayoutPathImpl.java 文件源码
项目:OpenJSharp
阅读 24
收藏 0
点赞 0
评论 0
public boolean pointToPath(Point2D pt, Point2D result) {
result.setLocation(pt);
if (tx != null) {
try {
tx.inverseTransform(pt, result);
}
catch (NoninvertibleTransformException ex) {
}
}
return result.getX() > 0;
}
NativeStrike.java 文件源码
项目:OpenJSharp
阅读 24
收藏 0
点赞 0
评论 0
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;
}
TexturePaintContext.java 文件源码
项目:jdk8u-jdk
阅读 49
收藏 0
点赞 0
评论 0
TexturePaintContext(ColorModel cm, AffineTransform xform,
int bWidth, int bHeight, int maxw) {
this.colorModel = getInternedColorModel(cm);
this.bWidth = bWidth;
this.bHeight = bHeight;
this.maxWidth = maxw;
try {
xform = xform.createInverse();
} catch (NoninvertibleTransformException e) {
xform.setToScale(0, 0);
}
this.incXAcross = mod(xform.getScaleX(), bWidth);
this.incYAcross = mod(xform.getShearY(), bHeight);
this.incXDown = mod(xform.getShearX(), bWidth);
this.incYDown = mod(xform.getScaleY(), bHeight);
this.xOrg = xform.getTranslateX();
this.yOrg = xform.getTranslateY();
this.colincx = (int) incXAcross;
this.colincy = (int) incYAcross;
this.colincxerr = fractAsInt(incXAcross);
this.colincyerr = fractAsInt(incYAcross);
this.rowincx = (int) incXDown;
this.rowincy = (int) incYDown;
this.rowincxerr = fractAsInt(incXDown);
this.rowincyerr = fractAsInt(incYDown);
}
SunGraphics2D.java 文件源码
项目:jdk8u-jdk
阅读 25
收藏 0
点赞 0
评论 0
public Shape untransformShape(Shape s) {
if (s == null) {
return null;
}
if (transformState > TRANSFORM_INT_TRANSLATE) {
try {
return transformShape(transform.createInverse(), s);
} catch (NoninvertibleTransformException e) {
return null;
}
} else {
return transformShape(-transX, -transY, s);
}
}
LayoutPathImpl.java 文件源码
项目:jdk8u-jdk
阅读 25
收藏 0
点赞 0
评论 0
public boolean pointToPath(Point2D pt, Point2D result) {
result.setLocation(pt);
if (tx != null) {
try {
tx.inverseTransform(pt, result);
}
catch (NoninvertibleTransformException ex) {
}
}
return result.getX() > 0;
}
NativeStrike.java 文件源码
项目:jdk8u-jdk
阅读 21
收藏 0
点赞 0
评论 0
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;
}
Test8004859.java 文件源码
项目:jdk8u-jdk
阅读 18
收藏 0
点赞 0
评论 0
public static void main(final String[] args)
throws NoninvertibleTransformException {
final BufferedImage bi = new BufferedImage(300, 300,
BufferedImage.TYPE_INT_RGB);
final Graphics2D g = (Graphics2D) bi.getGraphics();
test(g);
g.translate(2.0, 2.0);
test(g);
g.translate(-4.0, -4.0);
test(g);
g.scale(2.0, 2.0);
test(g);
g.scale(-4.0, -4.0);
test(g);
g.rotate(Math.toRadians(90));
test(g);
g.rotate(Math.toRadians(90));
test(g);
g.rotate(Math.toRadians(90));
test(g);
g.rotate(Math.toRadians(90));
test(g);
g.dispose();
if (!status) {
throw new RuntimeException("Test failed");
}
}