APIdia Launch Partner
Top Description Fields Constructors Methods
javafx.scene.control.skin

public abstract Class LabeledSkinBase<C extends Labeled>

extends SkinBase<C extends Labeled>
Class Inheritance
Known Direct Subclasses
javafx.scene.control.skin.ButtonSkin, javafx.scene.control.skin.CellSkinBase, javafx.scene.control.skin.CheckBoxSkin, javafx.scene.control.skin.HyperlinkSkin, javafx.scene.control.skin.LabelSkin, javafx.scene.control.skin.RadioButtonSkin, javafx.scene.control.skin.TitledPaneSkin, javafx.scene.control.skin.ToggleButtonSkin
Type Parameters
<C>
the type of the labeled control
Static Imports
javafx.scene.control.ContentDisplay.BOTTOM, .ContentDisplay.LEFT, .ContentDisplay.RIGHT, .ContentDisplay.TOP, .OverrunStyle.CLIP

Default skin implementation for controls extends Labeled.
Since
9
See Also
Labeled

Field Summary

Modifier and TypeField and Description
private boolean
pack-priv double
ellipsisWidth

The cached width of the ellipsis string.

pack-priv Node
graphic

A reference to the last-known graphic on the Labeled.

pack-priv final InvalidationListener
graphicPropertyChangedListener

A listener which is applied to the graphic whenever the graphic is set and is visible within the labeled.

pack-priv boolean
invalidText

Indicates that the text content is invalid and needs to be updated.

private Node
private Line
private KeyCombination
private MnemonicInfo
private Scene
pack-priv LabeledText
text

The Text node used to display the text.

private Rectangle
private final AtomicBoolean
pack-priv double
textWidth

The cached full width of the non-truncated text.

private double
private double

Constructor Summary

AccessConstructor and Description
public
LabeledSkinBase(final C
The labeled that this skin should be installed onto.
labeled
)

Constructor for LabeledSkinBase.

Method Summary

Modifier and TypeMethod and Description
private void
pack-priv double
public double
computeBaselineOffset(double topInset, double rightInset, double bottomInset, double leftInset)

Overrides javafx.scene.control.SkinBase.computeBaselineOffset.

Calculates the baseline offset based on the first managed child.

protected double
computeMaxHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset)

Overrides javafx.scene.control.SkinBase.computeMaxHeight.

Computes the maximum allowable height of the Skin, based on the provided width.

protected double
computeMaxWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset)

Overrides javafx.scene.control.SkinBase.computeMaxWidth.

Computes the maximum allowable width of the Skin, based on the provided height.

protected double
computeMinHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset)

Overrides javafx.scene.control.SkinBase.computeMinHeight.

Computes the minimum allowable height of the Skin, based on the provided width.

private double
computeMinLabeledPartHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset)

private double
computeMinLabeledPartWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset)

protected double
computeMinWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset)

Overrides javafx.scene.control.SkinBase.computeMinWidth.

Compute and return the minimum width of this Labeled.

protected double
computePrefHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset)

Overrides javafx.scene.control.SkinBase.computePrefHeight.

Calculates the preferred height of this SkinBase.

protected double
computePrefWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset)

Overrides javafx.scene.control.SkinBase.computePrefWidth.

Calculates the preferred width of this SkinBase.

public void
dispose()

Overrides javafx.scene.control.SkinBase.dispose.

Implements javafx.scene.control.Skin.dispose.

Called when a previously installed skin is about to be removed from its associated control.

private String
getCleanText()

Gets the clean text, which is the source text after mnemonic symbols have been removed.

private void
invalidateWidths()

Marks minWidth as being invalid and in need of recomputation.

pack-priv boolean
isIgnoreGraphic()

Gets whether for various computations we can ignore the presence of the graphic (or lack thereof).

pack-priv boolean
isIgnoreText()

Gets whether for various computations we can ignore the presence of the text.

protected void
layoutChildren(final double x, final double y, final double w, final double h)

Overrides javafx.scene.control.SkinBase.layoutChildren.

