Class PatternBuilder


  • public final class PatternBuilder
    extends Object
    The pattern builder is the entry point to create a canvas pattern.
    Entity to apply a canvas pattern in the a data set as background.
    See here some interesting pattern images.
    Author:
    Andrea "Stock" Stocchero
    • Method Detail

      • create

        public static PatternBuilder create​(Img image)
        Creates the object using an image to use in the pattern.
        The repetition used is repeat.
        Parameters:
        image - image to use as pattern
        Returns:
        pattern builder instance
      • create

        public static PatternBuilder create​(Img image,
                                            Repetition repetition)
        Creates the object using an image to use in the pattern and repetition to apply to pattern.
        Parameters:
        image - image to use as pattern
        repetition - repetition value to apply to pattern
        Returns:
        pattern builder instance
      • create

        public static PatternBuilder create​(CanvasPatternItem canvasPattern)
        Creates the object using an already created canvas pattern.
        The dimension of canvas pattern image will be the default TilesFactoryDefaults.DEFAULT_SIZE. This is mainly used by tiles.
        Parameters:
        canvasPattern - canvas pattern instance
        Returns:
        pattern builder instance
      • create

        public static PatternBuilder create​(CanvasPatternItem canvasPattern,
                                            int squareSize)
        Creates the object using an already created canvas pattern.
        The dimension of canvas pattern image is unique then the image of pattern is a square. This is mainly used by tiles.
        Parameters:
        canvasPattern - canvas pattern instance
        squareSize - size of image applied to canvasPattern to be a square
        Returns:
        pattern builder instance
      • create

        public static PatternBuilder create​(CanvasPatternItem canvasPattern,
                                            int width,
                                            int height)
        Creates the object using an already created canvas pattern.
        This is mainly used by tiles.
        Parameters:
        canvasPattern - canvas pattern instance
        width - width of image applied to canvasPattern
        height - height of image applied to canvasPattern
        Returns:
        pattern builder instance
      • build

        public Pattern build()
        Builds and returns a pattern instance.
        Returns:
        a pattern instance, built by the builder.
      • build

        public static Pattern build​(NativeObject nativeObject)
        Creates a pattern, previously stored in the a native java script object
        Parameters:
        nativeObject - native java script object wrapped by pattern.
        Returns:
        a pattern instance, built by the builder.
      • retrieve

        public static Pattern retrieve​(CanvasPatternItem canvasPattern)
        Retrieves a cached pattern by a CanvasPatternItem instance.
        If the pattern doesn't exist, returns null.
        Parameters:
        canvasPattern - the canvas pattern to use for searching
        Returns:
        a cached pattern by a CanvasPatternItem instance.
        If the pattern doesn't exist, returns null