org.apache.batik.gvt.text
Class TextLayoutAdapter

java.lang.Object
  |
  +--org.apache.batik.gvt.text.TextLayoutAdapter
All Implemented Interfaces:
TextSpanLayout

public class TextLayoutAdapter
extends java.lang.Object
implements TextSpanLayout

Implementation of TextSpanLayout that uses java.awt.font.TextLayout for its internals.

See Also:
TextLayout, org.apache.batik.gvt.TextPainter.

Fields inherited from interface org.apache.batik.gvt.text.TextSpanLayout
DECORATION_ALL, DECORATION_OVERLINE, DECORATION_STRIKETHROUGH, DECORATION_UNDERLINE
 
Constructor Summary
TextLayoutAdapter(java.awt.font.TextLayout layout, java.awt.geom.Point2D offset, java.text.AttributedCharacterIterator aci)
           
 
Method Summary
 void draw(java.awt.Graphics2D g2d, GraphicsNodeRenderContext ctx)
          Paints the specified text layout using the specified Graphics2D and rendering context.
 float getAdvance()
          Returns the dimension of the completed glyph layout in the primary text advance direction (e.g.
 java.awt.geom.Point2D getAdvance2D()
          Returns the current text position at the completion of glyph layout.
 java.awt.geom.Rectangle2D getBounds()
          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.
 java.awt.geom.Rectangle2D getDecoratedBounds()
          Returns the rectangular bounds of the completed glyph layout.
 java.awt.Shape getDecorationOutline(int decorationType)
          Returns the outline of the specified decorations on the glyphs, transformed by an AffineTransform.
protected  float getDecorationThickness(java.text.AttributedCharacterIterator aci, java.awt.font.TextLayout layout)
           
 int getGlyphCount()
          Returns the number of glyphs in this layout.
 java.awt.Shape getLogicalHighlightShape(int begin, int end)
          Returns a Shape which encloses the currently selected glyphs as specified by glyph indices begin/tt> and end.
 java.awt.geom.Point2D getOffset()
          Returns the current text position at the beginning of glyph layout, before the application of explicit glyph positioning attributes.
 java.awt.Shape getOutline()
          Returns the outline of the completed glyph layout, transformed by an AffineTransform.
protected  java.awt.Shape getOverlineShape(java.text.AttributedCharacterIterator runaci, java.awt.font.TextLayout layout)
          Returns a shape describing the overline decoration for a given ACI.
protected  java.awt.Shape getStrikethroughShape(java.text.AttributedCharacterIterator runaci, java.awt.font.TextLayout layout)
          Returns a shape describing the strikethrough line for a given ACI.
protected  java.awt.Shape getUnderlineShape(java.text.AttributedCharacterIterator runaci, java.awt.font.TextLayout layout)
          Returns a shape describing the strikethrough line for a given ACI.
 TextHit hitTestChar(float x, float y)
          Perform hit testing for coordinate at x, y.
 boolean isVertical()
          Returns true if the advance direction of this text is vertical.
 void setOffset(java.awt.geom.Point2D offset)
          Sets the text position used for the implicit origin of glyph layout.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextLayoutAdapter

public TextLayoutAdapter(java.awt.font.TextLayout layout,
                         java.awt.geom.Point2D offset,
                         java.text.AttributedCharacterIterator aci)
Method Detail

draw

public void draw(java.awt.Graphics2D g2d,
                 GraphicsNodeRenderContext ctx)
Paints the specified text layout using the specified Graphics2D and rendering context.
Specified by:
draw in interface TextSpanLayout
Parameters:
g2d - the Graphics2D to use

getOffset

public java.awt.geom.Point2D getOffset()
Returns the current text position at the beginning of glyph layout, before the application of explicit glyph positioning attributes.
Specified by:
getOffset in interface TextSpanLayout

setOffset

public void setOffset(java.awt.geom.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).
Specified by:
setOffset in interface TextSpanLayout

getOutline

public java.awt.Shape getOutline()
Returns the outline of the completed glyph layout, transformed by an AffineTransform.
Specified by:
getOutline in interface TextSpanLayout

getDecorationOutline

public java.awt.Shape getDecorationOutline(int decorationType)
Returns the outline of the specified decorations on the glyphs, transformed by an AffineTransform.
Specified by:
getDecorationOutline in interface TextSpanLayout
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

getBounds

public java.awt.geom.Rectangle2D getBounds()
Returns the rectangular bounds of the completed glyph layout.
Specified by:
getBounds in interface TextSpanLayout

getDecoratedBounds

public java.awt.geom.Rectangle2D getDecoratedBounds()
Returns the rectangular bounds of the completed glyph layout.
Specified by:
getDecoratedBounds in interface TextSpanLayout

getAdvance

public float getAdvance()
Returns the dimension of the completed glyph layout in the primary text advance direction (e.g. width, for RTL or LTR text). (This is the dimension that should be used for positioning adjacent layouts.)
Specified by:
getAdvance in interface TextSpanLayout

getAdvance2D

public java.awt.geom.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.)
Specified by:
getAdvance2D in interface TextSpanLayout

getLogicalHighlightShape

public java.awt.Shape getLogicalHighlightShape(int begin,
                                               int end)
Returns a Shape which encloses the currently selected glyphs as specified by glyph indices begin/tt> and end.
Specified by:
getLogicalHighlightShape in interface TextSpanLayout
Parameters:
begin - the index of the first glyph in the contiguous selection.
end - the index of the last glyph in the contiguous selection.

hitTestChar

public TextHit hitTestChar(float x,
                           float y)
Perform hit testing for coordinate at x, y.
Specified by:
hitTestChar in interface TextSpanLayout
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

public boolean isVertical()
Description copied from interface: TextSpanLayout
Returns true if the advance direction of this text is vertical.
Specified by:
isVertical in interface TextSpanLayout

getGlyphCount

public int getGlyphCount()
Description copied from interface: TextSpanLayout
Returns the number of glyphs in this layout.
Specified by:
getGlyphCount in interface TextSpanLayout

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 interface TextSpanLayout
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.

getOverlineShape

protected java.awt.Shape getOverlineShape(java.text.AttributedCharacterIterator runaci,
                                          java.awt.font.TextLayout layout)
Returns a shape describing the overline decoration for a given ACI. Does not rely on TextLayout's internal strikethrough but computes it manually.

getUnderlineShape

protected java.awt.Shape getUnderlineShape(java.text.AttributedCharacterIterator runaci,
                                           java.awt.font.TextLayout layout)
Returns a shape describing the strikethrough line for a given ACI. Does not rely on TextLayout's internal strikethrough but computes it manually.

getStrikethroughShape

protected java.awt.Shape getStrikethroughShape(java.text.AttributedCharacterIterator runaci,
                                               java.awt.font.TextLayout layout)
Returns a shape describing the strikethrough line for a given ACI. Does not rely on TextLayout's internal strikethrough but computes it manually.

getDecorationThickness

protected float getDecorationThickness(java.text.AttributedCharacterIterator aci,
                                       java.awt.font.TextLayout layout)


Copyright © 2001 Apache Software Foundation. All Rights Reserved.