|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.batik.gvt.text.GlyphLayout
Implementation of TextSpanLayout which uses java.awt.font.GlyphVector.
TextSpanLayout
Field Summary | |
static float |
eps
|
static java.text.AttributedCharacterIterator.Attribute |
TEXT_COMPOUND_DELIMITER
|
Fields inherited from interface org.apache.batik.gvt.text.TextSpanLayout |
DECORATION_ALL, DECORATION_OVERLINE, DECORATION_STRIKETHROUGH, DECORATION_UNDERLINE |
Constructor Summary | |
GlyphLayout(java.text.AttributedCharacterIterator aci,
int[] charMap,
java.awt.geom.Point2D offset,
java.awt.font.FontRenderContext frc)
Creates the specified text layout using the specified AttributedCharacterIterator and rendering context. |
Method Summary | |
static void |
addPtsToPath(java.awt.geom.GeneralPath shape,
java.awt.geom.Point2D.Float[] topPts,
java.awt.geom.Point2D.Float[] botPts,
int numPts)
|
protected void |
adjustTextSpacing()
Does any spacing adjustments that may have been specified. |
protected void |
applyStretchTransform(boolean stretchGlyphs)
Stretches the text so that it becomes the specified length. |
protected void |
doExplicitGlyphLayout()
Explicitly lays out each of the glyphs in the glyph vector. |
protected void |
doPathLayout()
If this layout is on a text path, positions the characters along the path. |
protected java.awt.geom.Point2D |
doSpacing(java.lang.Float kern,
java.lang.Float letterSpacing,
java.lang.Float wordSpacing)
Performs any spacing adjustments required and returns the new advance value. |
void |
draw(java.awt.Graphics2D g2d)
Paints the text layout using the specified Graphics2D and rendering context. |
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, inclusive of "decoration" (underline, overline, etc.) |
java.awt.Shape |
getDecorationOutline(int decorationType)
Returns the outline of the specified decorations on the glyphs, |
protected GVTFont |
getFont()
Returns the GVTFont to use when rendering the specified character iterator. |
int |
getGlyphCount()
Returns the number of glyphs in this layout. |
int |
getGlyphIndex(int charIndex)
Returns the index of the glyph that has the specified char index. |
GVTGlyphMetrics |
getGlyphMetrics(int glyphIndex)
Returns the Metrics for a particular glyph. |
protected int |
getGlyphOrientationAngle()
Returns the value of the vertical glyph orientation angle. |
java.awt.Shape |
getHighlightShape(int beginCharIndex,
int endCharIndex)
Returns a Shape which encloses the currently selected glyphs as specified by the character indices. |
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. |
protected java.awt.Shape |
getOverlineShape()
Returns a shape describing the overline decoration for a given ACI. |
protected java.awt.Shape |
getStrikethroughShape()
Returns a shape describing the strikethrough line for a given ACI. |
java.awt.geom.Point2D |
getTextPathAdvance()
Returns the position to used when drawing a text run after this one. |
protected java.awt.Shape |
getUnderlineShape()
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. |
protected boolean |
isGlyphOrientationAuto()
Returns whether or not the vertical glyph orientation value is "auto". |
protected boolean |
isLatinChar(char c)
Returns true if the specified character is within one of the Latin unicode character blocks. |
boolean |
isLeftToRight()
Returns true if the text direction in this layout is from left to right. |
boolean |
isOnATextPath()
Returns true if this layout in on a text path. |
protected static boolean |
isSpace(char ch)
|
boolean |
isVertical()
Returns true if the advance direction of this text is vertical. |
static int |
makeConvexHull(java.awt.geom.Point2D.Float[] pts,
int numPts)
|
static void |
mergeAreas(java.awt.geom.GeneralPath shape,
java.awt.geom.Area[] shapes,
int nShapes)
|
void |
setOffset(java.awt.geom.Point2D offset)
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. |
static void |
textWrapTextChunk(java.text.AttributedCharacterIterator aci,
java.util.List layouts,
java.util.List flowRects,
java.util.List brLocs,
java.util.List pLocs,
int justification)
This will wrap the text associated with aci and layouts. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.text.AttributedCharacterIterator.Attribute TEXT_COMPOUND_DELIMITER
public static final float eps
Constructor Detail |
public GlyphLayout(java.text.AttributedCharacterIterator aci, int[] charMap, java.awt.geom.Point2D offset, java.awt.font.FontRenderContext frc)
aci
- the AttributedCharacterIterator whose text is to
be laid outcharMap
- Indicates how chars in aci map to original
text char array.offset
- The offset position of this text layoutfrc
- the FontRenderContext to use for generating glyphs.Method Detail |
public java.awt.geom.Point2D getOffset()
getOffset
in interface TextSpanLayout
public void setScale(float xScale, float yScale, boolean adjSpacing)
setScale
in interface TextSpanLayout
xScale
- Scale factor to apply in X direction.yScale
- Scale factor to apply in Y direction.adjSpacing
- True if only spaces should be adjusted.public void setOffset(java.awt.geom.Point2D offset)
setOffset
in interface TextSpanLayout
public GVTGlyphMetrics getGlyphMetrics(int glyphIndex)
TextSpanLayout
getGlyphMetrics
in interface TextSpanLayout
public boolean isVertical()
isVertical
in interface TextSpanLayout
public boolean isOnATextPath()
isOnATextPath
in interface TextSpanLayout
public int getGlyphCount()
getGlyphCount
in interface TextSpanLayout
public int getCharacterCount(int startGlyphIndex, int endGlyphIndex)
getCharacterCount
in interface TextSpanLayout
startGlyphIndex
- The index of the first glyph in the range.endGlyphIndex
- The index of the last glyph in the range.public boolean isLeftToRight()
isLeftToRight
in interface TextSpanLayout
public void draw(java.awt.Graphics2D g2d)
draw
in interface TextSpanLayout
g2d
- the Graphics2D to usecontext
- The current render contextpublic java.awt.geom.Point2D getAdvance2D()
getAdvance2D
in interface TextSpanLayout
public java.awt.Shape getOutline()
getOutline
in interface TextSpanLayout
public java.awt.Shape getDecorationOutline(int decorationType)
getDecorationOutline
in interface TextSpanLayout
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_STRIKETHROUGHpublic java.awt.geom.Rectangle2D getBounds()
getBounds
in interface TextSpanLayout
public java.awt.geom.Rectangle2D getDecoratedBounds()
getDecoratedBounds
in interface TextSpanLayout
public java.awt.geom.Point2D getTextPathAdvance()
getTextPathAdvance
in interface TextSpanLayout
public int getGlyphIndex(int charIndex)
getGlyphIndex
in interface TextSpanLayout
charIndex
- The original index of the character in the text node's
text string.public java.awt.Shape getHighlightShape(int beginCharIndex, int endCharIndex)
getHighlightShape
in interface TextSpanLayout
beginCharIndex
- the index of the first char in the
contiguous selection.endCharIndex
- the index of the last char in the
contiguous selection.public static int makeConvexHull(java.awt.geom.Point2D.Float[] pts, int numPts)
public static void addPtsToPath(java.awt.geom.GeneralPath shape, java.awt.geom.Point2D.Float[] topPts, java.awt.geom.Point2D.Float[] botPts, int numPts)
public static void mergeAreas(java.awt.geom.GeneralPath shape, java.awt.geom.Area[] shapes, int nShapes)
public TextHit hitTestChar(float x, float y)
hitTestChar
in interface TextSpanLayout
x
- the x coordinate of the point to be tested.y
- the y coordinate of the point to be tested.protected GVTFont getFont()
aci
- The character iterator to get the font attribute from.protected java.awt.Shape getOverlineShape()
protected java.awt.Shape getUnderlineShape()
protected java.awt.Shape getStrikethroughShape()
protected void doExplicitGlyphLayout()
applyOffset
- Specifies whether or not to add the offset position
to each of the glyph positions.protected void adjustTextSpacing()
protected java.awt.geom.Point2D doSpacing(java.lang.Float kern, java.lang.Float letterSpacing, java.lang.Float wordSpacing)
kern
- The kerning adjustment to apply to the space
between each char.letterSpacing
- The amount of spacing required between each char.wordSpacing
- The amount of spacing required between each word.protected void applyStretchTransform(boolean stretchGlyphs)
stretchGlyphs
- if true xScale, yScale will be applied to
each glyphs transform.protected void doPathLayout()
protected boolean isLatinChar(char c)
c
- The char to test.protected boolean isGlyphOrientationAuto()
protected int getGlyphOrientationAngle()
public static void textWrapTextChunk(java.text.AttributedCharacterIterator aci, java.util.List layouts, java.util.List flowRects, java.util.List brLocs, java.util.List pLocs, int justification)
aci
- The Attributed Charater Iterator for text to wrap.
used exclusively to access font information.layouts
- A List of GlyphLayout objects that are to
be wrapped as a whole.flowRects
- A List of Rectangle2D representing the regions
to flow text into.brLocs
- A List of Integer. Each integer indicates the
the aci index of the char after the end of a
br/line element. Note that a particular value can
be repeated several times for sequences of br/line
elements without chars between them.pLocs
- A List of Integer. Each integer indicates the
the aci index of the char after the end of a
p element. Note that a particular value can be
repeated several times for sequences of p
elements without chars between them.justification
- an integer in the range: 0-3. 0 is left,
1 is center, 2 is right, and
3 is fully justified.protected static boolean isSpace(char ch)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |