Interface TextSpanLayout

All Known Implementing Classes:
FlowExtGlyphLayout, FlowGlyphLayout, GlyphLayout

public interface TextSpanLayout
Class that performs layout of attributed text strings into glyph sets paintable by TextPainter instances. Similar to java.awt.font.TextLayout in function and purpose. Note that while this utility interface is provided for the convenience of TextPainter implementations, conforming TextPainters are not required to use this class.
Version:
$Id: TextSpanLayout.java 1808001 2017-09-11 09:51:29Z ssteiner $
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final int
     
    static final int
     
    static final int
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Paints the specified text layout using the specified Graphics2D and rendering context.
    Returns the current text position at the completion of glyph layout.
    Returns the rectangular bounds of the completed glyph layout.
    int
    getCharacterCount(int startGlyphIndex, int endGlyphIndex)
    Returns the number of chars represented by the glyphs within the specified range.
    double
    Return the rotation angle applied to the character.
    getDecorationOutline(int decorationType)
    Returns the outline of the specified decorations on the glyphs, transformed by an AffineTransform.
    Returns the bounds of the geometry (this is always the bounds of the outline).
    float[]
    Returns the advance between each glyph in text progression direction.
    int
    Returns the number of glyphs in this layout.
    int
    getGlyphIndex(int charIndex)
    Returns the glyph index of the glyph that has the specified char index.
    getGlyphMetrics(int glyphIndex)
    Returns the Metrics for a particular glyph.
    Return the glyph vector asociated to this layout.
    getHighlightShape(int beginCharIndex, int endCharIndex)
    Returns a Shape which encloses the currently selected glyphs as specified by glyph indices begin and end.
    Returns the Line metrics for this text span.
    Returns the current text position at the completion beginning of glyph layout, before the application of explicit glyph positioning attributes.
    Returns the outline of the completed glyph layout, transformed by an AffineTransform.
     
    boolean
    hasCharacterIndex(int index)
    Return true is the character index is represented by glyphs in this layout.
    hitTestChar(float x, float y)
    Perform hit testing for coordinate at x, y.
    boolean
    Return true if this text run represents an alt glyph.
    boolean
    Returns true if the text direction in this layout is from left to right.
    boolean
    Returns true if this layout in on a text path.
    boolean
    Return true if this text has been reversed.
    boolean
    Returns true if the advance direction of this text is vertical.
    void
    maybeReverse(boolean mirror)
    Reverse (and optionally mirror) glyphs if not already reversed.
    void
    Sets the text position used for the implicit origin of glyph layout.
    void
    setScale(float xScale, float yScale, boolean adjSpacing)
    Sets the scaling factor to use for string.
  • Field Details

  • Method Details

    • draw

      void draw(Graphics2D g2d)
      Paints the specified text layout using the specified Graphics2D and rendering context.
      Parameters:
      g2d - the Graphics2D to use
    • getDecorationOutline

      Shape getDecorationOutline(int decorationType)
      Returns the outline of the specified decorations on the glyphs, transformed by an AffineTransform.
      Parameters:
      decorationType - an integer indicating the type(s) of decorations included in this shape. May be the result of "OR-ing" several values together: e.g. DECORATION_UNDERLINE | DECORATION_STRIKETHROUGH
    • getBounds2D

      Rectangle2D getBounds2D()
      Returns the rectangular bounds of the completed glyph layout. This includes stroking information, this does not include deocrations.
    • getGeometricBounds

      Rectangle2D getGeometricBounds()
      Returns the bounds of the geometry (this is always the bounds of the outline).
    • getOutline

      Shape getOutline()
      Returns the outline of the completed glyph layout, transformed by an AffineTransform.
    • getAdvance2D

      Point2D getAdvance2D()
      Returns the current text position at the completion of glyph layout. (This is the position that should be used for positioning adjacent layouts.)
    • getGlyphAdvances

      float[] getGlyphAdvances()
      Returns the advance between each glyph in text progression direction.
    • getGlyphMetrics

      GVTGlyphMetrics getGlyphMetrics(int glyphIndex)
      Returns the Metrics for a particular glyph.
    • getLineMetrics

      GVTLineMetrics getLineMetrics()
      Returns the Line metrics for this text span.
    • getTextPathAdvance

      Point2D getTextPathAdvance()
    • getOffset

      Point2D getOffset()
      Returns the current text position at the completion beginning of glyph layout, before the application of explicit glyph positioning attributes.
    • setScale

      void setScale(float xScale, float yScale, boolean adjSpacing)
      Sets the scaling factor to use for string. if ajdSpacing is true then only the spacing between glyphs will be adjusted otherwise the glyphs and the spaces between them will be adjusted.
      Parameters:
      xScale - Scale factor to apply in X direction.
      yScale - Scale factor to apply in Y direction.
      adjSpacing - True if only spaces should be adjusted.
    • setOffset

      void setOffset(Point2D offset)
      Sets the text position used for the implicit origin of glyph layout. Ignored if multiple explicit glyph positioning attributes are present in ACI (e.g. if the aci has multiple X or Y values).
    • getHighlightShape

      Shape getHighlightShape(int beginCharIndex, int endCharIndex)
      Returns a Shape which encloses the currently selected glyphs as specified by glyph indices begin and end.
      Parameters:
      beginCharIndex - the index of the first glyph in the contiguous selection.
      endCharIndex - the index of the last glyph in the contiguous selection.
    • hitTestChar

      TextHit hitTestChar(float x, float y)
      Perform hit testing for coordinate at x, y.
      Parameters:
      x - the x coordinate of the point to be tested.
      y - the y coordinate of the point to be tested.
      Returns:
      a TextHit object encapsulating the character index for successful hits and whether the hit is on the character leading edge.
    • isVertical

      boolean isVertical()
      Returns true if the advance direction of this text is vertical.
    • isOnATextPath

      boolean isOnATextPath()
      Returns true if this layout in on a text path.
    • getGlyphCount

      int getGlyphCount()
      Returns the number of glyphs in this layout.
    • getCharacterCount

      int getCharacterCount(int startGlyphIndex, int endGlyphIndex)
      Returns the number of chars represented by the glyphs within the specified range.
      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.
    • getGlyphIndex

      int getGlyphIndex(int charIndex)
      Returns the glyph index of the glyph that has the specified char index.
      Parameters:
      charIndex - The original index of the character in the text node's text string.
      Returns:
      The index of the matching glyph in this layout's glyph vector, or -1 if a matching glyph could not be found.
    • isLeftToRight

      boolean isLeftToRight()
      Returns true if the text direction in this layout is from left to right.
    • hasCharacterIndex

      boolean hasCharacterIndex(int index)
      Return true is the character index is represented by glyphs in this layout.
      Parameters:
      index - index of the character in the ACI.
      Returns:
      true if the layout represents that character.
    • getGlyphVector

      GVTGlyphVector getGlyphVector()
      Return the glyph vector asociated to this layout.
      Returns:
      glyph vector
    • getComputedOrientationAngle

      double getComputedOrientationAngle(int index)
      Return the rotation angle applied to the character.
      Parameters:
      index - index of the character in the ACI
      Returns:
      rotation angle
    • isAltGlyph

      boolean isAltGlyph()
      Return true if this text run represents an alt glyph.
    • isReversed

      boolean isReversed()
      Return true if this text has been reversed.
    • maybeReverse

      void maybeReverse(boolean mirror)
      Reverse (and optionally mirror) glyphs if not already reversed.