package com.xtremelabs.droidsugar.fakes;

import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import com.xtremelabs.droidsugar.util.Implements;

import java.util.ArrayList;
import java.util.List;

@SuppressWarnings({"UnusedDeclaration"})
@Implements(Canvas.class)
public class FakeCanvas {
    private List<PaintEvents> pathPaintEvents = new ArrayList<PaintEvents>();
    public Paint drawnPaint;
    public Paint circlePaint;
    public float circleCenterX;
    public float circleCenterY;
    public float circleRadius;
    public boolean drewSomethingAfterCircle;

    public void drawPaint(Paint paint) {
        drawnPaint = paint;
    }

    public void drawPath(Path path, Paint paint) {
        pathPaintEvents.add(new PaintEvents(path, paint));
        if(hasDrawnCircle()) {
            drewSomethingAfterCircle = true;
        }
    }

    public void drawCircle(float cx, float cy, float radius, Paint paint) {
        circleCenterX = cx;
        circleCenterY = cy;
        circleRadius = radius;
        circlePaint = paint;
        drewSomethingAfterCircle = false;
    }

    public int getPathPaintCount() {
        return pathPaintEvents.size();
    }

    public boolean hasDrawnPath() {
        return getPathPaintCount() > 0;
    }

    public boolean hasDrawnCircle() {
        return circlePaint != null;
    }

    public Paint getDrawnPathPaint(int i) {
        return pathPaintEvents.get(i).pathPaint;
    }

    public Path getDrawnPath(int i) {
        return pathPaintEvents.get(i).drawnPath;
    }

    private static class PaintEvents {
        private Path drawnPath;
        private Paint pathPaint;

        PaintEvents(Path drawnPath, Paint pathPaint) {
            this.drawnPath = drawnPath;
            this.pathPaint = pathPaint;
        }
    }
}

@@ -343,25 +343,35 @@
  List%3CPa
-int
+thPaintHistory
 Event
-s
 %3E pathPa
@@ -398,25 +398,35 @@
 yList%3CPa
-int
+thPaintHistory
 Event
-s
 %3E();%0A   
@@ -431,48 +431,44 @@
    p
-ublic Paint drawnPaint;%0A    public Pai
+rivate List%3CCirclePaintHistoryEve
 nt
+%3E
  cir
@@ -479,103 +479,86 @@
 aint
-;%0A    public float circleCenterX;%0A    public float circleCenterY;%0A    public float circleRadius
+Events = new ArrayList%3CCirclePaintHistoryEvent%3E();%0A    public Paint drawnPaint
 ;%0A  
@@ -762,25 +762,35 @@
 d(new Pa
-int
+thPaintHistory
 Event
-s
 (path, p
@@ -984,108 +984,75 @@
 rcle
-CenterX = cx;%0A        circleCenterY = cy;%0A        circleRadius = radius;%0A        circlePaint =
+PaintEvents.add(new CirclePaintHistoryEvent(cx, cy, radius,
  paint
+))
 ;%0A  
@@ -1117,32 +1117,39 @@
 int getPathPaint
+History
 Count() %7B%0A      
@@ -1180,32 +1180,126 @@
 .size();%0A    %7D%0A%0A
+    public int getCirclePaintHistoryCount() %7B%0A        return circlePaintEvents.size();%0A    %7D%0A%0A
     public boole
@@ -1345,16 +1345,23 @@
 athPaint
+History
 Count() 
@@ -1440,16 +1440,25 @@
 aint
- != null
+Events.size() %3E 0
 ;%0A  
@@ -1652,24 +1652,245 @@
 ath;%0A    %7D%0A%0A
+    public CirclePaintHistoryEvent getDrawnCircle(int i) %7B%0A        return circlePaintEvents.get(i);%0A    %7D%0A%0A    public void resetCanvasHistory() %7B%0A        pathPaintEvents.clear();%0A        circlePaintEvents.clear();%0A    %7D%0A%0A
     private 
@@ -1904,25 +1904,35 @@
 class Pa
-int
+thPaintHistory
 Event
-s
  %7B%0A     
@@ -2000,27 +2000,37 @@
         
+Path
 Paint
+History
 Event
-s
 (Path dr
@@ -2152,11 +2152,433 @@
  %7D%0A    %7D
+%0A%0A    public static class CirclePaintHistoryEvent %7B%0A        public Paint paint;%0A        public float centerX;%0A        public float centerY;%0A        public float radius;%0A%0A        private CirclePaintHistoryEvent(float centerX, float centerY, float radius, Paint paint) %7B%0A            this.paint = paint;%0A            this.centerX = centerX;%0A            this.centerY = centerY;%0A            this.radius = radius;%0A        %7D%0A    %7D
 %0A%7D%0A

Improve the Canvas to keep track of multiple drawn circles