|
@@ -1,550 +0,0 @@
|
|
|
-package com.compdfkit.tools.common.views.pdfproperties.writing;
|
|
|
-
|
|
|
-/**
|
|
|
- * @classname:
|
|
|
- * @author: LiuXiaoLong
|
|
|
- * @date: 2023/5/24
|
|
|
- * description:
|
|
|
- */
|
|
|
-
|
|
|
-
|
|
|
-import android.graphics.Bitmap;
|
|
|
-import android.graphics.Bitmap.Config;
|
|
|
-import android.graphics.Canvas;
|
|
|
-import android.graphics.Color;
|
|
|
-import android.graphics.Paint;
|
|
|
-import android.graphics.Paint.Cap;
|
|
|
-import android.graphics.Paint.Join;
|
|
|
-import android.graphics.Paint.Style;
|
|
|
-import android.graphics.Path;
|
|
|
-import android.graphics.PointF;
|
|
|
-import android.graphics.PorterDuff.Mode;
|
|
|
-import android.graphics.PorterDuffXfermode;
|
|
|
-import android.graphics.RectF;
|
|
|
-
|
|
|
-import com.kdanmobile.handwriting.KMLineProcess;
|
|
|
-import com.kdanmobile.handwriting.LPPoint;
|
|
|
-
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Iterator;
|
|
|
-
|
|
|
-public class CKMHandWritingHelper {
|
|
|
- private static final String TAG = "KMHandwritingHelper";
|
|
|
- private KMLineProcess lineProcess;
|
|
|
- private LPPoint[] lpPoints;
|
|
|
- private Paint mPaint;
|
|
|
- private Paint erasePaint;
|
|
|
- private Bitmap mBitmap;
|
|
|
- private Canvas mCanvas;
|
|
|
- private int color;
|
|
|
- private float penWidth = 60.0F;
|
|
|
- private float eraseWidth = 60.0F;
|
|
|
- private float halfPenWidth = 30.0F;
|
|
|
- private LPPoint prePoint = null;
|
|
|
- private CKMHandWritingHelper.DrawMode drawMode;
|
|
|
- private CKMHandWritingHelper.DrawEffect drawEffect;
|
|
|
- private Path erasePath;
|
|
|
- private Path drawNormalTmpPath;
|
|
|
- private float oldX;
|
|
|
- private float oldY;
|
|
|
- private int canvasWidth;
|
|
|
- private int canvasHeight;
|
|
|
- private boolean isInited;
|
|
|
- private boolean isOnMoving;
|
|
|
- private ArrayList<Float[]> srcPoints;
|
|
|
- private ArrayList<Float[]> recoverPoints;
|
|
|
- private ArrayList<Float> tmpPoints;
|
|
|
- private int START;
|
|
|
- private RectF area;
|
|
|
-
|
|
|
- public CKMHandWritingHelper() {
|
|
|
- this.drawMode = CKMHandWritingHelper.DrawMode.DRAW;
|
|
|
- this.drawEffect = CKMHandWritingHelper.DrawEffect.PENSTROKE;
|
|
|
- this.isInited = false;
|
|
|
- this.isOnMoving = false;
|
|
|
- this.srcPoints = new ArrayList();
|
|
|
- this.recoverPoints = new ArrayList();
|
|
|
- this.tmpPoints = new ArrayList();
|
|
|
- this.START = 6;
|
|
|
- this.mPaint = new Paint();
|
|
|
- this.mPaint.setColor(-65536);
|
|
|
- this.color = -65536;
|
|
|
- this.mPaint.setStyle(Style.STROKE);
|
|
|
- this.mPaint.setStrokeCap(Cap.ROUND);
|
|
|
- this.mPaint.setStrokeJoin(Join.ROUND);
|
|
|
- this.mPaint.setAntiAlias(true);
|
|
|
- this.mPaint.setStrokeMiter(1.0F);
|
|
|
- this.mPaint.setXfermode(new PorterDuffXfermode(Mode.SRC));
|
|
|
- this.erasePaint = new Paint();
|
|
|
- this.erasePaint.setStyle(Style.STROKE);
|
|
|
- this.erasePaint.setStrokeCap(Cap.ROUND);
|
|
|
- this.erasePaint.setStrokeJoin(Join.ROUND);
|
|
|
- this.erasePaint.setAntiAlias(true);
|
|
|
- this.erasePaint.setStrokeMiter(1.0F);
|
|
|
- this.erasePaint.setXfermode(new PorterDuffXfermode(Mode.CLEAR));
|
|
|
- this.lineProcess = new KMLineProcess();
|
|
|
- this.lineProcess.setPenWidth(this.penWidth);
|
|
|
- this.erasePath = new Path();
|
|
|
- this.drawNormalTmpPath = new Path();
|
|
|
- }
|
|
|
-
|
|
|
- public void initCanvas(int width, int height) {
|
|
|
- if (width != 0 && height != 0) {
|
|
|
- this.canvasWidth = width;
|
|
|
- this.canvasHeight = height;
|
|
|
- this.mBitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
|
|
|
- this.mCanvas = new Canvas(this.mBitmap);
|
|
|
- this.mCanvas.drawColor(0);
|
|
|
- this.isInited = true;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public int getCanvasWidth() {
|
|
|
- return this.canvasWidth;
|
|
|
- }
|
|
|
-
|
|
|
- public int getCanvasHeight() {
|
|
|
- return this.canvasHeight;
|
|
|
- }
|
|
|
-
|
|
|
- public boolean isInited() {
|
|
|
- return this.isInited;
|
|
|
- }
|
|
|
-
|
|
|
- public void setPenWidth(float penWidth) {
|
|
|
- this.penWidth = penWidth;
|
|
|
- this.halfPenWidth = penWidth / 2.0F;
|
|
|
- this.lineProcess.setPenWidth(penWidth);
|
|
|
- }
|
|
|
-
|
|
|
- public void setEraseWidth(float eraseWidth) {
|
|
|
- this.eraseWidth = eraseWidth;
|
|
|
- }
|
|
|
-
|
|
|
- public void setDrawMode(CKMHandWritingHelper.DrawMode drawMode) {
|
|
|
- this.drawMode = drawMode;
|
|
|
- }
|
|
|
-
|
|
|
- public void setDrawEffect(CKMHandWritingHelper.DrawEffect drawEffect) {
|
|
|
- this.drawEffect = drawEffect;
|
|
|
- }
|
|
|
-
|
|
|
- public CKMHandWritingHelper.DrawMode getDrawMode() {
|
|
|
- return this.drawMode;
|
|
|
- }
|
|
|
-
|
|
|
- public void setColor(int color) {
|
|
|
- this.mPaint.setColor(color);
|
|
|
- this.color = this.color & -16777216 | color;
|
|
|
- }
|
|
|
-
|
|
|
- public void refreshSrcPointsColor(int color){
|
|
|
- if (srcPoints != null) {
|
|
|
- for (Float[] srcPoint : srcPoints) {
|
|
|
- srcPoint[2] = (float) Color.alpha(color);
|
|
|
- srcPoint[3] = (float) Color.red(color);
|
|
|
- srcPoint[4] = (float) Color.green(color);
|
|
|
- srcPoint[5] = (float) Color.blue(color);
|
|
|
- }
|
|
|
- reDrawBitmap();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public void refreshPenWidth(float penWidth){
|
|
|
- if (srcPoints != null) {
|
|
|
- for (Float[] srcPoint : srcPoints) {
|
|
|
- float currentPenWidth = srcPoint[1];
|
|
|
- if (currentPenWidth != -1F){
|
|
|
- srcPoint[1] = penWidth;
|
|
|
- }
|
|
|
- }
|
|
|
- reDrawBitmap();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public void setAlpha(int alpha) {
|
|
|
- this.mPaint.setAlpha(alpha);
|
|
|
- this.color = this.color & 16777215 | alpha << 24;
|
|
|
- }
|
|
|
-
|
|
|
- public void clean() {
|
|
|
- if (this.mCanvas != null) {
|
|
|
- this.mCanvas.drawColor(0, Mode.CLEAR);
|
|
|
- }
|
|
|
-
|
|
|
- if (this.mBitmap != null && !this.mBitmap.isRecycled()) {
|
|
|
- this.mBitmap.recycle();
|
|
|
- }
|
|
|
-
|
|
|
- this.mBitmap = null;
|
|
|
- this.isInited = false;
|
|
|
- this.area = null;
|
|
|
- this.srcPoints.clear();
|
|
|
- this.recoverPoints.clear();
|
|
|
- this.tmpPoints.clear();
|
|
|
- }
|
|
|
-
|
|
|
- public boolean onDown(float x, float y, float pressure, float altitude) {
|
|
|
- x = this.limitPoint(x, true);
|
|
|
- y = this.limitPoint(y, false);
|
|
|
- x = Math.max(0.0F, x);
|
|
|
- x = Math.min((float)this.canvasWidth, x);
|
|
|
- y = Math.max(0.0F, y);
|
|
|
- y = Math.min((float)this.canvasHeight, y);
|
|
|
- this.tmpPoints.clear();
|
|
|
- if (this.drawMode == CKMHandWritingHelper.DrawMode.DRAW) {
|
|
|
- this.lineProcess.onDown(x, y, pressure, altitude);
|
|
|
- this.tmpPoints.add(-1.0F);
|
|
|
- this.mPaint.setStrokeWidth(this.penWidth);
|
|
|
- this.drawNormalTmpPath.reset();
|
|
|
- if (this.drawEffect == CKMHandWritingHelper.DrawEffect.NORMAL) {
|
|
|
- this.tmpPoints.add(this.penWidth);
|
|
|
- this.tmpPoints.add((float)Color.alpha(this.color));
|
|
|
- this.tmpPoints.add((float)Color.red(this.color));
|
|
|
- this.tmpPoints.add((float)Color.green(this.color));
|
|
|
- this.tmpPoints.add((float)Color.blue(this.color));
|
|
|
- this.tmpPoints.add(x);
|
|
|
- this.tmpPoints.add(y);
|
|
|
- this.drawNormalTmpPath.moveTo(x, y);
|
|
|
- if (this.area == null) {
|
|
|
- this.area = new RectF(x - this.penWidth, y - this.penWidth, x + this.penWidth, y + this.penWidth);
|
|
|
- } else {
|
|
|
- this.area.union(x - this.penWidth, y - this.penWidth, x + this.penWidth, y + this.penWidth);
|
|
|
- }
|
|
|
- } else {
|
|
|
- this.tmpPoints.add(-1.0F);
|
|
|
- this.tmpPoints.add((float)Color.alpha(this.color));
|
|
|
- this.tmpPoints.add((float)Color.red(this.color));
|
|
|
- this.tmpPoints.add((float)Color.green(this.color));
|
|
|
- this.tmpPoints.add((float)Color.blue(this.color));
|
|
|
- }
|
|
|
-
|
|
|
- this.prePoint = new LPPoint(x, y, 0.0F);
|
|
|
- } else {
|
|
|
- this.erasePaint.setStrokeWidth(this.eraseWidth);
|
|
|
- this.erasePath.reset();
|
|
|
- this.erasePath.moveTo(x, y);
|
|
|
- this.oldX = x;
|
|
|
- this.oldY = y;
|
|
|
- this.tmpPoints.add(this.eraseWidth);
|
|
|
- this.tmpPoints.add(this.eraseWidth);
|
|
|
- this.tmpPoints.add(x);
|
|
|
- this.tmpPoints.add(y);
|
|
|
- }
|
|
|
-
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- public boolean onMove(float x, float y, float pressure, float altitude) {
|
|
|
- x = this.limitPoint(x, true);
|
|
|
- y = this.limitPoint(y, false);
|
|
|
- x = Math.max(0.0F, x);
|
|
|
- x = Math.min((float)this.canvasWidth, x);
|
|
|
- y = Math.max(0.0F, y);
|
|
|
- y = Math.min((float)this.canvasHeight, y);
|
|
|
- if (this.drawMode == CKMHandWritingHelper.DrawMode.DRAW) {
|
|
|
- if (this.drawEffect == CKMHandWritingHelper.DrawEffect.PENSTROKE) {
|
|
|
- this.lpPoints = this.lineProcess.onMove(x, y, pressure, altitude);
|
|
|
- if (this.lpPoints != null && this.lpPoints.length > 0) {
|
|
|
- LPPoint[] var5 = this.lpPoints;
|
|
|
- int var6 = var5.length;
|
|
|
-
|
|
|
- for(int var7 = 0; var7 < var6; ++var7) {
|
|
|
- LPPoint point = var5[var7];
|
|
|
- if (point != null) {
|
|
|
- this.mPaint.setStrokeWidth(point.size);
|
|
|
- if (this.mCanvas != null) {
|
|
|
- this.mCanvas.drawLine(this.prePoint.x, this.prePoint.y, point.x, point.y, this.mPaint);
|
|
|
- }
|
|
|
-
|
|
|
- this.prePoint = point;
|
|
|
- if (this.area == null) {
|
|
|
- this.area = new RectF(point.x - point.size, point.y - point.size, point.x + point.size, point.y + point.size);
|
|
|
- } else {
|
|
|
- this.area.union(point.x - point.size, point.y - point.size, point.x + point.size, point.y + point.size);
|
|
|
- }
|
|
|
-
|
|
|
- this.tmpPoints.add(point.x);
|
|
|
- this.tmpPoints.add(point.y);
|
|
|
- this.tmpPoints.add(point.size);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- this.isOnMoving = true;
|
|
|
- return true;
|
|
|
- } else {
|
|
|
- return false;
|
|
|
- }
|
|
|
- } else {
|
|
|
- this.drawNormalTmpPath.quadTo(this.prePoint.x, this.prePoint.y, (this.prePoint.x + x) / 2.0F, (this.prePoint.y + y) / 2.0F);
|
|
|
- this.prePoint.x = x;
|
|
|
- this.prePoint.y = y;
|
|
|
- if (this.mCanvas != null) {
|
|
|
- this.mCanvas.drawPath(this.drawNormalTmpPath, this.mPaint);
|
|
|
- }
|
|
|
-
|
|
|
- this.tmpPoints.add(x);
|
|
|
- this.tmpPoints.add(y);
|
|
|
- if (this.area == null) {
|
|
|
- this.area = new RectF(x - this.penWidth, y - this.penWidth, x + this.penWidth, y + this.penWidth);
|
|
|
- } else {
|
|
|
- this.area.union(x - this.penWidth, y - this.penWidth, x + this.penWidth, y + this.penWidth);
|
|
|
- }
|
|
|
-
|
|
|
- this.isOnMoving = true;
|
|
|
- return true;
|
|
|
- }
|
|
|
- } else {
|
|
|
- this.erasePath.quadTo(this.oldX, this.oldY, (this.oldX + x) / 2.0F, (this.oldY + y) / 2.0F);
|
|
|
- this.oldX = x;
|
|
|
- this.oldY = y;
|
|
|
- this.tmpPoints.add(x);
|
|
|
- this.tmpPoints.add(y);
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public boolean onUp(float x, float y, float pressure, float altitude) {
|
|
|
- this.isOnMoving = false;
|
|
|
- x = Math.max(0.0F, x);
|
|
|
- x = Math.min((float)this.canvasWidth, x);
|
|
|
- y = Math.max(0.0F, y);
|
|
|
- y = Math.min((float)this.canvasHeight, y);
|
|
|
- if (this.drawMode == CKMHandWritingHelper.DrawMode.DRAW) {
|
|
|
- if (this.drawEffect == CKMHandWritingHelper.DrawEffect.PENSTROKE) {
|
|
|
- this.lpPoints = this.lineProcess.onUp(x, y, pressure, altitude);
|
|
|
- if (this.lpPoints != null && this.lpPoints.length > 0) {
|
|
|
- LPPoint[] var5 = this.lpPoints;
|
|
|
- int var6 = var5.length;
|
|
|
-
|
|
|
- for(int var7 = 0; var7 < var6; ++var7) {
|
|
|
- LPPoint point = var5[var7];
|
|
|
- if (point != null) {
|
|
|
- this.mPaint.setStrokeWidth(point.size);
|
|
|
- if (this.mCanvas != null) {
|
|
|
- this.mCanvas.drawLine(this.prePoint.x, this.prePoint.y, point.x, point.y, this.mPaint);
|
|
|
- }
|
|
|
-
|
|
|
- this.prePoint = point;
|
|
|
- if (this.area == null) {
|
|
|
- this.area = new RectF(point.x - point.size, point.y - point.size, point.x + point.size, point.y + point.size);
|
|
|
- } else {
|
|
|
- this.area.union(point.x - point.size, point.y - point.size, point.x + point.size, point.y + point.size);
|
|
|
- }
|
|
|
-
|
|
|
- this.tmpPoints.add(point.x);
|
|
|
- this.tmpPoints.add(point.y);
|
|
|
- this.tmpPoints.add(point.size);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- this.addSrcPoints(this.tmpPoints);
|
|
|
- return true;
|
|
|
- } else {
|
|
|
- return false;
|
|
|
- }
|
|
|
- } else {
|
|
|
- this.drawNormalTmpPath.lineTo(x, y);
|
|
|
- if (this.mCanvas != null) {
|
|
|
- this.mCanvas.drawPath(this.drawNormalTmpPath, this.mPaint);
|
|
|
- }
|
|
|
-
|
|
|
- this.tmpPoints.add(x);
|
|
|
- this.tmpPoints.add(y);
|
|
|
- this.addSrcPoints(this.tmpPoints);
|
|
|
- if (this.area == null) {
|
|
|
- this.area = new RectF(x - this.penWidth, y - this.penWidth, x + this.penWidth, y + this.penWidth);
|
|
|
- } else {
|
|
|
- this.area.union(x - this.penWidth, y - this.penWidth, x + this.penWidth, y + this.penWidth);
|
|
|
- }
|
|
|
-
|
|
|
- return true;
|
|
|
- }
|
|
|
- } else {
|
|
|
- this.erasePath.lineTo(x, y);
|
|
|
- if (this.mCanvas != null) {
|
|
|
- this.mCanvas.drawPath(this.erasePath, this.erasePaint);
|
|
|
- }
|
|
|
-
|
|
|
- this.erasePath.reset();
|
|
|
- this.tmpPoints.add(x);
|
|
|
- this.tmpPoints.add(y);
|
|
|
- this.addSrcPoints(this.tmpPoints);
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public void onUndo() {
|
|
|
- int len = this.srcPoints.size();
|
|
|
- if (len > 0) {
|
|
|
- Float[] undoPoints = (Float[])this.srcPoints.remove(len - 1);
|
|
|
- this.recoverPoints.add(undoPoints);
|
|
|
- this.reDrawBitmap();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public void onRedo() {
|
|
|
- int len = this.recoverPoints.size();
|
|
|
- if (len > 0) {
|
|
|
- Float[] redoPoints = (Float[])this.recoverPoints.remove(len - 1);
|
|
|
- this.srcPoints.add(redoPoints);
|
|
|
- this.reDrawBitmap();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public void onMisTouch() {
|
|
|
- if (this.isOnMoving) {
|
|
|
- this.addSrcPoints(this.tmpPoints);
|
|
|
- int len = this.srcPoints.size();
|
|
|
- if (len <= 0) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- this.srcPoints.remove(len - 1);
|
|
|
- this.reDrawBitmap();
|
|
|
- }
|
|
|
-
|
|
|
- this.isOnMoving = false;
|
|
|
- }
|
|
|
-
|
|
|
- public Path getErasePath() {
|
|
|
- return this.erasePath;
|
|
|
- }
|
|
|
-
|
|
|
- public RectF getArea() {
|
|
|
- RectF resRect = new RectF(this.area);
|
|
|
- resRect.intersect(0.0F, 0.0F, (float)this.canvasWidth, (float)this.canvasHeight);
|
|
|
- return resRect;
|
|
|
- }
|
|
|
-
|
|
|
- public Bitmap getBitmap() {
|
|
|
- return this.mBitmap;
|
|
|
- }
|
|
|
-
|
|
|
- private float limitPoint(float point, Boolean isXCoordinate) {
|
|
|
- int canvasWidth = this.mCanvas.getWidth();
|
|
|
- int canvasHeight = this.mCanvas.getHeight();
|
|
|
- if (point < this.halfPenWidth) {
|
|
|
- point = this.halfPenWidth;
|
|
|
- }
|
|
|
-
|
|
|
- float maxRight;
|
|
|
- if (isXCoordinate) {
|
|
|
- maxRight = (float)canvasWidth - this.halfPenWidth;
|
|
|
- if (point > maxRight) {
|
|
|
- point = maxRight;
|
|
|
- }
|
|
|
- } else {
|
|
|
- maxRight = (float)canvasHeight - this.halfPenWidth;
|
|
|
- if (point > maxRight) {
|
|
|
- point = maxRight;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return point;
|
|
|
- }
|
|
|
-
|
|
|
- private void addSrcPoints(ArrayList<Float> points) {
|
|
|
- Float[] fpoints = new Float[points.size()];
|
|
|
- points.toArray(fpoints);
|
|
|
- this.srcPoints.add(fpoints);
|
|
|
- this.recoverPoints.clear();
|
|
|
- points.clear();
|
|
|
- }
|
|
|
-
|
|
|
- private void reDrawBitmap() {
|
|
|
- if (this.mCanvas != null) {
|
|
|
- this.mCanvas.drawColor(0, Mode.CLEAR);
|
|
|
- }
|
|
|
-
|
|
|
- Iterator var1 = this.srcPoints.iterator();
|
|
|
-
|
|
|
- while(true) {
|
|
|
- while(true) {
|
|
|
- while(true) {
|
|
|
- Float[] line;
|
|
|
- do {
|
|
|
- if (!var1.hasNext()) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- line = (Float[])var1.next();
|
|
|
- } while(line.length <= 2);
|
|
|
-
|
|
|
- if (line[0] < 0.0F) {
|
|
|
- PointF prePoint = null;
|
|
|
- Float alpha = line[2];
|
|
|
- Float red = line[3];
|
|
|
- Float green = line[4];
|
|
|
- Float blue = line[5];
|
|
|
- this.mPaint.setColor(Color.argb(alpha.intValue(), red.intValue(), green.intValue(), blue.intValue()));
|
|
|
- if (line[1] < 0.0F) {
|
|
|
- for(int i = 0; i < (line.length - this.START) / 3; ++i) {
|
|
|
- if (prePoint != null) {
|
|
|
- this.mPaint.setStrokeWidth(line[i * 3 + this.START + 2]);
|
|
|
- if (this.mCanvas != null) {
|
|
|
- this.mCanvas.drawLine(prePoint.x, prePoint.y, line[i * 3 + this.START], line[i * 3 + this.START + 1], this.mPaint);
|
|
|
- }
|
|
|
-
|
|
|
- prePoint.set(line[i * 3 + this.START], line[i * 3 + this.START + 1]);
|
|
|
- } else {
|
|
|
- prePoint = new PointF(line[i * 3 + this.START], line[i * 3 + this.START + 1]);
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- Path path = new Path();
|
|
|
-
|
|
|
- for(int i = 0; i < (line.length - this.START) / 2; ++i) {
|
|
|
- if (i == 0) {
|
|
|
- path.moveTo(line[i * 2 + this.START], line[i * 2 + this.START + 1]);
|
|
|
- } else if (i < (line.length - this.START) / 2 - 1) {
|
|
|
- path.quadTo(line[i * 2 + this.START - 2], line[i * 2 + this.START - 1], (line[i * 2 + this.START - 2] + line[i * 2 + this.START]) / 2.0F, (line[i * 2 + this.START - 1] + line[i * 2 + this.START + 1]) / 2.0F);
|
|
|
- } else {
|
|
|
- path.lineTo(line[i * 2 + this.START], line[i * 2 + this.START + 1]);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- this.mPaint.setStrokeWidth(line[1]);
|
|
|
- if (this.mCanvas != null) {
|
|
|
- this.mCanvas.drawPath(path, this.mPaint);
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- Path path = new Path();
|
|
|
-
|
|
|
- for(int i = 0; i < (line.length - 2) / 2; ++i) {
|
|
|
- if (i == 0) {
|
|
|
- path.moveTo(line[i * 2 + 2], line[i * 2 + 3]);
|
|
|
- } else if (i < (line.length - 2) / 2 - 1) {
|
|
|
- path.quadTo(line[i * 2], line[i * 2 + 1], (line[i * 2] + line[i * 2 + 2]) / 2.0F, (line[i * 2 + 1] + line[i * 2 + 3]) / 2.0F);
|
|
|
- } else {
|
|
|
- path.lineTo(line[i * 2 + 2], line[i * 2 + 3]);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- this.erasePaint.setStrokeWidth(line[0]);
|
|
|
- if (this.mCanvas != null) {
|
|
|
- this.mCanvas.drawPath(path, this.erasePaint);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public static enum DrawEffect {
|
|
|
- NORMAL,
|
|
|
- PENSTROKE;
|
|
|
-
|
|
|
- private DrawEffect() {
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public static enum DrawMode {
|
|
|
- DRAW,
|
|
|
- ERASE;
|
|
|
-
|
|
|
- private DrawMode() {
|
|
|
- }
|
|
|
- }
|
|
|
-}
|