public class CssUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static boolean |
compareFloats(double d1,
double d2)
Helper method for comparing floating point numbers
|
static boolean |
compareFloats(float f1,
float f2)
Helper method for comparing floating point numbers
|
static double |
convertPtsToPx(double pts)
Convert given point value to a pixel value.
|
static float |
convertPtsToPx(float pts)
Convert given point value to a pixel value.
|
static double |
convertPxToPts(double px)
Convert given point value to a point value.
|
static float |
convertPxToPts(float px)
Convert given point value to a point value.
|
static int |
determinePositionBetweenValueAndUnit(String string)
Method used in preparation of splitting a string containing a numeric value with a metric unit (e.g.
|
static List<List<String>> |
extractShorthandProperties(String str)
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.
|
static String |
extractUrl(String url)
Parses
url("file.jpg") to file.jpg. |
static int |
findNextUnescapedChar(String source,
char ch,
int startIndex)
Find the next unescaped character.
|
static boolean |
isAngleValue(String value)
Checks whether a string contains an allowed metric unit in HTML/CSS; rad, deg and grad.
|
static boolean |
isBase64Data(String data)
Checks if a data is base 64 encoded.
|
static boolean |
isColorProperty(String value)
Checks if a value is a color property.
|
static boolean |
isEmValue(String value)
Checks whether a string contains an allowed value relative to parent value.
|
static boolean |
isExValue(String value)
Checks whether a string contains an allowed value relative to element font height.
|
static boolean |
isFontRelativeValue(String value)
Checks whether a string contains an allowed value relative to font.
|
static boolean |
isInitialOrInheritOrUnset(String value)
Checks if value is initial, inherit or unset.
|
static boolean |
isMetricValue(String value)
Checks whether a string contains an allowed metric unit in HTML/CSS; px, in, cm, mm, pc, Q or pt.
|
static boolean |
isNumericValue(String value)
Checks whether a string matches a numeric value (e.g.
|
static boolean |
isPercentageValue(String value)
Checks whether a string contains a percentage value
|
static boolean |
isRelativeValue(String value)
Checks whether a string contains an allowed value relative to previously set value.
|
static boolean |
isRemValue(String value)
Checks whether a string contains an allowed value relative to previously set root value.
|
static boolean |
isStyleSheetLink(IElementNode headChildElement)
Checks if an
IElementNode represents a style sheet link. |
static boolean |
isValidNumericValue(String value)
Checks if a string is in a valid format.
|
static String |
normalizeCssProperty(String str)
Normalizes a CSS property.
|
static float |
parseAbsoluteFontSize(String fontSizeValue)
Parses the absolute font size.
|
static float |
parseAbsoluteFontSize(String fontSizeValue,
String defaultMetric)
Parses the absolute font size.
|
static float |
parseAbsoluteLength(String length)
Parses the absolute length.
|
static float |
parseAbsoluteLength(String length,
String defaultMetric)
Parses a length with an allowed metric unit (px, pt, in, cm, mm, pc, q) or numeric value (e.g.
|
static float |
parseAngle(String angle)
Parses a angle with an allowed metric unit (deg, grad, rad) or numeric value (e.g.
|
static float |
parseAngle(String angle,
String defaultMetric)
Parses an angle with an allowed metric unit (deg, grad, rad) or numeric value (e.g.
|
static int[] |
parseAspectRatio(String str)
Parses an aspect ratio into an array with two integers.
|
static BlendMode |
parseBlendMode(String cssValue)
Parses the given css blend mode value.
|
static Double |
parseDouble(String str)
Parses a double without throwing an exception if something goes wrong.
|
static Float |
parseFloat(String str)
Parses a float without throwing an exception if something goes wrong.
|
static Integer |
parseInteger(String str)
Parses an integer without throwing an exception if something goes wrong.
|
static UnitValue |
parseLengthValueToPt(String value,
float emValue,
float remValue)
Convenience method for parsing a value to pt.
|
static float |
parseRelativeFontSize(String relativeFontSizeValue,
float baseValue)
Parses the relative font size.
|
static float |
parseRelativeValue(String relativeValue,
float baseValue)
Parses an relative value based on the base value that was given, in the metric unit of the base value.
(e.g. |
static float |
parseResolution(String resolutionStr)
Parses the resolution.
|
static float[] |
parseRgbaColor(String colorValue)
Parses the RGBA color.
|
static UnitValue[] |
parseSpecificCornerBorderRadius(String specificBorderRadius,
float emValue,
float remValue)
Parses the border radius of specific corner.
|
static Range |
parseUnicodeRange(String unicodeRange)
Parses the unicode range.
|
static String |
removeDoubleSpacesAndTrim(String str)
Removes double spaces and trims a string.
|
static List<String> |
splitStringWithComma(String value)
Splits the provided
String by comma with respect of brackets. |
public static List<String> splitStringWithComma(String value)
String by comma with respect of brackets.value - to splitList of split resultpublic static BlendMode parseBlendMode(String cssValue)
null or an unknown blend
mode, then the default css BlendMode.NORMAL value would be returned.cssValue - the value to parseBlendMode instance representing the parsed valuepublic static List<List<String>> extractShorthandProperties(String str)
str - the source string with shorthand propertiespublic static String normalizeCssProperty(String str)
str - the propertypublic static String removeDoubleSpacesAndTrim(String str)
str - the stringpublic static Integer parseInteger(String str)
str - a string that might be an integer valuepublic static Float parseFloat(String str)
str - a string that might be a float valuepublic static Double parseDouble(String str)
str - a string that might be a double valuepublic static float parseAngle(String angle, String defaultMetric)
angle - String containing the angle to parsedefaultMetric - default metric to use in case the input string does not specify a metricpublic static float parseAngle(String angle)
angle - String containing the angle to parsepublic static int[] parseAspectRatio(String str)
str - a string that might contain two integer valuespublic static float parseAbsoluteLength(String length, String defaultMetric)
length - the string containing the length.defaultMetric - the string containing the metric if it is possible that the length string does not contain
one. If null the length is considered to be in px as is default in HTML/CSS.public static float parseAbsoluteLength(String length)
length - the length as a stringpublic static float parseRelativeValue(String relativeValue, float baseValue)
relativeValue - in %, em or ex.baseValue - the value the returned float is based on.public static UnitValue parseLengthValueToPt(String value, float emValue, float remValue)
value - the valueemValue - the em valueremValue - the root em valuepublic static boolean isValidNumericValue(String value)
value - the string that needs to be checked.public static float parseAbsoluteFontSize(String fontSizeValue, String defaultMetric)
A numeric value (without px, pt, etc in the given length string) is considered to be in the default metric that was given.
fontSizeValue - the font size value as a StringdefaultMetric - the string containing the metric if it is possible that the length string does not contain
one. If null the length is considered to be in px as is default in HTML/CSS.floatpublic static float parseAbsoluteFontSize(String fontSizeValue)
A numeric value (without px, pt, etc in the given length string) is considered to be in the px.
fontSizeValue - the font size value as a Stringfloatpublic static float parseRelativeFontSize(String relativeFontSizeValue, float baseValue)
relativeFontSizeValue - the relative font size value as a StringbaseValue - the base valuefloatpublic static UnitValue[] parseSpecificCornerBorderRadius(String specificBorderRadius, float emValue, float remValue)
specificBorderRadius - string that defines the border radius of specific corner.emValue - the em valueremValue - the root em valueUnitValues that define horizontal and vertical border radius valuespublic static float parseResolution(String resolutionStr)
resolutionStr - the resolution as a stringpublic static int determinePositionBetweenValueAndUnit(String string)
string - containing a numeric value with a metric unitpublic static boolean isMetricValue(String value)
value - the string that needs to be checked.public static boolean isAngleValue(String value)
value - the string that needs to be checked.public static boolean isRelativeValue(String value)
value - the string that needs to be checked.public static boolean isFontRelativeValue(String value)
value - the string that needs to be checked.public static boolean isPercentageValue(String value)
value - the string that needs to be checkedpublic static boolean isRemValue(String value)
value - the string that needs to be checked.public static boolean isEmValue(String value)
value - the string that needs to be checked.public static boolean isExValue(String value)
value - the string that needs to be checked.public static boolean isNumericValue(String value)
value - the string that needs to be checked.public static String extractUrl(String url)
url("file.jpg") to file.jpg.url - the url attribute to parsepublic static boolean isBase64Data(String data)
data - the datapublic static int findNextUnescapedChar(String source, char ch, int startIndex)
source - a sourcech - the character to look forstartIndex - where to start lookingpublic static boolean isColorProperty(String value)
value - the valuepublic static boolean compareFloats(double d1,
double d2)
d1 - first float to compared2 - second float to comparepublic static boolean compareFloats(float f1,
float f2)
f1 - first float to comparef2 - second float to comparepublic static float[] parseRgbaColor(String colorValue)
colorValue - the color valuepublic static Range parseUnicodeRange(String unicodeRange)
unicodeRange - the string which stores the unicode rangeRange objectpublic static float convertPtsToPx(float pts)
pts - float value to be converted to pixelspublic static double convertPtsToPx(double pts)
pts - double value to be converted to pixelspublic static float convertPxToPts(float px)
px - float value to be converted to pixelspublic static double convertPxToPts(double px)
px - double value to be converted to pixelspublic static boolean isStyleSheetLink(IElementNode headChildElement)
IElementNode represents a style sheet link.headChildElement - the head child elementpublic static boolean isInitialOrInheritOrUnset(String value)
value - value to check.Copyright © 1998–2020 iText Group NV. All rights reserved.