Code example for Paint

Methods: setAntiAlias, setColor, setStrokeWidth, setStyle

0
    private ArrayList<Slice> mSlices = Lists.newArrayList();
 
    private int mOriginAngle;
    private Matrix mMatrix = new Matrix();
 
    private Paint mPaintOutline = new Paint();
 
    private Path mPathSide = new Path();
    private Path mPathSideOutline = new Path();
 
    private Path mPathOutline = new Path();
 
    private int mSideWidth;
 
    public class Slice { 
        public long value;
 
        public Path path = new Path();
        public Path pathSide = new Path();
        public Path pathOutline = new Path();
 
        public Paint paint;
 
        public Slice(long value, int color) {
            this.value = value;
            this.paint = buildFillPaint(color, getResources());
        } 
    } 
 
    public PieChartView(Context context) {
        this(context, null);
    } 
 
    public PieChartView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    } 
 
    public PieChartView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
 
        mPaintOutline.setColor(Color.BLACK);
        mPaintOutline.setStyle(Style.STROKE);
        mPaintOutline.setStrokeWidth(3f * getResources().getDisplayMetrics().density);
        mPaintOutline.setAntiAlias(true);
 
        mSideWidth = (int) (20 * getResources().getDisplayMetrics().density);
 
        setWillNotDraw(false);
    }