本文整理匯總了Java中java.awt.font.GlyphVector.getGlyphOutline方法的典型用法代碼示例。如果您正苦於以下問題:Java GlyphVector.getGlyphOutline方法的具體用法?Java GlyphVector.getGlyphOutline怎麽用?Java GlyphVector.getGlyphOutline使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.font.GlyphVector
的用法示例。
在下文中一共展示了GlyphVector.getGlyphOutline方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createImage
import java.awt.font.GlyphVector; //導入方法依賴的package包/類
protected BufferedImage createImage(Color bgColor) {
BufferedImage bufferedImage = new BufferedImage(END_X, END_Y,
BufferedImage.TYPE_INT_RGB);
// create graphics and graphics2d
final Graphics graphics = bufferedImage.getGraphics();
final Graphics2D g2d = (Graphics2D) graphics;
// set the background color
g2d.setBackground(bgColor == null ? Color.gray : bgColor);
g2d.clearRect(START_X, START_Y, END_X, END_Y);
// create a pattern for the background
createPattern(g2d);
// set the fonts and font rendering hints
Font font = new Font("Helvetica", Font.ITALIC, 30);
g2d.setFont(font);
FontRenderContext frc = g2d.getFontRenderContext();
g2d.translate(10, 24);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setStroke(new BasicStroke(3));
// sets the foreground color
g2d.setPaint(Color.DARK_GRAY);
GlyphVector gv = font.createGlyphVector(frc, message);
int numGlyphs = gv.getNumGlyphs();
for (int ii = 0; ii < numGlyphs; ii++) {
AffineTransform at;
Point2D p = gv.getGlyphPosition(ii);
at = AffineTransform.getTranslateInstance(p.getX(), p.getY());
at.rotate(Math.PI / 8);
Shape shape = gv.getGlyphOutline(ii);
Shape sss = at.createTransformedShape(shape);
g2d.fill(sss);
}
return blurImage(bufferedImage);
}
示例2: Glyph
import java.awt.font.GlyphVector; //導入方法依賴的package包/類
/**
* Create a new glyph
*
* @param codePoint The code point in which this glyph can be found
* @param bounds The bounds that this glrph can fill
* @param vector The vector this glyph is part of
* @param index The index of this glyph within the vector
* @param unicodeFont The font this glyph forms part of
*/
public Glyph(int codePoint, Rectangle bounds, GlyphVector vector, int index, UnicodeFont unicodeFont) {
this.codePoint = codePoint;
GlyphMetrics metrics = vector.getGlyphMetrics(index);
int lsb = (int)metrics.getLSB();
if (lsb > 0) lsb = 0;
int rsb = (int)metrics.getRSB();
if (rsb > 0) rsb = 0;
int glyphWidth = bounds.width - lsb - rsb;
int glyphHeight = bounds.height;
if (glyphWidth > 0 && glyphHeight > 0) {
int padTop = unicodeFont.getPaddingTop();
int padRight = unicodeFont.getPaddingRight();
int padBottom = unicodeFont.getPaddingBottom();
int padLeft = unicodeFont.getPaddingLeft();
int glyphSpacing = 1; // Needed to prevent filtering problems.
width = (short)(glyphWidth + padLeft + padRight + glyphSpacing);
height = (short)(glyphHeight + padTop + padBottom + glyphSpacing);
yOffset = (short)(unicodeFont.getAscent() + bounds.y - padTop);
}
shape = vector.getGlyphOutline(index, -bounds.x + unicodeFont.getPaddingLeft(), -bounds.y + unicodeFont.getPaddingTop());
isMissing = !unicodeFont.getFont().canDisplay((char)codePoint);
}
示例3: runTest
import java.awt.font.GlyphVector; //導入方法依賴的package包/類
public void runTest(Object ctx, int numReps) {
GVContext gvctx = (GVContext)ctx;
GlyphVector gv = gvctx.gv;
Shape s;
do {
for (int i = 0, e = gv.getNumGlyphs(); i < e; ++i) {
s = gv.getGlyphOutline(i);
}
} while (--numReps >= 0);
}