Class ShapeDrawer

  • Direct Known Subclasses:
    CharacterShape, ImageShape

    public abstract class ShapeDrawer
    extends Object
    Base class for all shape drawer, classes which must designer on canvas the shape.
    A tile is always a square and for some shapes is divided in 4 sections and not all sections are designed.
    A tile is designed as following:
     +---------+---------+
     |         |         |
     |         |         |
     |         |         |
     +---------+---------+
     |         |         |
     |         |         |
     |         |         |
     +---------+---------+
     
    Depending on shape, the parts can be designed or not.
    Author:
    Andrea "Stock" Stocchero
    • Constructor Detail

      • ShapeDrawer

        public ShapeDrawer()
    • Method Detail

      • initCanvas

        protected final Canvas initCanvas​(Canvas outerCanvas,
                                          int size)
        Initialized the internal canvas to use for drawing.
        Parameters:
        outerCanvas - canvas instance of tile factory
        size - dimension of internal canvas
        Returns:
        a created and configured canvas element element to use for drawing.
      • drawTile

        protected abstract void drawTile​(Context2dItem context,
                                         String backgroundColor,
                                         String shapeColor,
                                         int size)
        Draws the tile applying the requested shape.
        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
      • applyStrokeProperties

        protected final void applyStrokeProperties​(Context2dItem context,
                                                   String shapeColor,
                                                   int size)
        Applies the common configuration to context for stroke designing.
        Parameters:
        context - context of canvas to design the shape
        shapeColor - color of shape
        size - the size of tile, which is a square
      • applyStrokeProperties

        protected final void applyStrokeProperties​(Context2dItem context,
                                                   String shapeColor,
                                                   int size,
                                                   CapStyle lineCap,
                                                   JoinStyle lineJoin)
        Applies the common configuration to context for stroke designing.
        Parameters:
        context - context of canvas to design the shape
        shapeColor - color of shape
        size - the size of tile, which is a square
        lineCap - determines the shape used to draw the end points of lines
        lineJoin - determines the shape used to join two line segments where they meet
      • applyFillProperties

        protected final void applyFillProperties​(Context2dItem context,
                                                 String shapeColor)
        Applies the common configuration to context for fill designing.
        Parameters:
        context - context of canvas to design the shape
        shapeColor - color of shape