目录
0、相关文章:
参考文章:
1、MoveAndCropRectView.java
public class MoveAndCropRectView extends View {
// 绘制 损害框和损害名称
private Paint mPaint;
private RectF mRectF;
// 边缘字体
private BorderedText mBorderedText;
// 标题 或 名字
private String mTitle;
// 概率
private float mConfidence;
// 矩形框 corner 的角度:直角、圆角
private int mCornerAngle;
//直角 默认
public static final int RIGHT_CORNER = 0;
//圆角
public static final int ROUND_CORNER = 1;
// Remove Rect
private int MODE;
private static final int MODE_OUTSIDE = 0x000000aa;/*170*/
private static final int MODE_INSIDE = 0x000000bb;/*187*/
private static final int MODE_POINT = 0X000000cc;/*204*/
private static final int MODE_ILLEGAL = 0X000000dd;/*221*/
private float startX;/*start X location*/
private float startY;/*start Y location*/
private float endX;/*end X location*/
private float endY;/*end Y location*/
private float currentX;/*X coordinate values while finger press*/
private float currentY;/*Y coordinate values while finger press*/
private float memoryX;/*the last time the coordinate values of X*/
private float memoryY;/*the last time the coordinate values of Y*/
private float mCoverWidth;/*width of selection box*/
private float mCoverHeight;/*height of selection box*/
private static final int ACCURACY = 100;/*touch accuracy*/
private int pointPosition;/*vertex of a rectangle*/
private static final float minWidth = 100.0f;/*the minimum width of the rectangle*/
private static final float minHeight = 200.0f;/*the minimum height of the rectangle*/
private onLocationListener mLocationListener;/*listen to the Rect */
private static final float EDGE_WIDTH = 1.8f;
public MoveAndCropRectView(Context context) {
this(context, null);
}
public MoveAndCropRectView(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
public MoveAndCropRectView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initDatas(context);
}
private void initDatas(Context context) {
mPaint = new Paint();
mRectF = new RectF();
//画笔设置空心
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setColor(Color.RED);
mPaint.setStrokeWidth(5);
mPaint.setAntiAlias(true);
float textSizePx = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
18.0f, context.getResources().getDisplayMetrics());
mBorderedText = new BorderedText(textSizePx);
currentX = 0;
currentY = 0;
}
p