public EraserTool(Context context, ToolType toolType) { super(context, toolType); mPreviousPaint = new Paint(PaintroidApplication.currentTool.getDrawPaint()); changePaintColor(Color.TRANSPARENT); mCanvasPaint.setStrokeCap(mPreviousPaint.getStrokeCap()); mCanvasPaint.setStrokeWidth(mPreviousPaint.getStrokeWidth()); }
/** * Determine the minimum sweep angle that should be allowed for the current settings. If the sweep * is 360 a complete circle is drawn, if the sweep is 0 nothing is drawn. In some states even if * the data is say 0 out of 100 and mathematically the sweep angle is 0 we want to draw a point * anyway which is why this function exists * * @return minimum number of degrees allowed in the current state */ protected float getMinSweepAngle() { if (!mSeriesItem.showPointWhenEmpty()) { return MIN_SWEEP_ANGLE_NONE; } if (mSeriesItem.getChartStyle() == SeriesItem.ChartStyle.STYLE_PIE) { return MIN_SWEEP_ANGLE_PIE; } if (mPaint.getStrokeCap() == Paint.Cap.ROUND) { return MIN_SWEEP_ANGLE; } return MIN_SWEEP_ANGLE_FLAT; }
/** * @param canvas * @param ctx */ private void drawDrawing(Canvas canvas, DrawingContext ctx) { /* * Get draw points. */ // Blue inside, black outside Paint.Cap oldCaps = mPaint.getStrokeCap(); mPaint.setStrokeCap( Paint.Cap.ROUND); // We use a wide line. Without ROUND the line looks broken. mPaint.setColor(Color.BLACK); mPaint.setStrokeWidth(6 * mDipToPix); mService.getDraw().drawShape(canvas, mPaint, mOrigin); mPaint.setColor(Color.BLUE); mPaint.setStrokeWidth(2 * mDipToPix); mService.getDraw().drawShape(canvas, mPaint, mOrigin); mPaint.setStrokeCap(oldCaps); // Restore the Cap we had before drawing }