Class StyleUtil


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

      Fields 
      Modifier and Type Field Description
      private static java.util.List<java.lang.String> fontSizeDependentPercentage
      List to store the properties whose value can depend on parent or element font-size
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private StyleUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static boolean checkInheritance​(java.lang.String styleProperty, java.util.Set<IStyleInheritance> inheritanceRules)
      Check all inheritance rule-sets to see if the passed property is inheritable
      static java.util.Map<java.lang.String,​java.lang.String> mergeParentStyleDeclaration​(java.util.Map<java.lang.String,​java.lang.String> styles, java.lang.String styleProperty, java.lang.String parentPropValue, java.lang.String parentFontSizeString, java.util.Set<IStyleInheritance> inheritanceRules)
      Merge parent CSS declarations.
      private static boolean valueIsOfMeasurement​(java.lang.String value, java.lang.String measurement)
      Check to see if the passed value is a measurement of the type based on the passed measurement symbol string
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • fontSizeDependentPercentage

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

      • StyleUtil

        private StyleUtil()
    • Method Detail

      • mergeParentStyleDeclaration

        public static java.util.Map<java.lang.String,​java.lang.String> mergeParentStyleDeclaration​(java.util.Map<java.lang.String,​java.lang.String> styles,
                                                                                                         java.lang.String styleProperty,
                                                                                                         java.lang.String parentPropValue,
                                                                                                         java.lang.String parentFontSizeString,
                                                                                                         java.util.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​(java.lang.String styleProperty,
                                                java.util.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​(java.lang.String value,
                                                    java.lang.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