- All Implemented Interfaces:
- Cloneable
public abstract class GlyphVector extends Object implements Cloneable
GlyphVector object is a collection of glyphs
 containing geometric information for the placement of each glyph
 in a transformed coordinate space which corresponds to the
 device on which the GlyphVector is ultimately
 displayed.
 
 The GlyphVector does not attempt any interpretation of
 the sequence of glyphs it contains.  Relationships between adjacent
 glyphs in sequence are solely used to determine the placement of
 the glyphs in the visual coordinate space.
 
 Instances of GlyphVector are created by a Font.
 
 In a text processing application that can cache intermediate
 representations of text, creation and subsequent caching of a
 GlyphVector for use during rendering is the fastest
 method to present the visual representation of characters to a user.
 
 A GlyphVector is associated with exactly one
 Font, and can provide data useful only in relation to
 this Font.  In addition, metrics obtained from a
 GlyphVector are not generally geometrically scalable
 since the pixelization and spacing are dependent on grid-fitting
 algorithms within a Font.  To facilitate accurate
 measurement of a GlyphVector and its component
 glyphs, you must specify a scaling transform, anti-alias mode, and
 fractional metrics mode when creating the GlyphVector.
 These characteristics can be derived from the destination device.
 
 For each glyph in the GlyphVector, you can obtain:
 
- the position of the glyph
- the transform associated with the glyph
- the metrics of the glyph in the context of the
   GlyphVector. The metrics of the glyph may be different under different transforms, application specified rendering hints, and the specific instance of the glyph within theGlyphVector.
 Altering the data used to create the GlyphVector does not
 alter the state of the GlyphVector.
 
 Methods are provided to adjust the positions of the glyphs
 within the GlyphVector.  These methods are most
 appropriate for applications that are performing justification
 operations for the presentation of the glyphs.
 
 Methods are provided to transform individual glyphs within the
 GlyphVector.  These methods are primarily useful for
 special effects.
 
 Methods are provided to return both the visual, logical, and pixel bounds
 of the entire GlyphVector or of individual glyphs within
 the GlyphVector.
 
 Methods are provided to return a Shape for the
 GlyphVector, and for individual glyphs within the
 GlyphVector.
