Class FlowUtilities

java.lang.Object
org.eclipse.draw2d.text.FlowUtilities

public class FlowUtilities extends Object
Utility class for FlowFigures.
Since:
3.4
  • Field Details

    • INSTANCE

      public static FlowUtilities INSTANCE
      a singleton default instance
  • Constructor Details

    • FlowUtilities

      public FlowUtilities()
  • Method Details

    • getAverageCharWidth

      protected float getAverageCharWidth(TextFragmentBox fragment, Font font)
      Gets the average character width.
      Parameters:
      fragment - the supplied TextFragmentBox to use for calculation. if the length is 0 or if the width is or below 0, the average character width is taken from standard font metrics.
      font - the font to use in case the TextFragmentBox conditions above are true.
      Returns:
      the average character width
    • setupFragment

      protected final void setupFragment(TextFragmentBox fragment, Font font, String string)
      Sets up the fragment width based using the font and string passed in.
      Parameters:
      fragment - the text fragment whose width will be set
      font - the font to be used in the calculation
      string - the string to be used in the calculation
    • wrapFragmentInContext

      protected final int wrapFragmentInContext(TextFragmentBox frag, String string, FlowContext context, org.eclipse.draw2d.text.FlowUtilities.LookAhead lookahead, Font font, int wrapping)
      Sets up a fragment and returns the number of characters consumed from the given String. An average character width can be provided as a hint for faster calculation. If a fragment's bidi level is set, a TextLayout will be used to calculate the width.
      Parameters:
      frag - the TextFragmentBox
      string - the String
      font - the Font used for measuring
      context - the flow context
      wrapping - the word wrap style
      Returns:
      the number of characters that will fit in the given space; can be 0 (eg., when the first character of the given string is a newline)
    • getTextLayoutBounds

      protected Rectangle getTextLayoutBounds(String s, Font f, int start, int end)
      See Also:
    • getTextUtilities

      protected TextUtilities getTextUtilities()
      Returns an instance of a TextUtililities class on which text calculations can be performed. Clients may override to customize.
      Returns:
      the TextUtililities instance
      Since:
      3.4