Labelled

abstract class Labelled(text: String, graphic: Node? = null) : Region

The base class for many Nodes which display a single line of text (and an optional graphic). Label is the obvious subclass, but there are many others, including Button.

Anatomy

Example 1. When contentDisplay = LEFT, alignment = BOTTOM_LEFT :

◁╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌width╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌▷
◁╌╌╌╌╌╌╌╌╌╌╌╌╌prefWidth╌╌╌╌╌╌╌╌╌╌╌▷
                   ◁╌╌╌╌labelPadding.left╴
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓} borderSize.top
┃                                        ┃
┃                 ┌╌╌╌╌╌╌╌╌╌╌╌┐     s    ┃
┃   ┌╌╌╌╌╌╌╌┐     ┆           ┆     p    ┃ } labelPadding.top
┃   ┆       ┆     ┆   text    ┆     a    ┃
┃   ┆graphic┆     ┆           ┆     c    ┃ } labelPadding.bottom
┃   └╌╌╌╌╌╌╌┘     └╌╌╌╌╌╌╌╌╌╌╌┘     e    ┃
┃                                        ┃ } padding.bottom
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ } borderSize.bottom
◁╌╌╌╌padding.left╴
             ◁╌╌╌╌╌graphicTextGap╴

If the width allocated to the Labelled == prefWidth, then there will be no space on the right (apart from padding.right) and the horizontal part of alignment will make no difference.

Example 2. When contentDisplay = TOP, alignment = TOP_CENTER : ┏━━━━━━━━━━━━━━━━━━━━┓ } borderSize.top ┃ ┃ ╷ padding.top ┃ ┌╌╌╌╌╌╌╌┐ ┃ ╵ ┃ ┆ ┆ ┃ ┃ ┆graphic┆ ┃ ┃ └╌╌╌╌╌╌╌┘ ┃ ╷ ┃ ┃ ┆ graphicTextGap ┃ ┌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┐ ┃ ╵ ┃ ┆ ┆ ┃ } labelPadding.top ┃ ┆ text ┆ ┃ ┃ ┆ ┆ ┃ } labelPadding.bottom ┃ └╌╌╌╌╌╌╌╌╌╌╌╌╌╌┘ ┃ ┃ ┃ } padding.bottom ┃ empty space ┃ ┃ ┃ ┃ ┃ ┗━━━━━━━━━━━━━━━━━━━━┛ } borderSize.bottom ◁╌╌╌╌▷ labelPadding.left ◁╌▷ padding.left If the height allocated to the Labelled == prefHeight, then there will be no space at the bottom (apart from padding.bottom) and the vertical part of alignment will make no difference.

  • The thick lines are the visible border (see super-class Region).

  • The dashed inner lines are not drawn.

  • The graphic has no padding of its own.

The graphic which can be any Node.

contentDisplay determines where the graphic is compared to the text (the defaults is ContentDisplay.LEFT).

When contentDisplay is TOP or BOTTOM, graphicTextGap is the Y distance, otherwise it is the X distance.

Theme DSL

("label" or "button" or "toggleButton" ... ) {

    alignment( value : Pos )

    contentDisplay( value : ContentDisplay )

    font( value : Font )
    font( size : Int, style : FontStyle, family : String... )
    font( size : Int, family : String... )

    graphicTextGap( value : Number )

    labelPadding( value : Edges )
    labelPadding( size : Number )
    labelPadding( topBottom : Number, leftRight : Number )
    labelPadding( top : Number, right : Number, bottom : Number, left : Number )

    textColor( value : Color )
    textColor( value : String )

}

Labelled inherits all the features of Region.

Inheritors

Constructors

Link copied to clipboard
constructor(text: String, graphic: Node? = null)

Properties

Link copied to clipboard
Link copied to clipboard
open override val children: ObservableList<Node>

The base class Node has no children, so this is an empty list.

Link copied to clipboard
Link copied to clipboard
var font: Font
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
open override fun Number.em(): ObservableOptionalFloat

Converts em units to LogicalPixels.

Link copied to clipboard
open override fun nodeMinHeight(): Float

Each subclass of node can determine the minimum width it requires. This can be overridden on an ad-hoc basis using overrideMinHeight. The default implementation returns 0.

Link copied to clipboard
open override fun nodeMinWidth(): Float

Each subclass of node can determine the minimum width it requires. This can be overridden on an ad-hoc basis using overrideMinWidth. The default implementation returns 0.

Link copied to clipboard
open override fun nodePrefHeight(): Float

Each subclass of node can determine its preferred height. As most nodes are composed of smaller nodes, this is typically calculated using evalPrefWidth of the child nodes, with extra added for spacing, padding and borders.

Link copied to clipboard
open override fun nodePrefWidth(): Float

Each subclass of node can determine its preferred width. As most nodes are composed of smaller nodes, this is typically calculated using evalPrefWidth of the child nodes, with extra added for spacing, padding and borders.

Link copied to clipboard
open override fun toString(): String