Class StyleUtil

java.lang.Object
com.itextpdf.styledxmlparser.util.StyleUtil

public final class StyleUtil extends Object
Utility class for resolving parent-inheritance of style and attribute declarations.
  • Field Details

    • fontSizeDependentPercentage

      private static final List<String> fontSizeDependentPercentage
      List to store the properties whose value can depend on parent or element font-size
  • Constructor Details

    • StyleUtil

      private StyleUtil()
  • Method Details

    • mergeParentStyleDeclaration

      public static Map<String,String> mergeParentStyleDeclaration(Map<String,String> styles, String styleProperty, String parentPropValue, String parentFontSizeString, Set<IStyleInheritance> inheritanceRules)
      Merge parent CSS declarations.
      Parameters:
      styles - the styles map
      styleProperty - the CSS property
      parentPropValue - the parent properties value
      parentFontSizeString - is a font size of parent element
      inheritanceRules - set of inheritance rules
      Returns:
      a map of updated styles after merging parent and child style declarations
    • checkInheritance

      private static boolean checkInheritance(String styleProperty, Set<IStyleInheritance> inheritanceRules)
      Check all inheritance rule-sets to see if the passed property is inheritable
      Parameters:
      styleProperty - property identifier to check
      inheritanceRules - a set of inheritance rules
      Returns:
      True if the property is inheritable by one of the rule-sets, false if it is not marked as inheritable in all rule-sets
    • valueIsOfMeasurement

      private static boolean valueIsOfMeasurement(String value, String measurement)
      Check to see if the passed value is a measurement of the type based on the passed measurement symbol string
      Parameters:
      value - string containing value to check
      measurement - measurement symbol (e.g. % for relative, px for pixels)
      Returns:
      True if the value is numerical and ends with the measurement symbol, false otherwise