Class CssUtils
java.lang.Object
com.itextpdf.styledxmlparser.css.util.CssUtils
Utilities class for CSS operations.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final floatprivate static final org.slf4j.Loggerprivate static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static booleanaddRange(RangeBuilder builder, String range) private static booleanaddRange(RangeBuilder builder, String left, String right) static booleancompareFloats(double d1, double d2) Helper method for comparing floating point numbersstatic booleancompareFloats(float f1, float f2) Helper method for comparing floating point numbersstatic doubleconvertPtsToPx(double pts) Convert given point value to a pixel value.static floatconvertPtsToPx(float pts) Convert given point value to a pixel value.static doubleconvertPxToPts(double px) Convert given point value to a point value.static floatconvertPxToPts(float px) Convert given point value to a point value.static StringextractAttributeValue(String attrStr, IElementNode element) Parses string and return attribute value.private static StringextractFallback(String fallbackString) Extracts shorthand properties as list of string lists from a string, where the top level list is shorthand property and the lower level list is properties included in shorthand property.private static StringextractTypeOfAttribute(String typeString) static StringUnquotes the passed string, e.g.static StringextractUrl(String url) Parsesurl("file.jpg")tofile.jpg.static intfindNextUnescapedChar(String source, char ch, int startIndex) Find the next unescaped character.private static StringgetAttributeValue(String attributeName, String typeOfAttribute, String fallback, IElementNode elementNode) private static booleanisAttributeNameValid(String attributeName) static booleanisStyleSheetLink(IElementNode headChildElement) Checks if anIElementNoderepresents a style sheet link.static StringNormalizes a CSS property.static BlendModeparseBlendMode(String cssValue) Parses the given css blend mode value.static RangeparseUnicodeRange(String unicodeRange) Parses the unicode range.static StringRemoves double spaces and trims a string.splitString(String value, char splitChar, EscapeGroup... escapeCharacters) Splits the providedStringby split character with respect of escape characters.splitStringWithComma(String value) Splits the providedStringby comma with respect of brackets.
-
Field Details
-
EPSILON
private static final float EPSILON- See Also:
-
logger
private static final org.slf4j.Logger logger -
QUANTITY_OF_PARAMS_WITH_FALLBACK_OR_TYPE
private static final int QUANTITY_OF_PARAMS_WITH_FALLBACK_OR_TYPE- See Also:
-
-
Constructor Details
-
CssUtils
private CssUtils()Creates a newCssUtilsinstance.
-
-
Method Details
-
splitStringWithComma
-
splitString
public static List<String> splitString(String value, char splitChar, EscapeGroup... escapeCharacters) Splits the providedStringby split character with respect of escape characters.- Parameters:
value- value to splitsplitChar- character to split the StringescapeCharacters- escape characters- Returns:
- the
Listof split result
-
parseBlendMode
Parses the given css blend mode value. If the argument isnullor an unknown blend mode, then the default cssBlendMode.NORMALvalue would be returned.- Parameters:
cssValue- the value to parse- Returns:
- the
BlendModeinstance representing the parsed value
-
extractShorthandProperties
Extracts shorthand properties as list of string lists from a string, where the top level list is shorthand property and the lower level list is properties included in shorthand property.- Parameters:
str- the source string with shorthand properties- Returns:
- the list of string lists
-
normalizeCssProperty
-
removeDoubleSpacesAndTrim
-
extractUrl
-
extractUnquotedString
-
extractAttributeValue
Parses string and return attribute value.- Parameters:
attrStr- the string contains attr() to extract attribute valueelement- the parentNode from which we extract information- Returns:
- the value of attribute
-
findNextUnescapedChar
Find the next unescaped character.- Parameters:
source- a sourcech- the character to look forstartIndex- where to start looking- Returns:
- the position of the next unescaped character
-
compareFloats
public static boolean compareFloats(double d1, double d2) Helper method for comparing floating point numbers- Parameters:
d1- first float to compared2- second float to compare- Returns:
- True if both floats are equal within a Epsilon defined in this class, false otherwise
-
compareFloats
public static boolean compareFloats(float f1, float f2) Helper method for comparing floating point numbers- Parameters:
f1- first float to comparef2- second float to compare- Returns:
- True if both floats are equal within a Epsilon defined in this class, false otherwise
-
parseUnicodeRange
-
convertPtsToPx
public static float convertPtsToPx(float pts) Convert given point value to a pixel value. 1 px is 0.75 pts.- Parameters:
pts- float value to be converted to pixels- Returns:
- float converted value pts/0.75f
-
convertPtsToPx
public static double convertPtsToPx(double pts) Convert given point value to a pixel value. 1 px is 0.75 pts.- Parameters:
pts- double value to be converted to pixels- Returns:
- double converted value pts/0.75
-
convertPxToPts
public static float convertPxToPts(float px) Convert given point value to a point value. 1 px is 0.75 pts.- Parameters:
px- float value to be converted to pixels- Returns:
- float converted value px*0.75
-
convertPxToPts
public static double convertPxToPts(double px) Convert given point value to a point value. 1 px is 0.75 pts.- Parameters:
px- double value to be converted to pixels- Returns:
- double converted value px*0.75
-
isStyleSheetLink
Checks if anIElementNoderepresents a style sheet link.- Parameters:
headChildElement- the head child element- Returns:
- true, if the element node represents a style sheet link
-
addRange
-
addRange
-
isAttributeNameValid
-
extractFallback
-
extractTypeOfAttribute
-
getAttributeValue
private static String getAttributeValue(String attributeName, String typeOfAttribute, String fallback, IElementNode elementNode)
-