The Layout algorithm works like this: - Get the labeled w/h, graphic w/h, text w/h - Compute content w/h based on graphicVPos, graphicHPos, graphicTextGap, and graphic w/h and text w/h - (Note that the text content has been pre-truncated where necessary) - compute content x/y based on content w/h and labeled w/h and the labeled's hpos and vpos - position the graphic and text

protected void
layoutLabelInArea(double
The x position of the label part of the control, inside padding
x
,
double
The y position of the label part of the control, inside padding
y
,
double
The width of the label part of the control, not including padding
w
,
double
The height of the label part of the control, not including padding
h
)

Performs the actual layout of the label content within the area given.

protected void
layoutLabelInArea(double
The x position of the label part of the control, inside padding
x
,
double
The y position of the label part of the control, inside padding
y
,
double
The width of the label part of the control, not including padding
w
,
double
The height of the label part of the control, not including padding
h
,
Pos
The alignment of the label part of the control within the given area. If null, then the control's alignment will be used.
alignment
)

Performs the actual layout of the label content within the area given.

pack-priv double
pack-priv void
protected Object
queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters)

Overrides javafx.scene.control.SkinBase.queryAccessibleAttribute.

This method is called by the assistive technology to request the value for an attribute.

private void
pack-priv double
private void
private void
textMetricsChanged()

Called whenever some state has changed that affects the text metrics.

pack-priv double
protected void
updateChildren()

Updates the children managed by LabeledSkinBase, which can be the Labeled graphic and/or a Text node.

pack-priv void
updateDisplayedText()

Updates the content of the underlying Text node.

private void
updateDisplayedText(double w, double h)

private void
updateWrappingWidth()

Updates the wrapping width of the text node.

Inherited from javafx.scene.control.SkinBase:
consumeMouseEventsexecuteAccessibleActiongetChildrengetClassCssMetaDatagetCssMetaDatagetNodegetSkinnablelayoutInArealayoutInArealayoutInAreapositionInAreapositionInAreapseudoClassStateChangedregisterChangeListenerregisterInvalidationListenerregisterListChangeListenersnappedBottomInsetsnappedLeftInsetsnappedRightInsetsnappedTopInsetsnapPositionsnapPositionXsnapPositionYsnapSizesnapSizeXsnapSizeYsnapSpacesnapSpaceXsnapSpaceYunregisterChangeListenersunregisterInvalidationListenersunregisterListChangeListeners

Field Detail

containsMnemonicback to summary
private boolean containsMnemonic
ellipsisWidthback to summary
pack-priv double ellipsisWidth

The cached width of the ellipsis string. This will be recomputed if the font or the ellipsisString property have changed. This is package private ONLY FOR THE SAKE OF TESTING

graphicback to summary
pack-priv Node graphic

A reference to the last-known graphic on the Labeled. This reference is kept so that we can remove listeners from the old graphic later

graphicPropertyChangedListenerback to summary
pack-priv final InvalidationListener graphicPropertyChangedListener

A listener which is applied to the graphic whenever the graphic is set and is visible within the labeled. For example, if there is a graphic defined on the Labeled but the ContentDisplay is set to TEXT_ONLY, then we will not bother installing this listener on the graphic. In all other cases, if the graphic is defined, it will have this listener added to it, which ensures that if the graphic's layout bounds change, we end up performing a layout and potentially update the visible text. This is package private ONLY FOR THE SAKE OF TESTING

invalidTextback to summary
pack-priv boolean invalidText

Indicates that the text content is invalid and needs to be updated. This is package private only for the sake of testing.

labeledNodeback to summary
private Node labeledNode
mnemonic_underscoreback to summary
private Line mnemonic_underscore
mnemonicCodeback to summary
private KeyCombination mnemonicCode
mnemonicInfoback to summary
private MnemonicInfo mnemonicInfo
mnemonicSceneback to summary
private Scene mnemonicScene
textback to summary
pack-priv LabeledText text

The Text node used to display the text. This is package only for the sake of testing!

textClipback to summary
private Rectangle textClip
textTruncatedback to summary
private final AtomicBoolean textTruncated
textWidthback to summary
pack-priv double textWidth

