public class GlyphLayout extends Object implements TextSpanLayout
TextSpanLayout| Modifier and Type | Field and Description |
|---|---|
protected Point2D |
advance |
static double |
eps |
static AttributedCharacterIterator.Attribute |
FLOW_EMPTY_PARAGRAPH |
static AttributedCharacterIterator.Attribute |
FLOW_LINE_BREAK |
static AttributedCharacterIterator.Attribute |
FLOW_PARAGRAPH |
protected GVTGlyphVector |
gv |
static AttributedCharacterIterator.Attribute |
GVT_FONT |
static AttributedCharacterIterator.Attribute |
HORIZONTAL_ORIENTATION_ANGLE |
protected boolean |
layoutApplied |
static AttributedCharacterIterator.Attribute |
LINE_HEIGHT |
protected static Set |
runAtts |
protected static Set |
szAtts |
static AttributedCharacterIterator.Attribute |
VERTICAL_ORIENTATION |
static AttributedCharacterIterator.Attribute |
VERTICAL_ORIENTATION_ANGLE |
DECORATION_ALL, DECORATION_OVERLINE, DECORATION_STRIKETHROUGH, DECORATION_UNDERLINE| Constructor and Description |
|---|
GlyphLayout(AttributedCharacterIterator aci,
int[] charMap,
Point2D offset,
FontRenderContext frc)
Creates the specified text layout using the
specified AttributedCharacterIterator and rendering context.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
addPtsToPath(GeneralPath shape,
Point2D.Float[] topPts,
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 Point2D |
doSpacing(Float kern,
Float letterSpacing,
Float wordSpacing)
Performs any spacing adjustments required and returns the new advance
value.
|
void |
draw(Graphics2D g2d)
Paints the text layout using the
specified Graphics2D and rendering context.
|
static boolean |
epsEQ(double a,
double b) |
Point2D |
getAdvance2D()
Returns the current text position at the completion
of glyph layout.
|
Rectangle2D |
getBounds2D()
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 |
getComputedOrientationAngle(int index)
Return the angle value according to the orientation
of the character.
|
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.
|
Rectangle2D |
getGeometricBounds()
Returns the rectangular bounds of the completed glyph layout,
inclusive of "decoration" (underline, overline, etc.)
|
float[] |
getGlyphAdvances()
Returns the advance between each glyph in text progression direction.
|
int |
getGlyphCount()
Returns the number of glyphs in this layout.
|
int |
getGlyphIndex(int charIndex)
Returns the index of the first 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.
|
GVTGlyphVector |
getGlyphVector()
Return the glyph vector asociated to this layout.
|
Shape |
getHighlightShape(int beginCharIndex,
int endCharIndex)
Returns a Shape which encloses the currently selected glyphs
as specified by the character indices.
|
int |
getLastGlyphIndex(int charIndex)
Returns the index of the last glyph that has the specified char index.
|
GVTLineMetrics |
getLineMetrics()
Returns the Line metrics for this text span.
|
Point2D |
getOffset()
Returns the current text position at the beginning
of glyph layout, before the application of explicit
glyph positioning attributes.
|
Shape |
getOutline()
Returns the outline of the completed glyph layout.
|
protected Shape |
getOverlineShape()
Returns a shape describing the overline decoration for a given ACI.
|
protected Shape |
getStrikethroughShape()
Returns a shape describing the strikethrough line for a given ACI.
|
Point2D |
getTextPathAdvance()
Returns the position to used when drawing a text run after this one.
|
protected Shape |
getUnderlineShape()
Returns a shape describing the undeline decoration for a given ACI.
|
boolean |
hasCharacterIndex(int index)
Return true is the character index is represented by glyphs
in this layout.
|
TextHit |
hitTestChar(float x,
float y)
Perform hit testing for coordinate at x, y.
|
boolean |
isAltGlyph()
Return true if this text run represents
an alt glyph.
|
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.
|
boolean |
isReversed()
Return true if this text has been reversed.
|
boolean |
isVertical()
Returns true if the advance direction of this text is vertical.
|
static int |
makeConvexHull(Point2D.Float[] pts,
int numPts) |
void |
maybeReverse(boolean mirror)
Reverse (and optionally mirror) glyphs if not
already reversed.
|
static void |
mergeAreas(GeneralPath shape,
Area[] shapes,
int nShapes) |
void |
setOffset(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.
|
protected GVTGlyphVector gv
protected Point2D advance
protected boolean layoutApplied
public static final AttributedCharacterIterator.Attribute FLOW_LINE_BREAK
public static final AttributedCharacterIterator.Attribute FLOW_PARAGRAPH
public static final AttributedCharacterIterator.Attribute FLOW_EMPTY_PARAGRAPH
public static final AttributedCharacterIterator.Attribute LINE_HEIGHT
public static final AttributedCharacterIterator.Attribute VERTICAL_ORIENTATION
public static final AttributedCharacterIterator.Attribute VERTICAL_ORIENTATION_ANGLE
public static final AttributedCharacterIterator.Attribute HORIZONTAL_ORIENTATION_ANGLE
public static final AttributedCharacterIterator.Attribute GVT_FONT
protected static Set runAtts
protected static Set szAtts
public static final double eps
public GlyphLayout(AttributedCharacterIterator aci, int[] charMap, Point2D offset, 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.public GVTGlyphVector getGlyphVector()
TextSpanLayoutgetGlyphVector in interface TextSpanLayoutpublic Point2D getOffset()
getOffset in interface TextSpanLayoutpublic void setScale(float xScale,
float yScale,
boolean adjSpacing)
setScale in interface TextSpanLayoutxScale - 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(Point2D offset)
setOffset in interface TextSpanLayoutpublic GVTGlyphMetrics getGlyphMetrics(int glyphIndex)
TextSpanLayoutgetGlyphMetrics in interface TextSpanLayoutpublic GVTLineMetrics getLineMetrics()
TextSpanLayoutgetLineMetrics in interface TextSpanLayoutpublic boolean isVertical()
isVertical in interface TextSpanLayoutpublic boolean isOnATextPath()
isOnATextPath in interface TextSpanLayoutpublic int getGlyphCount()
getGlyphCount in interface TextSpanLayoutpublic int getCharacterCount(int startGlyphIndex,
int endGlyphIndex)
getCharacterCount in interface TextSpanLayoutstartGlyphIndex - 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 TextSpanLayoutpublic void draw(Graphics2D g2d)
draw in interface TextSpanLayoutg2d - the Graphics2D to usepublic Point2D getAdvance2D()
getAdvance2D in interface TextSpanLayoutpublic Shape getOutline()
getOutline in interface TextSpanLayoutpublic float[] getGlyphAdvances()
TextSpanLayoutgetGlyphAdvances in interface TextSpanLayoutpublic Shape getDecorationOutline(int decorationType)
getDecorationOutline in interface TextSpanLayoutdecorationType - 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 Rectangle2D getBounds2D()
getBounds2D in interface TextSpanLayoutpublic Rectangle2D getGeometricBounds()
getGeometricBounds in interface TextSpanLayoutpublic Point2D getTextPathAdvance()
getTextPathAdvance in interface TextSpanLayoutpublic int getGlyphIndex(int charIndex)
getGlyphIndex in interface TextSpanLayoutcharIndex - The original index of the character in the text node's
text string.public int getLastGlyphIndex(int charIndex)
charIndex - The original index of the character in the text node's
text string.public double getComputedOrientationAngle(int index)
getComputedOrientationAngle in interface TextSpanLayoutindex - index of the character in the ACIpublic Shape getHighlightShape(int beginCharIndex, int endCharIndex)
getHighlightShape in interface TextSpanLayoutbeginCharIndex - the index of the first char in the
contiguous selection.endCharIndex - the index of the last char in the
contiguous selection.public static boolean epsEQ(double a,
double b)
public static int makeConvexHull(Point2D.Float[] pts, int numPts)
public static void addPtsToPath(GeneralPath shape, Point2D.Float[] topPts, Point2D.Float[] botPts, int numPts)
public static void mergeAreas(GeneralPath shape, Area[] shapes, int nShapes)
public TextHit hitTestChar(float x, float y)
hitTestChar in interface TextSpanLayoutx - the x coordinate of the point to be tested.y - the y coordinate of the point to be tested.protected GVTFont getFont()
protected Shape getOverlineShape()
protected Shape getUnderlineShape()
protected Shape getStrikethroughShape()
protected void doExplicitGlyphLayout()
protected void adjustTextSpacing()
protected Point2D doSpacing(Float kern, Float letterSpacing, 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 boolean hasCharacterIndex(int index)
hasCharacterIndex in interface TextSpanLayoutindex - index of the character in the ACI.public boolean isAltGlyph()
isAltGlyph in interface TextSpanLayoutpublic boolean isReversed()
TextSpanLayoutisReversed in interface TextSpanLayoutpublic void maybeReverse(boolean mirror)
TextSpanLayoutmaybeReverse in interface TextSpanLayoutCopyright © 2000–2024 Apache Software Foundation. All rights reserved.