Package org.apache.batik.gvt.font
Class AWTGVTGlyphVector
- java.lang.Object
-
- org.apache.batik.gvt.font.AWTGVTGlyphVector
-
- All Implemented Interfaces:
GVTGlyphVector
public class AWTGVTGlyphVector extends java.lang.Object implements GVTGlyphVector
This is a wrapper class for a java.awt.font.GlyphVector instance.- Version:
- $Id: AWTGVTGlyphVector.java 1733416 2016-03-03 07:07:13Z gadams $
-
-
Field Summary
Fields Modifier and Type Field Description private float
ascent
private java.awt.font.GlyphVector
awtGlyphVector
private java.awt.geom.Rectangle2D
bounds2D
private TextPaintInfo
cacheTPI
private java.text.CharacterIterator
ci
private java.awt.geom.Point2D[]
defaultGlyphPositions
private float
descent
private static boolean
drawGlyphVectorWorks
private java.awt.Shape[]
glyphLogicalBounds
private GVTGlyphMetrics[]
glyphMetrics
private java.awt.Shape[]
glyphOutlines
private java.awt.geom.Point2D.Float[]
glyphPositions
private java.awt.geom.AffineTransform[]
glyphTransforms
private static boolean
glyphVectorTransformWorks
private boolean[]
glyphVisible
private java.awt.Shape[]
glyphVisualBounds
private AWTGVTFont
gvtFont
private java.awt.geom.Rectangle2D
logicalBounds
private java.awt.geom.GeneralPath
outline
private static boolean
outlinesPositioned
static java.text.AttributedCharacterIterator.Attribute
PAINT_INFO
private double
scaleFactor
private java.awt.geom.Rectangle2D
visualBounds
-
Constructor Summary
Constructors Constructor Description AWTGVTGlyphVector(java.awt.font.GlyphVector glyphVector, AWTGVTFont font, double scaleFactor, java.text.CharacterIterator ci)
Creates and new AWTGVTGlyphVector from the specified GlyphVector and AWTGVTFont objects.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
computeGlyphLogicalBounds()
Calculates the logical bounds for each glyph.void
draw(java.awt.Graphics2D graphics2D, java.text.AttributedCharacterIterator aci)
Draws this glyph vector.java.awt.geom.Rectangle2D
getBounds2D(java.text.AttributedCharacterIterator aci)
Returns a tight bounds on the GlyphVector including stroking.int
getCharacterCount(int startGlyphIndex, int endGlyphIndex)
Returns the number of chars represented by the glyphs within the specified range.GVTFont
getFont()
Returns the GVTFont associated with this GVTGlyphVector.java.awt.font.FontRenderContext
getFontRenderContext()
Returns the FontRenderContext associated with this GlyphVector.java.awt.geom.Rectangle2D
getGeometricBounds()
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.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.int
getGlyphCode(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.GlyphJustificationInfo
getGlyphJustificationInfo(int glyphIndex)
Returns the justification information for the glyph at the specified index into this GlyphVector.java.awt.Shape
getGlyphLogicalBounds(int glyphIndex)
Returns the logical bounds of the specified glyph within this GlyphVector.GVTGlyphMetrics
getGlyphMetrics(int glyphIndex)
Returns the metrics of the glyph at the specified index into this GVTGlyphVector.java.awt.Shape
getGlyphOutline(int glyphIndex)
Returns a Shape whose interior corresponds to the visual representation of the specified glyph within this GlyphVector.java.awt.geom.Point2D
getGlyphPosition(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.AffineTransform
getGlyphTransform(int glyphIndex)
Gets the transform of the specified glyph within this GlyphVector.java.awt.Shape
getGlyphVisualBounds(int glyphIndex)
Returns the visual bounds of the specified glyph within the GlyphVector.java.awt.geom.Rectangle2D
getLogicalBounds()
Returns the logical bounds of this GlyphVector.int
getNumGlyphs()
Returns the number of glyphs in this GlyphVector.java.awt.Shape
getOutline()
Returns a Shape whose interior corresponds to the visual representation of this GlyphVector.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.boolean
isGlyphVisible(int glyphIndex)
Returns true if specified glyph will be rendered.boolean
isReversed()
Return true if glyphs have been reversed.void
maybeReverse(boolean mirror)
Reverse (and optionally mirror) glyphs if not already reversed.(package private) static boolean
outlinesPositioned()
void
performDefaultLayout()
Assigns default positions to each glyph in this GlyphVector.void
setGlyphPosition(int glyphIndex, java.awt.geom.Point2D newPos)
Sets the position of the specified glyph within this GlyphVector.void
setGlyphTransform(int glyphIndex, java.awt.geom.AffineTransform newTX)
Sets the transform of the specified glyph within this GlyphVector.void
setGlyphVisible(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
-
awtGlyphVector
private java.awt.font.GlyphVector awtGlyphVector
-
gvtFont
private AWTGVTFont gvtFont
-
ci
private java.text.CharacterIterator ci
-
defaultGlyphPositions
private java.awt.geom.Point2D[] defaultGlyphPositions
-
glyphPositions
private java.awt.geom.Point2D.Float[] glyphPositions
-
glyphTransforms
private java.awt.geom.AffineTransform[] glyphTransforms
-
glyphOutlines
private java.awt.Shape[] glyphOutlines
-
glyphVisualBounds
private java.awt.Shape[] glyphVisualBounds
-
glyphLogicalBounds
private java.awt.Shape[] glyphLogicalBounds
-
glyphVisible
private boolean[] glyphVisible
-
glyphMetrics
private GVTGlyphMetrics[] glyphMetrics
-
outline
private java.awt.geom.GeneralPath outline
-
visualBounds
private java.awt.geom.Rectangle2D visualBounds
-
logicalBounds
private java.awt.geom.Rectangle2D logicalBounds
-
bounds2D
private java.awt.geom.Rectangle2D bounds2D
-
scaleFactor
private double scaleFactor
-
ascent
private float ascent
-
descent
private float descent
-
cacheTPI
private TextPaintInfo cacheTPI
-
outlinesPositioned
private static final boolean outlinesPositioned
-
drawGlyphVectorWorks
private static final boolean drawGlyphVectorWorks
-
glyphVectorTransformWorks
private static final boolean glyphVectorTransformWorks
-
-
Constructor Detail
-
AWTGVTGlyphVector
public AWTGVTGlyphVector(java.awt.font.GlyphVector glyphVector, AWTGVTFont font, double scaleFactor, java.text.CharacterIterator ci)
Creates and new AWTGVTGlyphVector from the specified GlyphVector and AWTGVTFont objects.- Parameters:
glyphVector
- The glyph vector that this one will be based upon.font
- The font that is creating this glyph vector.scaleFactor
- The scale factor to apply to the glyph vector. IMPORTANT: This is only required because the GlyphVector class doesn't handle font sizes less than 1 correctly. By using the scale factor we can use a GlyphVector created by a larger font and then scale it down to the correct size.ci
- The character string that this glyph vector represents.
-
-
Method Detail
-
getFont
public GVTFont getFont()
Returns the GVTFont associated with this GVTGlyphVector.- Specified by:
getFont
in interfaceGVTGlyphVector
-
getFontRenderContext
public java.awt.font.FontRenderContext getFontRenderContext()
Returns the FontRenderContext associated with this GlyphVector.- Specified by:
getFontRenderContext
in interfaceGVTGlyphVector
-
getGlyphCode
public int getGlyphCode(int glyphIndex)
Returns the glyphcode of the specified glyph.- Specified by:
getGlyphCode
in interfaceGVTGlyphVector
-
getGlyphCodes
public int[] getGlyphCodes(int beginGlyphIndex, int numEntries, int[] codeReturn)
Returns an array of glyphcodes for the specified glyphs.- Specified by:
getGlyphCodes
in interfaceGVTGlyphVector
-
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:
getGlyphJustificationInfo
in interfaceGVTGlyphVector
-
getBounds2D
public java.awt.geom.Rectangle2D getBounds2D(java.text.AttributedCharacterIterator aci)
Returns a tight bounds on the GlyphVector including stroking.- Specified by:
getBounds2D
in 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:
getLogicalBounds
in interfaceGVTGlyphVector
-
getGlyphLogicalBounds
public java.awt.Shape getGlyphLogicalBounds(int glyphIndex)
Returns the logical bounds of the specified glyph within this GlyphVector.- Specified by:
getGlyphLogicalBounds
in interfaceGVTGlyphVector
-
computeGlyphLogicalBounds
private void computeGlyphLogicalBounds()
Calculates the logical bounds for each glyph. The logical bounds are what is used for highlighting the glyphs when selected.
-
getGlyphMetrics
public GVTGlyphMetrics getGlyphMetrics(int glyphIndex)
Returns the metrics of the glyph at the specified index into this GVTGlyphVector.- Specified by:
getGlyphMetrics
in 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:
getGlyphOutline
in interfaceGVTGlyphVector
-
outlinesPositioned
static boolean outlinesPositioned()
-
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:
getGlyphCellBounds
in interfaceGVTGlyphVector
-
getGlyphPosition
public java.awt.geom.Point2D getGlyphPosition(int glyphIndex)
Returns the position of the specified glyph within this GlyphVector.- Specified by:
getGlyphPosition
in interfaceGVTGlyphVector
-
getGlyphPositions
public float[] getGlyphPositions(int beginGlyphIndex, int numEntries, float[] positionReturn)
Returns an array of glyph positions for the specified glyphs- Specified by:
getGlyphPositions
in interfaceGVTGlyphVector
-
getGlyphTransform
public java.awt.geom.AffineTransform getGlyphTransform(int glyphIndex)
Gets the transform of the specified glyph within this GlyphVector.- Specified by:
getGlyphTransform
in interfaceGVTGlyphVector
-
getGlyphVisualBounds
public java.awt.Shape getGlyphVisualBounds(int glyphIndex)
Returns the visual bounds of the specified glyph within the GlyphVector.- Specified by:
getGlyphVisualBounds
in interfaceGVTGlyphVector
-
getNumGlyphs
public int getNumGlyphs()
Returns the number of glyphs in this GlyphVector.- Specified by:
getNumGlyphs
in interfaceGVTGlyphVector
-
getOutline
public java.awt.Shape getOutline()
Returns a Shape whose interior corresponds to the visual representation of this GlyphVector.- Specified by:
getOutline
in 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:
getOutline
in interfaceGVTGlyphVector
-
getGeometricBounds
public java.awt.geom.Rectangle2D getGeometricBounds()
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.- Specified by:
getGeometricBounds
in interfaceGVTGlyphVector
-
performDefaultLayout
public void performDefaultLayout()
Assigns default positions to each glyph in this GlyphVector.- Specified by:
performDefaultLayout
in interfaceGVTGlyphVector
-
setGlyphPosition
public void setGlyphPosition(int glyphIndex, java.awt.geom.Point2D newPos)
Sets the position of the specified glyph within this GlyphVector.- Specified by:
setGlyphPosition
in interfaceGVTGlyphVector
-
setGlyphTransform
public void setGlyphTransform(int glyphIndex, java.awt.geom.AffineTransform newTX)
Sets the transform of the specified glyph within this GlyphVector.- Specified by:
setGlyphTransform
in interfaceGVTGlyphVector
-
setGlyphVisible
public void setGlyphVisible(int glyphIndex, boolean visible)
Tells the glyph vector whether or not to draw the specified glyph.- Specified by:
setGlyphVisible
in interfaceGVTGlyphVector
-
isGlyphVisible
public boolean isGlyphVisible(int glyphIndex)
Returns true if specified glyph will be rendered.- Specified by:
isGlyphVisible
in interfaceGVTGlyphVector
-
getCharacterCount
public int getCharacterCount(int startGlyphIndex, int endGlyphIndex)
Returns the number of chars represented by the glyphs within the specified range.- Specified by:
getCharacterCount
in 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:GVTGlyphVector
Return true if glyphs have been reversed.- Specified by:
isReversed
in interfaceGVTGlyphVector
-
maybeReverse
public void maybeReverse(boolean mirror)
Description copied from interface:GVTGlyphVector
Reverse (and optionally mirror) glyphs if not already reversed.- Specified by:
maybeReverse
in interfaceGVTGlyphVector
-
draw
public void draw(java.awt.Graphics2D graphics2D, java.text.AttributedCharacterIterator aci)
Draws this glyph vector.- Specified by:
draw
in interfaceGVTGlyphVector
-
-