Class ImageBuilder
java.lang.Object
io.github.sosuisen.jfxbuilder.graphics.ImageBuilder
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 Summary
Modifier and TypeMethodDescriptionApplies a function to the Image instance being constructed.build()
Builds and returns an instance of theImage
class.static ImageBuilder
create
(InputStream is) Accepts the constructor arguments ofImage(InputStream)
and returns an instance ofImageBuilder
.static ImageBuilder
create
(InputStream is, double requestedWidth, double requestedHeight, boolean preserveRatio, boolean smooth) Accepts the constructor arguments ofImage(InputStream, double, double, boolean, boolean)
and returns an instance ofImageBuilder
.static ImageBuilder
Accepts the constructor arguments ofImage(String)
and returns an instance ofImageBuilder
.static ImageBuilder
Accepts the constructor arguments ofImage(String, boolean)
and returns an instance ofImageBuilder
.static ImageBuilder
create
(String url, double requestedWidth, double requestedHeight, boolean preserveRatio, boolean smooth) Accepts the constructor arguments ofImage(String, double, double, boolean, boolean)
and returns an instance ofImageBuilder
.static ImageBuilder
create
(String url, double requestedWidth, double requestedHeight, boolean preserveRatio, boolean smooth, boolean backgroundLoading) Accepts the constructor arguments ofImage(String, double, double, boolean, boolean, boolean)
and returns an instance ofImageBuilder
.Applies a function to theerrorProperty
of the instance being constructed.Applies a function to theexceptionProperty
of the instance being constructed.Applies a function to theheightProperty
of the instance being constructed.Applies a function to theprogressProperty
of the instance being constructed.Applies a function to thewidthProperty
of the instance being constructed.
-
Method Details
-
create
Accepts the constructor arguments ofImage(InputStream)
and returns an instance ofImageBuilder
.- 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 ofImage(InputStream, double, double, boolean, boolean)
and returns an instance ofImageBuilder
.- Returns:
- an instance of the
ImageBuilder
.
-
create
Accepts the constructor arguments ofImage(String)
and returns an instance ofImageBuilder
.- Returns:
- an instance of the
ImageBuilder
.
-
create
Accepts the constructor arguments ofImage(String, boolean)
and returns an instance ofImageBuilder
.- 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 ofImage(String, double, double, boolean, boolean)
and returns an instance ofImageBuilder
.- 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 ofImage(String, double, double, boolean, boolean, boolean)
and returns an instance ofImageBuilder
.- Returns:
- an instance of the
ImageBuilder
.
-
build
Builds and returns an instance of theImage
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
Applies a function to the Image instance being constructed. Most operations on the instance can be performed using this method.- Returns:
- builder instance
-
errorPropertyApply
Applies a function to theerrorProperty
of the instance being constructed. This serves as a shorthand form of theapply
method.Example:
// Use apply .apply(obj -> obj.errorProperty().bind(anotherProperty)) // Use shorthand form .errorPropertyApply(prop -> prop.bind(anotherProperty))
- Returns:
- builder instance
-
exceptionPropertyApply
Applies a function to theexceptionProperty
of the instance being constructed. This serves as a shorthand form of theapply
method.Example:
// Use apply .apply(obj -> obj.exceptionProperty().bind(anotherProperty)) // Use shorthand form .exceptionPropertyApply(prop -> prop.bind(anotherProperty))
- Returns:
- builder instance
-
heightPropertyApply
Applies a function to theheightProperty
of the instance being constructed. This serves as a shorthand form of theapply
method.Example:
// Use apply .apply(obj -> obj.heightProperty().bind(anotherProperty)) // Use shorthand form .heightPropertyApply(prop -> prop.bind(anotherProperty))
- Returns:
- builder instance
-
progressPropertyApply
Applies a function to theprogressProperty
of the instance being constructed. This serves as a shorthand form of theapply
method.Example:
// Use apply .apply(obj -> obj.progressProperty().bind(anotherProperty)) // Use shorthand form .progressPropertyApply(prop -> prop.bind(anotherProperty))
- Returns:
- builder instance
-
widthPropertyApply
Applies a function to thewidthProperty
of the instance being constructed. This serves as a shorthand form of theapply
method.Example:
// Use apply .apply(obj -> obj.widthProperty().bind(anotherProperty)) // Use shorthand form .widthPropertyApply(prop -> prop.bind(anotherProperty))
- Returns:
- builder instance
-