Class TextSvgBranchRenderer
java.lang.Object
com.itextpdf.svg.renderers.impl.AbstractSvgNodeRenderer
com.itextpdf.svg.renderers.impl.TextSvgBranchRenderer
- All Implemented Interfaces:
ISvgTextNodeRenderer, ISvgNodeRenderer
- Direct Known Subclasses:
TextSvgTSpanBranchRenderer
ISvgNodeRenderer implementation for the <text> and <tspan> tag.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classNested classes/interfaces inherited from class AbstractSvgNodeRenderer
AbstractSvgNodeRenderer.FillProperties, AbstractSvgNodeRenderer.StrokeProperties -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final List<ISvgTextNodeRenderer> private booleanprivate Rectangleprivate Paragraphprotected booleanDeprecated.private booleanprotected static final AffineTransformTop level transformation to flip the y-axis results in the character glyphs being mirrored, this tf corrects for this behaviourprivate booleanprivate floatprivate float[]private floatprivate float[]Fields inherited from class AbstractSvgNodeRenderer
attributesAndStyles, doFill, doStroke -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddChild(ISvgTextNodeRenderer child) Adds a child to the currentTextSvgBranchRendererrenderer.(package private) voidaddTextChild(Text text, SvgDrawContext drawContext) (package private) voidapplyFillAndStrokeProperties(AbstractSvgNodeRenderer.FillProperties fillProperties, AbstractSvgNodeRenderer.StrokeProperties strokeProperties, SvgDrawContext context) (package private) voidapplyFontProperties(IElement element, SvgDrawContext context) private voidprivate voidapplyTextAnchor(String textAnchorValue, boolean isRtl) (package private) voidapplyTextRenderingMode(IElement element) private voidcollectChildren(List<ISvgTextNodeRenderer> children) booleanThis method is deprecated and will be replaced with new signaturecontainsAbsolutePositionChange(SvgDrawContext).booleanChecks whether current <text> or <tspan> element contains absolute position attributes.booleanDeprecated.booleancontainsRelativeMove(SvgDrawContext context) Checks whether current <text> or <tspan> element contains relative position change.Creates a deep copy of this renderer, including it's subtree of childrenprivate voiddeepCopyChildren(TextSvgBranchRenderer deepCopy) protected voiddoDraw(SvgDrawContext context) Method that will set properties to be inherited by this branch renderer's children and will iterate over all children in order to draw them.private voiddrawLastTextChunk(SvgDrawContext context) (package private) voidfloat[][]This method is deprecated and will be replaced with new signaturegetAbsolutePositionChanges(SvgDrawContext).float[][]getAbsolutePositionChanges(SvgDrawContext context) Gets absolute position of the current <text> or <tspan> element.final List<ISvgTextNodeRenderer> Retrieves a list of all children of the currentTextSvgBranchRendererrenderer.private static RectanglegetCommonRectangleWithAnchor(Rectangle commonRect, Rectangle textChunkRect, float absoluteX, String textAnchorValue) Adjust absolutely positioned text chunk (shift it to the start of view port, apply text anchor) and merge it with the common text rectangle.getObjectBoundingBox(SvgDrawContext context) Calculates the current object bounding box.private float[]getPositionsFromString(String rawValuesString, SvgDrawContext context, boolean isHorizontal) float[]Deprecated.float[]getRelativeTranslation(SvgDrawContext context) Gets relative translation of the current <text> or <tspan> element.private PointgetStartPoint(SvgDrawContext context, Point basePoint) floatgetTextContentLength(float parentFontSize, PdfFont font) Deprecated.getTextRectangle(SvgDrawContext context, Point startPoint) Return the bounding rectangle of the text element.private static AffineTransformgetTextTransform(float[][] absolutePositions, SvgDrawContext context) voidMarks white-space property as processed.(package private) voidperformDrawing(SvgDrawContext context) (package private) voidpreDraw(SvgDrawContext context) Operations to perform before drawing an element.private voidprivate voidresolveRelativeTextMove(SvgDrawContext context) private voidstartNewTextChunk(SvgDrawContext context, AffineTransform newTransform) Methods inherited from class AbstractSvgNodeRenderer
applyNonScalingStrokeTransform, calculateViewPortTranslation, canConstructViewPort, canElementFill, deepCopyAttributesAndStyles, doStrokeOrFill, draw, getAttribute, getAttributeMapCopy, getAttributeOrDefault, getCurrentFontSize, getCurrentFontSize, getCurrentViewBox, getParent, getParentClipPath, isHidden, parseAbsoluteLength, parseHorizontalLength, parseVerticalLength, postDraw, retrieveAlignAndMeet, setAttribute, setAttributesAndStyles, setParentMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ISvgNodeRenderer
draw, getAttribute, getAttributeMapCopy, getParent, setAttribute, setAttributesAndStyles, setParent
-
Field Details
-
TEXTFLIP
Top level transformation to flip the y-axis results in the character glyphs being mirrored, this tf corrects for this behaviour -
children
-
performRootTransformations
Deprecated. -
paragraph
-
objectBoundingBox
-
moveResolved
private boolean moveResolved -
xMove
private float xMove -
yMove
private float yMove -
posResolved
private boolean posResolved -
xPos
private float[] xPos -
yPos
private float[] yPos -
whiteSpaceProcessed
private boolean whiteSpaceProcessed
-
-
Constructor Details
-
TextSvgBranchRenderer
public TextSvgBranchRenderer()Creates newTextSvgBranchRendererinstance.
-
-
Method Details
-
createDeepCopy
Description copied from interface:ISvgNodeRendererCreates a deep copy of this renderer, including it's subtree of children- Specified by:
createDeepCopyin interfaceISvgNodeRenderer- Returns:
- deep copy of this renderer
-
fillCopy
-
addChild
Adds a child to the currentTextSvgBranchRendererrenderer.- Parameters:
child-ISvgTextNodeRendererchild to add
-
getChildren
Retrieves a list of all children of the currentTextSvgBranchRendererrenderer.- Returns:
- a list of
ISvgTextNodeRendererchildren
-
getTextContentLength
Deprecated.Description copied from interface:ISvgTextNodeRendererGets text content length.- Specified by:
getTextContentLengthin interfaceISvgTextNodeRenderer- Parameters:
parentFontSize- parent font sizefont- current font- Returns:
- text content length
-
getRelativeTranslation
Deprecated.Description copied from interface:ISvgTextNodeRendererThis method is deprecated and will be replaced with new signaturegetRelativeTranslation(SvgDrawContext). This is needed because xMove/yMove can contain relative values, so SvgDrawContext is needed to resolve them.- Specified by:
getRelativeTranslationin interfaceISvgTextNodeRenderer- Returns:
- text relative translation
-
getRelativeTranslation
Gets relative translation of the current <text> or <tspan> element.- Parameters:
context- currentSvgDrawContext- Returns:
- float array that contains relative
dxanddytranslations
-
containsRelativeMove
Deprecated.Description copied from interface:ISvgTextNodeRendererThis method is deprecated and will be replaced with new signaturecontainsRelativeMove(SvgDrawContext). This is needed because xMove/yMove can contain relative values, so SvgDrawContext is needed to resolve them.- Specified by:
containsRelativeMovein interfaceISvgTextNodeRenderer- Returns:
trueif there is a relative move,falseotherwise
-
containsRelativeMove
Checks whether current <text> or <tspan> element contains relative position change.- Parameters:
context- currentSvgDrawContext- Returns:
trueis current element contains relative position,falseotherwise
-
containsAbsolutePositionChange
public boolean containsAbsolutePositionChange()Description copied from interface:ISvgTextNodeRendererThis method is deprecated and will be replaced with new signaturecontainsAbsolutePositionChange(SvgDrawContext). This is needed because x/y can contain relative values, so SvgDrawContext is needed to resolve them.- Specified by:
containsAbsolutePositionChangein interfaceISvgTextNodeRenderer- Returns:
trueif an absolute position is specified via x/y attributes,falseotherwise
-
containsAbsolutePositionChange
Checks whether current <text> or <tspan> element contains absolute position attributes.- Parameters:
context- currentSvgDrawContext- Returns:
trueis current element contains absolute position,falseotherwise
-
getAbsolutePositionChanges
public float[][] getAbsolutePositionChanges()Description copied from interface:ISvgTextNodeRendererThis method is deprecated and will be replaced with new signaturegetAbsolutePositionChanges(SvgDrawContext). This is needed because x/y can contain relative values, so SvgDrawContext is needed to resolve them.- Specified by:
getAbsolutePositionChangesin interfaceISvgTextNodeRenderer- Returns:
- text absolute position
-
getAbsolutePositionChanges
Gets absolute position of the current <text> or <tspan> element.- Parameters:
context- currentSvgDrawContext- Returns:
- float array that contains absolute
xandypositions as either single item arrays or null if attribute is not present
-
markWhiteSpaceProcessed
public void markWhiteSpaceProcessed()Marks white-space property as processed. -
getTextRectangle
Description copied from interface:ISvgTextNodeRendererReturn the bounding rectangle of the text element.- Specified by:
getTextRectanglein interfaceISvgTextNodeRenderer- Parameters:
context- currentSvgDrawContextstartPoint- end point of previous text element- Returns:
- created instance of
TextRectangle
-
getObjectBoundingBox
Description copied from interface:ISvgNodeRendererCalculates the current object bounding box.- Specified by:
getObjectBoundingBoxin interfaceISvgNodeRenderer- Parameters:
context- the current context, for instance it contains current viewport and available font data- Returns:
- the
Rectanglerepresenting the current object's bounding box, or null if bounding box is undefined
-
preDraw
Description copied from class:AbstractSvgNodeRendererOperations to perform before drawing an element. This includes setting stroke color and width, fill color.- Overrides:
preDrawin classAbstractSvgNodeRenderer- Parameters:
context- the svg draw context
-
doDraw
Method that will set properties to be inherited by this branch renderer's children and will iterate over all children in order to draw them.- Specified by:
doDrawin classAbstractSvgNodeRenderer- Parameters:
context- the object that knows the place to draw this element and maintains its state
-
applyFontProperties
-
applyTextRenderingMode
-
addTextChild
-
performDrawing
-
startNewTextChunk
-
drawLastTextChunk
-
applyFillAndStrokeProperties
void applyFillAndStrokeProperties(AbstractSvgNodeRenderer.FillProperties fillProperties, AbstractSvgNodeRenderer.StrokeProperties strokeProperties, SvgDrawContext context) - Overrides:
applyFillAndStrokePropertiesin classAbstractSvgNodeRenderer
-
resolveRelativeTextMove
-
resolveAbsoluteTextPosition
-
getPositionsFromString
private float[] getPositionsFromString(String rawValuesString, SvgDrawContext context, boolean isHorizontal) -
getTextTransform
private static AffineTransform getTextTransform(float[][] absolutePositions, SvgDrawContext context) -
getCommonRectangleWithAnchor
private static Rectangle getCommonRectangleWithAnchor(Rectangle commonRect, Rectangle textChunkRect, float absoluteX, String textAnchorValue) Adjust absolutely positioned text chunk (shift it to the start of view port, apply text anchor) and merge it with the common text rectangle.- Parameters:
commonRect- rectangle for the whole text tagtextChunkRect- rectangle for the last absolutely positioned text chunkabsoluteX- last absolute x positiontextAnchorValue- text anchor for the last text chunk- Returns:
- merged common text rectangle
-
deepCopyChildren
-
applyTextAnchor
private void applyTextAnchor() -
applyTextAnchor
-
getStartPoint
-
collectChildren
-