java.lang.Object
io.sf.carte.doc.style.css.om.BoxModelHelper
Box model helper class.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
Find the number of characters of the longest word in the supplied text.static float
computeNodeMinimumWidth
(String text, ComputedCSSStyle styledecl, short unitType) Compute the approximate minimum width of a node that contains the given text.static float
computeNodeMinimumWidth
(String text, ComputedCSSStyle style, CSSCanvas canvas, short unitType) Compute the minimum width of a node that contains the given text.static float
computeTextWidth
(String text, ComputedCSSStyle styledecl, short unitType) Compute the approximate width of the given text, in the given unit type.static String
Contracts all the spaces of a given String, leaving only one space between characters
-
Constructor Details
-
BoxModelHelper
public BoxModelHelper()
-
-
Method Details
-
contractSpaces
Contracts all the spaces of a given String, leaving only one space between characters- Parameters:
t
- the string to compact.- Returns:
- the compacted string.
-
computeNodeMinimumWidth
public static float computeNodeMinimumWidth(String text, ComputedCSSStyle style, CSSCanvas canvas, short unitType) Compute the minimum width of a node that contains the given text.- Parameters:
text
- the text content of he node.style
- the style that applies to the node.canvas
- the canvas that is going to draw the node.unitType
- the desired unit type. If negative, uses the style's natural unit.- Returns:
- the minimum width of the node.
-
computeNodeMinimumWidth
public static float computeNodeMinimumWidth(String text, ComputedCSSStyle styledecl, short unitType) Compute the approximate minimum width of a node that contains the given text.- Parameters:
text
- the text content of he node.styledecl
- the style that applies to the node.unitType
- the desired unit type. If negative, uses the style's natural unit.- Returns:
- the approximate minimum width of the node.
-
computeMinimumCharsWidth
Find the number of characters of the longest word in the supplied text.- Parameters:
text
- the text to evaluate.- Returns:
- the character length of the longest word in text.
-
computeTextWidth
Compute the approximate width of the given text, in the given unit type.- Parameters:
text
- the text to evaluate.styledecl
- the style that applies to the text.unitType
- the desired unit type. If negative, uses the style's natural unit.- Returns:
- the approximate width of the given text.
-