public abstract class AbstractSvgNodeRenderer extends Object implements ISvgNodeRenderer
ISvgNodeRenderer abstract implementation.| Modifier and Type | Field and Description |
|---|---|
protected Map<String,String> |
attributesAndStyles
Map that contains attributes and styles used for drawing operations.
|
| Constructor and Description |
|---|
AbstractSvgNodeRenderer() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canConstructViewPort()
Method to see if the renderer can create a viewport
|
protected boolean |
canElementFill()
Method to see if a certain renderer can use fill.
|
protected void |
deepCopyAttributesAndStyles(ISvgNodeRenderer deepCopy)
Make a deep copy of the styles and attributes of this renderer
Helper method for deep copying logic
|
protected abstract void |
doDraw(SvgDrawContext context)
Draws this element to a canvas-like object maintained in the context.
|
void |
draw(SvgDrawContext context)
Applies transformations set to this object, if any, and delegates the drawing of this element and its children
to the
doDraw method. |
String |
getAttribute(String key)
Retrieves the property value for a given key name.
|
Map<String,String> |
getAttributeMapCopy()
Get a modifiable copy of the style and attribute map
|
String |
getAttributeOrDefault(String key,
String defaultValue)
Retrieves the property value for a given key name or default if the property value is
null or missing. |
float |
getCurrentFontSize()
Deprecated.
|
float |
getCurrentFontSize(SvgDrawContext context)
Return font-size of the current element in px.
|
com.itextpdf.kernel.geom.Rectangle |
getCurrentViewBox(SvgDrawContext context)
Gets the viewbox from the first parent element which can define it.
|
ISvgNodeRenderer |
getParent()
Gets the parent of this renderer.
|
protected boolean |
isHidden()
Check if this renderer should draw the element based on its attributes (e.g.
|
protected float |
parseAbsoluteLength(String length,
float percentBaseValue,
float defaultValue,
SvgDrawContext context)
Deprecated.
|
protected float |
parseHorizontalLength(String length,
SvgDrawContext context)
Parse x-axis length value.
|
protected float |
parseVerticalLength(String length,
SvgDrawContext context)
Parse y-axis length value.
|
void |
setAttribute(String key,
String value)
Sets a property key and value pairs for a given attribute
|
void |
setAttributesAndStyles(Map<String,String> attributesAndStyles)
Sets the map of XML node attributes and CSS style properties that this
renderer needs.
|
void |
setParent(ISvgNodeRenderer parent)
Sets the parent of this renderer.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcreateDeepCopy, getObjectBoundingBoxpublic void setParent(ISvgNodeRenderer parent)
ISvgNodeRenderersetParent in interface ISvgNodeRendererparent - the parent rendererpublic ISvgNodeRenderer getParent()
ISvgNodeRenderergetParent in interface ISvgNodeRendererpublic void setAttributesAndStyles(Map<String,String> attributesAndStyles)
ISvgNodeRenderersetAttributesAndStyles in interface ISvgNodeRendererattributesAndStyles - the mapping from key names to valuespublic String getAttribute(String key)
ISvgNodeRenderergetAttribute in interface ISvgNodeRendererkey - the name of the property to search fornullpublic String getAttributeOrDefault(String key, String defaultValue)
null or missing.key - the name of the property to search fordefaultValue - the default value to be returned if the property is
null or missingdefaultValuepublic void setAttribute(String key, String value)
ISvgNodeRenderersetAttribute in interface ISvgNodeRendererkey - the name of the attributevalue - the value of the attributepublic Map<String,String> getAttributeMapCopy()
ISvgNodeRenderergetAttributeMapCopy in interface ISvgNodeRendererpublic final void draw(SvgDrawContext context)
doDraw method.draw in interface ISvgNodeRenderercontext - the object that knows the place to draw this element and maintains its stateprotected boolean canElementFill()
public boolean canConstructViewPort()
@Deprecated public float getCurrentFontSize()
This method is deprecated in favour of getCurrentFontSize(SvgDrawContext) because
current one can't support relative values (em, rem) and those can't be resolved without SvgDrawContext.
public float getCurrentFontSize(SvgDrawContext context)
context - draw context from which root font size can be extractedpublic com.itextpdf.kernel.geom.Rectangle getCurrentViewBox(SvgDrawContext context)
See SVG specification to find which elements can define a viewbox.
context - draw context from which fallback viewbox can be extractednull if the element doesn't have parent which can define the viewboxprotected void deepCopyAttributesAndStyles(ISvgNodeRenderer deepCopy)
deepCopy - renderer to insert the deep copied attributes intoprotected abstract void doDraw(SvgDrawContext context)
context - the object that knows the place to draw this element and maintains its stateprotected boolean isHidden()
protected float parseHorizontalLength(String length, SvgDrawContext context)
SvgDrawContext, a default current viewport
will be created. This can happen if svg is created manually
(not through SvgImage or SvgImageXObject)
and don't have PdfRootSvgNodeRenderer as its parent.length - String length for parsingcontext - current SvgDrawContext instanceprotected float parseVerticalLength(String length, SvgDrawContext context)
SvgDrawContext, a default current viewport
will be created. This can happen if svg is created manually
(not through SvgImage or SvgImageXObject)
and don't have PdfRootSvgNodeRenderer as its parent.length - String length for parsingcontext - current SvgDrawContext instance@Deprecated protected float parseAbsoluteLength(String length, float percentBaseValue, float defaultValue, SvgDrawContext context)
This method is deprecated and
SvgCssUtils.parseAbsoluteLength(AbstractSvgNodeRenderer, String, float, float, SvgDrawContext) should
be used instead.
length - String for parsingpercentBaseValue - the value on which percent length is based ondefaultValue - default value if length is not recognizedcontext - current SvgDrawContextCopyright © 1998–2025 Apryse Group NV. All rights reserved.