- See Also:
- Font,- GlyphMetrics,- TextLayout
- 
Field SummaryFields Modifier and Type Field Description static intFLAG_COMPLEX_GLYPHSA flag used with getLayoutFlags that indicates that thisGlyphVectorhas a complex glyph-to-char mapping (one that does not map glyphs to chars one-to-one in strictly ascending or descending order matching the run direction).static intFLAG_HAS_POSITION_ADJUSTMENTSA flag used with getLayoutFlags that indicates that thisGlyphVectorhas position adjustments.static intFLAG_HAS_TRANSFORMSA flag used with getLayoutFlags that indicates that thisGlyphVectorhas per-glyph transforms.static intFLAG_MASKA mask for supported flags from getLayoutFlags.static intFLAG_RUN_RTLA flag used with getLayoutFlags that indicates that thisGlyphVectorhas a right-to-left run direction.
- 
Constructor SummaryConstructors Constructor Description GlyphVector()
- 
Method SummaryModifier and Type Method Description abstract booleanequals(GlyphVector set)Tests if the specifiedGlyphVectorexactly equals thisGlyphVector.abstract FontgetFont()Returns theFontassociated with thisGlyphVector.abstract FontRenderContextgetFontRenderContext()Returns theFontRenderContextassociated with thisGlyphVector.intgetGlyphCharIndex(int glyphIndex)Returns the character index of the specified glyph.int[]getGlyphCharIndices(int beginGlyphIndex, int numEntries, int[] codeReturn)Returns the character indices of the specified glyphs.abstract intgetGlyphCode(int glyphIndex)Returns the glyphcode of the specified glyph.abstract int[]getGlyphCodes(int beginGlyphIndex, int numEntries, int[] codeReturn)Returns an array of glyphcodes for the specified glyphs.abstract GlyphJustificationInfogetGlyphJustificationInfo(int glyphIndex)Returns the justification information for the glyph at the specified index into thisGlyphVector.abstract ShapegetGlyphLogicalBounds(int glyphIndex)Returns the logical bounds of the specified glyph within thisGlyphVector.abstract GlyphMetricsgetGlyphMetrics(int glyphIndex)Returns the metrics of the glyph at the specified index into thisGlyphVector.abstract ShapegetGlyphOutline(int glyphIndex)Returns aShapewhose interior corresponds to the visual representation of the specified glyph within thisGlyphVector.ShapegetGlyphOutline(int glyphIndex, float x, float y)Returns aShapewhose interior corresponds to the visual representation of the specified glyph within thisGlyphVector, offset to x, y.RectanglegetGlyphPixelBounds(int index, FontRenderContext renderFRC, float x, float y)Returns the pixel bounds of the glyph at index when thisGlyphVectoris rendered in aGraphicswith the givenFontRenderContextat the given location.abstract Point2DgetGlyphPosition(int glyphIndex)Returns the position of the specified glyph relative to the origin of thisGlyphVector.abstract float[]getGlyphPositions(int beginGlyphIndex, int numEntries, float[] positionReturn)Returns an array of glyph positions for the specified glyphs.abstract AffineTransformgetGlyphTransform(int glyphIndex)Returns the transform of the specified glyph within thisGlyphVector.abstract ShapegetGlyphVisualBounds(int glyphIndex)Returns the visual bounds of the specified glyph within theGlyphVector.intgetLayoutFlags()Returns flags describing the global state of the GlyphVector.abstract Rectangle2DgetLogicalBounds()Returns the logical bounds of thisGlyphVector.abstract intgetNumGlyphs()Returns the number of glyphs in thisGlyphVector.abstract ShapegetOutline()Returns aShapewhose interior corresponds to the visual representation of thisGlyphVector.abstract ShapegetOutline(float x, float y)Returns aShapewhose interior corresponds to the visual representation of thisGlyphVectorwhen rendered at x, y.RectanglegetPixelBounds(FontRenderContext renderFRC, float x, float y)Returns the pixel bounds of thisGlyphVectorwhen rendered in a graphics with the givenFontRenderContextat the given location.abstract Rectangle2DgetVisualBounds()Returns the visual bounds of thisGlyphVectorThe visual bounds is the bounding box of the outline of thisGlyphVector.abstract voidperformDefaultLayout()Assigns default positions to each glyph in thisGlyphVector.abstract voidsetGlyphPosition(int glyphIndex, Point2D newPos)Sets the position of the specified glyph within thisGlyphVector.abstract voidsetGlyphTransform(int glyphIndex, AffineTransform newTX)Sets the transform of the specified glyph within thisGlyphVector.
- 
Field Details- 
FLAG_HAS_TRANSFORMSpublic static final int FLAG_HAS_TRANSFORMSA flag used with getLayoutFlags that indicates that thisGlyphVectorhas per-glyph transforms.- Since:
- 1.4
- See Also:
- Constant Field Values
 
- 
FLAG_HAS_POSITION_ADJUSTMENTSpublic static final int FLAG_HAS_POSITION_ADJUSTMENTSA flag used with getLayoutFlags that indicates that thisGlyphVectorhas position adjustments. When this is true, the glyph positions don't match the accumulated default advances of the glyphs (for example, if kerning has been done).- Since:
- 1.4
- See Also:
- Constant Field Values
 
- 
FLAG_RUN_RTLpublic static final int FLAG_RUN_RTLA flag used with getLayoutFlags that indicates that thisGlyphVectorhas a right-to-left run direction. This refers to the glyph-to-char mapping and does not imply that the visual locations of the glyphs are necessarily in this order, although generally they will be.- Since:
- 1.4
- See Also:
- Constant Field Values
 
- 
FLAG_COMPLEX_GLYPHSpublic static final int FLAG_COMPLEX_GLYPHSA flag used with getLayoutFlags that indicates that thisGlyphVectorhas a complex glyph-to-char mapping (one that does not map glyphs to chars one-to-one in strictly ascending or descending order matching the run direction).- Since:
- 1.4
- See Also:
- Constant Field Values
 
- 
FLAG_MASKpublic static final int FLAG_MASKA mask for supported flags from getLayoutFlags. Only bits covered by the mask should be tested.- Since:
- 1.4
- See Also:
- Constant Field Values
 
 
- 
- 
Constructor Details- 
GlyphVectorpublic GlyphVector()
 
- 
- 
Method Details- 
getFontReturns theFontassociated with thisGlyphVector.- Returns:
- Fontused to create this- GlyphVector.
- See Also:
- Font
 
- 
getFontRenderContextReturns theFontRenderContextassociated with thisGlyphVector.- Returns:
- FontRenderContextused to create this- GlyphVector.
- See Also:
- FontRenderContext,- Font
 
- 
performDefaultLayoutpublic abstract void performDefaultLayout()Assigns default positions to each glyph in thisGlyphVector. This can destroy information generated during initial layout of thisGlyphVector.
- 
getNumGlyphspublic abstract int getNumGlyphs()Returns the number of glyphs in thisGlyphVector.- Returns:
- number of glyphs in this GlyphVector.
 
