本文整理汇总了Java中java.awt.font.GlyphVector.getVisualBounds方法的典型用法代码示例。如果您正苦于以下问题:Java GlyphVector.getVisualBounds方法的具体用法?Java GlyphVector.getVisualBounds怎么用?Java GlyphVector.getVisualBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.font.GlyphVector
的用法示例。
在下文中一共展示了GlyphVector.getVisualBounds方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBounds2D
import java.awt.font.GlyphVector; //导入方法依赖的package包/类
public Rectangle2D getBounds2D(String str, double x, double y,
double dx, double dy, double scale) {
if (isScaleInvariant()) {
if (scale <= 0.d) {
return new java.awt.geom.Rectangle2D.Double(x, y, 0, 0);
} else {
dx /= scale;
dy /= scale;
}
} else {
scale = 1;
}
// see http://forum.java.sun.com/thread.jspa?forumID=5&threadID=619854
// for an example of how to measure text size
FontRenderContext frc = new FontRenderContext(null, true, false);
GlyphVector gv = font.createGlyphVector(frc, str);
Rectangle2D visualBounds = gv.getVisualBounds();
double voffset = visualBounds.getHeight() + visualBounds.getY();
Rectangle2D bounds = new Rectangle2D.Double(x + dx,
y - voffset + dy,
visualBounds.getWidth() * this.fontScale / scale,
visualBounds.getHeight() * this.fontScale / scale);
return bounds;
}
示例2: runTest
import java.awt.font.GlyphVector; //导入方法依赖的package包/类
public void runTest(Object ctx, int numReps) {
GVContext gvctx = (GVContext)ctx;
GlyphVector gv = gvctx.gv;
Rectangle2D r;
do {
r = gv.getVisualBounds();
} while (--numReps >= 0);
}