Class FontBuilder

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

public class FontBuilder extends Object
The FontBuilder class constructs instances of the Font 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 Font constructor and returns an instance of the FontBuilder.

You can use method chaining to call the builder methods for configuring the Font. Finally, invoke the build method to generate an instance of the Font 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 FontBuilder create(double size)
      Accepts the constructor arguments of Font(double) and returns an instance of FontBuilder.
      Returns:
      an instance of the FontBuilder.
    • create

      public static FontBuilder create(String name, double size)
      Accepts the constructor arguments of Font(String, double) and returns an instance of FontBuilder.
      Returns:
      an instance of the FontBuilder.
    • build

      public Font build()
      Builds and returns an instance of the Font 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 Font class
    • apply

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