java.lang.Object
io.github.sosuisen.jfxbuilder.graphics.ImageBuilder

public class ImageBuilder extends Object
The ImageBuilder class constructs instances of the Image class and offers a fluent interface for creating and configuring it.

This class includes a static create method that accepts the same arguments as the original Image constructor and returns an instance of the ImageBuilder.

You can use method chaining to call the builder methods for configuring the Image. Finally, invoke the build method to generate an instance of the Image class.

Note that intermediate builder methods are not evaluated until the build method is called, meaning they are evaluated lazily.

Author:
Hidekazu Kubota <hidekazu.kubota@gmail.com>
  • Method Details

    • create

      public static ImageBuilder create(InputStream is)
      Accepts the constructor arguments of Image(InputStream) and returns an instance of ImageBuilder.
      Returns:
      an instance of the ImageBuilder.
    • create

      public static ImageBuilder create(InputStream is, double requestedWidth, double requestedHeight, boolean preserveRatio, boolean smooth)
      Accepts the constructor arguments of Image(InputStream, double, double, boolean, boolean) and returns an instance of ImageBuilder.
      Returns:
      an instance of the ImageBuilder.
    • create

      public static ImageBuilder create(String url)
      Accepts the constructor arguments of Image(String) and returns an instance of ImageBuilder.
      Returns:
      an instance of the ImageBuilder.
    • create

      public static ImageBuilder create(String url, boolean backgroundLoading)
      Accepts the constructor arguments of Image(String, boolean) and returns an instance of ImageBuilder.
      Returns:
      an instance of the ImageBuilder.
    • create

      public static ImageBuilder create(String url, double requestedWidth, double requestedHeight, boolean preserveRatio, boolean smooth)
      Accepts the constructor arguments of Image(String, double, double, boolean, boolean) and returns an instance of ImageBuilder.
      Returns:
      an instance of the ImageBuilder.
    • create

      public static ImageBuilder create(String url, double requestedWidth, double requestedHeight, boolean preserveRatio, boolean smooth, boolean backgroundLoading)
      Accepts the constructor arguments of Image(String, double, double, boolean, boolean, boolean) and returns an instance of ImageBuilder.
      Returns:
      an instance of the ImageBuilder.
    • build

      public Image build()
      Builds and returns an instance of the Image class.

      Intermediate builder methods are not evaluated until the build method is called; in other words, they are evaluated lazily.

      Returns:
      new instance of the Image class
    • apply

      public ImageBuilder apply(Consumer<Image> func)
      Applies a function to the Image instance being constructed. Most operations on the instance can be performed using this method.
      Returns:
      builder instance
    • errorPropertyApply

      public ImageBuilder errorPropertyApply(Consumer<ReadOnlyBooleanProperty> op)
      Applies a function to the errorProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      Returns:
      builder instance
    • exceptionPropertyApply

      public ImageBuilder exceptionPropertyApply(Consumer<ReadOnlyObjectProperty<Exception>> op)
      Applies a function to the exceptionProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      Returns:
      builder instance
    • heightPropertyApply

      public ImageBuilder heightPropertyApply(Consumer<ReadOnlyDoubleProperty> op)
      Applies a function to the heightProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      Returns:
      builder instance
    • progressPropertyApply

      public ImageBuilder progressPropertyApply(Consumer<ReadOnlyDoubleProperty> op)
      Applies a function to the progressProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      Returns:
      builder instance
    • widthPropertyApply

      public ImageBuilder widthPropertyApply(Consumer<ReadOnlyDoubleProperty> op)
      Applies a function to the widthProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      Returns:
      builder instance