本文整理汇总了Java中java.awt.font.GlyphVector.getPixelBounds方法的典型用法代码示例。如果您正苦于以下问题:Java GlyphVector.getPixelBounds方法的具体用法?Java GlyphVector.getPixelBounds怎么用?Java GlyphVector.getPixelBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.font.GlyphVector
的用法示例。
在下文中一共展示了GlyphVector.getPixelBounds方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cacheVector
import java.awt.font.GlyphVector; //导入方法依赖的package包/类
private Rectangle cacheVector(GlyphVector vector) {
/*
* Compute the exact area that the rendered string will take up in the image buffer. Note that
* the string will actually be drawn at a positive (x,y) offset from (0,0) to leave enough room
* for the ascent above the baseline and to correct for a few glyphs that appear to have negative
* horizontal bearing (e.g. U+0423 Cyrillic uppercase letter U on Windows 7).
*/
final Rectangle vectorBounds = vector.getPixelBounds(fontContext, 0, 0);
/* Enlage the stringImage if it is too small to store the entire rendered string */
if (vectorBounds.width > stringImage.getWidth() || vectorBounds.height > stringImage.getHeight())
allocateStringImage(Math.max(vectorBounds.width, stringImage.getWidth()),
Math.max(vectorBounds.height, stringImage.getHeight()));
/* Erase the upper-left corner where the string will get drawn*/
stringGraphics.clearRect(0, 0, vectorBounds.width, vectorBounds.height);
/* Draw string with opaque white color and baseline adjustment so the upper-left corner of the image is at (0,0) */
stringGraphics.drawGlyphVector(vector, -vectorBounds.x, -vectorBounds.y);
return vectorBounds;
}
示例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.getPixelBounds(null, 0, 0); // !!! add opt to provide different frc?
} while (--numReps >= 0);
}
示例3: getStringBounds
import java.awt.font.GlyphVector; //导入方法依赖的package包/类
private Rectangle getStringBounds(Graphics2D g2, String str, float x, float y) {
FontRenderContext frc = g2.getFontRenderContext();
GlyphVector gv = g2.getFont().createGlyphVector(frc, str);
return gv.getPixelBounds(null, x, y);
}
示例4: getStringBounds
import java.awt.font.GlyphVector; //导入方法依赖的package包/类
private static Rectangle getStringBounds(Graphics g2, String str,
float x, float y) {
FontRenderContext frc = ((Graphics2D) g2).getFontRenderContext();
GlyphVector gv = g2.getFont().createGlyphVector(frc, str);
return gv.getPixelBounds(null, x, y);
}