// Path: app/src/main/java/jgh/artistex/engine/ILayer.java
// public interface ILayer {
// 
// 
// 
// 
//     /**
//      * Signals the <code>ILayer</code> implementation to start being manipulated by the user
//      * This indicates the lyaer has been set as the currently manipulated layer.
//      */
//     void setStart();
// 
// 
//     /**
//      * Signals the <code>ILayer</code> implementation to stop being manipulated by the user.
//      * This indicates that another <code>ILayer</code> implementation is set as the currently
//      * manipulated layer.
//      */
//     void setStop();
// 
// 
//     /**
//      * Draw the Layer on the given canvas.
//      *
//      * @param canvas drawing canvas
//      */
//     void draw(Canvas canvas, boolean showTransformBox);
// 
// 
//     /**
//      * Applies a motion event to the layer.
//      * Effect of the motion event is left to
//      * implementation.
//      *
//      * @param event motion event
//      * @return An <code>IUndo</code> object, making the given effect undoable.
//      */
//     IUndo onEvent(MotionEvent event);
// 
// 
//     /**
//      * Returns the <code>LayerType</code> of the Layer.
//      *
//      * @return layer type enum
//      */
//     LayerType getLayerType();
// 
// 
//     /**
//      * Returns a string tag, to represent this Layer type or uniquely identify this
//      * Layer.
//      *
//      * @return string tag
//      */
//     String getTag();
// 
// 
//     /**
//      * Sets the Layer tag to identify this layer or layer type.
//      *
//      * @param tag
//      */
//     void setTag(String tag);
// 
// 
//     /**
//      * Makes a duplicate copy of this layer.
//      *
//      * @return duplicate copy.
//      */
//     ILayer copy();
// 
// 
//     /**
//      * Serializes the layer into an SVG (XML) formatted string, for exporting.
//      *
//      * @return SVG string represtining this layer.
//      */
//     String getXml();
// 
// 
//     /**
//      * Accepts a visit by the <code>ILayerVisitor</code> implementation.
//      *
//      * @param visitor Visitor object.
//      */
//     void accept(ILayerVisitor visitor);
// 
// 
// }
// 
// Path: app/src/main/java/jgh/artistex/engine/IUndo.java
// public final class IUndo {
// 
//     /**
//      * The <code>UndoHandler</code> performs the
//      * actual undo and redo operations, defined per implementation.
//      */
//     private IUndoHandler mUndoHandler;
// 
// 
//     /**
//      * Creates an instance of IUndo. A non-null argument must be passed, or an
//      * <code>IllegalArgumentException</code> will be thrown.
//      *
//      * @param undoHandler the undo handler, hadnles the specifics of the undo and redo actions.
//      */
//     public IUndo(IUndoHandler undoHandler) {
//         if (undoHandler == null) throw new IllegalArgumentException("Cannot pass null argument.");
//         mUndoHandler = undoHandler;
//     }
// 
// 
//     /**
//      * Undo action -- should only be called in <code>DrawingEngine</code> because
//      * it should be applied after this <code>IUndo</code> instance is  popped
//      * off the undo stack <b>only</b>.
//      */
//     /* default */ void undo() {
//         mUndoHandler.handleUndo();
//     }
// 
// 
//     /**
//      * Redo action -- should only be called in <code>DrawingEngine</code>
//      */
//     /* default */ void redo() {
//         mUndoHandler.handleRedo();
//     }
// }
// 
// Path: app/src/main/java/jgh/artistex/engine/IUndoHandler.java
// public interface IUndoHandler {
// 
//     /**
//      * Handles the undo action.
//      */
//     void handleUndo();
// 
//     /**
//      * Handles the redo action
//      */
//     void handleRedo();
// }
// 
// Path: app/src/main/java/jgh/artistex/engine/LayerType.java
// public enum LayerType {
// 
//     PENCIL,
//     PEN,
//     SHAPE,
//     TEXT,
//     IMAGE
// }


import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PointF;
import android.view.MotionEvent;
import java.util.ArrayList;
import jgh.artistex.engine.ILayer;
import jgh.artistex.engine.IUndo;
import jgh.artistex.engine.IUndoHandler;
import jgh.artistex.engine.LayerType;
package jgh.artistex.engine.Layers.Pens;





/**
 * The <code>Pencil</code> type is similar to the parnet class, <code>Pen</code>, but whereas Pens will add new vertices
 * when the user touches down on the screen, Pencils add new points when user input moves on the screen,
 * giving a smooth motion and smooth curve.
 */
public class Pencil extends Pen {

    public Pencil() {
        mVertexList = new ArrayList<>();
        mBezierVertexList = new ArrayList<>();
        mPath = new Path();
        mStrokePaint = new Paint(Color.GREEN);
        mStrokePaint.setColor(Color.GREEN);
        mStrokePaint.setStyle(Paint.Style.STROKE);
        mFillPaint = new Paint();
        mFillPaint.setColor(0x00FFFFFF);
        mTransformer = new PenTransformer(this);
        mRotMatrix = new Matrix();
        mLastPosition = new PointF();
        mBezierController = new BezierController();
        mVertexController = new VertexController();
    }

