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


Java GlyphVector.getNumGlyphs方法代碼示例

本文整理匯總了Java中java.awt.font.GlyphVector.getNumGlyphs方法的典型用法代碼示例。如果您正苦於以下問題:Java GlyphVector.getNumGlyphs方法的具體用法?Java GlyphVector.getNumGlyphs怎麽用?Java GlyphVector.getNumGlyphs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.font.GlyphVector的用法示例。


在下文中一共展示了GlyphVector.getNumGlyphs方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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);
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:37,代碼來源:ImageProducer.java

示例2: findWidth

import java.awt.font.GlyphVector; //導入方法依賴的package包/類
/**
 * @param text the string to find the width of
 * @param logical whether to add the space the letters should occupy on the end
 * @return width of string.
 */
private int findWidth(String text,boolean logical) {
    char[] chars = text.toCharArray();
    GlyphVector vector = font.layoutGlyphVector(GlyphPage.renderContext, chars, 0, chars.length, Font.LAYOUT_LEFT_TO_RIGHT);

    int width = 0;
    int extraX = 0;
    boolean startNewLine = false;
    for (int glyphIndex = 0, n = vector.getNumGlyphs(); glyphIndex < n; glyphIndex++) {
        int charIndex = vector.getGlyphCharIndex(glyphIndex);
        int codePoint = text.codePointAt(charIndex);

        Rectangle bounds = logical ? vector.getLogicalBounds().getBounds() : getGlyphBounds(vector, glyphIndex, codePoint);

        if (startNewLine && codePoint != '\n') extraX = -bounds.x;

        if (glyphIndex > 0) extraX += paddingLeft + paddingRight + paddingAdvanceX;
        width = Math.max(width, bounds.x + extraX + bounds.width);

        if (codePoint == '\n') startNewLine = true;
    }
    return width;
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:28,代碼來源:UnicodeFont.java

示例3: samePositions

import java.awt.font.GlyphVector; //導入方法依賴的package包/類
private boolean samePositions(GlyphVector gv, int[] gvcodes,
                              int[] origCodes, float[] origPositions) {

    int numGlyphs = gv.getNumGlyphs();
    float[] gvpos = gv.getGlyphPositions(0, numGlyphs, null);

    /* this shouldn't happen here, but just in case */
    if (numGlyphs != gvcodes.length ||  /* real paranoia here */
        origCodes.length != gvcodes.length ||
        origPositions.length != gvpos.length) {
        return false;
    }

    for (int i=0; i<numGlyphs; i++) {
        if (gvcodes[i] != origCodes[i] || gvpos[i] != origPositions[i]) {
            return false;
        }
    }
    return true;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:21,代碼來源:PathGraphics.java

示例4: addGlyphs

import java.awt.font.GlyphVector; //導入方法依賴的package包/類
/**
 * Queues the glyphs in the specified text to be loaded. Note that the glyphs are not actually loaded until
 * {@link #loadGlyphs()} is called.
 * 
 * @param text The text containing the glyphs to be added
 */
public void addGlyphs(String text) {
	if (text == null) throw new IllegalArgumentException("text cannot be null.");

	char[] chars = text.toCharArray();
	GlyphVector vector = font.layoutGlyphVector(GlyphPage.renderContext, chars, 0, chars.length, Font.LAYOUT_LEFT_TO_RIGHT);
	for (int i = 0, n = vector.getNumGlyphs(); i < n; i++) {
		int codePoint = text.codePointAt(vector.getGlyphCharIndex(i));
		Rectangle bounds = getGlyphBounds(vector, i, codePoint);
		getGlyph(vector.getGlyphCode(i), codePoint, bounds, vector, i);
	}
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:18,代碼來源:UnicodeFont.java

示例5: getHeight

import java.awt.font.GlyphVector; //導入方法依賴的package包/類
/**
 * @see org.newdawn.slick.Font#getHeight(java.lang.String)
 */
public int getHeight (String text) {
	if (text == null) throw new IllegalArgumentException("text cannot be null.");
	if (text.length() == 0) return 0;

	if (displayListCaching) {
		DisplayList displayList = (DisplayList)displayLists.get(text);
		if (displayList != null) return displayList.height;
	}

	char[] chars = text.toCharArray();
	GlyphVector vector = font.layoutGlyphVector(GlyphPage.renderContext, chars, 0, chars.length, Font.LAYOUT_LEFT_TO_RIGHT);

	int lines = 0, height = 0;
	for (int i = 0, n = vector.getNumGlyphs(); i < n; i++) {
		int charIndex = vector.getGlyphCharIndex(i);
		int codePoint = text.codePointAt(charIndex);
		if (codePoint == ' ') continue;
		Rectangle bounds = getGlyphBounds(vector, i, codePoint);

		height = Math.max(height, ascent + bounds.y + bounds.height);

		if (codePoint == '\n') {
			lines++;
			height = 0;
		}
	}
	return lines * getLineHeight() + height;
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:32,代碼來源:UnicodeFont.java

示例6: 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);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:11,代碼來源:TextMeasureTests.java

示例7: 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.getGlyphLogicalBounds(i);
        }
    } while (--numReps >= 0);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:11,代碼來源:TextMeasureTests.java

示例8: StandardGlyphVector

import java.awt.font.GlyphVector; //導入方法依賴的package包/類
/**
 * Utility used by getStandardGV.
 * Constructs a StandardGlyphVector from a generic glyph vector.
 * Do not call this from new contexts without considering the comment
 * about "userGlyphs".
 */
private StandardGlyphVector(GlyphVector gv, FontRenderContext frc) {
    this.font = gv.getFont();
    this.frc = frc;
    initFontData();

    int nGlyphs = gv.getNumGlyphs();
    this.userGlyphs = gv.getGlyphCodes(0, nGlyphs, null);
    if (gv instanceof StandardGlyphVector) {
        /* userGlyphs will be OK because this is a private constructor
         * and the returned instance is used only for rendering.
         * It's not constructable by user code, nor returned to the
         * application. So we know "userGlyphs" are valid as having
         * been either already validated or are the result of layout.
         */
        this.glyphs = userGlyphs;
    } else {
        this.glyphs = getValidatedGlyphs(this.userGlyphs);
    }
    this.flags = gv.getLayoutFlags() & FLAG_MASK;

    if ((flags & FLAG_HAS_POSITION_ADJUSTMENTS) != 0) {
        this.positions = gv.getGlyphPositions(0, nGlyphs + 1, null);
    }

    if ((flags & FLAG_COMPLEX_GLYPHS) != 0) {
        this.charIndices = gv.getGlyphCharIndices(0, nGlyphs, null);
    }

    if ((flags & FLAG_HAS_TRANSFORMS) != 0) {
        AffineTransform[] txs = new AffineTransform[nGlyphs]; // worst case
        for (int i = 0; i < nGlyphs; ++i) {
            txs[i] = gv.getGlyphTransform(i); // gv doesn't have getGlyphsTransforms
        }

        setGlyphTransforms(txs);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:44,代碼來源:StandardGlyphVector.java

示例9: 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.getGlyphVisualBounds(i);
        }
    } while (--numReps >= 0);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:11,代碼來源:TextMeasureTests.java


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