当前位置: 首页>>代码示例>>Java>>正文


Java Paint.getPathEffect方法代码示例

本文整理汇总了Java中android.graphics.Paint.getPathEffect方法的典型用法代码示例。如果您正苦于以下问题:Java Paint.getPathEffect方法的具体用法?Java Paint.getPathEffect怎么用?Java Paint.getPathEffect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.graphics.Paint的用法示例。


在下文中一共展示了Paint.getPathEffect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: draw

import android.graphics.Paint; //导入方法依赖的package包/类
@SuppressWarnings("SuspiciousNameCombination")
@Override
public void draw(Canvas canvas, Paint paint) {
    if (mBorder == null)
        return;

    float width = getWidth();
    float height = getHeight();

    if (mPathEffect == null) {

        // left
        if (mBorder.left > 0)
            canvas.drawRect(0, 0, mBorder.left, height, paint);

        // top
        if (mBorder.top > 0)
            canvas.drawRect(0, 0, width, mBorder.top, paint);

        // right
        if (mBorder.right > 0)
            canvas.drawRect(width - mBorder.right, 0, width, height, paint);

        // bottom
        if (mBorder.bottom > 0)
            canvas.drawRect(0, height - mBorder.bottom, width, height, paint);

    } else {
        if (paint.getPathEffect() != mPathEffect) {
            paint.setStyle(Paint.Style.STROKE);
            paint.setPathEffect(mPathEffect);
        }

        // left
        if (mBorder.left > 0) {
            paint.setStrokeWidth(mBorder.left);
            initPath(mBorder.left / 2, 0, mBorder.left / 2, height);
            canvas.drawPath(mPath, paint);
        }

        // top
        if (mBorder.top > 0) {
            paint.setStrokeWidth(mBorder.top);
            initPath(0, mBorder.top / 2, width, mBorder.top / 2);
            canvas.drawPath(mPath, paint);
        }

        // right
        if (mBorder.right > 0) {
            paint.setStrokeWidth(mBorder.right);
            initPath(width - mBorder.right / 2, 0, width - mBorder.right / 2, height);
            canvas.drawPath(mPath, paint);
        }

        // bottom
        if (mBorder.bottom > 0) {
            paint.setStrokeWidth(mBorder.bottom);
            initPath(0, height - mBorder.bottom / 2, width, height - mBorder.bottom / 2);
            canvas.drawPath(mPath, paint);
        }
    }
}
 
开发者ID:coding-dream,项目名称:TPlayer,代码行数:63,代码来源:BorderShape.java

示例2: drawLine

import android.graphics.Paint; //导入方法依赖的package包/类
public void drawLine(Canvas canvas, Position3D p3PrevPoint, Position3D p3NextPoint, Paint paint, LineStyle lineStyle)	{
	if (lineStyle.menumLinePattern == LINEPATTERN.LINEPATTERN_NON)	{
		return;
	}
	int nOriginalColor = paint.getColor();
	Style styleOriginal = paint.getStyle();
	float fOriginalStrokeWidth = paint.getStrokeWidth();
	PathEffect pathEffectOriginal = paint.getPathEffect();

	if (lineStyle.mclr != null)	{
		paint.setColor(lineStyle.mclr.getARGB());
	}
	paint.setStyle(Style.STROKE);
	paint.setStrokeWidth((float)lineStyle.mdLineWidth);
	switch (lineStyle.menumLinePattern)	{
	case LINEPATTERN_DASH:
	{
		paint.setPathEffect(new DashPathEffect(new float[]{(float)mdVerySmallSize, (float)mdTinySize}, 0));
		break;
	}
	case LINEPATTERN_DOT:
	{
		paint.setPathEffect(new DashPathEffect(new float[]{(float)mdVeryTinySize, (float)mdTinySize}, 0));
		break;
	}
	case LINEPATTERN_DASH_DOT:
	{
		paint.setPathEffect(new DashPathEffect(new float[]{(float)mdVerySmallSize, (float)mdTinySize, (float)mdVeryTinySize, (float)mdTinySize}, 0));
		break;
	}
	/* case LINEPATTERN_NON:	// need not to consider LINEPATTERN_NON
	{
		paint.setPathEffect(new DashPathEffect(new float[]{0, (float)mdMediumSize}, 0));
		break;
	} */
	default:	// solid
		paint.setPathEffect(new PathEffect());
	}
	
	float fX0 = (float)p3PrevPoint.getX(), fY0 = (float)p3PrevPoint.getY(),
			fX1 = (float)p3NextPoint.getX(), fY1 = (float)p3NextPoint.getY();
	canvas.drawLine(fX0, fY0, fX1, fY1, paint);
	
	paint.setColor(nOriginalColor);
	paint.setStyle(styleOriginal);
	paint.setStrokeWidth(fOriginalStrokeWidth);
	paint.setPathEffect(pathEffectOriginal);
}
 
开发者ID:woshiwpa,项目名称:SmartMath,代码行数:49,代码来源:FlatChart.java


注:本文中的android.graphics.Paint.getPathEffect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。