Class CharacterShape

  • All Implemented Interfaces:
    IsShape, Key

    public final class CharacterShape
    extends ShapeDrawer
    This is a shape which can draw a character on the tile.
    This object is also a shape drawer.
    The font size is calculated automatically based on tile size.
    It designs a char in the following tile sections (A and B):
     +---------+---------+
     |         |         |
     |    A    |         |
     |         |         |
     +---------+---------+
     |         |         |
     |         |    B    |
     |         |         |
     +---------+---------+
     
    Author:
    Andrea "Stock" Stocchero
    • Field Detail

      • CHARACTER_SHAPE_NAME

        public static final String CHARACTER_SHAPE_NAME
        Name of shape to draw a character, "char".
        See Also:
        Constant Field Values
    • Constructor Detail

      • CharacterShape

        public CharacterShape​(String character)
        Creates a shape with a character as shape, using the default font family
        Parameters:
        character - character to draw in the tile as shape
      • CharacterShape

        public CharacterShape​(String character,
                              String fontFamily)
        Creates a shape with a character as shape using passed font family.
        Parameters:
        character - character to draw in the tile as shape
        fontFamily - font family to apply on tile
    • Method Detail

      • drawTile

        protected void drawTile​(Context2dItem context,
                                String backgroundColor,
                                String shapeColor,
                                int size)
        Description copied from class: ShapeDrawer
        Draws the tile applying the requested shape.
        Specified by:
        drawTile in class ShapeDrawer
        Parameters:
        context - context of canvas to design the shape
        backgroundColor - background of tile
        shapeColor - color of shape
        size - the size of tile, which is a square
      • value

        public final String value()
        Description copied from interface: Key
        Returns the name value of property
        Specified by:
        value in interface Key
        Returns:
        the name value of property
      • getDrawer

        public final ShapeDrawer getDrawer()
        Description copied from interface: IsShape
        Returns the instance of shape drawer.
        Specified by:
        getDrawer in interface IsShape
        Returns:
        the instance of shape drawer.
      • getKeyPrefix

        public final String getKeyPrefix()
        Description copied from interface: IsShape
        Returns a unique key prefix for shape to use in the cache.
        Specified by:
        getKeyPrefix in interface IsShape
        Returns:
        a unique key prefix for shape to use in the cache
      • setKeyPrefix

        protected void setKeyPrefix​(String keyPrefix)
        Sets the key prefix for caching.
        Parameters:
        keyPrefix - the key prefix for caching to set