Package org.apache.batik.gvt.font
Class SVGGVTGlyphVector
- java.lang.Object
-
- org.apache.batik.gvt.font.SVGGVTGlyphVector
-
- All Implemented Interfaces:
GVTGlyphVector
public final class SVGGVTGlyphVector extends java.lang.Object implements GVTGlyphVector
A GVTGlyphVector class for SVG fonts.- Version:
- $Id: SVGGVTGlyphVector.java 1733416 2016-03-03 07:07:13Z gadams $
-
-
Field Summary
Fields Modifier and Type Field Description private java.awt.geom.Rectangle2Dbounds2Dprivate TextPaintInfocacheTPIprivate java.awt.geom.Point2DendPosprivate GVTFontfontprivate java.awt.font.FontRenderContextfrcprivate java.awt.Shape[]glyphLogicalBoundsprivate Glyph[]glyphsprivate boolean[]glyphVisibleprivate java.awt.geom.Rectangle2DlogicalBoundsprivate java.awt.geom.GeneralPathoutlinestatic java.text.AttributedCharacterIterator.AttributePAINT_INFO
-
Constructor Summary
Constructors Constructor Description SVGGVTGlyphVector(GVTFont font, Glyph[] glyphs, java.awt.font.FontRenderContext frc)Constructs an SVGGVTGlyphVector.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcomputeGlyphLogicalBounds()voiddraw(java.awt.Graphics2D graphics2D, java.text.AttributedCharacterIterator aci)Draws this glyph vector.java.awt.geom.Rectangle2DgetBounds2D(java.text.AttributedCharacterIterator aci)Returns a tight bounds on the GylphVector including stroking.intgetCharacterCount(int startGlyphIndex, int endGlyphIndex)Returns the number of chars represented by the glyphs within the specified range.GVTFontgetFont()Returns the Font associated with this GlyphVector.java.awt.font.FontRenderContextgetFontRenderContext()Returns the FontRenderContext associated with this GlyphVector.java.awt.geom.Rectangle2DgetGeometricBounds()Returns the geometric bounds of this GlyphVector.java.awt.geom.Rectangle2DgetGlyphCellBounds(int glyphIndex)Returns the bounding box of the specified glyph, considering only the glyph's metrics (ascent, descent, advance) rather than the actual glyph shape.intgetGlyphCode(int glyphIndex)Returns the glyphcode of the specified glyph.int[]getGlyphCodes(int beginGlyphIndex, int numEntries, int[] codeReturn)Returns an array of glyphcodes for the specified glyphs.java.awt.font.GlyphJustificationInfogetGlyphJustificationInfo(int glyphIndex)Returns the justification information for the glyph at the specified index into this GlyphVector.java.awt.ShapegetGlyphLogicalBounds(int glyphIndex)Returns the logical bounds of the specified glyph within this GlyphVector.GVTGlyphMetricsgetGlyphMetrics(int idx)Returns the metrics of the glyph at the specified index into this GlyphVector.java.awt.ShapegetGlyphOutline(int glyphIndex)Returns a Shape whose interior corresponds to the visual representation of the specified glyph within this GlyphVector.java.awt.geom.Point2DgetGlyphPosition(int glyphIndex)Returns the position of the specified glyph within this GlyphVector.float[]getGlyphPositions(int beginGlyphIndex, int numEntries, float[] positionReturn)Returns an array of glyph positions for the specified glyphsjava.awt.geom.AffineTransformgetGlyphTransform(int glyphIndex)Gets the transform of the specified glyph within this GlyphVector.java.awt.ShapegetGlyphVisualBounds(int glyphIndex)Returns the visual bounds of the specified glyph within the GlyphVector.java.awt.geom.Rectangle2DgetLogicalBounds()Returns the logical bounds of this GlyphVector.intgetNumGlyphs()Returns the number of glyphs in this GlyphVector.java.awt.ShapegetOutline()Returns a Shape whose interior corresponds to the visual representation of this GlyphVector.java.awt.ShapegetOutline(float x, float y)Returns a Shape whose interior corresponds to the visual representation of this GlyphVector, offset to x, y.booleanisGlyphVisible(int glyphIndex)Returns true if specified glyph will be rendered.booleanisReversed()Return true if glyphs have been reversed.voidmaybeReverse(boolean mirror)Reverse (and optionally mirror) glyphs if not already reversed.voidperformDefaultLayout()Assigns default positions to each glyph in this GlyphVector.voidsetGlyphPosition(int glyphIndex, java.awt.geom.Point2D newPos)Sets the position of the specified glyph within this GlyphVector.voidsetGlyphTransform(int glyphIndex, java.awt.geom.AffineTransform newTX)Sets the transform of the specified glyph within this GlyphVector.voidsetGlyphVisible(int glyphIndex, boolean visible)Tells the glyph vector whether or not to draw the specified glyph.
-
-
-
Field Detail
-
PAINT_INFO
public static final java.text.AttributedCharacterIterator.Attribute PAINT_INFO
-
font
private GVTFont font
-
glyphs
private Glyph[] glyphs
-
frc
private java.awt.font.FontRenderContext frc
-
outline
private java.awt.geom.GeneralPath outline
-
logicalBounds
private java.awt.geom.Rectangle2D logicalBounds
-
bounds2D
private java.awt.geom.Rectangle2D bounds2D
-
glyphLogicalBounds
private java.awt.Shape[] glyphLogicalBounds
-
glyphVisible
private boolean[] glyphVisible
-
endPos
private java.awt.geom.Point2D endPos
-
cacheTPI
private TextPaintInfo cacheTPI
-
-
Constructor Detail
-
SVGGVTGlyphVector
public SVGGVTGlyphVector(GVTFont font, Glyph[] glyphs, java.awt.font.FontRenderContext frc)
Constructs an SVGGVTGlyphVector.- Parameters:
font- The font that is creating this glyph vector.glyphs- An array containing the glyphs that form the basis for this glyph vector.frc- The current font render context.
-
-
Method Detail
-
getFont
public GVTFont getFont()
Returns the Font associated with this GlyphVector.- Specified by:
getFontin interfaceGVTGlyphVector
-
getFontRenderContext
public java.awt.font.FontRenderContext getFontRenderContext()
Returns the FontRenderContext associated with this GlyphVector.- Specified by:
getFontRenderContextin interfaceGVTGlyphVector
-
getGlyphCode
public int getGlyphCode(int glyphIndex) throws java.lang.IndexOutOfBoundsExceptionReturns the glyphcode of the specified glyph.- Specified by:
getGlyphCodein interfaceGVTGlyphVector- Throws:
java.lang.IndexOutOfBoundsException
-
getGlyphCodes
public int[] getGlyphCodes(int beginGlyphIndex, int numEntries, int[] codeReturn) throws java.lang.IndexOutOfBoundsException, java.lang.IllegalArgumentExceptionReturns an array of glyphcodes for the specified glyphs.- Specified by:
getGlyphCodesin interfaceGVTGlyphVector- Throws:
java.lang.IndexOutOfBoundsExceptionjava.lang.IllegalArgumentException
-
getGlyphJustificationInfo
public java.awt.font.GlyphJustificationInfo getGlyphJustificationInfo(int glyphIndex)
Returns the justification information for the glyph at the specified index into this GlyphVector.- Specified by:
getGlyphJustificationInfoin interfaceGVTGlyphVector
-
getGlyphLogicalBounds
public java.awt.Shape getGlyphLogicalBounds(int glyphIndex)
Returns the logical bounds of the specified glyph within this GlyphVector.- Specified by:
getGlyphLogicalBoundsin interfaceGVTGlyphVector
-
computeGlyphLogicalBounds
private void computeGlyphLogicalBounds()
-
getGlyphMetrics
public GVTGlyphMetrics getGlyphMetrics(int idx)
Returns the metrics of the glyph at the specified index into this GlyphVector.- Specified by:
getGlyphMetricsin interfaceGVTGlyphVector
-
getGlyphOutline
public java.awt.Shape getGlyphOutline(int glyphIndex)
Returns a Shape whose interior corresponds to the visual representation of the specified glyph within this GlyphVector.- Specified by:
getGlyphOutlinein interfaceGVTGlyphVector
-
getGlyphCellBounds
public java.awt.geom.Rectangle2D getGlyphCellBounds(int glyphIndex)
Returns the bounding box of the specified glyph, considering only the glyph's metrics (ascent, descent, advance) rather than the actual glyph shape.- Specified by:
getGlyphCellBoundsin interfaceGVTGlyphVector
-
getGlyphPosition
public java.awt.geom.Point2D getGlyphPosition(int glyphIndex)
Returns the position of the specified glyph within this GlyphVector.- Specified by:
getGlyphPositionin interfaceGVTGlyphVector
-
getGlyphPositions
public float[] getGlyphPositions(int beginGlyphIndex, int numEntries, float[] positionReturn)Returns an array of glyph positions for the specified glyphs- Specified by:
getGlyphPositionsin interfaceGVTGlyphVector
-
getGlyphTransform
public java.awt.geom.AffineTransform getGlyphTransform(int glyphIndex)
Gets the transform of the specified glyph within this GlyphVector.- Specified by:
getGlyphTransformin interfaceGVTGlyphVector
-
getGlyphVisualBounds
public java.awt.Shape getGlyphVisualBounds(int glyphIndex)
Returns the visual bounds of the specified glyph within the GlyphVector.- Specified by:
getGlyphVisualBoundsin interfaceGVTGlyphVector
-
getBounds2D
public java.awt.geom.Rectangle2D getBounds2D(java.text.AttributedCharacterIterator aci)
Returns a tight bounds on the GylphVector including stroking.- Specified by:
getBounds2Din interfaceGVTGlyphVector- Parameters:
aci- Required to get painting attributes of glyphVector.
-
getLogicalBounds
public java.awt.geom.Rectangle2D getLogicalBounds()
Returns the logical bounds of this GlyphVector. This is a bound useful for hit detection and highlighting.- Specified by:
getLogicalBoundsin interfaceGVTGlyphVector
-
getNumGlyphs
public int getNumGlyphs()
Returns the number of glyphs in this GlyphVector.- Specified by:
getNumGlyphsin interfaceGVTGlyphVector
-
getOutline
public java.awt.Shape getOutline()
Returns a Shape whose interior corresponds to the visual representation of this GlyphVector.- Specified by:
getOutlinein interfaceGVTGlyphVector
-
getOutline
public java.awt.Shape getOutline(float x, float y)Returns a Shape whose interior corresponds to the visual representation of this GlyphVector, offset to x, y.- Specified by:
getOutlinein interfaceGVTGlyphVector
-
getGeometricBounds
public java.awt.geom.Rectangle2D getGeometricBounds()
Returns the geometric bounds of this GlyphVector. The geometric bounds is the tightest rectangle enclosing the geometry of the glyph vector (not including stroke).- Specified by:
getGeometricBoundsin interfaceGVTGlyphVector
-
performDefaultLayout
public void performDefaultLayout()
Assigns default positions to each glyph in this GlyphVector. The default layout is horizontal.- Specified by:
performDefaultLayoutin interfaceGVTGlyphVector
-
setGlyphPosition
public void setGlyphPosition(int glyphIndex, java.awt.geom.Point2D newPos) throws java.lang.IndexOutOfBoundsExceptionSets the position of the specified glyph within this GlyphVector.- Specified by:
setGlyphPositionin interfaceGVTGlyphVector- Throws:
java.lang.IndexOutOfBoundsException
-
setGlyphTransform
public void setGlyphTransform(int glyphIndex, java.awt.geom.AffineTransform newTX)Sets the transform of the specified glyph within this GlyphVector.- Specified by:
setGlyphTransformin interfaceGVTGlyphVector
-
setGlyphVisible
public void setGlyphVisible(int glyphIndex, boolean visible)Tells the glyph vector whether or not to draw the specified glyph.- Specified by:
setGlyphVisiblein interfaceGVTGlyphVector
-
isGlyphVisible
public boolean isGlyphVisible(int glyphIndex)
Returns true if specified glyph will be rendered.- Specified by:
isGlyphVisiblein interfaceGVTGlyphVector
-
getCharacterCount
public int getCharacterCount(int startGlyphIndex, int endGlyphIndex)Returns the number of chars represented by the glyphs within the specified range.- Specified by:
getCharacterCountin interfaceGVTGlyphVector- Parameters:
startGlyphIndex- The index of the first glyph in the range.endGlyphIndex- The index of the last glyph in the range.- Returns:
- The number of chars.
-
isReversed
public boolean isReversed()
Description copied from interface:GVTGlyphVectorReturn true if glyphs have been reversed.- Specified by:
isReversedin interfaceGVTGlyphVector
-
maybeReverse
public void maybeReverse(boolean mirror)
Description copied from interface:GVTGlyphVectorReverse (and optionally mirror) glyphs if not already reversed.- Specified by:
maybeReversein interfaceGVTGlyphVector
-
draw
public void draw(java.awt.Graphics2D graphics2D, java.text.AttributedCharacterIterator aci)Draws this glyph vector.- Specified by:
drawin interfaceGVTGlyphVector
-
-