概述
package com.huangxudong.widget;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.view.View;
public class PaintCycle extends View {
private int cWidth;
private int cHeight;
private Path path = new Path();
private Path pathLeft = new Path();
private Path pathRight = new Path();
private Path pathTop = new Path();
private Path pathBottom = new Path();
private Paint fillPaint = new Paint();
private Paint sidePaint = new Paint();
private Paint pointPaint = new Paint();
public static PaintCycle INSTANCE;
int[] centerPX = new int[2];
private int offsetX;
private int offsetY;
private int moveX;
private int moveY;
public PaintCycle(Context context) {
super(context);
INSTANCE = this;
this.cWidth = (910 / 2);
this.cHeight = (603 / 2);
this.sidePaint.setColor(Color.argb(255, 0, 0, 0));
this.sidePaint.setStyle(Paint.Style.STROKE);
this.sidePaint.setStrokeWidth(1.0F);
this.sidePaint.setAntiAlias(true);
this.fillPaint.setColor(Color.argb(32, 0, 0, 0));
this.fillPaint.setStyle(Paint.Style.FILL);
this.fillPaint.setAntiAlias(true);
this.pointPaint.setColor(Color.argb(255, 237, 28, 36));
this.pointPaint.setStyle(Paint.Style.FILL);
this.pointPaint.setStrokeWidth(1.0F);
this.pointPaint.setAntiAlias(true);
move(0, 0);
}
public static PaintCycle getInstance() {
return INSTANCE;
}
public int[] getCenterPX() {
return this.centerPX;
}
protected void onDraw(Canvas canvas) {
canvas.drawPath(this.path, this.sidePaint);
canvas.drawPath(this.pathLeft, this.sidePaint);
canvas.drawPath(this.pathRight, this.sidePaint);
canvas.drawPath(this.pathTop, this.sidePaint);
canvas.drawPath(this.pathBottom, this.sidePaint);
canvas.drawPath(this.path, this.fillPaint);
this.centerPX[0] = (this.cWidth + this.moveX + this.offsetX);
this.centerPX[1] = (this.cHeight + this.moveY + this.offsetY);
canvas.drawCircle(this.centerPX[0], this.centerPX[1], 1.5F,
this.pointPaint);
}
public void move(int moveX, int moveY) {
this.moveX = moveX;
this.moveY = moveY;
this.path.reset();
this.path.moveTo(this.cWidth - 50 + moveX + this.offsetX, this.cHeight
- 50 + moveY + this.offsetY);
this.path.lineTo(this.cWidth + 50 + moveX + this.offsetX, this.cHeight
- 50 + moveY + this.offsetY);
this.path.lineTo(this.cWidth + 50 + moveX + this.offsetX, this.cHeight
+ 50 + moveY + this.offsetY);
this.path.lineTo(this.cWidth - 50 + moveX + this.offsetX, this.cHeight
+ 50 + moveY + this.offsetY);
this.path.close();
this.pathLeft.reset();
this.pathLeft.moveTo(this.cWidth - 70 + moveX + this.offsetX,
this.cHeight + moveY + this.offsetY);
this.pathLeft.lineTo(this.cWidth - 30 + moveX + this.offsetX,
this.cHeight + moveY + this.offsetY);
this.pathRight.reset();
this.pathRight.moveTo(this.cWidth + 70 + moveX + this.offsetX,
this.cHeight + moveY + this.offsetY);
this.pathRight.lineTo(this.cWidth + 30 + moveX + this.offsetX,
this.cHeight + moveY + this.offsetY);
this.pathTop.reset();
this.pathTop.moveTo(this.cWidth + moveX + this.offsetX, this.cHeight
- 70 + moveY + this.offsetY);
this.pathTop.lineTo(this.cWidth + moveX + this.offsetX, this.cHeight
- 30 + moveY + this.offsetY);
this.pathBottom.reset();
this.pathBottom.moveTo(this.cWidth + moveX + this.offsetX, this.cHeight
+ 70 + moveY + this.offsetY);
this.pathBottom.lineTo(this.cWidth + moveX + this.offsetX, this.cHeight
+ 30 + moveY + this.offsetY);
postInvalidate();
}
public void moveFinish() {
this.offsetX = (this.moveX + this.offsetX);
this.offsetY = (this.moveY + this.offsetY);
this.moveX = (this.moveY = 0);
}
}
最后
以上就是可靠香烟为你收集整理的android精确取点组件(实用地图上取点瞄准)的全部内容,希望文章能够帮你解决android精确取点组件(实用地图上取点瞄准)所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复