本文整理汇总了Java中java.awt.font.GlyphMetrics.getBounds2D方法的典型用法代码示例。如果您正苦于以下问题:Java GlyphMetrics.getBounds2D方法的具体用法?Java GlyphMetrics.getBounds2D怎么用?Java GlyphMetrics.getBounds2D使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.font.GlyphMetrics
的用法示例。
在下文中一共展示了GlyphMetrics.getBounds2D方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getGlyphLogicalBounds
import java.awt.font.GlyphMetrics; //导入方法依赖的package包/类
public Shape getGlyphLogicalBounds(int glyphIndex)
{
GlyphMetrics gm = getGlyphMetrics( glyphIndex );
if( gm == null )
return null;
Rectangle2D r = gm.getBounds2D();
Point2D p = getGlyphPosition( glyphIndex );
double[] bounds = new double[] {p.getX() + r.getX() - gm.getLSB(),
p.getY() + r.getY(),
p.getX() + r.getX() - gm.getLSB() + gm.getAdvanceX(),
p.getY() + r.getY() + r.getHeight()};
if (glyphTransforms[glyphIndex] != null)
glyphTransforms[glyphIndex].transform(bounds, 0, bounds, 0, 2);
return new Rectangle2D.Double(bounds[0], bounds[1], bounds[2] - bounds[0],
bounds[3] - bounds[1]);
}
示例2: getGlyphLogicalBounds
import java.awt.font.GlyphMetrics; //导入方法依赖的package包/类
public Shape getGlyphLogicalBounds(int glyphIndex)
{
GlyphMetrics gm = getGlyphMetrics( glyphIndex );
if( gm == null )
return null;
Rectangle2D r = gm.getBounds2D();
Point2D p = getGlyphPosition( glyphIndex );
double[] bounds = new double[] {p.getX() + r.getX() - gm.getLSB(),
p.getY() + r.getY(),
p.getX() + r.getX() - gm.getLSB() + gm.getAdvanceX(),
p.getY() + r.getY() + r.getHeight()};
if (glyphTransforms[glyphIndex] != null)
glyphTransforms[glyphIndex].transform(bounds, 0, bounds, 0, 2);
return new Rectangle2D.Double(bounds[0], bounds[1], bounds[2] - bounds[0],
bounds[3] - bounds[1]);
}
示例3: writeGlyph
import java.awt.font.GlyphMetrics; //导入方法依赖的package包/类
protected void writeGlyph(String characterName, Shape glyph,
GlyphMetrics glyphMetrics) throws IOException {
PDFStream glyphStream = pdf.openStream(
createCharacterReference(characterName), new String[] {
"Flate", "ASCII85" });
Rectangle2D bounds = glyphMetrics != null ? glyphMetrics.getBounds2D()
: glyph.getBounds2D();
double advance = glyphMetrics != null ? glyphMetrics.getAdvance()
: getUndefinedWidth();
glyphStream.glyph(advance, 0, bounds.getX(), bounds.getY(), bounds
.getX()
+ bounds.getWidth(), bounds.getY() + bounds.getHeight());
boolean windingRule = glyphStream.drawPath(glyph);
if (windingRule) {
glyphStream.fillEvenOdd();
} else {
glyphStream.fill();
}
pdf.close(glyphStream);
}
示例4: getGlyphGeometry
import java.awt.font.GlyphMetrics; //导入方法依赖的package包/类
/**
* Returns the geometry of the specified character. This method also put
* the in cache the geometry associated to the specified character if
* needed.
*/
public static
AWTGlyphGeometryCache.Value getGlyphGeometry(AWTGVTFont font,
char c,
GlyphVector gv,
int glyphIndex,
Point2D glyphPos) {
AWTGlyphGeometryCache glyphCache =
(AWTGlyphGeometryCache)fontCache.get(font.awtFont);
AWTGlyphGeometryCache.Value v = glyphCache.get(c);
if (v == null) {
Shape outline = gv.getGlyphOutline(glyphIndex);
GlyphMetrics metrics = gv.getGlyphMetrics(glyphIndex);
Rectangle2D gmB = metrics.getBounds2D();
if (AWTGVTGlyphVector.outlinesPositioned()) {
AffineTransform tr = AffineTransform.getTranslateInstance
(-glyphPos.getX(), -glyphPos.getY());
outline = tr.createTransformedShape(outline);
}
v = new AWTGlyphGeometryCache.Value(outline, gmB);
//System.out.println("put "+font.awtFont+" "+c);
glyphCache.put(c, v);
}
return v;
}