    private Pencil(Paint strokePaint, Paint fillPaint, ArrayList<PointF> bezierPoints,
                ArrayList<PointF> vertexPoints) {
        mVertexList = new ArrayList<>();
        mBezierVertexList = new ArrayList<>();
        mPath = new Path();
// Path: app/src/main/java/jgh/artistex/engine/ILayer.java
// public interface ILayer {
// 
// 
// 
// 
//     /**
//      * Signals the <code>ILayer</code> implementation to start being manipulated by the user
//      * This indicates the lyaer has been set as the currently manipulated layer.
//      */
//     void setStart();
// 
// 
//     /**
//      * Signals the <code>ILayer</code> implementation to stop being manipulated by the user.
//      * This indicates that another <code>ILayer</code> implementation is set as the currently
//      * manipulated layer.
//      */
//     void setStop();
// 
// 
//     /**
//      * Draw the Layer on the given canvas.
//      *
//      * @param canvas drawing canvas
//      */
//     void draw(Canvas canvas, boolean showTransformBox);
// 
// 
//     /**
//      * Applies a motion event to the layer.
//      * Effect of the motion event is left to
//      * implementation.
//      *
//      * @param event motion event
//      * @return An <code>IUndo</code> object, making the given effect undoable.
//      */
//     IUndo onEvent(MotionEvent event);
// 
// 
//     /**
//      * Returns the <code>LayerType</code> of the Layer.
//      *
//      * @return layer type enum
//      */
//     LayerType getLayerType();
// 
// 
//     /**
//      * Returns a string tag, to represent this Layer type or uniquely identify this
//      * Layer.
//      *
//      * @return string tag
//      */
//     String getTag();
// 
// 
//     /**
//      * Sets the Layer tag to identify this layer or layer type.
//      *
//      * @param tag
//      */
//     void setTag(String tag);
// 
// 
//     /**
//      * Makes a duplicate copy of this layer.
//      *
//      * @return duplicate copy.
//      */
//     ILayer copy();
// 
// 
//     /**
//      * Serializes the layer into an SVG (XML) formatted string, for exporting.
//      *
//      * @return SVG string represtining this layer.
//      */
//     String getXml();
// 
// 
//     /**
//      * Accepts a visit by the <code>ILayerVisitor</code> implementation.
//      *
//      * @param visitor Visitor object.
//      */
//     void accept(ILayerVisitor visitor);
// 
// 
// }
// 
// Path: app/src/main/java/jgh/artistex/engine/IUndo.java
// public final class IUndo {
// 
//     /**
//      * The <code>UndoHandler</code> performs the
//      * actual undo and redo operations, defined per implementation.
//      */
//     private IUndoHandler mUndoHandler;
// 
// 
//     /**
//      * Creates an instance of IUndo. A non-null argument must be passed, or an
//      * <code>IllegalArgumentException</code> will be thrown.
//      *
//      * @param undoHandler the undo handler, hadnles the specifics of the undo and redo actions.
//      */
//     public IUndo(IUndoHandler undoHandler) {
//         if (undoHandler == null) throw new IllegalArgumentException("Cannot pass null argument.");
//         mUndoHandler = undoHandler;
//     }
// 
// 
//     /**
//      * Undo action -- should only be called in <code>DrawingEngine</code> because
//      * it should be applied after this <code>IUndo</code> instance is  popped
//      * off the undo stack <b>only</b>.
//      */
//     /* default */ void undo() {
//         mUndoHandler.handleUndo();
//     }
// 
// 
//     /**
//      * Redo action -- should only be called in <code>DrawingEngine</code>
//      */
//     /* default */ void redo() {
//         mUndoHandler.handleRedo();
//     }
// }
// 
// Path: app/src/main/java/jgh/artistex/engine/IUndoHandler.java
// public interface IUndoHandler {
// 
//     /**
//      * Handles the undo action.
//      */
//     void handleUndo();
// 
//     /**
//      * Handles the redo action
//      */
//     void handleRedo();
// }
// 
// Path: app/src/main/java/jgh/artistex/engine/LayerType.java
// public enum LayerType {
// 
//     PENCIL,
//     PEN,
//     SHAPE,
//     TEXT,
//     IMAGE
// }


// Path: app/src/main/java/jgh/artistex/engine/Layers/Pens/Pencil.java
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PointF;
import android.view.MotionEvent;
import java.util.ArrayList;
import jgh.artistex.engine.ILayer;
import jgh.artistex.engine.IUndo;
import jgh.artistex.engine.IUndoHandler;
import jgh.artistex.engine.LayerType;

package jgh.artistex.engine.Layers.Pens;





/**
 * The <code>Pencil</code> type is similar to the parnet class, <code>Pen</code>, but whereas Pens will add new vertices
 * when the user touches down on the screen, Pencils add new points when user input moves on the screen,
 * giving a smooth motion and smooth curve.
 */
public class Pencil extends Pen {

    public Pencil() {
        mVertexList = new ArrayList<>();
        mBezierVertexList = new ArrayList<>();
        mPath = new Path();
        mStrokePaint = new Paint(Color.GREEN);
        mStrokePaint.setColor(Color.GREEN);
        mStrokePaint.setStyle(Paint.Style.STROKE);
        mFillPaint = new Paint();
        mFillPaint.setColor(0x00FFFFFF);
        mTransformer = new PenTransformer(this);
        mRotMatrix = new Matrix();
        mLastPosition = new PointF();
        mBezierController = new BezierController();
        mVertexController = new VertexController();
    }

    private Pencil(Paint strokePaint, Paint fillPaint, ArrayList<PointF> bezierPoints,
                ArrayList<PointF> vertexPoints) {
        mVertexList = new ArrayList<>();
        mBezierVertexList = new ArrayList<>();
        mPath = new Path();
        mStrokePaint = new Paint(strokePaint);