java.lang.Object
net.sourceforge.jeuclid.elements.support.text.StringUtil

public final class StringUtil extends Object
Utilities for String handling.
Version:
$Revision: 480d7f8c8b4e $
  • Field Details

    • OSX

      public static final boolean OSX
      Set to true if we're running under Mac OS X.
  • Method Details

    • convertStringtoAttributedString

      public static AttributedString convertStringtoAttributedString(String inputString, MathVariant baseVariant, float fontSize, LayoutContext context)
      Converts a given String to an attributed string with the proper variants set.
      Parameters:
      inputString - the string to convert.
      baseVariant - variant to base on for regular characters
      fontSize - size of Font to use.
      context - Layout Context to use.
      Returns:
      an attributed string that has Textattribute.FONT set for all characters.
    • textContentAsAttributedCharacterIterator

      public static AttributedCharacterIterator textContentAsAttributedCharacterIterator(LayoutContext contextNow, JEuclidElement contextElement, Node node, float corrector)
      Provide the text content of the current element as AttributedCharacterIterator.
      Parameters:
      contextNow - LayoutContext of the parent element.
      contextElement - Parent Element.
      node - Current node.
      corrector - Font-size corrector.
      Returns:
      An AttributedCharacterIterator over the text contents.
    • createTextLayoutFromAttributedString

      public static TextLayout createTextLayoutFromAttributedString(Graphics2D g, AttributedString aString, LayoutContext context)
      Safely creates a Text Layout from an attributed string. Unlike the TextLayout constructor, the String here may actually be empty.
      Parameters:
      g - Graphics context.
      aString - an Attributed String
      context - Layout Context to use.
      Returns:
      a TextLayout
    • getWidthForTextLayout

      public static float getWidthForTextLayout(TextLayout layout)
      Retrieves the real width from a given text layout.
      Parameters:
      layout - the textlayout
      Returns:
      width
    • getTextLayoutInfo

      public static StringUtil.TextLayoutInfo getTextLayoutInfo(TextLayout textLayout, boolean trim)
      Retrieve the actual layout information from a textLayout. This is different than the values given when calling the functions directly.
      Parameters:
      textLayout - TextLayout to look at.
      trim - Trim to actual content
      Returns:
      a TextLayoutInfo.