本文整理匯總了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);
}