From be7bfed74b44def0c37d5a94d52d2c30ccf69b52 Mon Sep 17 00:00:00 2001 From: Paul Gardiner Date: Thu, 2 Jan 2014 14:29:39 +0000 Subject: Bug 694732: Android: draw single point strokes when inking Make single-point strokes display by special casing them as circles. Thanks for Michael Cadilhac for the suggestion. --- .../src/com/artifex/mupdfdemo/PageView.java | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'platform/android/src') diff --git a/platform/android/src/com/artifex/mupdfdemo/PageView.java b/platform/android/src/com/artifex/mupdfdemo/PageView.java index d835016f..b7ef580d 100644 --- a/platform/android/src/com/artifex/mupdfdemo/PageView.java +++ b/platform/android/src/com/artifex/mupdfdemo/PageView.java @@ -366,6 +366,16 @@ public abstract class PageView extends ViewGroup { if (mDrawing != null) { Path path = new Path(); PointF p; + + paint.setAntiAlias(true); + paint.setDither(true); + paint.setStrokeJoin(Paint.Join.ROUND); + paint.setStrokeCap(Paint.Cap.ROUND); + + paint.setStyle(Paint.Style.FILL); + paint.setStrokeWidth(INK_THICKNESS * scale); + paint.setColor(INK_COLOR); + Iterator> it = mDrawing.iterator(); while (it.hasNext()) { ArrayList arc = it.next(); @@ -384,18 +394,13 @@ public abstract class PageView extends ViewGroup { mY = y; } path.lineTo(mX, mY); + } else { + p = arc.get(0); + canvas.drawCircle(p.x * scale, p.y * scale, INK_THICKNESS * scale / 2, paint); } } - paint.setAntiAlias(true); - paint.setDither(true); - paint.setStrokeJoin(Paint.Join.ROUND); - paint.setStrokeCap(Paint.Cap.ROUND); - paint.setStyle(Paint.Style.STROKE); - paint.setStrokeWidth(INK_THICKNESS * scale); - paint.setColor(INK_COLOR); - canvas.drawPath(path, paint); } } @@ -464,6 +469,7 @@ public abstract class PageView extends ViewGroup { ArrayList arc = new ArrayList(); arc.add(new PointF(docRelX, docRelY)); mDrawing.add(arc); + mSearchView.invalidate(); } public void continueDraw(float x, float y) { -- cgit v1.2.3