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 aSvgStyleResolver
with a given default CSS. -
Method Summary
Modifier and TypeMethodDescriptiongetFonts()
Gets the list of fonts.static boolean
isElementNested
(IElementNode element, String parentElementNameForSearch) Checks whether element is nested within the passed parent element.static void
resolveFontSizeStyle
(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 aSvgStyleResolver
with 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
-SvgCssContext
instance 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
-IElementNode
element to check -
parentElementNameForSearch
- expected parent element name - Returns:
-
true
if element is nested within the expected parent,false
otherwise
-
resolveStyles
Description copied from interface:ICssResolver
Resolves the styles of a node given the passed context.- Specified by:
-
resolveStyles
in 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
CssFontFaceRule
instances
-