/** * Returns a new GlyphVector object created with the specified integer * array and the specified FontRenderContext. */ public GVTGlyphVector createGlyphVector(FontRenderContext frc, int[] glyphCodes, CharacterIterator ci) { return new AWTGVTGlyphVector (awtFont.createGlyphVector(frc, glyphCodes), this, scale, ci); }
/** * Returns the logical bounds of this GlyphVector. * This is a bound useful for hit detection and highlighting. */ public Rectangle2D getLogicalBounds() { if (logicalBounds == null) { // This fills in logicalBounds... computeGlyphLogicalBounds(); } return logicalBounds; }
/** * Returns the bounding box of the specified glyph, considering only the * glyph's metrics (ascent, descent, advance) rather than the actual glyph * shape. */ public Rectangle2D getGlyphCellBounds(int glyphIndex) { return getGlyphLogicalBounds(glyphIndex).getBounds2D(); }
/** * Returns a Shape whose interior corresponds to the visual representation * of this GlyphVector. */ public Shape getOutline() { if (outline != null) return outline; outline = new GeneralPath(); for (int i = 0; i < getNumGlyphs(); i++) { if (glyphVisible[i]) { Shape glyphOutline = getGlyphOutline(i); outline.append(glyphOutline, false); } } return outline; }
Shape[] tempLogicalBounds = new Shape[getNumGlyphs()]; boolean[] rotated = new boolean[getNumGlyphs()]; for (int i = 0; i < getNumGlyphs(); i++) { AffineTransform glyphTransform = getGlyphTransform(i); GVTGlyphMetrics glyphMetrics = getGlyphMetrics(i); Point2D gpos = getGlyphPosition(i); AffineTransform tr = AffineTransform.getTranslateInstance (gpos.getX(), gpos.getY()); for (int i = 0; i < getNumGlyphs(); i++) { if (tempLogicalBounds[i] != null) { logicalBoundsPath.append(tempLogicalBounds[i], false); for (int i = 0; i < getNumGlyphs(); i++) { if ((i < getNumGlyphs()-1) && (tempLogicalBounds[i+1] != null)) { for (int i = 0; i < getNumGlyphs(); i++) { if ((i < getNumGlyphs()-1) && (tempLogicalBounds[i+1] != null)) { System.arraycopy( tempLogicalBounds, 0, glyphLogicalBounds, 0, getNumGlyphs() );
(getGlyphPosition(glyphIndex).getX(), getGlyphPosition(glyphIndex).getY()); AffineTransform glyphTransform = getGlyphTransform(glyphIndex); if (glyphTransform != null) { tr.concatenate(glyphTransform);
int numGlyphs = getNumGlyphs(); Shape outline = getOutline();
/** * Returns the visual bounds of this GlyphVector The visual bounds is the * tightest rectangle enclosing all non-background pixels in the rendered * representation of this GlyphVector. */ public Rectangle2D getGeometricBounds() { if (visualBounds == null) { Shape outline = getOutline(); visualBounds = outline.getBounds2D(); } return visualBounds; }
/** * Sets the position of the specified glyph within this GlyphVector. */ public void setGlyphPosition(int glyphIndex, Point2D newPos) { glyphPositions[glyphIndex].x = (float)newPos.getX(); glyphPositions[glyphIndex].y = (float)newPos.getY(); outline = null; visualBounds = null; logicalBounds = null; bounds2D = null; if (glyphIndex != getNumGlyphs()) { glyphVisualBounds [glyphIndex] = null; glyphLogicalBounds[glyphIndex] = null; glyphOutlines [glyphIndex] = null; glyphMetrics [glyphIndex] = null; } }
/** * Returns an array of glyph positions for the specified glyphs */ public float[] getGlyphPositions(int beginGlyphIndex, int numEntries, float[] positionReturn) { if (positionReturn == null) { positionReturn = new float[numEntries*2]; } for (int i = beginGlyphIndex; i < (beginGlyphIndex+numEntries); i++) { Point2D glyphPos = getGlyphPosition(i); positionReturn[(i-beginGlyphIndex)*2] = (float)glyphPos.getX(); positionReturn[(i-beginGlyphIndex)*2 + 1] = (float)glyphPos.getY(); } return positionReturn; }
/** * 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; }
Shape[] tempLogicalBounds = new Shape[getNumGlyphs()]; boolean[] rotated = new boolean[getNumGlyphs()]; for (int i = 0; i < getNumGlyphs(); i++) { AffineTransform glyphTransform = getGlyphTransform(i); GVTGlyphMetrics glyphMetrics = getGlyphMetrics(i); Point2D gpos = getGlyphPosition(i); AffineTransform tr = AffineTransform.getTranslateInstance (gpos.getX(), gpos.getY()); for (int i = 0; i < getNumGlyphs(); i++) { if (tempLogicalBounds[i] != null) { logicalBoundsPath.append(tempLogicalBounds[i], false); for (int i = 0; i < getNumGlyphs(); i++) { if ((i < getNumGlyphs()-1) && (tempLogicalBounds[i+1] != null)) { for (int i = 0; i < getNumGlyphs(); i++) { if ((i < getNumGlyphs()-1) && (tempLogicalBounds[i+1] != null)) { System.arraycopy( tempLogicalBounds, 0, glyphLogicalBounds, 0, getNumGlyphs() );
(getGlyphPosition(glyphIndex).getX(), getGlyphPosition(glyphIndex).getY()); AffineTransform glyphTransform = getGlyphTransform(glyphIndex); if (glyphTransform != null) { tr.concatenate(glyphTransform);
/** * Returns a Shape whose interior corresponds to the visual representation * of this GlyphVector. */ public Shape getOutline() { if (outline != null) return outline; outline = new GeneralPath(); for (int i = 0; i < getNumGlyphs(); i++) { if (glyphVisible[i]) { Shape glyphOutline = getGlyphOutline(i); outline.append(glyphOutline, false); } } return outline; }
int numGlyphs = getNumGlyphs(); Shape outline = getOutline();
/** * Returns the visual bounds of this GlyphVector The visual bounds is the * tightest rectangle enclosing all non-background pixels in the rendered * representation of this GlyphVector. */ public Rectangle2D getGeometricBounds() { if (visualBounds == null) { Shape outline = getOutline(); visualBounds = outline.getBounds2D(); } return visualBounds; }
/** * Sets the position of the specified glyph within this GlyphVector. */ public void setGlyphPosition(int glyphIndex, Point2D newPos) { glyphPositions[glyphIndex].x = (float)newPos.getX(); glyphPositions[glyphIndex].y = (float)newPos.getY(); outline = null; visualBounds = null; logicalBounds = null; bounds2D = null; if (glyphIndex != getNumGlyphs()) { glyphVisualBounds [glyphIndex] = null; glyphLogicalBounds[glyphIndex] = null; glyphOutlines [glyphIndex] = null; glyphMetrics [glyphIndex] = null; } }
/** * Returns an array of glyph positions for the specified glyphs */ public float[] getGlyphPositions(int beginGlyphIndex, int numEntries, float[] positionReturn) { if (positionReturn == null) { positionReturn = new float[numEntries*2]; } for (int i = beginGlyphIndex; i < (beginGlyphIndex+numEntries); i++) { Point2D glyphPos = getGlyphPosition(i); positionReturn[(i-beginGlyphIndex)*2] = (float)glyphPos.getX(); positionReturn[(i-beginGlyphIndex)*2 + 1] = (float)glyphPos.getY(); } return positionReturn; }
/** * 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; }
Shape[] tempLogicalBounds = new Shape[getNumGlyphs()]; boolean[] rotated = new boolean[getNumGlyphs()]; for (int i = 0; i < getNumGlyphs(); i++) { AffineTransform glyphTransform = getGlyphTransform(i); GVTGlyphMetrics glyphMetrics = getGlyphMetrics(i); Point2D gpos = getGlyphPosition(i); AffineTransform tr = AffineTransform.getTranslateInstance (gpos.getX(), gpos.getY()); for (int i = 0; i < getNumGlyphs(); i++) { if (tempLogicalBounds[i] != null) { logicalBoundsPath.append(tempLogicalBounds[i], false); for (int i = 0; i < getNumGlyphs(); i++) { if ((i < getNumGlyphs()-1) && (tempLogicalBounds[i+1] != null)) { for (int i = 0; i < getNumGlyphs(); i++) { if ((i < getNumGlyphs()-1) && (tempLogicalBounds[i+1] != null)) { System.arraycopy( tempLogicalBounds, 0, glyphLogicalBounds, 0, getNumGlyphs() );