Package com.itextpdf.svg.renderers.impl
Class AbstractBranchSvgNodeRenderer
- java.lang.Object
-
- com.itextpdf.svg.renderers.impl.AbstractSvgNodeRenderer
-
- com.itextpdf.svg.renderers.impl.AbstractBranchSvgNodeRenderer
-
- All Implemented Interfaces:
IBranchSvgNodeRenderer
,ISvgNodeRenderer
- Direct Known Subclasses:
AbstractContainerSvgNodeRenderer
,AbstractGradientSvgNodeRenderer
,ClipPathSvgNodeRenderer
,DefsSvgNodeRenderer
,GroupSvgNodeRenderer
,MarkerSvgNodeRenderer
,PatternSvgNodeRenderer
,StopSvgNodeRenderer
public abstract class AbstractBranchSvgNodeRenderer extends AbstractSvgNodeRenderer implements IBranchSvgNodeRenderer
Abstract class that will be the superclass for any element that can function as a parent.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<ISvgNodeRenderer>
children
private static org.slf4j.Logger
LOGGER
protected static int
VIEWBOX_VALUES_NUMBER
The number of viewBox values.-
Fields inherited from class com.itextpdf.svg.renderers.impl.AbstractSvgNodeRenderer
attributesAndStyles, doFill, doStroke, partOfClipPath
-
-
Constructor Summary
Constructors Constructor Description AbstractBranchSvgNodeRenderer()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addChild(ISvgNodeRenderer child)
Adds a renderer as the last element of the list of children.(package private) static void
addXObject(PdfCanvas canvas, PdfXObject xObject, float x, float y)
(package private) void
applyViewBox(SvgDrawContext context)
Applies a transformation based on a viewBox for a given branch node.private void
applyViewportClip(SvgDrawContext context)
Applies a clipping operation based on the view port.private void
applyViewportTranslationCorrection(SvgDrawContext context)
(package private) void
calculateAndApplyViewBox(SvgDrawContext context, float[] values, Rectangle currentViewPort)
private void
cleanUp(SvgDrawContext context)
Cleans up the SvgDrawContext by removing the current viewport and by popping the current canvas.abstract ISvgNodeRenderer
createDeepCopy()
Creates a deep copy of this renderer, including it's subtree of childrenprotected void
deepCopyChildren(AbstractBranchSvgNodeRenderer deepCopy)
Create a deep copy of every child renderer and add them to the passedAbstractBranchSvgNodeRenderer
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.java.util.List<ISvgNodeRenderer>
getChildren()
Gets all child renderers of this object.(package private) float[]
getViewBoxValues()
private static boolean
isOverflowVisible(AbstractSvgNodeRenderer currentElement)
(package private) void
postDraw(SvgDrawContext context)
Operations to be performed after drawing the element.(package private) AffineTransform
processAspectRatioPosition(SvgDrawContext context, float[] viewBoxValues, java.lang.String align, float scaleWidth, float scaleHeight)
If present, process the preserveAspectRatio position.(package private) java.lang.String[]
retrieveAlignAndMeet()
private static float[]
scaleViewBoxValues(float[] values, float scaleWidth, float scaleHeight)
(package private) void
setPartOfClipPath(boolean isPart)
private static void
writeBBoxAccordingToVisibleOverflow(SvgDrawContext context, PdfStream stream)
When in the svg elementoverflow
isvisible
the corresponding formXObject should have a BBox (form XObject’s bounding box; see PDF 32000-1:2008 - 8.10.2 Form Dictionaries) that should cover the entire svg space (page in pdf) in order to be able to show parts of the element which are outside the current element viewPort.-
Methods inherited from class com.itextpdf.svg.renderers.impl.AbstractSvgNodeRenderer
calculateViewPortTranslation, canConstructViewPort, canElementFill, deepCopyAttributesAndStyles, draw, getAttribute, getAttributeMapCopy, getAttributeOrDefault, getCurrentFontSize, getParent, parseAbsoluteLength, preDraw, setAttribute, setAttributesAndStyles, setParent
-
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, getObjectBoundingBox, getParent, setAttribute, setAttributesAndStyles, setParent
-
-
-
-
Field Detail
-
VIEWBOX_VALUES_NUMBER
protected static final int VIEWBOX_VALUES_NUMBER
The number of viewBox values.- See Also:
- Constant Field Values
-
children
private final java.util.List<ISvgNodeRenderer> children
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
-
Method Detail
-
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
-
addXObject
static void addXObject(PdfCanvas canvas, PdfXObject xObject, float x, float y)
-
applyViewBox
void applyViewBox(SvgDrawContext context)
Applies a transformation based on a viewBox for a given branch node.- Parameters:
context
- current svg draw context
-
retrieveAlignAndMeet
java.lang.String[] retrieveAlignAndMeet()
-
applyViewportClip
private void applyViewportClip(SvgDrawContext context)
Applies a clipping operation based on the view port.- Parameters:
context
- the svg draw context
-
applyViewportTranslationCorrection
private void applyViewportTranslationCorrection(SvgDrawContext context)
-
processAspectRatioPosition
AffineTransform processAspectRatioPosition(SvgDrawContext context, float[] viewBoxValues, java.lang.String align, float scaleWidth, float scaleHeight)
If present, process the preserveAspectRatio position.- Parameters:
context
- the svg draw contextviewBoxValues
- the four values depicting the viewbox [min-x min-y width height]align
- alignment method to usescaleWidth
- the multiplier for scaling widthscaleHeight
- the multiplier for scaling height- Returns:
- the transformation based on the preserveAspectRatio value
-
cleanUp
private void cleanUp(SvgDrawContext context)
Cleans up the SvgDrawContext by removing the current viewport and by popping the current canvas.- Parameters:
context
- context to clean
-
addChild
public final void addChild(ISvgNodeRenderer child)
Description copied from interface:IBranchSvgNodeRenderer
Adds a renderer as the last element of the list of children.- Specified by:
addChild
in interfaceIBranchSvgNodeRenderer
- Parameters:
child
- any renderer
-
getChildren
public final java.util.List<ISvgNodeRenderer> getChildren()
Description copied from interface:IBranchSvgNodeRenderer
Gets all child renderers of this object.- Specified by:
getChildren
in interfaceIBranchSvgNodeRenderer
- Returns:
- the list of child renderers (in the order that they were added)
-
deepCopyChildren
protected final void deepCopyChildren(AbstractBranchSvgNodeRenderer deepCopy)
Create a deep copy of every child renderer and add them to the passedAbstractBranchSvgNodeRenderer
- Parameters:
deepCopy
- renderer to add copies of children to
-
postDraw
void postDraw(SvgDrawContext context)
Description copied from class:AbstractSvgNodeRenderer
Operations to be performed after drawing the element. This includes filling, stroking.- Overrides:
postDraw
in classAbstractSvgNodeRenderer
- Parameters:
context
- the svg draw context
-
createDeepCopy
public abstract 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
-
setPartOfClipPath
void setPartOfClipPath(boolean isPart)
- Overrides:
setPartOfClipPath
in classAbstractSvgNodeRenderer
-
calculateAndApplyViewBox
void calculateAndApplyViewBox(SvgDrawContext context, float[] values, Rectangle currentViewPort)
-
getViewBoxValues
float[] getViewBoxValues()
-
scaleViewBoxValues
private static float[] scaleViewBoxValues(float[] values, float scaleWidth, float scaleHeight)
-
isOverflowVisible
private static boolean isOverflowVisible(AbstractSvgNodeRenderer currentElement)
-
writeBBoxAccordingToVisibleOverflow
private static void writeBBoxAccordingToVisibleOverflow(SvgDrawContext context, PdfStream stream)
When in the svg elementoverflow
isvisible
the corresponding formXObject should have a BBox (form XObject’s bounding box; see PDF 32000-1:2008 - 8.10.2 Form Dictionaries) that should cover the entire svg space (page in pdf) in order to be able to show parts of the element which are outside the current element viewPort. To do this, we get the inverse matrix of all the current transformation matrix changes and apply it to the root viewPort. This allows you to get the root rectangle in the final coordinate system.- Parameters:
context
- current context to get canvases and view portsstream
- stream to write a BBox
-
-