protected Point2D getEndPoint(CharacterInformation info){ GVTGlyphVector it = info.layout.getGlyphVector(); if (!it.isGlyphVisible(info.glyphIndexEnd)) return null; Point2D b = it.getGlyphPosition(info.glyphIndexEnd); AffineTransform glyphTransform; glyphTransform = it.getGlyphTransform(info.glyphIndexEnd); GVTGlyphMetrics metrics = it.getGlyphMetrics(info.glyphIndexEnd); Point2D.Float result = new Point2D.Float (metrics.getHorizontalAdvance(), 0); if ( glyphTransform != null ) glyphTransform.transform(result,result); result.x += b.getX(); result.y += b.getY(); return result; }
AffineTransform.getScaleInstance(xScale, yScale); int numGlyphs = gv.getNumGlyphs(); float [] gp = gv.getGlyphPositions(0, numGlyphs+1, null); pos.x = initX+dx*xScale; pos.y = initY+dy*yScale; gv.setGlyphPosition(i, pos); AffineTransform glyphTransform = gv.getGlyphTransform(i); if (glyphTransform != null) { glyphTransform.preConcatenate(scaleAT); gv.setGlyphTransform(i, glyphTransform); } else { gv.setGlyphTransform (i, scaleAT);
/** * Draws the glyph vector. */ public void draw(Graphics2D g2d, AttributedCharacterIterator aci) { int begin = aci.getBeginIndex(); for (GVTGlyphVector gv : gvs) { int end = gv.getCharacterCount(0, gv.getNumGlyphs()) + 1; gv.draw(g2d, new AttributedCharacterSpanIterator(aci, begin, end)); begin = end; } }
@Override protected void doExplicitGlyphLayout() { GVTGlyphVector gv = this.gv; gv.performDefaultLayout(); int ng = gv.getNumGlyphs(); if (ng > 0) { this.advance = gv.getGlyphPosition(ng); } else { this.advance = new Point2D.Float(0, 0); } this.layoutApplied = true; }
/** * Get the visual advance associated with the current glyph. * This is the distance from the location of the glyph to * the rightmost part of the glyph. */ protected float getCharWidth(int gvIdx) { Rectangle2D lcBound = gv.getGlyphVisualBounds(gvIdx).getBounds2D(); Point2D lcLoc = gv.getGlyphPosition(gvIdx); return (float)(lcBound.getX()+lcBound.getWidth()- lcLoc.getX()); } }
this.gv.performDefaultLayout(); (float) gv.getLogicalBounds().getWidth() : (metrics.getAscent() + Math.abs(metrics.getDescent())); int numGlyphs = gv.getNumGlyphs(); float[] gp = gv.getGlyphPositions(0, numGlyphs+1, null); float verticalFirstOffset = 0f; float horizontalFirstOffset = 0f; GVTGlyphMetrics gm = gv.getGlyphMetrics(i); } else { Rectangle2D glyphBounds = gv.getGlyphVisualBounds(i).getBounds2D(); ox -= (float)((glyphBounds.getMaxX() - gp[2*i]) - glyphBounds.getWidth()/2); = gv.getGlyphVisualBounds(i).getBounds2D(); if (glyphOrientationAngle == 0) { ox -= (float)((glyphBounds.getMaxX() - gp[2*i]) - gv.setGlyphPosition(i, pos); gv.setGlyphTransform (i, AffineTransform.getTranslateInstance (0, advanceY));
int numGlyphs = gv.getNumGlyphs(); gv.setGlyphVisible(i, true); glyphsLength = (float) gv.getLogicalBounds().getWidth(); } else { glyphsLength = (float) gv.getLogicalBounds().getHeight(); Point2D firstGlyphPosition = gv.getGlyphPosition(0); float glyphOffset = 0; // offset perpendicular to path float currentPosition; Point2D currentGlyphPos = gv.getGlyphPosition(i); Point2D nextGlyphPosition = gv.getGlyphPosition(i+1); if (horizontal) { glyphAdvance = (float)(nextGlyphPosition.getX() - Rectangle2D glyphBounds = gv.getGlyphOutline(i).getBounds2D(); float glyphWidth = (float) glyphBounds.getWidth(); float glyphHeight = (float) glyphBounds.getHeight(); AffineTransform glyphTransform = gv.getGlyphTransform(i); if (glyphTransform != null) { glyphPathTransform.concatenate(glyphTransform); gv.setGlyphTransform(i, glyphPathTransform); gv.setGlyphPosition (i, charMidPoint);
int numGlyphs = gv.getNumGlyphs(); Point2D prevPos = gv.getGlyphPosition(0); int prevCode = gv.getGlyphCode(0); float x = (float) prevPos.getX(); float y = (float) prevPos.getY(); = new Point2D.Double(advance.getX() - (gv.getGlyphPosition(numGlyphs-1).getX() - x), advance.getY() - (gv.getGlyphPosition(numGlyphs-1).getY() - y)); GVTFont font = gv.getFont(); Point2D gpos = gv.getGlyphPosition(i); int currCode; currCode = (i == numGlyphs)?-1:gv.getGlyphCode(i); dx = (float)gpos.getX()-(float)prevPos.getX(); dy = (float)gpos.getY()-(float)prevPos.getY(); gv.setGlyphPosition(i, newPositions[i]); prevPos = gv.getGlyphPosition(0); x = (float) prevPos.getX(); y = (float) prevPos.getY(); Point2D gpos = gv.getGlyphPosition(i); dx = (float)gpos.getX()-(float)prevPos.getX(); dy = (float)gpos.getY()-(float)prevPos.getY(); GVTGlyphMetrics gm = gv.getGlyphMetrics(i);
int numGlyphs = gv.getNumGlyphs(); float [] gp = gv.getGlyphPositions(0, numGlyphs+1, null); Point2D.Float pos = new Point2D.Float(); for (int i=0; i<=numGlyphs; i++) { pos.x = gp[2*i ]+dx; pos.y = gp[2*i+1]+dy; gv.setGlyphPosition(i, pos);
public GlyphIterator(AttributedCharacterIterator aci, GVTGlyphVector gv) { this.aci = aci; this.gv = gv; this.idx = 0; this.chIdx = 0; this.lineIdx = 0; this.aciIdx = aci.getBeginIndex(); this.charCount = gv.getCharacterCount(idx, idx); this.ch = aci.first(); this.frc = gv.getFontRenderContext(); this.font = (GVTFont)aci.getAttribute(GVT_FONT); if (font == null) { font = new AWTGVTFont(aci.getAttributes()); } fontStart = aciIdx; this.maxFontSize = -Float.MAX_VALUE; this.maxAscent = -Float.MAX_VALUE; this.maxDescent = -Float.MAX_VALUE; // Figure out where the font size might change again... this.runLimit = aci.getRunLimit(TEXT_COMPOUND_ID); this.lineBreakRunLimit = aci.getRunLimit(FLOW_LINE_BREAK); Object o = aci.getAttribute(FLOW_LINE_BREAK); this.lineBreakCount = (o == null)?0:1; this.numGlyphs = gv.getNumGlyphs(); this.gp = gv.getGlyphPositions(0, this.numGlyphs+1, null); this.gvBase = new Point2D.Float(gp[0], gp[1]); this.adv = getCharWidth(); this.adj = getCharAdvance(); }
gv.setGlyphVisible(pggi.getEnd(), false); int end = ggi.getEnd(); boolean [] hide = ggi.getHide(); Point2D p2d = gv.getGlyphPosition(start); double deltaX = p2d.getX(); double advAdj = 0; for (int g=start; g<=end; g++) { Point2D np2d = gv.getGlyphPosition(g+1); if (hide[g-start]) { gv.setGlyphVisible(g, false); advAdj += np2d.getX()-p2d.getX(); } else { gv.setGlyphVisible(g, true); gv.setGlyphPosition(g, p2d); p2d = np2d; advAdj -= gAdv;
int numWords, FontRenderContext frc) { int numGlyphs = gv.getNumGlyphs(); int [] glyphWords = new int[numGlyphs]; int [] wordMap = allocWordMap(null, 10); int cnt = gv.getCharacterCount(i,i); aci.setIndex(aciIdx); Integer integer = (Integer)aci.getAttribute(WORD_LIMIT); boolean [] hide = new boolean[numGlyphs]; boolean [] space = new boolean[numGlyphs]; float [] glyphPos = gv.getGlyphPositions(0, numGlyphs+1, null); for (int i=0; i<numGlyphs; i++) { char pch = ch; int chCnt = gv.getCharacterCount(i,i); if (chCnt == 1) { char nch;
/** * Returns the bounds of this GlyphVector. This includes * stroking effects. */ public Rectangle2D getBounds2D(AttributedCharacterIterator aci) { Rectangle2D ret = null; int begin = aci.getBeginIndex(); for (GVTGlyphVector gv : gvs) { int end = gv.getCharacterCount(0, gv.getNumGlyphs()) + 1; Rectangle2D b = gv.getBounds2D (new AttributedCharacterSpanIterator(aci, begin, end)); if (ret == null) ret = b; //else ret = ret.createUnion(b); else ret.add(b); begin = end; } return ret; }
for (int i = 0; i < gv.getNumGlyphs(); i++) { Shape gbounds = gv.getGlyphLogicalBounds(i); if (gbounds != null) { Rectangle2D gbounds2d = gbounds.getBounds2D();
protected Point2D getStartPoint(CharacterInformation info){ GVTGlyphVector it = info.layout.getGlyphVector(); if (!it.isGlyphVisible(info.glyphIndexStart)) return null; Point2D b = it.getGlyphPosition(info.glyphIndexStart); AffineTransform glyphTransform; glyphTransform = it.getGlyphTransform(info.glyphIndexStart); //glyph are defined starting at position (0,0) Point2D.Float result = new Point2D.Float(0, 0); if ( glyphTransform != null ) //apply the glyph transformation to the start point glyphTransform.transform(result,result); result.x += b.getX(); result.y += b.getY(); return result; }
public float [] getGlyphAdvances() { if (glyphAdvances != null) return glyphAdvances; if (!spacingApplied) // This will layout the text if needed. adjustTextSpacing(); int numGlyphs = gv.getNumGlyphs(); float [] glyphPos = gv.getGlyphPositions(0, numGlyphs+1, null); glyphAdvances = new float[numGlyphs+1]; int off = 0; if (isVertical()) off = 1; float start = glyphPos[off]; for (int i=0; i<numGlyphs+1; i++) { glyphAdvances[i] = glyphPos[2*i+off]-start; } return glyphAdvances; }
int numGlyphs = gv.getNumGlyphs(); gv.setGlyphVisible(idx, false); continue; gv.setGlyphVisible(idx++, false);
(ch == ZERO_WIDTH_JOINER)) { gv.setGlyphVisible(idx, false); float chAdv = getCharAdvance(); adj -= chAdv; ch = aci.setIndex(aciIdx); idx++; charCount = gv.getCharacterCount(idx,idx); if (idx == numGlyphs) return;
Point2D.Float verticalAlignOffset) { if (ch == SOFT_HYPHEN) { gv.setGlyphVisible(idx, true); nextLSI = leftShiftIdx[lsi]; gv.setGlyphPosition(ci, new Point2D.Float(gp[2*ci]-leftShift, gp[2*ci+1])); gv.setGlyphVisible(idx, false); gv.setGlyphVisible(i, false);
/** * Returns the number of glyphs in this layout. */ public int getGlyphCount() { return gv.getNumGlyphs(); }