|
@@ -5,8 +5,8 @@ import android.graphics.Canvas;
|
|
|
import android.graphics.Color;
|
|
|
import android.graphics.DashPathEffect;
|
|
|
import android.graphics.Paint;
|
|
|
-import android.graphics.Path;
|
|
|
import android.graphics.Rect;
|
|
|
+import android.graphics.RectF;
|
|
|
import android.util.AttributeSet;
|
|
|
import android.view.View;
|
|
|
|
|
@@ -89,9 +89,16 @@ public class CAnnotShapePreviewView extends CBasicAnnotPreviewView {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void setDashedSpace(int dashedSpace) {
|
|
|
+ public void setDashedGsp(int dashedGap) {
|
|
|
if (shapeView != null) {
|
|
|
- shapeView.setDashGap(dashedSpace);
|
|
|
+ shapeView.setDashGap(dashedGap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void setShapeType(CShapeView.ShapeType shapeType){
|
|
|
+ if (shapeView != null){
|
|
|
+ shapeView.setShapeType(shapeType);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -99,7 +106,7 @@ public class CAnnotShapePreviewView extends CBasicAnnotPreviewView {
|
|
|
|
|
|
enum ShapeType {
|
|
|
SQUARE,
|
|
|
- OVAL,
|
|
|
+ CIRCLE,
|
|
|
LINE,
|
|
|
ARROW,
|
|
|
}
|
|
@@ -121,14 +128,16 @@ public class CAnnotShapePreviewView extends CBasicAnnotPreviewView {
|
|
|
|
|
|
private int borderWidth = 0;
|
|
|
|
|
|
- private Rect squareRect = new Rect();
|
|
|
+ private RectF borderRectF = new RectF();
|
|
|
|
|
|
- private Rect fillSquareRect = new Rect();
|
|
|
+ private RectF fillRectF = new RectF();
|
|
|
|
|
|
private int mDashWidth = 8;
|
|
|
|
|
|
private int mDashGap = 0;
|
|
|
|
|
|
+ private Rect sizeRect = new Rect();
|
|
|
+
|
|
|
public CShapeView(Context context) {
|
|
|
this(context, null);
|
|
|
}
|
|
@@ -206,7 +215,10 @@ public class CAnnotShapePreviewView extends CBasicAnnotPreviewView {
|
|
|
invalidate();
|
|
|
}
|
|
|
|
|
|
- private Rect sizeRect = new Rect();
|
|
|
+ public void setShapeType(ShapeType shapeType) {
|
|
|
+ this.shapeType = shapeType;
|
|
|
+ invalidate();
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
protected void onDraw(Canvas canvas) {
|
|
@@ -221,14 +233,31 @@ public class CAnnotShapePreviewView extends CBasicAnnotPreviewView {
|
|
|
(int) (left + width),
|
|
|
getHeight());
|
|
|
|
|
|
- fillSquareRect.set(sizeRect.left + borderWidth, sizeRect.top + borderWidth, sizeRect.right - borderWidth, sizeRect.bottom - borderWidth);
|
|
|
- canvas.drawRect(fillSquareRect, fillPaint);
|
|
|
+ fillRectF.set(sizeRect.left + borderWidth, sizeRect.top + borderWidth, sizeRect.right - borderWidth, sizeRect.bottom - borderWidth);
|
|
|
+ canvas.drawRect(fillRectF, fillPaint);
|
|
|
+
|
|
|
+ borderRectF.set(fillRectF.left - (borderWidth / 2F),
|
|
|
+ fillRectF.top - (borderWidth / 2F),
|
|
|
+ fillRectF.right + (borderWidth / 2F),
|
|
|
+ fillRectF.bottom + (borderWidth / 2F));
|
|
|
+ canvas.drawRect(borderRectF, borderPaint);
|
|
|
+ break;
|
|
|
+
|
|
|
+ case CIRCLE:
|
|
|
+ float circleWidth = getHeight();
|
|
|
+ float circleLeft = (float) getWidth() / 2F - (circleWidth / 2);
|
|
|
+ sizeRect.set((int) circleLeft,
|
|
|
+ 0,
|
|
|
+ (int) (circleLeft + circleWidth),
|
|
|
+ getHeight());
|
|
|
+ fillRectF.set(sizeRect.left + borderWidth, sizeRect.top + borderWidth, sizeRect.right - borderWidth, sizeRect.bottom - borderWidth);
|
|
|
+ canvas.drawOval(fillRectF, fillPaint);
|
|
|
+ borderRectF.set(fillRectF.left - (borderWidth / 2F),
|
|
|
+ fillRectF.top - (borderWidth / 2F),
|
|
|
+ fillRectF.right + (borderWidth / 2F),
|
|
|
+ fillRectF.bottom + (borderWidth / 2F));
|
|
|
+ canvas.drawOval(borderRectF, borderPaint);
|
|
|
|
|
|
- squareRect.set(fillSquareRect.left - (borderWidth / 2),
|
|
|
- fillSquareRect.top - (borderWidth / 2),
|
|
|
- fillSquareRect.right + (borderWidth / 2),
|
|
|
- fillSquareRect.bottom + (borderWidth / 2));
|
|
|
- canvas.drawRect(squareRect, borderPaint);
|
|
|
break;
|
|
|
default:
|
|
|
break;
|