- 
getGlyphCodepublic abstract int getGlyphCode(int glyphIndex)Returns the glyphcode of the specified glyph. This return value is meaningless to anything other than theFontobject that created thisGlyphVector.- Parameters:
- glyphIndex- the index into this- GlyphVectorthat corresponds to the glyph from which to retrieve the glyphcode.
- Returns:
- the glyphcode of the glyph at the specified
 glyphIndex.
- Throws:
- IndexOutOfBoundsException- if- glyphIndexis less than 0 or greater than or equal to the number of glyphs in this- GlyphVector
 
- 
getGlyphCodespublic abstract int[] getGlyphCodes(int beginGlyphIndex, int numEntries, int[] codeReturn)Returns an array of glyphcodes for the specified glyphs. The contents of this return value are meaningless to anything other than theFontused to create thisGlyphVector. This method is used for convenience and performance when processing glyphcodes. If no array is passed in, a new array is created.- Parameters:
- beginGlyphIndex- the index into this- GlyphVectorat which to start retrieving glyphcodes
- numEntries- the number of glyphcodes to retrieve
- codeReturn- the array that receives the glyphcodes and is then returned
- Returns:
- an array of glyphcodes for the specified glyphs.
- Throws:
- IllegalArgumentException- if- numEntriesis less than 0
- IndexOutOfBoundsException- if- beginGlyphIndexis less than 0
- IndexOutOfBoundsException- if the sum of- beginGlyphIndexand- numEntriesis greater than the number of glyphs in this- GlyphVector
 
- 
getGlyphCharIndexpublic int getGlyphCharIndex(int glyphIndex)Returns the character index of the specified glyph. The character index is the index of the first logical character represented by the glyph. The default implementation assumes a one-to-one, left-to-right mapping of glyphs to characters.- Parameters:
- glyphIndex- the index of the glyph
- Returns:
- the index of the first character represented by the glyph
- Since:
- 1.4
 
- 
getGlyphCharIndicespublic int[] getGlyphCharIndices(int beginGlyphIndex, int numEntries, int[] codeReturn)Returns the character indices of the specified glyphs. The character index is the index of the first logical character represented by the glyph. Indices are returned in glyph order. The default implementation invokes getGlyphCharIndex for each glyph, and subclassers will probably want to override this implementation for performance reasons. Use this method for convenience and performance in processing of glyphcodes. If no array is passed in, a new array is created.- Parameters:
- beginGlyphIndex- the index of the first glyph
- numEntries- the number of glyph indices
- codeReturn- the array into which to return the character indices
- Returns:
- an array of character indices, one per glyph.
- Since:
- 1.4
 
- 
getLogicalBoundsReturns the logical bounds of thisGlyphVector. This method is used when positioning thisGlyphVectorin relation to visually adjacentGlyphVectorobjects.- Returns:
- a Rectangle2Dthat is the logical bounds of thisGlyphVector.
 
- 
getVisualBoundsReturns the visual bounds of thisGlyphVectorThe visual bounds is the bounding box of the outline of thisGlyphVector. Because of rasterization and alignment of pixels, it is possible that this box does not enclose all pixels affected by rendering thisGlyphVector.- Returns:
- a Rectangle2Dthat is the bounding box of thisGlyphVector.
 
- 
getPixelBoundsReturns the pixel bounds of thisGlyphVectorwhen rendered in a graphics with the givenFontRenderContextat the given location. The renderFRC need not be the same as theFontRenderContextof thisGlyphVector, and can be null. If it is null, theFontRenderContextof thisGlyphVectoris used. The default implementation returns the visual bounds, offset to x, y and rounded out to the next integer value (i.e. returns an integer rectangle which encloses the visual bounds) and ignores the FRC. Subclassers should override this method.- Parameters:
- renderFRC- the- FontRenderContextof the- Graphics.
- x- the x-coordinate at which to render this- GlyphVector.
- y- the y-coordinate at which to render this- GlyphVector.
- Returns:
- a Rectanglebounding the pixels that would be affected.
- Since:
- 1.4
 
- 
getOutlineReturns aShapewhose interior corresponds to the visual representation of thisGlyphVector.- Returns:
- a Shapethat is the outline of thisGlyphVector.
 
- 
getOutlineReturns aShapewhose interior corresponds to the visual representation of thisGlyphVectorwhen rendered at x, y.- Parameters:
- x- the X coordinate of this- GlyphVector.
- y- the Y coordinate of this- GlyphVector.
- Returns:
- a Shapethat is the outline of thisGlyphVectorwhen rendered at the specified coordinates.
 
