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
FieldsModifier and TypeFieldDescriptionprivate CssStyleSheet
private static final String
private static final float
private MediaDeviceDescription
The device description.private static final String[]
private final List
<CssFontFaceRule> The list of fonts.static final Set
<IStyleInheritance> private boolean
private static final org.slf4j.Logger
private final ResourceResolver
The resource resolver -
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 TypeMethodDescriptionprivate void
collectCssDeclarations
(INode rootNode, ResourceResolver resourceResolver) private void
Collects fonts from the style sheet.private void
collectFonts
(CssStatement cssStatement) Collects fonts from aCssStatement
.getFonts()
Gets the list of fonts.static boolean
isElementNested
(IElementNode element, String parentElementNameForSearch) private boolean
Checks if string starts with #.private static boolean
private void
processAttribute
(IAttribute attr, Map<String, String> styles) private void
processXLink
(IAttribute attr, Map<String, String> attributesMap) Resolves the full path of link href attribute, thanks to the resource resolver.static void
resolveFontSizeStyle
(Map<String, String> styles, SvgCssContext cssContext, String parentFontSizeStr) 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.resolveStyles
(INode element, SvgCssContext context)
-
Field Details
-
INHERITANCE_RULES
-
ELEMENTS_INHERITING_PARENT_STYLES
-
DEFAULT_FONT_SIZE
private static final float DEFAULT_FONT_SIZE -
LOGGER
private static final org.slf4j.Logger LOGGER -
css
-
DEFAULT_CSS_PATH
- See Also:
-
isFirstSvgElement
private boolean isFirstSvgElement -
deviceDescription
The device description. -
fonts
The list of fonts. -
resourceResolver
The resource resolver
-
-
Constructor Details
-
SvgStyleResolver
public SvgStyleResolver(InputStream defaultCssStream, SvgProcessorContext context) throws IOException Creates aSvgStyleResolver
with a given default CSS.- Parameters:
defaultCssStream
- the default CSScontext
- 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 fromcontext
- the processor context
-
-
Method Details
-
resolveFontSizeStyle
public static void resolveFontSizeStyle(Map<String, String> styles, SvgCssContext cssContext, String parentFontSizeStr) -
isElementNested
-
resolveStyles
Description copied from interface:ICssResolver
Resolves the styles of a node given the passed context.- Specified by:
resolveStyles
in interfaceICssResolver
- Parameters:
element
- the nodecontext
- 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 nodecssContext
- the CSS context (RootFontSize, etc.)- Returns:
- the map containing the resolved styles that are defined in the body of the element
-
onlyNativeStylesShouldBeResolved
-
resolveStyles
-
processXLink
Resolves the full path of link href attribute, thanks to the resource resolver.- Parameters:
attr
- the attribute to processattributesMap
- the element styles map
-
isStartedWithHash
Checks if string starts with #.- Parameters:
s
- the test string- Returns:
- true if the string starts with #, otherwise false
-
collectCssDeclarations
-
getFonts
Gets the list of fonts.- Returns:
- the list of
CssFontFaceRule
instances
-
collectFonts
private void collectFonts()Collects fonts from the style sheet. -
collectFonts
Collects fonts from aCssStatement
.- Parameters:
cssStatement
- the CSS statement
-
processAttribute
-
parseStylesFromStyleAttribute
-