Package org.apache.batik.bridge
Class StrokingTextPainter
java.lang.Object
org.apache.batik.bridge.BasicTextPainter
org.apache.batik.bridge.StrokingTextPainter
- All Implemented Interfaces:
TextPainter
- Direct Known Subclasses:
FlowExtTextPainter
,FlowTextPainter
More sophisticated implementation of TextPainter which
renders the attributed character iterator of a
TextNode
.
StrokingTextPainter includes support for stroke, fill, opacity,
text-decoration, and other attributes.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static class
Inner convenience class for associating a TextLayout for sub-spans, and the ACI which iterates over that subspan.Nested classes/interfaces inherited from class org.apache.batik.bridge.BasicTextPainter
BasicTextPainter.BasicMark
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Integer
static final Integer
static final GVTAttributedCharacterIterator.TextAttribute
static final AttributedCharacterIterator.Attribute
static final AttributedCharacterIterator.Attribute
static final AttributedCharacterIterator.Attribute
static final AttributedCharacterIterator.Attribute
static final AttributedCharacterIterator.Attribute
static final AttributedCharacterIterator.Attribute
static final AttributedCharacterIterator.Attribute
protected static TextPainter
A unique instance of this class.static final AttributedCharacterIterator.Attribute
static final AttributedCharacterIterator.Attribute
static final AttributedCharacterIterator.Attribute
static final Integer
static final Integer
static final AttributedCharacterIterator.Attribute
static final AttributedCharacterIterator.Attribute
Fields inherited from class org.apache.batik.bridge.BasicTextPainter
aaOffFontRenderContext, fontRenderContext
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Point2D
adjustChunkOffsets
(Point2D location, List textRuns, StrokingTextPainter.TextChunk chunk) Adjusts the position of the text runs within the specified text chunk to account for any text anchor properties.computeTextRuns
(TextNode node, AttributedCharacterIterator aci, AttributedCharacterIterator[] chunkACIs) protected List
computeTextRuns
(TextNode node, AttributedCharacterIterator aci, AttributedCharacterIterator[] chunkACIs, int[][] chunkCharMaps) protected AttributedCharacterIterator
Returns a new AttributedCharacterIterator that contains resolved GVTFont attributes.getBounds2D
(TextNode node) Get a Rectangle2D in userspace coords which encloses the textnode glyphs including stroke etc.protected Shape
getDecorationOutline
(List textRuns, int decorationType) Returns the outline of the specified decoration type.protected Shape
getDecorationStrokeOutline
(List textRuns, int decorationType) Returns the stroked outline of the specified decoration type.protected FontFamilyResolver
getHighlightShape
(Mark beginMark, Mark endMark) Return a Shape, in the coordinate system of the text layout, which encloses the text selection delineated by two Mark instances.static TextPainter
Returns a unique instance of this class.Returns a mark for the char at index in node's AttributedCharacterIterator.getOutline
(TextNode node) Get a Shape in userspace coords which defines the textnode glyph outlines.int[]
getSelected
(Mark startMark, Mark finishMark) Returns an array of ints representing begin/end index pairs into an AttributedCharacterIterator which represents the text selection delineated by two Mark instances.protected StrokingTextPainter.TextChunk
getTextChunk
(TextNode node, AttributedCharacterIterator aci, int[] charMap, List textRuns, StrokingTextPainter.TextChunk prevChunk) protected AttributedCharacterIterator[]
Returns an array of ACIs, one for each text chunk within the given text node.protected Set
getTextRuns
(TextNode node, AttributedCharacterIterator aci) protected Mark
Returns the mark for the specified parameters.void
paint
(TextNode node, Graphics2D g2d) Paints the specified text node using the specified Graphics2D.protected void
paintDecorations
(List textRuns, Graphics2D g2d, int decorationType) Paints decorations of the specified type.protected void
paintTextRuns
(List textRuns, Graphics2D g2d) Paints the text in each text run.protected void
protected List
reorderTextRuns
(StrokingTextPainter.TextChunk chunk, List runs) Reorder text runs as required by bidi algorithm.selectFirst
(TextNode node) Selects the first glyph in the text node.selectLast
(TextNode node) Selects the last glyph in the text node.Methods inherited from class org.apache.batik.bridge.BasicTextPainter
getGeometryBounds, getTextLayoutFactory, selectAt, selectTo
-
Field Details
-
PAINT_INFO
-
FLOW_REGIONS
-
FLOW_PARAGRAPH
-
TEXT_COMPOUND_ID
-
GVT_FONT
-
GVT_FONTS
-
BIDI_LEVEL
-
XPOS
-
YPOS
-
TEXTPATH
-
WRITING_MODE
-
WRITING_MODE_TTB
-
WRITING_MODE_RTL
-
ANCHOR_TYPE
-
ADJUST_SPACING
-
ADJUST_ALL
-
ALT_GLYPH_HANDLER
-
singleton
A unique instance of this class.
-
-
Constructor Details
-
StrokingTextPainter
public StrokingTextPainter()
-
-
Method Details
-
getInstance
Returns a unique instance of this class. -
paint
Paints the specified text node using the specified Graphics2D.- Parameters:
node
- the text node to paintg2d
- the Graphics2D to use
-
printAttrs
-
getTextRuns
-
computeTextRuns
public List computeTextRuns(TextNode node, AttributedCharacterIterator aci, AttributedCharacterIterator[] chunkACIs) -
computeTextRuns
protected List computeTextRuns(TextNode node, AttributedCharacterIterator aci, AttributedCharacterIterator[] chunkACIs, int[][] chunkCharMaps) -
reorderTextRuns
Reorder text runs as required by bidi algorithm.- Parameters:
runs
- - unordered runs- Returns:
- reordered runs
-
getTextChunkACIs
Returns an array of ACIs, one for each text chunk within the given text node. -
createModifiedACIForFontMatching
protected AttributedCharacterIterator createModifiedACIForFontMatching(AttributedCharacterIterator aci) Returns a new AttributedCharacterIterator that contains resolved GVTFont attributes. This is then used when creating the text runs so that the text can be split on changes of font as well as tspans and trefs.- Parameters:
aci
- The aci to be modified should already be split into text chunks.- Returns:
- The new modified aci.
-
getFontFamilyResolver
-
getTextRunBoundaryAttributes
-
getTextChunk
protected StrokingTextPainter.TextChunk getTextChunk(TextNode node, AttributedCharacterIterator aci, int[] charMap, List textRuns, StrokingTextPainter.TextChunk prevChunk) -
adjustChunkOffsets
protected Point2D adjustChunkOffsets(Point2D location, List textRuns, StrokingTextPainter.TextChunk chunk) Adjusts the position of the text runs within the specified text chunk to account for any text anchor properties. -
paintDecorations
Paints decorations of the specified type. -
paintTextRuns
Paints the text in each text run. Decorations are not painted here. -
getOutline
Get a Shape in userspace coords which defines the textnode glyph outlines.- Parameters:
node
- the TextNode to measure
-
getBounds2D
Get a Rectangle2D in userspace coords which encloses the textnode glyphs including stroke etc.- Parameters:
node
- the TextNode to measure
-
getDecorationOutline
Returns the outline of the specified decoration type.- Parameters:
textRuns
- The list of text runs to get the decoration outline for.decorationType
- Indicates the type of decoration required. eg. underline, overline or strikethrough.- Returns:
- The decoration outline or null if the text is not decorated.
-
getDecorationStrokeOutline
Returns the stroked outline of the specified decoration type. If the decoration has no stroke it will return the fill outline- Parameters:
textRuns
- The list of text runs to get the decoration outline for.decorationType
- Indicates the type of decoration required. eg. underline, overline or strikethrough.- Returns:
- The decoration outline or null if the text is not decorated.
-
getMark
Description copied from interface:TextPainter
Returns a mark for the char at index in node's AttributedCharacterIterator. Leading edge indicates if the mark should be considered immediately 'before' glyph or after -
hitTest
Description copied from class:BasicTextPainter
Returns the mark for the specified parameters.- Specified by:
hitTest
in classBasicTextPainter
-
selectFirst
Selects the first glyph in the text node. -
selectLast
Selects the last glyph in the text node. -
getSelected
Returns an array of ints representing begin/end index pairs into an AttributedCharacterIterator which represents the text selection delineated by two Mark instances. Note: The Mark instances passed must have been instantiated by an instance of this enclosing TextPainter implementation. -
getHighlightShape
Return a Shape, in the coordinate system of the text layout, which encloses the text selection delineated by two Mark instances. Note: The Mark instances passed must have been instantiated by an instance of this enclosing TextPainter implementation.
-