Top Description Fields Constructors Methods
com.sun.javafx.scene.control.skin

public Class Utils

extends Object
Class Inheritance
Static Imports
javafx.scene.control.OverrunStyle.CENTER_ELLIPSIS, .OverrunStyle.CENTER_WORD_ELLIPSIS, .OverrunStyle.CLIP, .OverrunStyle.ELLIPSIS, .OverrunStyle.LEADING_ELLIPSIS, .OverrunStyle.LEADING_WORD_ELLIPSIS, .OverrunStyle.WORD_ELLIPSIS

BE REALLY CAREFUL WITH RESTORING OR RESETTING STATE OF helper NODE AS LEFTOVER STATE CAUSES REALLY ODD NASTY BUGS! We expect all methods to set the Font property of helper but other than that any properties set should be restored to defaults.

Field Summary

Modifier and TypeField and Description
private static final TextBoundsType
private static final double
private static final String
private static final double
private static final AtomicBoolean
private static final AtomicBoolean
private static final TextLayout
private static final Text

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static void
public static void
addMnemonics(ContextMenu popup, Scene scene, boolean initialState)

public static void
addMnemonics(ContextMenu popup, Scene scene, boolean initialState, List<Mnemonic> into)

public static double
boundedSize(double value, double min, double max)

public static String

Returns:

the actual text to be shown, with the ellipsis string inserted when needed
computeClippedText
(Font
the font
font
,
String
the original text
text
,
double
the available width
width
,
OverrunStyle
the truncation style
type
,
String
the ellipsis string
ellipsisString
,
AtomicBoolean
the reference to a flag indicating the truncation
textTruncated
)

Computes the actual text to be shown in the Labeled with the text wrapping disabled: unmodified if it fits into available area, or with the ellipsisString inserted into strategic place(s) if it does not.

public static String

Returns:

the actual text to be shown, with the ellipsis string inserted when needed
computeClippedWrappedText
(Font
the font
font
,
String
the original text
text
,
double
the available width
width
,
double
the available height
height
,
double
the line spacing
lineSpacing
,
OverrunStyle
the truncation style
truncationStyle
,
String
the ellipsis string
ellipsisString
,
AtomicBoolean
the reference to a flag indicating the truncation
textTruncated
,
TextBoundsType
the bounds type
boundsType
)

Computes the actual text to be shown in the Labeled with the text wrapping enabled: unmodified if it fits into available area, or with the ellipsisString inserted into strategic place(s) if it does not.

pack-priv static int
computeEndOfWord(Font font, String text, int index)

public static Point2D
computeMnemonicPosition(Font font, String text, int mnemonicIndex, double wrappingWidth, double lineSpacing, boolean isRTL)

pack-priv static int
computeStartOfWord(Font font, String text, int index)

public static double
computeTextHeight(Font font, String text, double wrappingWidth, TextBoundsType boundsType)

public static double
computeTextHeight(Font font, String text, double wrappingWidth, double lineSpacing, TextBoundsType boundsType)

public static double
computeTextWidth(Font font, String text, double wrappingWidth)

public static int
computeTruncationIndex(Font font, String text, double width)

public static double
computeXOffset(double width, double contentWidth, HPos hpos)

public static double
computeYOffset(double height, double contentHeight, VPos vpos)

public static <T> void
private static int
firstBreakCharIndex(String str, int start)

public static String
public static double
getAscent(Font font, TextBoundsType boundsType)

public static double
getLineHeight(Font font, TextBoundsType boundsType)

public static URL
private static Text
private static boolean
public static boolean
private static int
lastBreakCharIndex(String str, int start)

private static TextLayout
private static void
private static void
public static void
private static boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_BOUNDS_TYPEback to summary
private static final TextBoundsType DEFAULT_BOUNDS_TYPE
DEFAULT_LINE_SPACINGback to summary
private static final double DEFAULT_LINE_SPACING
DEFAULT_TEXTback to summary
private static final String DEFAULT_TEXT
DEFAULT_WRAPPING_WIDTHback to summary
private static final double DEFAULT_WRAPPING_WIDTH
helperGuardback to summary
private static final AtomicBoolean helperGuard
layoutGuardback to summary
private static final AtomicBoolean layoutGuard
layoutInstanceback to summary
private static final TextLayout layoutInstance
textInstanceback to summary
private static final Text textInstance

Constructor Detail

Utilsback to summary
public Utils()

