Class StringUtil
- java.lang.Object
-
- net.sourceforge.jeuclid.elements.support.text.StringUtil
-
public final class StringUtil extends java.lang.ObjectUtilities for String handling.- Version:
- $Revision: 480d7f8c8b4e $
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classStringUtil.TextLayoutInfoContains layout information retrieved from a TextLayout.
-
Field Summary
Fields Modifier and Type Field Description static booleanOSXSet to true if we're running under Mac OS X.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.text.AttributedStringconvertStringtoAttributedString(java.lang.String inputString, MathVariant baseVariant, float fontSize, LayoutContext context)Converts a given String to an attributed string with the proper variants set.static java.awt.font.TextLayoutcreateTextLayoutFromAttributedString(java.awt.Graphics2D g, java.text.AttributedString aString, LayoutContext context)Safely creates a Text Layout from an attributed string.static StringUtil.TextLayoutInfogetTextLayoutInfo(java.awt.font.TextLayout textLayout, boolean trim)Retrieve the actual layout information from a textLayout.static floatgetWidthForTextLayout(java.awt.font.TextLayout layout)Retrieves the real width from a given text layout.static java.text.AttributedCharacterIteratortextContentAsAttributedCharacterIterator(LayoutContext contextNow, JEuclidElement contextElement, org.w3c.dom.Node node, float corrector)Provide the text content of the current element as AttributedCharacterIterator.
-
-
-
Method Detail
-
convertStringtoAttributedString
public static java.text.AttributedString convertStringtoAttributedString(java.lang.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 charactersfontSize- 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 java.text.AttributedCharacterIterator textContentAsAttributedCharacterIterator(LayoutContext contextNow, JEuclidElement contextElement, org.w3c.dom.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
AttributedCharacterIteratorover the text contents.
-
createTextLayoutFromAttributedString
public static java.awt.font.TextLayout createTextLayoutFromAttributedString(java.awt.Graphics2D g, java.text.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 Stringcontext- Layout Context to use.- Returns:
- a TextLayout
-
getWidthForTextLayout
public static float getWidthForTextLayout(java.awt.font.TextLayout layout)
Retrieves the real width from a given text layout.- Parameters:
layout- the textlayout- Returns:
- width
-
getTextLayoutInfo
public static StringUtil.TextLayoutInfo getTextLayoutInfo(java.awt.font.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.
-
-