當前位置: 首頁>>代碼示例>>Java>>正文


Java GlyphMetrics.getBounds2D方法代碼示例

本文整理匯總了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]);
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:20,代碼來源:FreetypeGlyphVector.java

示例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]);
}
 
開發者ID:nmldiegues,項目名稱:jvm-stm,代碼行數:20,代碼來源:FreetypeGlyphVector.java

示例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);
}
 
開發者ID:phuseman,項目名稱:r2cat,代碼行數:24,代碼來源:PDFFontEmbedderType3.java

示例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;
}
 
開發者ID:git-moss,項目名稱:Push2Display,代碼行數:32,代碼來源:AWTGVTFont.java


注:本文中的java.awt.font.GlyphMetrics.getBounds2D方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。