private void drawCircle(Canvas canvas) {
Paint textPaint = new Paint();
textPaint.setColor(this.mCircleWhite);
textPaint.setAntiAlias(true);
textPaint.setTextSize(getResources().getDimension(R.dimen.out_indicator_size));
float textHeight = (float) ViewUtils.getTextHeight(textPaint);
float perAngle = 270.0f / (this.mEndIndicator - this.mStartIndicator);
int radius = (int) (((float) getViewRadius()) - (2.6f * ((float) this.mDividerWidth)));
FontMetricsInt fmi = textPaint.getFontMetricsInt();
float textRadius = (float) (radius - (Math.abs(fmi.bottom + fmi.top) / 2));
RectF oval = new RectF((float) (getCenterX() - radius), (float) (getCenterY() - radius),
(float) (getCenterX() + radius), (float) (getCenterY() + radius));
Path path = new Path();
path.addCircle((float) getCenterX(), (float) getCenterY(), textRadius, Direction.CW);
Paint circlePaint = new Paint();
circlePaint.setAntiAlias(true);
circlePaint.setStrokeWidth(16.0f + textHeight);
circlePaint.setStyle(Style.STROKE);
if (this.mDividerIndicator.size() == 0) {
circlePaint.setStrokeCap(Cap.ROUND);
circlePaint.setColor(this.mCircleGray);
canvas.drawArc(oval, 135.0f, 270.0f, false, circlePaint);
return;
}
circlePaint.setStrokeCap(Cap.ROUND);
drawCircleContent(canvas, (IndicatorItem) this.mDividerIndicator.get(0), oval, perAngle,
textRadius, path, textPaint, circlePaint);
Canvas canvas2 = canvas;
drawCircleContent(canvas2, (IndicatorItem) this.mDividerIndicator.get(this
.mDividerIndicator.size() - 1), oval, perAngle, textRadius, path, textPaint,
circlePaint);
circlePaint.setStrokeCap(Cap.BUTT);
for (int i = 1; i < this.mDividerIndicator.size() - 1; i++) {
drawCircleContent(canvas, (IndicatorItem) this.mDividerIndicator.get(i), oval,
perAngle, textRadius, path, textPaint, circlePaint);
}
}
java类android.graphics.Path.Direction的实例源码
CircleIndicator.java 文件源码
项目:boohee_v5.6
阅读 33
收藏 0
点赞 0
评论 0
BubbleRelativeLayout.java 文件源码
项目:BubblePopupWindow
阅读 16
收藏 0
点赞 0
评论 0
@Override
protected void onDraw(Canvas canvas) {
final float width = canvas.getWidth();
final float height = canvas.getHeight();
mPath.rewind();
mPath.addRoundRect(new RectF(PADDING, PADDING, width - PADDING, height - PADDING), CORNER_RADIUS, CORNER_RADIUS, Direction.CW);
mPath.addPath(mBubbleLegPrototype, renderBubbleLegMatrix(width, height));
canvas.drawPath(mPath, mPaint);
canvas.scale((width - STROKE_WIDTH) / width, (height - STROKE_WIDTH) / height, width / 2f, height / 2f);
canvas.drawPath(mPath, mFillPaint);
}
BulletSpan.java 文件源码
项目:memoir
阅读 15
收藏 0
点赞 0
评论 0
private void draw(Canvas c, Paint p, int x, int dir, int top, int bottom, int size) {
sBulletPath.reset();
sBulletPath.addCircle(0.0f, 0.0f, size, Direction.CW);
c.save();
c.translate(x + dir * size, (top + bottom) / 2.0f);
c.drawPath(sBulletPath, p);
c.restore();
}
BulletSpan.java 文件源码
项目:memoir
阅读 16
收藏 0
点赞 0
评论 0
private void draw(Canvas c, Paint p, int x, int dir, int top, int bottom, int size) {
sBulletPath.reset();
sBulletPath.addCircle(0.0f, 0.0f, size, Direction.CW);
c.save();
c.translate(x + dir * size, (top + bottom) / 2.0f);
c.drawPath(sBulletPath, p);
c.restore();
}
FolderIconCreater.java 文件源码
项目:PowerToggles
阅读 16
收藏 0
点赞 0
评论 0
public FolderIconCreater(Context c) {
mRes = c.getResources();
mSize = BitmapUtils.getActivityIconSize(c);
mIconSize = mSize * 3 / 5;
mRoundRect = new Path();
float gap = (mSize - mIconSize) * 0.25f;
mRoundRect.addRoundRect(new RectF(gap, gap, mSize - gap, mSize - gap), gap / 2, gap / 2, Direction.CW);
// Init variables
// cos(45) = 0.707 + ~= 0.1) = 0.8f
mBaselineIconScale = (1 + 0.8f) / (2 * (1 + PERSPECTIVE_SHIFT_FACTOR));
mBaselineIconSize = (int) (mSize * mBaselineIconScale);
mMaxPerspectiveShift = mBaselineIconSize * PERSPECTIVE_SHIFT_FACTOR;
}
CircularRevealHelper.java 文件源码
项目:material-components-android
阅读 23
收藏 0
点赞 0
评论 0
private void invalidateRevealInfo() {
if (STRATEGY == CLIP_PATH) {
revealPath.rewind();
if (revealInfo != null) {
revealPath.addCircle(
revealInfo.centerX, revealInfo.centerY, revealInfo.radius, Direction.CW);
}
}
view.invalidate();
}
XYChart.java 文件源码
项目:iOffice
阅读 31
收藏 0
点赞 0
评论 0
protected void drawSeriesBackgroundAndFrame(XYMultipleSeriesRenderer renderer, Canvas canvas, Rect rect, Paint paint)
{
int alpha = paint.getAlpha();
Path path = new Path();
path.addRect((float)rect.left, (float)rect.top, (float)rect.right, (float)rect.bottom, Direction.CCW);
// draw fill
BackgroundAndFill fill = renderer.getSeriesBackgroundColor();
if (fill != null)
{
paint.setStyle(Style.FILL);
BackgroundDrawer.drawPathBackground(canvas, null, 1, fill, rect, null, 1.0f, path, paint);
paint.setAlpha(alpha);
}
// draw border
Line frame = renderer.getSeriesFrame();
if (frame != null)
{
paint.setStyle(Style.STROKE);
paint.setStrokeWidth(2);
if(frame.isDash())
{
DashPathEffect dashPathEffect = new DashPathEffect(new float[] {5, 5}, 10);
paint.setPathEffect(dashPathEffect);
}
BackgroundDrawer.drawPathBackground(canvas, null, 1, frame.getBackgroundAndFill(), rect, null, 1.0f, path, paint);
paint.setStyle(Style.FILL);
paint.setAlpha(alpha);
}
paint.reset();
paint.setAntiAlias(true);
}
AbstractChart.java 文件源码
项目:iOffice
阅读 26
收藏 0
点赞 0
评论 0
/**
* Draws the chart background.
*
* @param renderer the chart renderer
* @param canvas the canvas to paint to
* @param x the top left x value of the view to draw to
* @param y the top left y value of the view to draw to
* @param width the width of the view to draw to
* @param height the height of the view to draw to
* @param paint the paint used for drawing
* @param newColor if a new color is to be used
* @param color the color to be used
*/
protected void drawBackgroundAndFrame(DefaultRenderer renderer, Canvas canvas, IControl control, Rect rect, Paint paint)
{
int alpha = paint.getAlpha();
Path path = new Path();
path.addRect((float)rect.left, (float)rect.top, (float)rect.right, (float)rect.bottom, Direction.CCW);
// draw fill
BackgroundAndFill fill = renderer.getBackgroundAndFill();
if (fill != null)
{
paint.setStyle(Style.FILL);
BackgroundDrawer.drawPathBackground(canvas, control, 1, fill, rect, null, 1.0f, path, paint);
paint.setAlpha(alpha);
}
// draw border
Line frame = renderer.getChartFrame();
if (frame != null)
{
paint.setStyle(Style.STROKE);
paint.setStrokeWidth(2);
if(frame.isDash())
{
DashPathEffect dashPathEffect = new DashPathEffect(new float[] {5, 5}, 10);
paint.setPathEffect(dashPathEffect);
}
BackgroundDrawer.drawPathBackground(canvas, null, 1, frame.getBackgroundAndFill(), rect, null, 1.0f, path, paint);
paint.setStyle(Style.FILL);
paint.setAlpha(alpha);
}
paint.reset();
paint.setAntiAlias(true);
}
WedgeCalloutDrawing.java 文件源码
项目:iOffice
阅读 15
收藏 0
点赞 0
评论 0
/**
* 线性标注1
* @param canvas
* @param shape
* @param rect
*/
private static Path getBorderCallout1Path(AutoShape shape, Rect rect)
{
float y1 = rect.top + rect.height() * 0.1875f;
float x1 = rect.left + rect.width() * (-0.08333f);
float y2 = rect.top + rect.height() * 1.125f;
float x2 = rect.left + rect.width() * (-0.38333f);
Float[] values = shape.getAdjustData();
if (values != null && values.length >= 4)
{
if (values[0] != null)
{
y1 = rect.top + rect.height() * values[0];
}
if (values[1] != null)
{
x1 = rect.left + rect.width() * values[1];
}
if (values[2] != null)
{
y2 = rect.top + rect.height() * values[2];
}
if (values[3] != null)
{
x2 = rect.left + rect.width() * values[3];
}
}
path.addRect(rect.left, rect.top, rect.right, rect.bottom, Path.Direction.CW);
path.moveTo(x1, y1);
path.lineTo(x2, y2);
return path;
}
WedgeCalloutDrawing.java 文件源码
项目:iOffice
阅读 15
收藏 0
点赞 0
评论 0
/**
* 线性标注1(带边框和强调线)
* @param canvas
* @param shape
* @param rect
*/
private static Path getAccentBorderCallout1(AutoShape shape, Rect rect)
{
float y1 = rect.top + rect.height() * 0.1875f;
float x1 = rect.left + rect.width() * (-0.08333f);
float y2 = rect.top + rect.height() * 1.125f;
float x2 = rect.left + rect.width() * (-0.38333f);
Float[] values = shape.getAdjustData();
if (values != null && values.length >= 4)
{
if (values[0] != null)
{
y1 = rect.top + rect.height() * values[0];
}
if (values[1] != null)
{
x1 = rect.left + rect.width() * values[1];
}
if (values[2] != null)
{
y2 = rect.top + rect.height() * values[2];
}
if (values[3] != null)
{
x2 = rect.left + rect.width() * values[3];
}
}
path.addRect(rect.left, rect.top, rect.right, rect.bottom, Path.Direction.CW);
path.moveTo(x1, rect.top);
path.lineTo(x1, rect.bottom);
path.moveTo(x1, y1);
path.lineTo(x2, y2);
return path;
}