本文整理汇总了Java中android.graphics.PathEffect类的典型用法代码示例。如果您正苦于以下问题:Java PathEffect类的具体用法?Java PathEffect怎么用?Java PathEffect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PathEffect类属于android.graphics包,在下文中一共展示了PathEffect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: WidgetTextFrame
import android.graphics.PathEffect; //导入依赖的package包/类
public WidgetTextFrame(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
setClipChildren(false);
setClipToPadding(false);
mContext = context.getApplicationContext();
mPaddingSpace = context.getResources().getDimensionPixelSize(R.dimen.edit_text_space);
mRoundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
PathEffect effect = new DashPathEffect(new float[]{20, 20}, 1);
mRoundPaint.setAntiAlias(true);
mRoundPaint.setColor(getResources().getColor(R.color.edit_text_background_color));
mRoundPaint.setPathEffect(effect);
mRoundPaint.setStyle(Paint.Style.STROKE);
mRoundPaint.setStrokeWidth(3);
mDeletePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mDeletePaint.setAntiAlias(true);
mDeletePaint.setFilterBitmap(true);
mDeletePaint.setDither(true);
setWillNotDraw(false);
}
示例2: getPathEffect
import android.graphics.PathEffect; //导入依赖的package包/类
public @Nullable PathEffect getPathEffect(float borderWidth) {
switch (this) {
case SOLID:
return null;
case DASHED:
return new DashPathEffect(
new float[] {borderWidth*3, borderWidth*3, borderWidth*3, borderWidth*3}, 0);
case DOTTED:
return new DashPathEffect(
new float[] {borderWidth, borderWidth, borderWidth, borderWidth}, 0);
default:
return null;
}
}
示例3: withDrawnDivider
import android.graphics.PathEffect; //导入依赖的package包/类
/**
* Procedure meant to set the value for {@link #mDrawnDivider} optional parameter.
* @param color the divider's target {@link Color} value.
* See {@link Paint#setColor(int)} for more information.
* @param thickness the divider's target line thickness value. This value must be greater or equal than 0.
* See {@link Paint#setStrokeWidth(float)} for more information.
* @param style the divider's target {@link Paint.Style}.
* See {@link Paint#setStyle(Paint.Style)} for more information.
* @param pathEffect the divider's target {@link PathEffect}.
* See {@link Paint#setPathEffect(PathEffect)} for more information.
* @return the same object builder object after setting the optional attribute.
*/
@NonNull
public DecorationSpecBuilder withDrawnDivider(@ColorInt int color,
@FloatRange(from = 0, fromInclusive = false) float thickness,
@Nullable final Paint.Style style,
@Nullable final PathEffect pathEffect) {
mDrawnDivider = new Paint();
mDrawnDivider.setColor(color);
mDrawnDivider.setStrokeWidth(thickness);
if (style != null) {
mDrawnDivider.setStyle(style);
}
if (pathEffect != null) {
mDrawnDivider.setPathEffect(pathEffect);
}
return this;
}
示例4: getPathEffect
import android.graphics.PathEffect; //导入依赖的package包/类
public
@Nullable
PathEffect getPathEffect(float borderWidth) {
switch (this) {
case SOLID:
return null;
case DASHED:
return new DashPathEffect(
new float[]{borderWidth * 3, borderWidth * 3, borderWidth * 3, borderWidth * 3}, 0);
case DOTTED:
return new DashPathEffect(
new float[]{borderWidth, borderWidth, borderWidth, borderWidth}, 0);
default:
return null;
}
}
示例5: createFailedPath
import android.graphics.PathEffect; //导入依赖的package包/类
private void createFailedPath(){
if(mFailedPath != null){
mFailedPath.reset();
mFailedPath2.reset();
}else{
mFailedPath = new Path();
mFailedPath2 = new Path();
}
float left = width/2 - mRadius + mRadius/2;
float top = mRadius/2 + mPadding;
mFailedPath.moveTo(left,top);
mFailedPath.lineTo(left+mRadius,top+mRadius);
mFailedPath2.moveTo(width/2 + mRadius/2,top);
mFailedPath2.lineTo(width/2 - mRadius + mRadius/2,top+mRadius);
PathMeasure measure = new PathMeasure(mFailedPath, false);
mFailedPathLength = measure.getLength();
mFailedPathIntervals = new float[]{mFailedPathLength, mFailedPathLength};
PathEffect PathEffect = new DashPathEffect(mFailedPathIntervals, mFailedPathLength);
mPathEffectPaint2.setPathEffect(PathEffect);
}
示例6: RichPolygon
import android.graphics.PathEffect; //导入依赖的package包/类
RichPolygon(final int zIndex,
final List<RichPoint> points,
final List<List<RichPoint>> holes,
final int strokeWidth,
final Paint.Cap strokeCap,
final Paint.Join strokeJoin,
final PathEffect pathEffect,
final MaskFilter maskFilter,
final boolean linearGradient,
final Integer strokeColor,
final boolean antialias,
final boolean closed,
final Shader strokeShader,
final Shader fillShader,
final Paint.Style style,
final Integer fillColor) {
super(zIndex, points, strokeWidth, strokeCap, strokeJoin, pathEffect, maskFilter,
strokeShader, linearGradient, strokeColor, antialias, closed);
this.fillShader = fillShader;
this.style = style;
this.fillColor = fillColor;
if (holes != null) {
addHoles(holes);
}
}
示例7: setPoints
import android.graphics.PathEffect; //导入依赖的package包/类
public void setPoints(ArrayList<float[]> pointsToPath){
synchronized (pointsToPath) {
this.points = pointsToPath;
float[] startPoint = convertXYToLinePoint(points.get(0));
path.moveTo(startPoint[0], startPoint[1]);
for (int i = 0; i<this.points.size(); i++) {
float[] linePoint = convertXYToLinePoint(points.get(i));
path.lineTo(linePoint[0],linePoint[1]);
}
}
pathMeasure = new PathMeasure(path, false);
pathLength = pathMeasure.getLength(); // the interpolated length of the entire path as it would be drawn on the screen in dp
PathEffect pathEffect = new PathDashPathEffect(makeConvexArrow(15.0f, 15.0f), 5.0f, 0.0f, PathDashPathEffect.Style.ROTATE);
paintSettings.setPathEffect(pathEffect);
invalidate();
}
示例8: onDraw
import android.graphics.PathEffect; //导入依赖的package包/类
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawColor(Color.BLACK);
pathMeasure.setPath(path, false);
float length = pathMeasure.getLength();
if (length > BUG_TRAIL_DP * density) {
// Note - this is likely a poor way to accomplish the result. Just for demo purposes.
@SuppressLint("DrawAllocation")
PathEffect effect = new DashPathEffect(new float[]{length, length}, -length + BUG_TRAIL_DP * density);
paint.setPathEffect(effect);
}
paint.setStyle(Paint.Style.STROKE);
canvas.drawPath(path, paint);
paint.setStyle(Paint.Style.FILL);
canvas.drawCircle(position.x, position.y, BUG_RADIUS_DP * density, paint);
}
示例9: SampleView
import android.graphics.PathEffect; //导入依赖的package包/类
public SampleView(Context context) {
super(context);
setFocusable(true);
setFocusableInTouchMode(true);
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeWidth(6);
mPath = makeFollowPath();
mEffects = new PathEffect[6];
mBonds = new RectF();
mColors = new int[] { Color.BLACK, Color.RED, Color.BLUE,
Color.GREEN, Color.MAGENTA, Color.BLACK
};
}
示例10: draw
import android.graphics.PathEffect; //导入依赖的package包/类
void draw(Canvas canvas) {
RectF rectF = new RectF(mLeftX, mY, mRightX, mY);
canvas.drawRoundRect(rectF, mBarWeight / 2, mBarWeight / 2, mBarPaint);
Path path = new Path();
path.moveTo(mLeftX + mMargin, mY);
path.lineTo(mRightX - mMargin, mY);
PathEffect effects = new DashPathEffect(new float[]{5, 5, 5, 5}, 1);
mEffectPaint.setPathEffect(effects);
canvas.drawPath(path, mEffectPaint);
}
示例11: setStroke
import android.graphics.PathEffect; //导入依赖的package包/类
private void setStroke(Cap cap, Join join, float miter, Style style, PathEffect pathEffect,
Paint paint) {
paint.setStrokeCap(cap);
paint.setStrokeJoin(join);
paint.setStrokeMiter(miter);
paint.setPathEffect(pathEffect);
paint.setStyle(style);
}
示例12: setDividerPaint
import android.graphics.PathEffect; //导入依赖的package包/类
private void setDividerPaint() {
mDividerPaint.setAlpha(0);
mDividerPaint.setAntiAlias(true);
mDividerPaint.setColor(mDividerColor);
mDividerPaint.setStrokeWidth(mDividerWidth);
if(mDividerType == DividerType.DASH)
mDividerPaint.setPathEffect(new DashPathEffect(new float[]{(float) mDividerDashLength, (float) mDividerDashGap}, 0.0f));
else
mDividerPaint.setPathEffect(new PathEffect());
}
示例13: PathEffectView
import android.graphics.PathEffect; //导入依赖的package包/类
public PathEffectView(Context context, AttributeSet attrs) {
super(context, attrs);
mPaint = new Paint();
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeWidth(5);
mPaint.setColor(Color.DKGRAY);
mPath = new Path();
mPath.moveTo(0, 0);
for (int i = 0; i <= 30; i++) {
mPath.lineTo(i * 35, (float) (Math.random() * 100));
}
mEffects = new PathEffect[6];
}
示例14: onDraw
import android.graphics.PathEffect; //导入依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
makeAndMeasurePath();
if (!isInEditMode()) {
// Apply the dash effect
float length = mPathMeasure.getLength();
PathEffect effect = new DashPathEffect(new float[]{length, length}, length * (1 - mRatio));
mPaint.setPathEffect(effect);
}
canvas.drawPath(mPath, mPaint);
}
示例15: HexagonDrawable
import android.graphics.PathEffect; //导入依赖的package包/类
public HexagonDrawable(@ColorInt int color, float width, float height, float padding)
{
mWidth = width;
mHeight = height;
mPadding = padding;
mLenght = width/2 - mPadding*2;
mOrigin_x = mWidth/2;
mOrigin_y = mHeight/2;
//六边形路径
mPath = new Path();
mPath.moveTo(mOrigin_x, mOrigin_y - mLenght);
mPath.lineTo((float) (mOrigin_x + Math.sqrt(3f)*mLenght/2), mOrigin_y - mLenght/2);
mPath.lineTo((float) (mOrigin_x + Math.sqrt(3f)*mLenght/2), mOrigin_y + mLenght/2);
mPath.lineTo(mOrigin_x, mOrigin_y + mLenght);
mPath.lineTo((float) (mOrigin_x - Math.sqrt(3f)*mLenght/2), mOrigin_y + mLenght/2);
mPath.lineTo((float) (mOrigin_x - Math.sqrt(3f)*mLenght/2), mOrigin_y - mLenght/2);
mPath.close();
//初始化画笔
mPaint = new Paint();
mPaint.setAntiAlias(true);
mPaint.setColor(color);
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
mPaint.setStrokeWidth(1f);
//连线节点平滑处理
PathEffect pathEffect = new CornerPathEffect(10);
mPaint.setPathEffect(pathEffect);
}