- 
getGlyphOutlineReturns aShapewhose interior corresponds to the visual representation of the specified glyph within thisGlyphVector. The outline returned by this method is positioned around the origin of each individual glyph.- Parameters:
- glyphIndex- the index into this- GlyphVector
- Returns:
- a Shapethat is the outline of the glyph at the specifiedglyphIndexof thisGlyphVector.
- Throws:
- IndexOutOfBoundsException- if- glyphIndexis less than 0 or greater than or equal to the number of glyphs in this- GlyphVector
 
- 
getGlyphOutlineReturns aShapewhose interior corresponds to the visual representation of the specified glyph within thisGlyphVector, offset to x, y. The outline returned by this method is positioned around the origin of each individual glyph.- Parameters:
- glyphIndex- the index into this- GlyphVector
- x- the X coordinate of the location of this- GlyphVector
- y- the Y coordinate of the location of this- GlyphVector
- Returns:
- a Shapethat is the outline of the glyph at the specifiedglyphIndexof thisGlyphVectorwhen rendered at the specified coordinates.
- Throws:
- IndexOutOfBoundsException- if- glyphIndexis less than 0 or greater than or equal to the number of glyphs in this- GlyphVector
- Since:
- 1.4
 
- 
getGlyphPositionReturns the position of the specified glyph relative to the origin of thisGlyphVector. IfglyphIndexequals the number of glyphs in thisGlyphVector, this method returns the position after the last glyph. This position is used to define the advance of the entireGlyphVector.- Parameters:
- glyphIndex- the index into this- GlyphVector
- Returns:
- a Point2Dobject that is the position of the glyph at the specifiedglyphIndex.
- Throws:
- IndexOutOfBoundsException- if- glyphIndexis less than 0 or greater than the number of glyphs in this- GlyphVector
- See Also:
- setGlyphPosition(int, java.awt.geom.Point2D)
 
- 
setGlyphPositionSets the position of the specified glyph within thisGlyphVector. IfglyphIndexequals the number of glyphs in thisGlyphVector, this method sets the position after the last glyph. This position is used to define the advance of the entireGlyphVector.- Parameters:
- glyphIndex- the index into this- GlyphVector
- newPos- the- Point2Dat which to position the glyph at the specified- glyphIndex
- Throws:
- IndexOutOfBoundsException- if- glyphIndexis less than 0 or greater than the number of glyphs in this- GlyphVector
- See Also:
- getGlyphPosition(int)
 
- 
getGlyphTransformReturns the transform of the specified glyph within thisGlyphVector. The transform is relative to the glyph position. If no special transform has been applied,nullcan be returned. A null return indicates an identity transform.- Parameters:
- glyphIndex- the index into this- GlyphVector
- Returns:
- an AffineTransformthat is the transform of the glyph at the specifiedglyphIndex.
- Throws:
- IndexOutOfBoundsException- if- glyphIndexis less than 0 or greater than or equal to the number of glyphs in this- GlyphVector
- See Also:
- setGlyphTransform(int, java.awt.geom.AffineTransform)
 
- 
setGlyphTransformSets the transform of the specified glyph within thisGlyphVector. The transform is relative to the glyph position. Anullargument fornewTXindicates that no special transform is applied for the specified glyph. This method can be used to rotate, mirror, translate and scale the glyph. Adding a transform can result in significant performance changes.- Parameters:
- glyphIndex- the index into this- GlyphVector
- newTX- the new transform of the glyph at- glyphIndex
- Throws:
- IndexOutOfBoundsException- if- glyphIndexis less than 0 or greater than or equal to the number of glyphs in this- GlyphVector
- See Also:
- getGlyphTransform(int)
 
- 
getLayoutFlagspublic int getLayoutFlags()Returns flags describing the global state of the GlyphVector. Flags not described below are reserved. The default implementation returns 0 (meaning false) for the position adjustments, transforms, rtl, and complex flags. Subclassers should override this method, and make sure it correctly describes the GlyphVector and corresponds to the results of related calls.- Returns:
- an int containing the flags describing the state
- Since:
- 1.4
- See Also:
- FLAG_HAS_POSITION_ADJUSTMENTS,- FLAG_HAS_TRANSFORMS,- FLAG_RUN_RTL,- FLAG_COMPLEX_GLYPHS,- FLAG_MASK
 
