Class BoxModelHelper

java.lang.Object
io.sf.carte.doc.style.css.om.BoxModelHelper

public class BoxModelHelper extends Object
Box model helper class.
  • Constructor Details

    • BoxModelHelper

      public BoxModelHelper()
  • Method Details

    • contractSpaces

      public static String contractSpaces(String t)
      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

      public static int computeMinimumCharsWidth(String text)
      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

      public static float computeTextWidth(String text, ComputedCSSStyle styledecl, short unitType)
      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.