Class PatternFactory


  • public class PatternFactory
    extends java.lang.Object
    Static class to creates tilable patterns.

    The createPattern() method draws a shape inside a usually square bitmap, so that it will match if tiled.

    Each pattern supports a scale factor between zero and one - default is .5. With a scale of zero no pattern will be produced. With a scale of one the pattern will cover all the background.

    • Constructor Summary

      Constructors 
      Constructor Description
      PatternFactory()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.awt.image.BufferedImage blur​(java.awt.image.BufferedImage sourceImage)
      Blurs an image.
      static java.awt.image.BufferedImage blur​(java.awt.image.BufferedImage sourceImage, int kernelSize)
      Blurs an image with a specified convolution matrix size.
      static java.awt.image.BufferedImage createPattern​(java.lang.String pattern)
      Draws a pattern using the default scale (.5), bitmap dimensions (32x32) and colors (light grey over a transparent background).
      static java.awt.image.BufferedImage createPattern​(java.lang.String pattern, float scale)
      Draws a pattern with a given scale using the default bitmap dimensions (32x32) and colors (light grey over a transparent background).
      static java.awt.image.BufferedImage createPattern​(java.lang.String pattern, float scale, java.awt.Color lineColor)
      Draws a pattern with a given scale and Color using the default bitmap dimensions (32x32) and backgound color (transparent).
      static java.awt.image.BufferedImage createPattern​(java.lang.String pattern, float scale, java.awt.Color lineColor, java.awt.Color backColor)
      Draws a pattern with a given scale and Colors using the default bitmap dimensions (32x32).
      static java.awt.image.BufferedImage createPattern​(java.lang.String pattern, java.awt.Color lineColor)
      Draws a pattern with a given Color using the default scale (.5), bitmap dimensions (32x32) and backgound color (transparent).
      static java.awt.image.BufferedImage createPattern​(java.lang.String pattern, java.awt.Dimension size, float scale, java.awt.Color lineColor)
      Draws a pattern with a given scale, Color and bitmap dimensions, using the default backgound color (transparent).
      static java.awt.image.BufferedImage createPattern​(java.lang.String pattern, java.awt.Dimension size, float scale, java.awt.Color lineColor, java.awt.Color backColor)
      Draws a pattern with the given scale, Colors and bitmap dimensions.
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PatternFactory

        public PatternFactory()
    • Method Detail

      • createPattern

        public static java.awt.image.BufferedImage createPattern​(java.lang.String pattern)
        Draws a pattern using the default scale (.5), bitmap dimensions (32x32) and colors (light grey over a transparent background).
        Parameters:
        pattern - the pattern to draw. See PatternFactory static constants.
        Returns:
        the corresponding BufferedImage.
      • createPattern

        public static java.awt.image.BufferedImage createPattern​(java.lang.String pattern,
                                                                 java.awt.Color lineColor)
        Draws a pattern with a given Color using the default scale (.5), bitmap dimensions (32x32) and backgound color (transparent).
        Parameters:
        pattern - the pattern to draw. See PatternFactory static constants.
        lineColor - the pattern Color.
        Returns:
        the corresponding BufferedImage.
      • createPattern

        public static java.awt.image.BufferedImage createPattern​(java.lang.String pattern,
                                                                 float scale)
        Draws a pattern with a given scale using the default bitmap dimensions (32x32) and colors (light grey over a transparent background).
        Parameters:
        pattern - the pattern to draw. See PatternFactory static constants.
        scale - the scale at which the pattern should be drawn (0 to 1).
        Returns:
        the corresponding BufferedImage.
      • createPattern

        public static java.awt.image.BufferedImage createPattern​(java.lang.String pattern,
                                                                 float scale,
                                                                 java.awt.Color lineColor)
        Draws a pattern with a given scale and Color using the default bitmap dimensions (32x32) and backgound color (transparent).
        Parameters:
        pattern - the pattern to draw. See PatternFactory static constants.
        scale - the scale at which the pattern should be drawn (0 to 1).
        lineColor - the pattern Color.
        Returns:
        the corresponding BufferedImage.
      • createPattern

        public static java.awt.image.BufferedImage createPattern​(java.lang.String pattern,
                                                                 float scale,
                                                                 java.awt.Color lineColor,
                                                                 java.awt.Color backColor)
        Draws a pattern with a given scale and Colors using the default bitmap dimensions (32x32).
        Parameters:
        pattern - the pattern to draw. See PatternFactory static constants.
        scale - the scale at which the pattern should be drawn (0 to 1).
        lineColor - the pattern Color.
        backColor - the pattern background Color.
        Returns:
        the corresponding BufferedImage.
      • createPattern

        public static java.awt.image.BufferedImage createPattern​(java.lang.String pattern,
                                                                 java.awt.Dimension size,
                                                                 float scale,
                                                                 java.awt.Color lineColor)
        Draws a pattern with a given scale, Color and bitmap dimensions, using the default backgound color (transparent).
        Parameters:
        pattern - the pattern to draw. See PatternFactory static constants.
        size - the Dimension of the BufferedImage produced.
        scale - the scale at which the pattern should be drawn (0 to 1).
        lineColor - the pattern Color.
        Returns:
        the corresponding BufferedImage.
      • createPattern

        public static java.awt.image.BufferedImage createPattern​(java.lang.String pattern,
                                                                 java.awt.Dimension size,
                                                                 float scale,
                                                                 java.awt.Color lineColor,
                                                                 java.awt.Color backColor)
        Draws a pattern with the given scale, Colors and bitmap dimensions.
        Parameters:
        pattern - the pattern to draw. See PatternFactory static constants.
        size - the Dimension of the BufferedImage produced.
        scale - the scale at which the pattern should be drawn (0 to 1).
        lineColor - the pattern Color.
        backColor - the pattern background Color.
        Returns:
        the corresponding BufferedImage.
      • blur

        public static java.awt.image.BufferedImage blur​(java.awt.image.BufferedImage sourceImage)
        Blurs an image.
        Parameters:
        sourceImage - the image to blur.
        Returns:
        the blurred image.
      • blur

        public static java.awt.image.BufferedImage blur​(java.awt.image.BufferedImage sourceImage,
                                                        int kernelSize)
        Blurs an image with a specified convolution matrix size.
        Parameters:
        sourceImage - the image to blur.
        kernelSize - the convolution matrix size.
        Returns:
        the blurred image.