/*
 * Copyright (C) 2017 Yaroslav Mytkalyk
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.doctoror.particlesdrawable.renderer;

import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.support.annotation.ColorInt;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.doctoror.particlesdrawable.contract.LowLevelRenderer;
import com.doctoror.particlesdrawable.contract.SceneRenderer;

/**
 * {@link SceneRenderer} that draws on {@link Canvas}
 */
public final class CanvasSceneRenderer implements LowLevelRenderer {

    private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);

    @Nullable
    private Canvas mCanvas;

    public void setCanvas(@Nullable final Canvas canvas) {
        mCanvas = canvas;
    }

    @NonNull
    public Paint getPaint() {
        return mPaint;
    }

    public void setColorFilter(final ColorFilter colorFilter) {
        mPaint.setColorFilter(colorFilter);
    }

    @Override
    public void drawLine(final float startX, final float startY, final float stopX,
            final float stopY, final float strokeWidth, @ColorInt final int color) {
        if (mCanvas == null) {
            throw new IllegalStateException("Called in wrong state");
        }
        mPaint.setStrokeWidth(strokeWidth);
        mPaint.setColor(color);
        mCanvas.drawLine(startX, startY, stopX, stopY, mPaint);
    }

    @Override
    public void fillCircle(final float cx, final float cy, final float radius,
            @ColorInt final int color) {
        if (mCanvas == null) {
            throw new IllegalStateException("Called in wrong state");
        }
        mPaint.setColor(color);
        mCanvas.drawCircle(cx, cy, radius, mPaint);
    }
}

@@ -1165,18 +1165,17 @@
 l Paint 
-mP
+p
 aint = n
@@ -1261,18 +1261,17 @@
  Canvas 
-mC
+c
 anvas;%0A%0A
@@ -1333,26 +1333,30 @@
 ) %7B%0A        
-mC
+this.c
 anvas = canv
@@ -1424,18 +1424,17 @@
  return 
-mP
+p
 aint;%0A  
@@ -1502,34 +1502,33 @@
 lter) %7B%0A        
-mP
+p
 aint.setColorFil
@@ -1739,34 +1739,33 @@
 ) %7B%0A        if (
-mC
+c
 anvas == null) %7B
@@ -1845,34 +1845,33 @@
       %7D%0A        
-mP
+p
 aint.setStrokeWi
@@ -1888,34 +1888,33 @@
 Width);%0A        
-mP
+p
 aint.setColor(co
@@ -1919,34 +1919,33 @@
 color);%0A        
-mC
+c
 anvas.drawLine(s
@@ -1973,18 +1973,17 @@
  stopY, 
-mP
+p
 aint);%0A 
@@ -2134,18 +2134,17 @@
     if (
-mC
+c
 anvas ==
@@ -2240,18 +2240,17 @@
         
-mP
+p
 aint.set
@@ -2275,10 +2275,9 @@
     
-mC
+c
 anva
@@ -2309,10 +2309,9 @@
 us, 
-mP
+p
 aint

Remove m prefixes