Klasse NodeBuilder<N extends Node,NN extends NodeBuilder<N,NN>>

java.lang.Object
com.dua3.utility.fx.controls.abstract_builders.NodeBuilder<N,NN>
Typparameter:
N - the type of node to be built
NN - the type of the concrete builder
Bekannte direkte Unterklassen:
ControlBuilder, ShapeBuilder

public abstract class NodeBuilder<N extends Node,NN extends NodeBuilder<N,NN>> extends Object
An abstract base class for building nodes, providing a fluent API for configuring and creating instances of the node type specified by the generic parameter N.
  • Konstruktordetails

    • NodeBuilder

      protected NodeBuilder(Supplier<? extends N> factory)
      Constructs a new instance of the NodeBuilder class using the specified factory.
      Parameter:
      factory - the supplier that provides a new instance of the node type to be built
  • Methodendetails

    • self

      protected final NN self()
      Returns the current instance of the builder with the proper type.
      Gibt zurück:
      this instance of the builder
    • apply

      protected final <T> void apply(@Nullable T value, Consumer<T> setter)
      Applies a value to the provided consumer if the value is not null.
      Typparameter:
      T - the type of the value to apply
      Parameter:
      value - the value to be applied; can be null
      setter - the consumer to which the value is applied if not null
    • apply

      protected final <T> void apply(@Nullable ObservableValue<? extends T> value, Property<? super T> property)
      Binds the given ObservableValue to the specified Property.

      This method ensures that the property is dynamically updated to reflect the value of the ObservableValue, if it is not null.

      Typparameter:
      T - the type of the value to be bound
      Parameter:
      value - the ObservableValue to be bound to the property; may be null
      property - the Property to bind the observable value to
    • build

      public N build()
      Builds and returns a new instance of the node type specified by the builder.

      Derived classes should always call super.build() to get an instance and then apply the added configuration.

      Gibt zurück:
      a new instance of the node created by the factory associated with this builder
    • disabled

      public NN disabled(boolean disabled)
      Set the node's disabled state to the supplied value.

      NOTE: Do not use together with bindEnabled(ObservableValue) and bindDisabled(ObservableValue).

      Parameter:
      disabled - the value to bind the node's disableProperty to
      Gibt zurück:
      this NodeBuilder instance
    • bindDisabled

      public NN bindDisabled(ObservableValue<Boolean> disabled)
      Bind the node's disabled state to an ObservableValue.

      NOTE: Use either this method or bindEnabled(ObservableValue), not both.

      Parameter:
      disabled - the value to bind the node's disableProperty to
      Gibt zurück:
      this NodeBuilder instance
    • bindEnabled

      public NN bindEnabled(ObservableValue<Boolean> enabled)
      Bind the button's enabled state to an ObservableValue.

      NOTE: Use either this method or bindDisabled(ObservableValue), not both.

      Parameter:
      enabled - the value to bind the button's disableProperty to
      Gibt zurück:
      this NodeBuilder instance
    • prefWidth

      public NN prefWidth(double width)
      Sets the preferred width for the node being built.
      Parameter:
      width - the preferred width to set for the node
      Gibt zurück:
      this instance of the builder
    • prefHeight

      public NN prefHeight(double height)
      Sets the preferred height of the node being built.
      Parameter:
      height - the preferred height to set
      Gibt zurück:
      this instance of the builder
    • prefSize

      public NN prefSize(double width, double height)
      Sets the preferred width and height for the node being built.
      Parameter:
      width - the preferred width to set for the node
      height - the preferred height to set for the node
      Gibt zurück:
      this instance of the builder