当前位置: 首页>>代码示例>>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;未经允许,请勿转载。