- 
getGlyphPositionspublic abstract float[] getGlyphPositions(int beginGlyphIndex, int numEntries, float[] positionReturn)Returns an array of glyph positions for the specified glyphs. This method is used for convenience and performance when processing glyph positions. If no array is passed in, a new array is created. Even numbered array entries beginning with position zero are the X coordinates of the glyph numberedbeginGlyphIndex + position/2. Odd numbered array entries beginning with position one are the Y coordinates of the glyph numberedbeginGlyphIndex + (position-1)/2. IfbeginGlyphIndexequals the number of glyphs in thisGlyphVector, this method gets the position after the last glyph and this position is used to define the advance of the entireGlyphVector.- Parameters:
- beginGlyphIndex- the index at which to begin retrieving glyph positions
- numEntries- the number of glyphs to retrieve
- positionReturn- the array that receives the glyph positions and is then returned.
- Returns:
- an array of glyph positions specified by
  beginGlyphIndexandnumEntries.
- Throws:
- IllegalArgumentException- if- numEntriesis less than 0
- IndexOutOfBoundsException- if- beginGlyphIndexis less than 0
- IndexOutOfBoundsException- if the sum of- beginGlyphIndexand- numEntriesis greater than the number of glyphs in this- GlyphVectorplus one
 
- 
getGlyphLogicalBoundsReturns the logical bounds of the specified glyph within thisGlyphVector. These logical bounds have a total of four edges, with two edges parallel to the baseline under the glyph's transform and the other two edges are shared with adjacent glyphs if they are present. This method is useful for hit-testing of the specified glyph, positioning of a caret at the leading or trailing edge of a glyph, and for drawing a highlight region around the specified glyph.- Parameters:
- glyphIndex- the index into this- GlyphVectorthat corresponds to the glyph from which to retrieve its logical bounds
- Returns:
- a Shapethat is the logical bounds of the glyph at the specifiedglyphIndex.
- Throws:
- IndexOutOfBoundsException- if- glyphIndexis less than 0 or greater than or equal to the number of glyphs in this- GlyphVector
- See Also:
- getGlyphVisualBounds(int)
 
- 
getGlyphVisualBoundsReturns the visual bounds of the specified glyph within theGlyphVector. The bounds returned by this method is positioned around the origin of each individual glyph.- Parameters:
- glyphIndex- the index into this- GlyphVectorthat corresponds to the glyph from which to retrieve its visual bounds
- Returns:
- a Shapethat is the visual bounds of the glyph at the specifiedglyphIndex.
- Throws:
- IndexOutOfBoundsException- if- glyphIndexis less than 0 or greater than or equal to the number of glyphs in this- GlyphVector
- See Also:
- getGlyphLogicalBounds(int)
 
- 
getGlyphPixelBoundsReturns the pixel bounds of the glyph at index when thisGlyphVectoris rendered in aGraphicswith the givenFontRenderContextat the given location. The renderFRC need not be the same as theFontRenderContextof thisGlyphVector, and can be null. If it is null, theFontRenderContextof thisGlyphVectoris used. The default implementation returns the visual bounds of the glyph, offset to x, y and rounded out to the next integer value, and ignores the FRC. Subclassers should override this method.- Parameters:
- index- the index of the glyph.
- renderFRC- the- FontRenderContextof the- Graphics.
- x- the X position at which to render this- GlyphVector.
- y- the Y position at which to render this- GlyphVector.
- Returns:
- a Rectanglebounding the pixels that would be affected.
- Since:
- 1.4
 
- 
getGlyphMetricsReturns the metrics of the glyph at the specified index into thisGlyphVector.- Parameters:
- glyphIndex- the index into this- GlyphVectorthat corresponds to the glyph from which to retrieve its metrics
- Returns:
- a GlyphMetricsobject that represents the metrics of the glyph at the specifiedglyphIndexinto thisGlyphVector.
- Throws:
- IndexOutOfBoundsException- if- glyphIndexis less than 0 or greater than or equal to the number of glyphs in this- GlyphVector
 
- 
getGlyphJustificationInfoReturns the justification information for the glyph at the specified index into thisGlyphVector.- Parameters:
- glyphIndex- the index into this- GlyphVectorthat corresponds to the glyph from which to retrieve its justification properties
- Returns:
- a GlyphJustificationInfoobject that represents the justification properties of the glyph at the specifiedglyphIndexinto thisGlyphVector.
- Throws:
- IndexOutOfBoundsException- if- glyphIndexis less than 0 or greater than or equal to the number of glyphs in this- GlyphVector
 
- 
equalsTests if the specifiedGlyphVectorexactly equals thisGlyphVector.- Parameters:
- set- the specified- GlyphVectorto test
- Returns:
- trueif the specified- GlyphVectorequals this- GlyphVector;- falseotherwise.
 
 
-