Package com.itextpdf.svg.renderers.impl
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
public class TextSvgBranchRenderer extends AbstractSvgNodeRenderer implements ISvgTextNodeRenderer
ISvgNodeRenderer
implementation for the <text> and <tspan> tag.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<ISvgTextNodeRenderer>
children
private PdfFont
font
private boolean
moveResolved
protected boolean
performRootTransformations
private boolean
posResolved
protected static AffineTransform
TEXTFLIP
Top level transformation to flip the y-axis results in the character glyphs being mirrored, this tf corrects for this behaviourprivate boolean
whiteSpaceProcessed
private float
xMove
private float[]
xPos
private float
yMove
private float[]
yPos
-
Fields inherited from class com.itextpdf.svg.renderers.impl.AbstractSvgNodeRenderer
attributesAndStyles, doFill, doStroke, partOfClipPath
-
-
Constructor Summary
Constructors Constructor Description TextSvgBranchRenderer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addChild(ISvgTextNodeRenderer child)
(package private) void
applyTextRenderingMode(PdfCanvas currentCanvas)
boolean
containsAbsolutePositionChange()
boolean
containsRelativeMove()
ISvgNodeRenderer
createDeepCopy()
Creates a deep copy of this renderer, including it's subtree of childrenprivate void
deepCopyChildren(TextSvgBranchRenderer deepCopy)
protected void
doDraw(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.(package private) void
fillCopy(TextSvgBranchRenderer copy)
float[][]
getAbsolutePositionChanges()
java.util.List<ISvgTextNodeRenderer>
getChildren()
(package private) PdfFont
getFont()
Return the font used in this text element.Rectangle
getObjectBoundingBox(SvgDrawContext context)
Calculates the current object bounding box.private static float[]
getPositionsFromString(java.lang.String rawValuesString)
float[]
getRelativeTranslation()
(package private) float
getTextAnchorAlignmentCorrection(float childContentLength)
float
getTextContentLength(float parentFontSize, PdfFont font)
TextRectangle
getTextRectangle(SvgDrawContext context, Point basePoint)
Return the bounding rectangle of the text element.(package private) static AffineTransform
getTextTransform(float[][] absolutePositions, SvgDrawContext context)
void
markWhiteSpaceProcessed()
(package private) void
performRootTransformations(PdfCanvas currentCanvas, SvgDrawContext context)
(package private) void
resolveFont(SvgDrawContext context)
private FontInfo
resolveFontName(java.lang.String fontFamily, java.lang.String fontWeight, java.lang.String fontStyle, FontProvider provider, FontSet tempFonts)
private void
resolveTextMove()
private void
resolveTextPosition()
-
Methods inherited from class com.itextpdf.svg.renderers.impl.AbstractSvgNodeRenderer
calculateViewPortTranslation, canConstructViewPort, canElementFill, deepCopyAttributesAndStyles, draw, getAttribute, getAttributeMapCopy, getAttributeOrDefault, getCurrentFontSize, getParent, parseAbsoluteLength, postDraw, preDraw, setAttribute, setAttributesAndStyles, setParent, setPartOfClipPath
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.itextpdf.svg.renderers.ISvgNodeRenderer
draw, getAttribute, getAttributeMapCopy, getParent, setAttribute, setAttributesAndStyles, setParent
-
-
-
-
Field Detail
-
TEXTFLIP
protected static final AffineTransform TEXTFLIP
Top level transformation to flip the y-axis results in the character glyphs being mirrored, this tf corrects for this behaviour
-
children
private final java.util.List<ISvgTextNodeRenderer> children
-
performRootTransformations
protected boolean performRootTransformations
-
font
private PdfFont font
-
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
-
-
Method Detail
-
createDeepCopy
public ISvgNodeRenderer createDeepCopy()
Description copied from interface:ISvgNodeRenderer
Creates a deep copy of this renderer, including it's subtree of children- Specified by:
createDeepCopy
in interfaceISvgNodeRenderer
- Returns:
- deep copy of this renderer
-
fillCopy
void fillCopy(TextSvgBranchRenderer copy)
-
addChild
public final void addChild(ISvgTextNodeRenderer child)
-
getChildren
public final java.util.List<ISvgTextNodeRenderer> getChildren()
-
getTextContentLength
public float getTextContentLength(float parentFontSize, PdfFont font)
- Specified by:
getTextContentLength
in interfaceISvgTextNodeRenderer
-
getRelativeTranslation
public float[] getRelativeTranslation()
- Specified by:
getRelativeTranslation
in interfaceISvgTextNodeRenderer
-
containsRelativeMove
public boolean containsRelativeMove()
- Specified by:
containsRelativeMove
in interfaceISvgTextNodeRenderer
-
containsAbsolutePositionChange
public boolean containsAbsolutePositionChange()
- Specified by:
containsAbsolutePositionChange
in interfaceISvgTextNodeRenderer
-
getAbsolutePositionChanges
public float[][] getAbsolutePositionChanges()
- Specified by:
getAbsolutePositionChanges
in interfaceISvgTextNodeRenderer
-
markWhiteSpaceProcessed
public void markWhiteSpaceProcessed()
-
getTextRectangle
public TextRectangle getTextRectangle(SvgDrawContext context, Point basePoint)
Description copied from interface:ISvgTextNodeRenderer
Return the bounding rectangle of the text element.- Specified by:
getTextRectangle
in interfaceISvgTextNodeRenderer
- Parameters:
context
- currentSvgDrawContext
basePoint
- end point of previous text element- Returns:
- created instance of
TextRectangle
-
getObjectBoundingBox
public Rectangle getObjectBoundingBox(SvgDrawContext context)
Description copied from interface:ISvgNodeRenderer
Calculates the current object bounding box.- Specified by:
getObjectBoundingBox
in interfaceISvgNodeRenderer
- Parameters:
context
- the current context, for instance it contains current viewport and available font data- Returns:
- the
Rectangle
representing the current object's bounding box, or null if bounding box is undefined
-
doDraw
protected void doDraw(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.- Specified by:
doDraw
in classAbstractSvgNodeRenderer
- Parameters:
context
- the object that knows the place to draw this element and maintains its state
-
performRootTransformations
void performRootTransformations(PdfCanvas currentCanvas, SvgDrawContext context)
-
resolveTextMove
private void resolveTextMove()
-
resolveFontName
private FontInfo resolveFontName(java.lang.String fontFamily, java.lang.String fontWeight, java.lang.String fontStyle, FontProvider provider, FontSet tempFonts)
-
resolveFont
void resolveFont(SvgDrawContext context)
-
getFont
PdfFont getFont()
Return the font used in this text element. Note that font should already be resolved withresolveFont(com.itextpdf.svg.renderers.SvgDrawContext)
.- Returns:
- font of the current text element
-
resolveTextPosition
private void resolveTextPosition()
-
getPositionsFromString
private static float[] getPositionsFromString(java.lang.String rawValuesString)
-
getTextTransform
static AffineTransform getTextTransform(float[][] absolutePositions, SvgDrawContext context)
-
applyTextRenderingMode
void applyTextRenderingMode(PdfCanvas currentCanvas)
-
deepCopyChildren
private void deepCopyChildren(TextSvgBranchRenderer deepCopy)
-
getTextAnchorAlignmentCorrection
float getTextAnchorAlignmentCorrection(float childContentLength)
-
-