The cached full width of the non-truncated text. We only want to recompute this if the text has itself changed, or if the font has changed. This is package private ONLY FOR THE SAKE OF TESTING

wrapHeightback to summary
private double wrapHeight
wrapWidthback to summary
private double wrapWidth

Constructor Detail

LabeledSkinBaseback to summary
public LabeledSkinBase(final C labeled)

Constructor for LabeledSkinBase. The Labeled must be specified, and cannot be null. At the conclusion of the constructor call, the skin will be marked as needsLayout, and will be fully configured based on the current state of the labeled. Any subsequent changes to the Labeled will be handled via listeners and applied appropriately.

Parameters
labeled:C

The labeled that this skin should be installed onto.

Method Detail

addMnemonicback to summary
private void addMnemonic()
bottomLabelPaddingback to summary
pack-priv double bottomLabelPadding()
computeBaselineOffsetback to summary
public double computeBaselineOffset(double topInset, double rightInset, double bottomInset, double leftInset)

Overrides javafx.scene.control.SkinBase.computeBaselineOffset.

Doc from javafx.scene.control.SkinBase.computeBaselineOffset.

Calculates the baseline offset based on the first managed child. If there is no such child, returns Node#getBaselineOffset().

Annotations
@Override
computeMaxHeightback to summary
protected double computeMaxHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset)

Overrides javafx.scene.control.SkinBase.computeMaxHeight.

Doc from javafx.scene.control.SkinBase.computeMaxHeight.

Computes the maximum allowable height of the Skin, based on the provided width.

Annotations
@Override
computeMaxWidthback to summary
protected double computeMaxWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset)

Overrides javafx.scene.control.SkinBase.computeMaxWidth.

Doc from javafx.scene.control.SkinBase.computeMaxWidth.

Computes the maximum allowable width of the Skin, based on the provided height.

Annotations
@Override
computeMinHeightback to summary
protected double computeMinHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset)

Overrides javafx.scene.control.SkinBase.computeMinHeight.

Doc from javafx.scene.control.SkinBase.computeMinHeight.

Computes the minimum allowable height of the Skin, based on the provided width.

Annotations
@Override
computeMinLabeledPartHeightback to summary
private double computeMinLabeledPartHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset)
computeMinLabeledPartWidthback to summary
private double computeMinLabeledPartWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset)
computeMinWidthback to summary
protected double computeMinWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset)

Overrides javafx.scene.control.SkinBase.computeMinWidth.

Compute and return the minimum width of this Labeled. The minimum width is the smaller of the width of "..." and the width with the actual text. In this way, if the text width itself is smaller than the ellipsis then we should use that as the min width, otherwise the ellipsis needs to be the min width.

We use the same calculation here regardless of whether we are talking about a single or multiline labeled. So a multiline labeled may find that the width of the "..." is as small as it will ever get.

Annotations
@Override
computePrefHeightback to summary
protected double computePrefHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset)

Overrides javafx.scene.control.SkinBase.computePrefHeight.

Doc from javafx.scene.control.SkinBase.computePrefHeight.

Calculates the preferred height of this SkinBase. The default implementation calculates this height as the height of the area occupied by its managed children when they are positioned at their current positions at their preferred heights.

Annotations
@Override
computePrefWidthback to summary
protected double computePrefWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset)

Overrides javafx.scene.control.SkinBase.computePrefWidth.

Doc from javafx.scene.control.SkinBase.computePrefWidth.

Calculates the preferred width of this SkinBase. The default implementation calculates this width as the width of the area occupied by its managed children when they are positioned at their current positions at their preferred widths.

Annotations
@Override
disposeback to summary
public void dispose()

Overrides javafx.scene.control.SkinBase.dispose.

Implements javafx.scene.control.Skin.dispose.

Doc from javafx.scene.control.SkinBase.dispose.

Called when a previously installed skin is about to be removed from its associated control. This allows the skin to do clean up, like removing listeners and bindings, and undo any changes to the control's properties. After this method completes, getSkinnable() and getNode() should return null.

Calling dispose() more than once has no effect.

