當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。