当前位置: 首页>>代码示例>>Java>>正文


Java GlyphVector.getPixelBounds方法代码示例

本文整理汇总了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;
}
 
开发者ID:ImpactDevelopment,项目名称:ClientAPI,代码行数:23,代码来源:FontCache.java

示例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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:TextMeasureTests.java

示例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);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:6,代码来源:AboutBox.java

示例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);
}
 
开发者ID:HearthProject,项目名称:OneClient,代码行数:7,代码来源:ImageUtil.java


注:本文中的java.awt.font.GlyphVector.getPixelBounds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。