package com.chaoran.component;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.View;

public class AntLine extends View {
	private Paint mPaint;  
	private int color;
	private int size=6;
	public int getSize() {
		return size;
	}
	public void setSize(int size) {
		this.size = size;
	}
	public AntLine(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
		init();
	}
	public AntLine(Context context, AttributeSet attrs) {
		super(context, attrs);
		init();
	}
	private void init(){
		color=Color.GREEN;
		mPaint = new Paint();        
		mPaint.setStyle(Paint.Style.STROKE);  
//		mPaint.setStrokeWidth(6);
//		mPaint.setColor(Color.RED);
	}
    @Override
    protected void onDraw(Canvas canvas) {
    	super.onDraw(canvas);
    	mPaint.setColor(color); 
    	mPaint.setStrokeWidth(size);
    	int wz=size/2;//计算画笔离边的宽度
    	Rect r=new Rect(wz,wz, this.getWidth()-wz,this.getHeight()-wz);
    	canvas.drawRect(r, mPaint);
    }
    public int getColor() {
		return color;
	}
	public void setColor(int color) {
		this.color = color;
	}
}
