Package com.itextpdf.svg.css.impl
Class SvgStyleResolver
java.lang.Object
com.itextpdf.svg.css.impl.SvgStyleResolver
- All Implemented Interfaces:
-
ICssResolver
Default implementation of SVG`s styles and attribute resolver .
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSvgStyleResolver(INode rootNode, SvgProcessorContext context) Creates aSvgStyleResolver.SvgStyleResolver(SvgProcessorContext context) Creates aSvgStyleResolver.SvgStyleResolver(InputStream defaultCssStream, SvgProcessorContext context) Creates aSvgStyleResolverwith a given default CSS. -
Method Summary
Modifier and TypeMethodDescriptiongetFonts()Gets the list of fonts.static booleanisElementNested(IElementNode element, String parentElementNameForSearch) Checks whether element is nested within the passed parent element.static voidresolveFontSizeStyle(Map<String, String> styles, SvgCssContext cssContext, String parentFontSizeStr) Resolves the font size stored inside the current element.resolveNativeStyles(INode node, AbstractCssContext cssContext) Resolves node styles without inheritance of parent element styles.resolveStyles(INode element, AbstractCssContext context) Resolves the styles of a node given the passed context.
-
Field Details
-
INHERITANCE_RULES
-
DEFAULT_FONT_SIZE
public static final float DEFAULT_FONT_SIZE
-
-
Constructor Details
-
SvgStyleResolver
public SvgStyleResolver(InputStream defaultCssStream, SvgProcessorContext context) throws IOException Creates aSvgStyleResolverwith a given default CSS.- Parameters:
-
defaultCssStream- the default CSS -
context- the processor context - Throws:
-
IOException- if any input/output issue occurs
-
SvgStyleResolver
Creates aSvgStyleResolver.- Parameters:
-
context- the processor context
-
SvgStyleResolver
Creates aSvgStyleResolver. This constructor will instantiate its internal style sheet and it will collect the css declarations from the provided node.- Parameters:
-
rootNode- node to collect css from -
context- the processor context
-
-
Method Details
-
resolveFontSizeStyle
public static void resolveFontSizeStyle(Map<String, String> styles, SvgCssContext cssContext, String parentFontSizeStr) Resolves the font size stored inside the current element.- Parameters:
-
styles- attributes map of the current element -
cssContext-SvgCssContextinstance in order to resolve relative font size -
parentFontSizeStr- parent font size value
-
isElementNested
Checks whether element is nested within the passed parent element. Nesting is checked at several levels (recursively).- Parameters:
-
element-IElementNodeelement to check -
parentElementNameForSearch- expected parent element name - Returns:
-
trueif element is nested within the expected parent,falseotherwise
-
resolveStyles
Description copied from interface:ICssResolverResolves the styles of a node given the passed context.- Specified by:
-
resolveStylesin interfaceICssResolver - Parameters:
-
element- the node -
context- the CSS context (RootFontSize, etc.) - Returns:
- the map containing the resolved styles
-
resolveNativeStyles
Resolves node styles without inheritance of parent element styles.- Parameters:
-
node- the node -
cssContext- the CSS context (RootFontSize, etc.) - Returns:
- the map containing the resolved styles that are defined in the body of the element
-
getFonts
Gets the list of fonts.- Returns:
-
the list of
CssFontFaceRuleinstances
-