Annotations
@Override
getCleanTextback to summary
private String getCleanText()

Gets the clean text, which is the source text after mnemonic symbols have been removed.

invalidateWidthsback to summary
private void invalidateWidths()

Marks minWidth as being invalid and in need of recomputation.

isIgnoreGraphicback to summary
pack-priv boolean isIgnoreGraphic()

Gets whether for various computations we can ignore the presence of the graphic (or lack thereof).

isIgnoreTextback to summary
pack-priv boolean isIgnoreText()

Gets whether for various computations we can ignore the presence of the text.

layoutChildrenback to summary
protected void layoutChildren(final double x, final double y, final double w, final double h)

Overrides javafx.scene.control.SkinBase.layoutChildren.

The Layout algorithm works like this: - Get the labeled w/h, graphic w/h, text w/h - Compute content w/h based on graphicVPos, graphicHPos, graphicTextGap, and graphic w/h and text w/h - (Note that the text content has been pre-truncated where necessary) - compute content x/y based on content w/h and labeled w/h and the labeled's hpos and vpos - position the graphic and text

Annotations
@Override
layoutLabelInAreaback to summary
protected void layoutLabelInArea(double x, double y, double w, double h)

Performs the actual layout of the label content within the area given. This method is called by subclasses that override layoutChildren().

Parameters
x:double

The x position of the label part of the control, inside padding

y:double

The y position of the label part of the control, inside padding

w:double

The width of the label part of the control, not including padding

h:double

The height of the label part of the control, not including padding

layoutLabelInAreaback to summary
protected void layoutLabelInArea(double x, double y, double w, double h, Pos alignment)

Performs the actual layout of the label content within the area given. This method is called by subclasses that override layoutChildren().

Parameters
x:double

The x position of the label part of the control, inside padding

y:double

The y position of the label part of the control, inside padding

w:double

The width of the label part of the control, not including padding

h:double

The height of the label part of the control, not including padding

alignment:Pos

The alignment of the label part of the control within the given area. If null, then the control's alignment will be used.

leftLabelPaddingback to summary
pack-priv double leftLabelPadding()
mnemonicTargetChangedback to summary
pack-priv void mnemonicTargetChanged()
queryAccessibleAttributeback to summary
protected Object queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters)

Overrides javafx.scene.control.SkinBase.queryAccessibleAttribute.

Doc from javafx.scene.control.SkinBase.queryAccessibleAttribute.

This method is called by the assistive technology to request the value for an attribute.

This method is commonly overridden by subclasses to implement attributes that are required for a specific role.
If a particular attribute is not handled, the superclass implementation must be called.

Annotations
@Override
removeMnemonicback to summary
private void removeMnemonic()
rightLabelPaddingback to summary
pack-priv double rightLabelPadding()
sceneChangedback to summary
private void sceneChanged()
textMetricsChangedback to summary
private void textMetricsChanged()

Called whenever some state has changed that affects the text metrics. Changes here will involve invalidating the display text so the next call to updateDisplayedText computes a new value, and call requestLayout.

topLabelPaddingback to summary
pack-priv double topLabelPadding()
updateChildrenback to summary
protected void updateChildren()

Updates the children managed by LabeledSkinBase, which can be the Labeled graphic and/or a Text node. Only those nodes which actually must be used are used. For example, with a ContentDisplay of GRAPHIC_ONLY the text node is not added, and with a ContentDisplay of TEXT_ONLY, the graphic is not added.

updateDisplayedTextback to summary
pack-priv void updateDisplayedText()

Updates the content of the underlying Text node. This method should only be called when necessary. If the invalidText flag is not set, then the method is a no-op. This care is taken because recomputing the text to display is an expensive operation. Package private ONLY FOR THE SAKE OF TESTING.

updateDisplayedTextback to summary
private void updateDisplayedText(double w, double h)
updateWrappingWidthback to summary
private void updateWrappingWidth()

Updates the wrapping width of the text node. Although changing the font does affect the metrics used for text layout, this method does not call requestLayout or invalidate the text, since it may be called from the constructor and such work would be duplicative and wasted.