Class Skeleton

java.lang.Object
javafx.scene.Node
javafx.scene.Parent
javafx.scene.layout.Region
javafx.scene.control.Control
com.dlsc.gemsfx.Skeleton
All Implemented Interfaces:
javafx.css.Styleable, javafx.event.EventTarget, javafx.scene.control.Skinnable

public class Skeleton extends javafx.scene.control.Control
Single-unit skeleton placeholder with a horizontal shimmer animation, intended for content-is-loading UI. The skeleton draws one of three variants selected via variantProperty() and overlays a shimmer band that scrolls left-to-right to suggest activity.

The skeleton is stretchable: its skin reports maxWidth and maxHeight as Double.MAX_VALUE, so the placeholder can grow to mirror real content as its container resizes.

Variants:

CSS Styleable Properties:

CSS Properties
PropertyTypeDescription
-fx-variantVariantGeometric form of the placeholder
-fx-corner-radiusSizeCorner radius for rounded rectangles
-fx-base-colorPaintBase block fill
-fx-shimmer-fillPaintMoving shimmer band fill
-fx-cycle-durationDurationDuration of one shimmer sweep
-fx-shimmer-widthSizeWidth of the shimmer band
-fx-line-countSizeNumber of text lines
-fx-line-heightSizeHeight of each text line
-fx-line-spacingSizeSpacing between text lines
-fx-last-line-fill-percentSizeWidth percentage of the final text line
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Geometric form of a Skeleton.
  • Property Summary

    Properties
    Type
    Property
    Description
    final javafx.beans.property.ObjectProperty<javafx.scene.paint.Paint>
    Paint used for the base block under the shimmer band.
    final javafx.beans.property.DoubleProperty
    final javafx.beans.property.ObjectProperty<javafx.util.Duration>
    Duration of one full left-to-right shimmer sweep.
    final javafx.beans.property.DoubleProperty
    Width of the last line for Skeleton.Variant.TEXT, expressed as a percent of the placeholder width.
    final javafx.beans.property.IntegerProperty
    Number of stacked lines drawn for Skeleton.Variant.TEXT.
    final javafx.beans.property.DoubleProperty
    Per-line height for Skeleton.Variant.TEXT, in pixels.
    final javafx.beans.property.DoubleProperty
    Vertical gap between adjacent lines for Skeleton.Variant.TEXT, in pixels.
    final javafx.beans.property.ObjectProperty<javafx.scene.paint.Paint>
    Fill paint used for the moving shimmer band.
    final javafx.beans.property.DoubleProperty
    Width of the shimmer band in pixels.
    final javafx.beans.property.ObjectProperty<Skeleton.Variant>
    Geometric form of the placeholder.

    Properties inherited from class javafx.scene.control.Control

    contextMenu, skin, tooltip

    Properties inherited from class javafx.scene.layout.Region

    background, border, cacheShape, centerShape, height, insets, maxHeight, maxWidth, minHeight, minWidth, opaqueInsets, padding, prefHeight, prefWidth, scaleShape, shape, snapToPixel, width

    Properties inherited from class javafx.scene.Parent

    needsLayout

    Properties inherited from class javafx.scene.Node

    accessibleHelp, accessibleRoleDescription, accessibleRole, accessibleText, blendMode, boundsInLocal, boundsInParent, cacheHint, cache, clip, cursor, depthTest, disabled, disable, effectiveNodeOrientation, effect, eventDispatcher, focused, focusTraversable, hover, id, inputMethodRequests, layoutBounds, layoutX, layoutY, localToParentTransform, localToSceneTransform, managed, mouseTransparent, nodeOrientation, onContextMenuRequested, onDragDetected, onDragDone, onDragDropped, onDragEntered, onDragExited, onDragOver, onInputMethodTextChanged, onKeyPressed, onKeyReleased, onKeyTyped, onMouseClicked, onMouseDragEntered, onMouseDragExited, onMouseDragged, onMouseDragOver, onMouseDragReleased, onMouseEntered, onMouseExited, onMouseMoved, onMousePressed, onMouseReleased, onRotate, onRotationFinished, onRotationStarted, onScrollFinished, onScroll, onScrollStarted, onSwipeDown, onSwipeLeft, onSwipeRight, onSwipeUp, onTouchMoved, onTouchPressed, onTouchReleased, onTouchStationary, onZoomFinished, onZoom, onZoomStarted, opacity, parent, pickOnBounds, pressed, rotate, rotationAxis, scaleX, scaleY, scaleZ, scene, style, translateX, translateY, translateZ, viewOrder, visible
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Skeleton.Variant
     

    Fields inherited from class javafx.scene.layout.Region

    USE_COMPUTED_SIZE, USE_PREF_SIZE

    Fields inherited from class javafx.scene.Node

    BASELINE_OFFSET_SAME_AS_HEIGHT
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a skeleton with the default variant.
    Creates a skeleton with the given variant.
  • Method Summary

    Modifier and Type
    Method
    Description
    final javafx.beans.property.ObjectProperty<javafx.scene.paint.Paint>
    Paint used for the base block under the shimmer band.
    final javafx.beans.property.DoubleProperty
    protected javafx.scene.control.Skin<?>
     
    static javafx.scene.paint.LinearGradient
    createShimmerGradient(javafx.scene.paint.Color highlightColor)
    Creates a standard shimmer gradient from a single highlight color.
    final javafx.beans.property.ObjectProperty<javafx.util.Duration>
    Duration of one full left-to-right shimmer sweep.
    final javafx.scene.paint.Paint
    Gets the base fill paint.
    static List<javafx.css.CssMetaData<? extends javafx.css.Styleable, ?>>
    Returns the CSS metadata associated with this class.
    List<javafx.css.CssMetaData<? extends javafx.css.Styleable, ?>>
    Returns the CSS metadata associated with this control instance.
    final double
    Gets the corner radius.
    final javafx.util.Duration
    Gets the shimmer cycle duration.
    final double
    Gets the fill percent used for the final text line.
    final int
    Gets the number of text lines.
    final double
    Gets the text line height.
    final double
    Gets the spacing between text lines.
    final javafx.scene.paint.Paint
    Gets the shimmer band fill paint.
    final double
    Gets the shimmer band width.
    Gets the geometric variant.
    final javafx.beans.property.DoubleProperty
    Width of the last line for Skeleton.Variant.TEXT, expressed as a percent of the placeholder width.
    final javafx.beans.property.IntegerProperty
    Number of stacked lines drawn for Skeleton.Variant.TEXT.
    final javafx.beans.property.DoubleProperty
    Per-line height for Skeleton.Variant.TEXT, in pixels.
    final javafx.beans.property.DoubleProperty
    Vertical gap between adjacent lines for Skeleton.Variant.TEXT, in pixels.
    final void
    setBaseColor(javafx.scene.paint.Paint value)
    Sets the base fill paint.
    final void
    setCornerRadius(double value)
    Sets the corner radius.
    final void
    setCycleDuration(javafx.util.Duration value)
    Sets the shimmer cycle duration.
    final void
    setLastLineFillPercent(double value)
    Sets the fill percent used for the final text line.
    final void
    setLineCount(int value)
    Sets the number of text lines.
    final void
    setLineHeight(double value)
    Sets the text line height.
    final void
    setLineSpacing(double value)
    Sets the spacing between text lines.
    final void
    setShimmerFill(javafx.scene.paint.Paint value)
    Sets the shimmer band fill paint.
    final void
    setShimmerWidth(double value)
    Sets the shimmer band width.
    final void
    Sets the geometric variant.
    final javafx.beans.property.ObjectProperty<javafx.scene.paint.Paint>
    Fill paint used for the moving shimmer band.
    final javafx.beans.property.DoubleProperty
    Width of the shimmer band in pixels.
    final javafx.beans.property.ObjectProperty<Skeleton.Variant>
    Geometric form of the placeholder.

    Methods inherited from class javafx.scene.control.Control

    computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, contextMenuProperty, executeAccessibleAction, getBaselineOffset, getContextMenu, getCssMetaData, getInitialFocusTraversable, getSkin, getTooltip, isResizable, layoutChildren, queryAccessibleAttribute, setContextMenu, setSkin, setTooltip, skinProperty, tooltipProperty

    Methods inherited from class javafx.scene.layout.Region

    backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, getBackground, getBorder, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getUserAgentStylesheet, getWidth, heightProperty, insetsProperty, isCacheShape, isCenterShape, isScaleShape, isSnapToPixel, layoutInArea, layoutInArea, layoutInArea, layoutInArea, maxHeight, maxHeightProperty, maxWidth, maxWidthProperty, minHeight, minHeightProperty, minWidth, minWidthProperty, opaqueInsetsProperty, paddingProperty, positionInArea, positionInArea, prefHeight, prefHeightProperty, prefWidth, prefWidthProperty, resize, scaleShapeProperty, setBackground, setBorder, setCacheShape, setCenterShape, setHeight, setMaxHeight, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinWidth, setOpaqueInsets, setPadding, setPrefHeight, setPrefSize, setPrefWidth, setScaleShape, setShape, setSnapToPixel, setWidth, shapeProperty, snappedBottomInset, snappedLeftInset, snappedRightInset, snappedTopInset, snapPosition, snapPositionX, snapPositionY, snapSize, snapSizeX, snapSizeY, snapSpace, snapSpaceX, snapSpaceY, snapToPixelProperty, widthProperty

    Methods inherited from class javafx.scene.Parent

    getChildren, getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, lookup, needsLayoutProperty, requestLayout, requestParentLayout, setNeedsLayout, updateBounds

    Methods inherited from class javafx.scene.Node

    accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, fireEvent, focusedProperty, focusTraversableProperty, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getContentBias, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, getInitialCursor, getInputMethodRequests, getLayoutBounds, getLayoutX, getLayoutY, getLocalToParentTransform, getLocalToSceneTransform, getNodeOrientation, getOnContextMenuRequested, getOnDragDetected, getOnDragDone, getOnDragDropped, getOnDragEntered, getOnDragExited, getOnDragOver, getOnInputMethodTextChanged, getOnKeyPressed, getOnKeyReleased, getOnKeyTyped, getOnMouseClicked, getOnMouseDragEntered, getOnMouseDragExited, getOnMouseDragged, getOnMouseDragOver, getOnMouseDragReleased, getOnMouseEntered, getOnMouseExited, getOnMouseMoved, getOnMousePressed, getOnMouseReleased, getOnRotate, getOnRotationFinished, getOnRotationStarted, getOnScroll, getOnScrollFinished, getOnScrollStarted, getOnSwipeDown, getOnSwipeLeft, getOnSwipeRight, getOnSwipeUp, getOnTouchMoved, getOnTouchPressed, getOnTouchReleased, getOnTouchStationary, getOnZoom, getOnZoomFinished, getOnZoomStarted, getOpacity, getParent, getProperties, getPseudoClassStates, getRotate, getRotationAxis, getScaleX, getScaleY, getScaleZ, getScene, getStyle, getStyleableParent, getStyleClass, getTransforms, getTranslateX, getTranslateY, getTranslateZ, getTypeSelector, getUserData, getViewOrder, hasProperties, hoverProperty, idProperty, inputMethodRequestsProperty, intersects, intersects, isCache, isDisable, isDisabled, isFocused, isFocusTraversable, isHover, isManaged, isMouseTransparent, isPickOnBounds, isPressed, isVisible, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParent, localToParent, localToParent, localToParent, localToParent, localToParentTransformProperty, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToSceneTransformProperty, localToScreen, localToScreen, localToScreen, localToScreen, localToScreen, lookupAll, managedProperty, mouseTransparentProperty, nodeOrientationProperty, notifyAccessibleAttributeChanged, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragEnteredProperty, onMouseDragExitedProperty, onMouseDraggedProperty, onMouseDragOverProperty, onMouseDragReleasedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onRotateProperty, onRotationFinishedProperty, onRotationStartedProperty, onScrollFinishedProperty, onScrollProperty, onScrollStartedProperty, onSwipeDownProperty, onSwipeLeftProperty, onSwipeRightProperty, onSwipeUpProperty, onTouchMovedProperty, onTouchPressedProperty, onTouchReleasedProperty, onTouchStationaryProperty, onZoomFinishedProperty, onZoomProperty, onZoomStartedProperty, opacityProperty, parentProperty, parentToLocal, parentToLocal, parentToLocal, parentToLocal, parentToLocal, pickOnBoundsProperty, pressedProperty, pseudoClassStateChanged, relocate, removeEventFilter, removeEventHandler, requestFocus, resizeRelocate, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, screenToLocal, screenToLocal, screenToLocal, setAccessibleHelp, setAccessibleRole, setAccessibleRoleDescription, setAccessibleText, setBlendMode, setCache, setCacheHint, setClip, setCursor, setDepthTest, setDisable, setDisabled, setEffect, setEventDispatcher, setEventHandler, setFocused, setFocusTraversable, setHover, setId, setInputMethodRequests, setLayoutX, setLayoutY, setManaged, setMouseTransparent, setNodeOrientation, setOnContextMenuRequested, setOnDragDetected, setOnDragDone, setOnDragDropped, setOnDragEntered, setOnDragExited, setOnDragOver, setOnInputMethodTextChanged, setOnKeyPressed, setOnKeyReleased, setOnKeyTyped, setOnMouseClicked, setOnMouseDragEntered, setOnMouseDragExited, setOnMouseDragged, setOnMouseDragOver, setOnMouseDragReleased, setOnMouseEntered, setOnMouseExited, setOnMouseMoved, setOnMousePressed, setOnMouseReleased, setOnRotate, setOnRotationFinished, setOnRotationStarted, setOnScroll, setOnScrollFinished, setOnScrollStarted, setOnSwipeDown, setOnSwipeLeft, setOnSwipeRight, setOnSwipeUp, setOnTouchMoved, setOnTouchPressed, setOnTouchReleased, setOnTouchStationary, setOnZoom, setOnZoomFinished, setOnZoomStarted, setOpacity, setPickOnBounds, setPressed, setRotate, setRotationAxis, setScaleX, setScaleY, setScaleZ, setStyle, setTranslateX, setTranslateY, setTranslateZ, setUserData, setViewOrder, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, usesMirroring, viewOrderProperty, visibleProperty

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface javafx.css.Styleable

    getStyleableNode
  • Property Details

  • Field Details

  • Constructor Details

    • Skeleton

      public Skeleton()
      Creates a skeleton with the default variant.
    • Skeleton

      public Skeleton(Skeleton.Variant variant)
      Creates a skeleton with the given variant.
      Parameters:
      variant - the initial variant; null keeps the default value and leaves the property settable from CSS
  • Method Details

    • createShimmerGradient

      public static javafx.scene.paint.LinearGradient createShimmerGradient(javafx.scene.paint.Color highlightColor)
      Creates a standard shimmer gradient from a single highlight color.
      Parameters:
      highlightColor - the center highlight color
      Returns:
      a linear gradient suitable for shimmerFillProperty()
      Throws:
      NullPointerException - if highlightColor is null
    • createDefaultSkin

      protected javafx.scene.control.Skin<?> createDefaultSkin()
      Overrides:
      createDefaultSkin in class javafx.scene.control.Control
    • variantProperty

      public final javafx.beans.property.ObjectProperty<Skeleton.Variant> variantProperty()
      Geometric form of the placeholder. A null value resolves to the default DEFAULT_VARIANT at the use site.
      Returns:
      the variant property
      See Also:
    • getVariant

      public final Skeleton.Variant getVariant()
      Gets the geometric variant.
      Returns:
      the current variant
    • setVariant

      public final void setVariant(Skeleton.Variant value)
      Sets the geometric variant.
      Parameters:
      value - the variant, or null to fall back to the default
    • cornerRadiusProperty

      public final javafx.beans.property.DoubleProperty cornerRadiusProperty()
      Corner radius applied when variantProperty() is Skeleton.Variant.ROUNDED_RECTANGLE. Negative values and NaN are treated as 0 at render time.
      Returns:
      the corner-radius property
      See Also:
    • getCornerRadius

      public final double getCornerRadius()
      Gets the corner radius.
      Returns:
      the corner radius in pixels
    • setCornerRadius

      public final void setCornerRadius(double value)
      Sets the corner radius.
      Parameters:
      value - the corner radius in pixels
    • baseColorProperty

      public final javafx.beans.property.ObjectProperty<javafx.scene.paint.Paint> baseColorProperty()
      Paint used for the base block under the shimmer band. Setting null renders no base fill.
      Returns:
      the base-color property
      See Also:
    • getBaseColor

      public final javafx.scene.paint.Paint getBaseColor()
      Gets the base fill paint.
      Returns:
      the base fill paint, or null for no base fill
    • setBaseColor

      public final void setBaseColor(javafx.scene.paint.Paint value)
      Sets the base fill paint.
      Parameters:
      value - the base fill paint, or null for no base fill
    • shimmerFillProperty

      public final javafx.beans.property.ObjectProperty<javafx.scene.paint.Paint> shimmerFillProperty()
      Fill paint used for the moving shimmer band. Setting null renders no shimmer fill.
      Returns:
      the shimmer-fill property
      See Also:
    • getShimmerFill

      public final javafx.scene.paint.Paint getShimmerFill()
      Gets the shimmer band fill paint.
      Returns:
      the shimmer band fill paint, or null for no shimmer fill
    • setShimmerFill

      public final void setShimmerFill(javafx.scene.paint.Paint value)
      Sets the shimmer band fill paint.
      Parameters:
      value - the shimmer band fill paint, or null for no shimmer fill
    • cycleDurationProperty

      public final javafx.beans.property.ObjectProperty<javafx.util.Duration> cycleDurationProperty()
      Duration of one full left-to-right shimmer sweep. A value of null, an unknown or indefinite duration, or any duration less than or equal to Duration.ZERO suppresses the animation.
      Returns:
      the cycle-duration property
      See Also:
    • getCycleDuration

      public final javafx.util.Duration getCycleDuration()
      Gets the shimmer cycle duration.
      Returns:
      the cycle duration, or null to disable animation
    • setCycleDuration

      public final void setCycleDuration(javafx.util.Duration value)
      Sets the shimmer cycle duration.
      Parameters:
      value - the cycle duration, or null to disable animation
    • shimmerWidthProperty

      public final javafx.beans.property.DoubleProperty shimmerWidthProperty()
      Width of the shimmer band in pixels. Values that are negative, NaN, or infinite are treated as 0 at render time.
      Returns:
      the shimmer-width property
      See Also:
    • getShimmerWidth

      public final double getShimmerWidth()
      Gets the shimmer band width.
      Returns:
      the shimmer band width in pixels
    • setShimmerWidth

      public final void setShimmerWidth(double value)
      Sets the shimmer band width.
      Parameters:
      value - the shimmer band width in pixels
    • lineCountProperty

      public final javafx.beans.property.IntegerProperty lineCountProperty()
      Number of stacked lines drawn for Skeleton.Variant.TEXT. Values less than 1 are treated as 1.
      Returns:
      the line-count property
      See Also:
    • getLineCount

      public final int getLineCount()
      Gets the number of text lines.
      Returns:
      the configured line count
    • setLineCount

      public final void setLineCount(int value)
      Sets the number of text lines.
      Parameters:
      value - the configured line count
    • lineHeightProperty

      public final javafx.beans.property.DoubleProperty lineHeightProperty()
      Per-line height for Skeleton.Variant.TEXT, in pixels. Values that are negative, NaN, or infinite are treated as 0 at render time.
      Returns:
      the line-height property
      See Also:
    • getLineHeight

      public final double getLineHeight()
      Gets the text line height.
      Returns:
      the line height in pixels
    • setLineHeight

      public final void setLineHeight(double value)
      Sets the text line height.
      Parameters:
      value - the line height in pixels
    • lineSpacingProperty

      public final javafx.beans.property.DoubleProperty lineSpacingProperty()
      Vertical gap between adjacent lines for Skeleton.Variant.TEXT, in pixels. Values that are negative, NaN, or infinite are treated as 0 at render time.
      Returns:
      the line-spacing property
      See Also:
    • getLineSpacing

      public final double getLineSpacing()
      Gets the spacing between text lines.
      Returns:
      the line spacing in pixels
    • setLineSpacing

      public final void setLineSpacing(double value)
      Sets the spacing between text lines.
      Parameters:
      value - the line spacing in pixels
    • lastLineFillPercentProperty

      public final javafx.beans.property.DoubleProperty lastLineFillPercentProperty()
      Width of the last line for Skeleton.Variant.TEXT, expressed as a percent of the placeholder width. Values are clamped to [0, 100] at render time.
      Returns:
      the last-line-fill-percent property
      See Also:
    • getLastLineFillPercent

      public final double getLastLineFillPercent()
      Gets the fill percent used for the final text line.
      Returns:
      the final line fill percent
    • setLastLineFillPercent

      public final void setLastLineFillPercent(double value)
      Sets the fill percent used for the final text line.
      Parameters:
      value - the final line fill percent
    • getClassCssMetaData

      public static List<javafx.css.CssMetaData<? extends javafx.css.Styleable, ?>> getClassCssMetaData()
      Returns the CSS metadata associated with this class.
      Returns:
      the CSS metadata
    • getControlCssMetaData

      public List<javafx.css.CssMetaData<? extends javafx.css.Styleable, ?>> getControlCssMetaData()
      Returns the CSS metadata associated with this control instance.
      Overrides:
      getControlCssMetaData in class javafx.scene.control.Control
      Returns:
      the CSS metadata