Package com.itextpdf.tool.xml.css.apply
Class MaxLeadingAndSize
- java.lang.Object
-
- com.itextpdf.tool.xml.css.apply.MaxLeadingAndSize
-
public final class MaxLeadingAndSize extends java.lang.ObjectServes as a container class for the largest font size and/or largest leading found in a tag and all its siblings.
-
-
Field Summary
Fields Modifier and Type Field Description private FontSizeTranslatorfontSizeTranslatorprivate floatlargestFontprivate floatlargestLeadingprivate CssUtilsutils
-
Constructor Summary
Constructors Constructor Description MaxLeadingAndSize()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.FloatcalculateLeading(Tag t)Calculates the leading of the given tag.floatgetLargestFont()floatgetLargestFontFromChildren(java.util.List<Tag> children)Iterates over all children in a List and returns the largest font size found.floatgetLargestLeading()private floatgetLargestLeadingFromChildren(java.util.List<Tag> children)Iterates over all children in a List and returns the largest leading found.voidsetLeading(Tag tag)Set the largest leading based on calculateLeading only.voidsetVariablesBasedOnChildren(Tag t)Sets largest font size and largest leading based on the css styles "font-size" and "line-height" of a given tag and its children.
-
-
-
Field Detail
-
utils
private final CssUtils utils
-
fontSizeTranslator
private final FontSizeTranslator fontSizeTranslator
-
largestLeading
private float largestLeading
-
largestFont
private float largestFont
-
-
Method Detail
-
getLargestLeading
public float getLargestLeading()
- Returns:
- largest leading
-
getLargestFont
public float getLargestFont()
- Returns:
- largest font size
-
setVariablesBasedOnChildren
public void setVariablesBasedOnChildren(Tag t)
Sets largest font size and largest leading based on the css styles "font-size" and "line-height" of a given tag and its children.- Parameters:
t- tag of which the variables need to be set.
-
setLeading
public void setLeading(Tag tag)
Set the largest leading based on calculateLeading only. (Children not taken into account)- Parameters:
tag- the tag
-
getLargestFontFromChildren
public float getLargestFontFromChildren(java.util.List<Tag> children)
Iterates over all children in a List and returns the largest font size found.- Parameters:
children- Listcontaining a list of children. - Returns:
- float largest font size.
-
getLargestLeadingFromChildren
private float getLargestLeadingFromChildren(java.util.List<Tag> children)
Iterates over all children in a List and returns the largest leading found.- Parameters:
children- Listcontaining a list of children. - Returns:
- float largest leading.
-
calculateLeading
public java.lang.Float calculateLeading(Tag t)
Calculates the leading of the given tag.
First checks which line-height string is present in the css of the tag, if any. Following strings are allowed;- a constant (containing px, in, cm, mm, pc, em, ex or pt),
- percentage (containing %),
- multiplier (only digits),
If no line-height was given or if the line-height:normal was given, leading = font-size * 1.5f.- Parameters:
t- tag of which the leading has to be calculated.- Returns:
- float containing the leading of the tag.
-
-