Package org.apache.batik.ext.awt.font
Class TextPathLayout
java.lang.Object
org.apache.batik.ext.awt.font.TextPathLayout
PathLayout can layout text along a Shape, usually a Path object.
There are a number of improvements that could be made to this class. I'll try to list some of them:
- The layout should really only modify the GlyphVector, rather than converting to a Shape.
- Maybe the functions should take a AttributedCharacterIterator or something? Should this class do the entire layout?
- The layout code works, but it's definitely not perfect.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Use the entire glyph to adjust for textLength.static final int
Use the spacing between the glyphs to adjust for textLength.static final int
Align the text at the end of the path.static final int
Align the text at the middle of the path.static final int
Align the text at the start of the path. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Shape
layoutGlyphVector
(GlyphVector glyphs, Shape path) Wraps the GlyphVector around the given path.static Shape
layoutGlyphVector
(GlyphVector glyphs, Shape path, int align) Wraps the GlyphVector around the given path.static Shape
layoutGlyphVector
(GlyphVector glyphs, Shape path, int align, float startOffset, float textLength, int lengthAdjustMode) Wraps the GlyphVector around the given path.
-
Field Details
-
ALIGN_START
public static final int ALIGN_STARTAlign the text at the start of the path.- See Also:
-
ALIGN_MIDDLE
public static final int ALIGN_MIDDLEAlign the text at the middle of the path.- See Also:
-
ALIGN_END
public static final int ALIGN_ENDAlign the text at the end of the path.- See Also:
-
ADJUST_SPACING
public static final int ADJUST_SPACINGUse the spacing between the glyphs to adjust for textLength.- See Also:
-
ADJUST_GLYPHS
public static final int ADJUST_GLYPHSUse the entire glyph to adjust for textLength.- See Also:
-
-
Constructor Details
-
TextPathLayout
public TextPathLayout()
-
-
Method Details
-
layoutGlyphVector
public static Shape layoutGlyphVector(GlyphVector glyphs, Shape path, int align, float startOffset, float textLength, int lengthAdjustMode) Wraps the GlyphVector around the given path. The results are mostly quite nice but you need to be careful choosing the size of the font that created the GlyphVector, as well as the "curvyness" of the path (really dynamic curves don't look so great, abrupt changes/vertices look worse).- Parameters:
glyphs
- The GlyphVector to layout.path
- The path (or shape) to wrap aroundalign
- The text alignment to use. Should be one of ALIGN_START, ALIGN_MIDDLE or ALIGN_END.startOffset
- The offset from the start of the path for the initial text position.textLength
- The length that the text should fill.lengthAdjustMode
- The method used to expand or contract the text to meet the textLength.- Returns:
- A shape that is the outline of the glyph vector wrapped along the path
-
layoutGlyphVector
Wraps the GlyphVector around the given path.- Parameters:
glyphs
- The GlyphVector to layout.path
- The path (or shape) to wrap aroundalign
- The text alignment to use. Should be one of ALIGN_START, ALIGN_MIDDLE or ALIGN_END.- Returns:
- A shape that is the outline of the glyph vector wrapped along the path
-
layoutGlyphVector
Wraps the GlyphVector around the given path.- Parameters:
glyphs
- The GlyphVector to layout.path
- The path (or shape) to wrap around- Returns:
- A shape that is the outline of the glyph vector wrapped along the path
-