Class NineBlockIdenticonRenderer2

  • All Implemented Interfaces:
    IdenticonRenderer

    public class NineBlockIdenticonRenderer2
    extends Object
    implements IdenticonRenderer
    9-block Identicon renderer.

    Current implementation uses only the lower 32 bits of identicon code.

    Author:
    don
    • Constructor Detail

      • NineBlockIdenticonRenderer2

        public NineBlockIdenticonRenderer2()
        Constructor.
    • Method Detail

      • getPatchSize

        public float getPatchSize()
        Returns the size in pixels at which each patch will be rendered before they are scaled down to requested identicon size.
        Returns:
        the size
      • setPatchSize

        public void setPatchSize​(float size)
        Set the size in pixels at which each patch will be rendered before they are scaled down to requested identicon size. Default size is 20 pixels which means, for 9-block identicon, a 60x60 image will be rendered and scaled down.
        Parameters:
        size - patch size in pixels
      • getBackgroundColor

        public Color getBackgroundColor()
      • setBackgroundColor

        public void setBackgroundColor​(Color backgroundColor)
      • render

        public BufferedImage render​(int code,
                                    int size)
        Returns rendered identicon image for given identicon code.

        Size of the returned identicon image is determined by patchSize set using setPatchSize(float). Since a 9-block identicon consists of 3x3 patches, width and height will be 3 times the patch size.

        Specified by:
        render in interface IdenticonRenderer
        Parameters:
        code - identicon code
        size - image size
        Returns:
        identicon image
      • renderQuilt

        protected BufferedImage renderQuilt​(int code,
                                            int size)