Examples of GlyphVector


Examples of java.awt.font.GlyphVector

        }
    }

    private void appendLine(String text, int start, int end, FontRenderContext fontRenderContext) {
        StringCharacterIterator line = new StringCharacterIterator(text, start, end, start);
        GlyphVector glyphVector = font.createGlyphVector(fontRenderContext, line);
        glyphVectors.add(glyphVector);

        Rectangle2D textBounds = glyphVector.getLogicalBounds();
        textHeight += textBounds.getHeight();
    }
View Full Code Here

Examples of java.awt.font.GlyphVector

                    break;
                }
            }

            for (int i = 0, n = glyphVectors.getLength(); i < n; i++) {
                GlyphVector glyphVector = glyphVectors.get(i);

                Rectangle2D textBounds = glyphVector.getLogicalBounds();
                float lineWidth = (float)textBounds.getWidth();

                float x = 0;
                switch (horizontalAlignment) {
                    case LEFT: {
View Full Code Here

Examples of java.awt.font.GlyphVector

     * @param glyphCode the glyphCode from the original 2D Font
     * @param bounds the 3D glyph's bounds
     */
    public void getBoundingBox(int glyphCode, BoundingBox bounds){
      int[] gCodes = {glyphCode};
      GlyphVector gVec = font.createGlyphVector(frc, gCodes);
      Rectangle2D.Float bounds2d = (Rectangle2D.Float)
  (((GlyphMetrics)(gVec.getGlyphMetrics(0))).getBounds2D());

      Point3d lower = new Point3d(bounds2d.x, bounds2d.y, 0.0);
      Point3d upper;
      if (fontExtrusion != null) {
          upper = new Point3d(bounds2d.x + bounds2d.width,
View Full Code Here

Examples of java.awt.font.GlyphVector

    final Rectangle2D rect = this.font.getMaxCharBounds(frc);
    this.maxCharAdvance = FontStrictGeomUtility.toInternalValue(rect.getWidth());
    this.ascent = FontStrictGeomUtility.toInternalValue(-rect.getY());
    this.descent = FontStrictGeomUtility.toInternalValue(rect.getHeight() + rect.getY());

    final GlyphVector gv = font.createGlyphVector(frc, "x");
    final Rectangle2D bounds = gv.getVisualBounds();
    this.xheight = FontStrictGeomUtility.toInternalValue(bounds.getHeight());

    this.cpBuffer = new char[4];
    this.cachedBaselines = new BaselineInfo[256 - 32];
    this.cachedWidths = new long[256 - 32];
View Full Code Here

Examples of java.awt.font.GlyphVector

    final int retvalC2 = CodePointUtilities.toChars(character, cpBuffer, retvalC1);
    if (retvalC2 > 0)
    {
      final int limit = (retvalC1 + retvalC2);
      final GlyphVector gv = font.createGlyphVector(frc, new String(cpBuffer, 0, limit));
      final long totalSize = FontStrictGeomUtility.toInternalValue(gv.getGlyphPosition(limit).getX());
      final long renderedWidth = FontStrictGeomUtility.toInternalValue(gv.getOutline().getBounds2D().getWidth());
      return totalSize - renderedWidth;
    }
    else
    {
      return 0;
View Full Code Here

Examples of java.awt.font.GlyphVector

                            lastWhitespaceIndex = -1;

                            // Append the current line
                            if ((i - 1) - start > 0) {
                                StringCharacterIterator line = new StringCharacterIterator(text, start, i, start);
                                GlyphVector glyphVector = font.createGlyphVector(FONT_RENDER_CONTEXT, line);
                                glyphVectors.add(glyphVector);

                                Rectangle2D textBounds = glyphVector.getLogicalBounds();
                                textHeight += textBounds.getHeight();
                            }

                            start = i + 1;
                        }

                        i++;
                    }

                    // Append the final line
                    if ((i - 1) - start > 0) {
                        StringCharacterIterator line = new StringCharacterIterator(text, start, i, start);
                        GlyphVector glyphVector = font.createGlyphVector(FONT_RENDER_CONTEXT, line);
                        glyphVectors.add(glyphVector);

                        Rectangle2D textBounds = glyphVector.getLogicalBounds();
                        textHeight += textBounds.getHeight();
                    }
                } else {
                    GlyphVector glyphVector = font.createGlyphVector(FONT_RENDER_CONTEXT, text);
                    glyphVectors.add(glyphVector);

                    Rectangle2D textBounds = glyphVector.getLogicalBounds();
                    textHeight += textBounds.getHeight();
                }
            }
        }
    }
View Full Code Here

Examples of java.awt.font.GlyphVector

                    break;
                }
            }

            for (int i = 0, n = glyphVectors.getLength(); i < n; i++) {
                GlyphVector glyphVector = glyphVectors.get(i);

                Rectangle2D textBounds = glyphVector.getLogicalBounds();
                float lineWidth = (float)textBounds.getWidth();

                float x = 0;
                switch(horizontalAlignment) {
                    case LEFT: {
View Full Code Here

Examples of java.awt.font.GlyphVector

        }

        this.font = font;

        int missingGlyphCode = font.getMissingGlyphCode();
        GlyphVector missingGlyphVector = font.createGlyphVector(FONT_RENDER_CONTEXT,
            new int[] {missingGlyphCode});
        Rectangle2D textBounds = missingGlyphVector.getLogicalBounds();

        Rectangle2D maxCharBounds = font.getMaxCharBounds(FONT_RENDER_CONTEXT);
        averageCharacterSize = new Dimensions((int)Math.ceil(textBounds.getWidth()),
            (int)Math.ceil(maxCharBounds.getHeight()));
View Full Code Here

Examples of java.awt.font.GlyphVector

            float ascent = lm.getAscent();

            float y = 0;

            for (int i = 0, n = glyphVectors.getLength(); i < n; i++) {
                GlyphVector glyphVector = glyphVectors.get(i);

                Rectangle2D textBounds = glyphVector.getLogicalBounds();
                float lineWidth = (float)textBounds.getWidth();

                float x = 0;
                switch(alignment) {
                    case LEFT: {
                        x = 0;
                        break;
                    }

                    case RIGHT: {
                        x = width - lineWidth;
                        break;
                    }

                    case CENTER: {
                        x = (width - lineWidth) / 2;
                        break;
                    }
                }

                if (fill != null) {
                    graphics.setFont(font);
                    graphics.setPaint(fill);
                    graphics.drawGlyphVector(glyphVector, x, y + ascent);
                }

                // TODO Would caching the outlines help optimize this method, or are they
                // already cached by the glyph vector itself?
                if (stroke != null
                    && strokeThickness > 0) {
                    java.awt.Shape outline = glyphVector.getOutline();

                    graphics.setPaint(stroke);
                    graphics.setStroke(new BasicStroke(strokeThickness));

                    graphics.translate(x, y + ascent);
View Full Code Here

Examples of java.awt.font.GlyphVector

                    || text.length() == 0) {
                    width = 0;
                    height = 0;
                } else {
                    // Create a single glyph vector representing the entire string
                    GlyphVector glyphVector = font.createGlyphVector(FONT_RENDER_CONTEXT, text);
                    glyphVectors.add(glyphVector);

                    Rectangle2D textBounds = glyphVector.getLogicalBounds();
                    width = (int)Math.ceil(textBounds.getWidth());
                    height = (int)Math.ceil(textBounds.getHeight());
                }
            } else {
                float textWidth = 0;
                float textHeight = 0;

                int n = text.length();
                if (n > 0) {
                    float lineWidth = 0;
                    int lastWhitespaceIndex = -1;

                    int start = 0;
                    int i = 0;
                    while (i < n) {
                        char c = text.charAt(i);
                        if (Character.isWhitespace(c)) {
                            lastWhitespaceIndex = i;
                        }

                        Rectangle2D characterBounds = font.getStringBounds(text, i, i + 1,
                            FONT_RENDER_CONTEXT);
                        lineWidth += characterBounds.getWidth();

                        if (lineWidth > this.width
                            && lastWhitespaceIndex != -1) {
                            i = lastWhitespaceIndex;

                            lineWidth = 0;
                            lastWhitespaceIndex = -1;

                            // Append the current line
                            if ((i - 1) - start > 0) {
                                StringCharacterIterator line = new StringCharacterIterator(text, start, i, start);
                                GlyphVector glyphVector = font.createGlyphVector(FONT_RENDER_CONTEXT, line);
                                glyphVectors.add(glyphVector);

                                Rectangle2D textBounds = glyphVector.getLogicalBounds();
                                textWidth = (float)Math.max(textBounds.getWidth(), textWidth);
                                textHeight += textBounds.getHeight();
                            }

                            start = i + 1;
                        }

                        i++;
                    }

                    // Append the final line
                    if ((i - 1) - start > 0) {
                        StringCharacterIterator line = new StringCharacterIterator(text, start, i, start);
                        GlyphVector glyphVector = font.createGlyphVector(FONT_RENDER_CONTEXT, line);
                        glyphVectors.add(glyphVector);

                        Rectangle2D textBounds = glyphVector.getLogicalBounds();
                        textWidth = (float)Math.max(textBounds.getWidth(), textWidth);
                        textHeight += textBounds.getHeight();
                    }

                    width = (int)Math.ceil(textWidth);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.