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 float
getAverageCharWidth
(TextFragmentBox fragment, Font font) Gets the average character width.protected Rectangle
getTextLayoutBounds
(String s, Font f, int start, int end) protected TextUtilities
Returns an instance of aTextUtililities
class on which text calculations can be performed.protected final void
setupFragment
(TextFragmentBox fragment, Font font, String string) Sets up the fragment width based using the font and string passed in.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.
-
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 Stringfont
- the Font used for measuringcontext
- the flow contextwrapping
- 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 aTextUtililities
class on which text calculations can be performed. Clients may override to customize.- Returns:
- the
TextUtililities
instance - Since:
- 3.4
-