Class BufferedImageBuilder


  • public final class BufferedImageBuilder
    extends java.lang.Object
    A builder for creating BufferedImage with specified parameters.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static int DEFAULT_TYPE
      The default image type of the BufferedImages to be created by this builder.
      private int height
      The height to use for the BufferedImage that is to be created.
      private int imageType
      The image type to use for the BufferedImage that is to be created.
      private int width
      The width to use for the BufferedImage that is to be created.
    • Constructor Summary

      Constructors 
      Constructor Description
      BufferedImageBuilder​(int width, int height)
      Instantiates a BufferedImageBuilder with the specified size, and the default image type.
      BufferedImageBuilder​(int width, int height, int imageType)
      Instantiates a BufferedImageBuilder with the specified size and image type.
      BufferedImageBuilder​(java.awt.Dimension size)
      Instantiates a BufferedImageBuilder with the specified size, and the default image type.
      BufferedImageBuilder​(java.awt.Dimension size, int imageType)
      Instantiates a BufferedImageBuilder with the specified size and image type.
    • Field Detail

      • DEFAULT_TYPE

        private static final int DEFAULT_TYPE
        The default image type of the BufferedImages to be created by this builder.
        See Also:
        Constant Field Values
      • imageType

        private int imageType
        The image type to use for the BufferedImage that is to be created.
      • width

        private int width
        The width to use for the BufferedImage that is to be created.
      • height

        private int height
        The height to use for the BufferedImage that is to be created.
    • Constructor Detail

      • BufferedImageBuilder

        public BufferedImageBuilder​(java.awt.Dimension size)
        Instantiates a BufferedImageBuilder with the specified size, and the default image type.
        Parameters:
        size - The size of the BufferedImage to build.
      • BufferedImageBuilder

        public BufferedImageBuilder​(java.awt.Dimension size,
                                    int imageType)
        Instantiates a BufferedImageBuilder with the specified size and image type.
        Parameters:
        size - The size of the BufferedImage to build.
        imageType - The image type of the BufferedImage to build.
      • BufferedImageBuilder

        public BufferedImageBuilder​(int width,
                                    int height)
        Instantiates a BufferedImageBuilder with the specified size, and the default image type.
        Parameters:
        width - The width of the BufferedImage to build.
        height - The height of the BufferedImage to build.
      • BufferedImageBuilder

        public BufferedImageBuilder​(int width,
                                    int height,
                                    int imageType)
        Instantiates a BufferedImageBuilder with the specified size and image type.
        Parameters:
        width - The width of the BufferedImage to build.
        height - The height of the BufferedImage to build.
        imageType - The image type of the BufferedImage to build.
    • Method Detail

      • build

        public java.awt.image.BufferedImage build()
        Generates a new BufferedImage.
        Returns:
        Returns a newly created BufferedImage from the parameters set in the BufferedImageBuilder.
      • imageType

        public BufferedImageBuilder imageType​(int imageType)
        Sets the type of the image of the BufferedImage.
        Parameters:
        imageType - The image type to use. If BufferedImage.TYPE_CUSTOM is used, it be substituted by BufferedImage.TYPE_INT_ARGB.
        Returns:
        This BufferedImageBuilder instance.
      • size

        public BufferedImageBuilder size​(int width,
                                         int height)
        Sets the size for the BufferedImage.
        Parameters:
        width - The width of the image to create.
        height - The height of the image to create.
        Returns:
        This BufferedImageBuilder instance.
      • height

        public BufferedImageBuilder height​(int height)
        Sets the height for the BufferedImage.
        Parameters:
        height - The height of the image to create.
        Returns:
        This BufferedImageBuilder instance.