Package org.eclipse.draw2d.text
Class FlowUtilities
java.lang.Object
org.eclipse.draw2d.text.FlowUtilities
Utility class for FlowFigures.
- Since:
- 3.4
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected floatgetAverageCharWidth(TextFragmentBox fragment, Font font) Gets the average character width.protected RectanglegetTextLayoutBounds(String s, Font f, int start, int end) protected TextUtilitiesReturns an instance of aTextUtililitiesclass on which text calculations can be performed.protected final voidsetupFragment(TextFragmentBox fragment, Font font, String string) Sets up the fragment width based using the font and string passed in.protected final intwrapFragmentInContext(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.
-
Field Details
-
INSTANCE
a singleton default instance
-
-
Constructor Details
-
FlowUtilities
public FlowUtilities()
-
-
Method Details
-
getAverageCharWidth
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
Sets up the fragment width based using the font and string passed in.- Parameters:
fragment- the text fragment whose width will be setfont- the font to be used in the calculationstring- 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 TextFragmentBoxstring- the Stringcontext- the flow contextfont- the Font used for measuringwrapping- 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
- See Also:
-
getTextUtilities
Returns an instance of aTextUtililitiesclass on which text calculations can be performed. Clients may override to customize.- Returns:
- the
TextUtililitiesinstance - Since:
- 3.4
-