Method Detail

addMnemonicsback to summary
public static void addMnemonics(ContextMenu popup, Scene scene)
addMnemonicsback to summary
public static void addMnemonics(ContextMenu popup, Scene scene, boolean initialState)
addMnemonicsback to summary
public static void addMnemonics(ContextMenu popup, Scene scene, boolean initialState, List<Mnemonic> into)
boundedSizeback to summary
public static double boundedSize(double value, double min, double max)
computeClippedTextback to summary
public static String computeClippedText(Font font, String text, double width, OverrunStyle type, String ellipsisString, AtomicBoolean textTruncated)

Computes the actual text to be shown in the Labeled with the text wrapping disabled: unmodified if it fits into available area, or with the ellipsisString inserted into strategic place(s) if it does not. The latter case will cause textTruncated reference set to true (the caller is expected to set the flag to false before invoking this method).

Parameters
font:Font

the font

text:String

the original text

width:double

the available width

type:OverrunStyle

the truncation style

ellipsisString:String

the ellipsis string

textTruncated:AtomicBoolean

the reference to a flag indicating the truncation

Returns:String

the actual text to be shown, with the ellipsis string inserted when needed

computeClippedWrappedTextback to summary
public static String computeClippedWrappedText(Font font, String text, double width, double height, double lineSpacing, OverrunStyle truncationStyle, String ellipsisString, AtomicBoolean textTruncated, TextBoundsType boundsType)

Computes the actual text to be shown in the Labeled with the text wrapping enabled: unmodified if it fits into available area, or with the ellipsisString inserted into strategic place(s) if it does not. The latter case will cause textTruncated reference set to true (the caller is expected to set the flag to false before invoking this method).

Parameters
font:Font

the font

text:String

the original text

width:double

the available width

height:double

the available height

lineSpacing:double

the line spacing

truncationStyle:OverrunStyle

the truncation style

ellipsisString:String

the ellipsis string

textTruncated:AtomicBoolean

the reference to a flag indicating the truncation

boundsType:TextBoundsType

the bounds type

Returns:String

the actual text to be shown, with the ellipsis string inserted when needed

computeEndOfWordback to summary
pack-priv static int computeEndOfWord(Font font, String text, int index)
computeMnemonicPositionback to summary
public static Point2D computeMnemonicPosition(Font font, String text, int mnemonicIndex, double wrappingWidth, double lineSpacing, boolean isRTL)
computeStartOfWordback to summary
pack-priv static int computeStartOfWord(Font font, String text, int index)
computeTextHeightback to summary
public static double computeTextHeight(Font font, String text, double wrappingWidth, TextBoundsType boundsType)
computeTextHeightback to summary
public static double computeTextHeight(Font font, String text, double wrappingWidth, double lineSpacing, TextBoundsType boundsType)
computeTextWidthback to summary
public static double computeTextWidth(Font font, String text, double wrappingWidth)
computeTruncationIndexback to summary
public static int computeTruncationIndex(Font font, String text, double width)
computeXOffsetback to summary
public static double computeXOffset(double width, double contentWidth, HPos hpos)
computeYOffsetback to summary
public static double computeYOffset(double height, double contentHeight, VPos vpos)
executeOnceWhenPropertyIsNonNullback to summary
public static <T> void executeOnceWhenPropertyIsNonNull(ObservableValue<T> p, Consumer<T> consumer)
firstBreakCharIndexback to summary
private static int firstBreakCharIndex(String str, int start)
formatHexStringback to summary
public static String formatHexString(Color c)
getAscentback to summary
public static double getAscent(Font font, TextBoundsType boundsType)
getLineHeightback to summary
public static double getLineHeight(Font font, TextBoundsType boundsType)
getResourceback to summary
public static URL getResource(String str)
helperback to summary
private static Text helper()
isPreferredBreakCharacterback to summary
private static boolean isPreferredBreakCharacter(char ch)
isTwoLevelFocusback to summary
public static boolean isTwoLevelFocus()
lastBreakCharIndexback to summary
private static int lastBreakCharIndex(String str, int start)
layoutback to summary
private static TextLayout layout()
releaseback to summary
private static void release(Text t)
releaseback to summary
private static void release(TextLayout t)
removeMnemonicsback to summary
public static void removeMnemonics(ContextMenu popup, Scene scene)
requiresComplexLayoutback to summary
private static boolean requiresComplexLayout(Font font, String string)