android.graphics.PathEffect Java Examples

The following examples show how to use android.graphics.PathEffect. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BugView.java    From Bugstick with MIT License 6 votes vote down vote up
@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);
}
 
Example #2
Source File: LinesChart.java    From OXChart with Apache License 2.0 6 votes vote down vote up
/**绘制X轴方向辅助网格*/
private void drawGrid(Canvas canvas){
    float yMarkSpace = (rectChart.bottom - rectChart.top)/(YMARK_NUM-1);
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeWidth(lineWidth);
    paint.setColor(defColor);
    paintEffect.setStyle(Paint.Style.STROKE);
    paintEffect.setStrokeWidth(lineWidth);
    paintEffect.setColor(defColor);
    canvas.drawLine(rectChart.left, rectChart.top, rectChart.left, rectChart.bottom, paint);
    canvas.drawLine(rectChart.right, rectChart.top, rectChart.right, rectChart.bottom, paint);

    for (int i = 0; i < YMARK_NUM; i++) {
        if(i==0||i ==YMARK_NUM-1) {   //实线
            canvas.drawLine(rectChart.left, rectChart.bottom-yMarkSpace*i,
                    rectChart.right, rectChart.bottom-yMarkSpace*i, paint);
        } else {              //虚线
            Path path = new Path();
            path.moveTo(rectChart.left, rectChart.bottom-yMarkSpace*i);
            path.lineTo(rectChart.right,rectChart.bottom-yMarkSpace*i);
            PathEffect effects = new DashPathEffect(new float[]{15,8,15,8},0);
            paintEffect.setPathEffect(effects);
            canvas.drawPath(path, paintEffect);
        }
    }
}
 
Example #3
Source File: RichPolygon.java    From richmaps with Apache License 2.0 6 votes vote down vote up
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);
    }
}
 
Example #4
Source File: ReactViewBackgroundDrawable.java    From react-native-GPay with MIT License 6 votes vote down vote up
public static @Nullable PathEffect getPathEffect(BorderStyle style, float borderWidth) {
  switch (style) {
    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;
  }
}
 
Example #5
Source File: WXBackgroundDrawable.java    From weex with Apache License 2.0 6 votes vote down vote up
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;
  }
}
 
Example #6
Source File: ItemDragCallback.java    From ChannelManageDemo_Java with MIT License 5 votes vote down vote up
public ItemDragCallback(ChannelAdapter mAdapter, int mPadding) {
    this.mAdapter = mAdapter;
    this.mPadding = mPadding;
    mPaint = new Paint();
    mPaint.setColor(Color.GRAY);
    mPaint.setAntiAlias(true);
    mPaint.setStrokeWidth(1);
    mPaint.setStyle(Paint.Style.STROKE);
    PathEffect pathEffect = new DashPathEffect(new float[]{5f, 5f}, 5f);    //虚线
    mPaint.setPathEffect(pathEffect);
}
 
Example #7
Source File: WorldMapEquirectangular.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void drawMajorLatitudes(Canvas c, int w, int h, double[] mid, WorldMapTask.WorldMapOptions options)
{
    Paint p = new Paint(Paint.ANTI_ALIAS_FLAG);
    p.setXfermode(new PorterDuffXfermode( options.hasTransparentBaseMap ? PorterDuff.Mode.DST_OVER : PorterDuff.Mode.SRC_OVER ));

    Paint.Style prevStyle = p.getStyle();
    PathEffect prevEffect = p.getPathEffect();
    float prevStrokeWidth = p.getStrokeWidth();

    float strokeWidth = sunStroke(c, options) * options.latitudeLineScale;
    p.setStrokeWidth(strokeWidth);

    p.setColor(options.latitudeColors[0]);                    // equator
    p.setPathEffect((options.latitudeLinePatterns[0][0] > 0) ? new DashPathEffect(options.latitudeLinePatterns[0], 0) : null);
    c.drawLine(0, (int)mid[1], w, (int)mid[1], p);

    double tropics = r_tropics * mid[1];
    int tropicsY0 = (int)(mid[1] + tropics);
    int tropicsY1 = (int)(mid[1] - tropics);
    p.setColor(options.latitudeColors[1]);                    // tropics
    p.setPathEffect((options.latitudeLinePatterns[1][0] > 0) ? new DashPathEffect(options.latitudeLinePatterns[1], 0) : null);
    c.drawLine(0, tropicsY0, w, tropicsY0, p);
    c.drawLine(0, tropicsY1, w, tropicsY1, p);

    double polar = r_polar * mid[1];
    int polarY0 = (int)(mid[1] + polar);
    int polarY1 = (int)(mid[1] - polar);
    p.setColor(options.latitudeColors[2]);                    // polar
    p.setPathEffect((options.latitudeLinePatterns[2][0] > 0) ? new DashPathEffect(options.latitudeLinePatterns[2], 0) : null);
    c.drawLine(0, polarY0, w, polarY0, p);
    c.drawLine(0, polarY1, w, polarY1, p);

    p.setStyle(prevStyle);
    p.setPathEffect(prevEffect);
    p.setStrokeWidth(prevStrokeWidth);
    p.setXfermode(new PorterDuffXfermode( PorterDuff.Mode.SRC_OVER) );
}
 
Example #8
Source File: RichPolyline.java    From richmaps with Apache License 2.0 5 votes vote down vote up
RichPolyline(final int zIndex,
             final List<RichPoint> points,
             final int strokeWidth,
             final Paint.Cap strokeCap,
             final Paint.Join strokeJoin,
             final PathEffect pathEffect,
             final MaskFilter maskFilter,
             final Shader strokeShader,
             final boolean linearGradient,
             final Integer strokeColor,
             final boolean antialias,
             final boolean closed) {
    super(zIndex, points, strokeWidth, strokeCap, strokeJoin, pathEffect, maskFilter,
            strokeShader, linearGradient, strokeColor, antialias, closed);
}
 
Example #9
Source File: RichShape.java    From richmaps with Apache License 2.0 5 votes vote down vote up
RichShape(final int zIndex,
          final List<RichPoint> points,
          final int strokeWidth,
          final Paint.Cap strokeCap,
          final Paint.Join strokeJoin,
          final PathEffect pathEffect,
          final MaskFilter maskFilter,
          final Shader strokeShader,
          final boolean linearGradient,
          final Integer strokeColor,
          final boolean antialias,
          final boolean closed) {
    this.zIndex = zIndex;
    this.strokeWidth = strokeWidth;
    this.strokeCap = strokeCap;
    this.strokeJoin = strokeJoin;
    this.pathEffect = pathEffect;
    this.maskFilter = maskFilter;
    this.strokeShader = strokeShader;
    this.linearGradient = linearGradient;
    this.strokeColor = strokeColor;
    this.antialias = antialias;
    this.closed = closed;
    if (points != null) {
        for (RichPoint point : points) {
            add(point);
        }
    }
}
 
Example #10
Source File: CustomClickTopicSpan.java    From GSYRickText with MIT License 5 votes vote down vote up
@Override
public void updateDrawState(TextPaint ds) {
    super.updateDrawState(ds);
    ds.setUnderlineText(true);
    ds.setStyle(Paint.Style.FILL_AND_STROKE);
    PathEffect effects = new DashPathEffect(new float[]{1, 1}, 1);
    ds.setPathEffect(effects);
    ds.setStrokeWidth(2);
}
 
Example #11
Source File: CustomClickAtUserSpan.java    From GSYRickText with MIT License 5 votes vote down vote up
@Override
public void updateDrawState(TextPaint ds) {
    super.updateDrawState(ds);
    ds.setUnderlineText(true);
    //间隔线
    ds.setStyle(Paint.Style.STROKE);
    PathEffect effects = new DashPathEffect(new float[]{1, 1}, 1);
    ds.setPathEffect(effects);
    ds.setStrokeWidth(5);
}
 
Example #12
Source File: BindNormalActivity.java    From LazyRecyclerAdapter with MIT License 5 votes vote down vote up
public void init() {

        normalAdapterManager = new BindSuperAdapterManager();
        normalAdapterManager
                .bind(BindImageModel.class, BindImageHolder.ID, BindImageHolder.class)
                .bind(BindTextModel.class, BindTextHolder.ID, BindTextHolder.class)
                .bind(BindMutliModel.class, BindMutliHolder.ID, BindMutliHolder.class)
                .bind(BindClickModel.class, BindClickHolder.ID, BindClickHolder.class)
                .bindEmpty(BindNoDataHolder.NoDataModel.class, BindNoDataHolder.ID, BindNoDataHolder.class)
                .setNeedAnimation(true)
                .setOnItemClickListener(new OnItemClickListener() {
                    @Override
                    public void onItemClick(Context context, int position) {
                        Toast.makeText(context, "点击了!! " + position, Toast.LENGTH_SHORT).show();
                    }
                });


        adapter = new BindRecyclerAdapter(this, normalAdapterManager, datas);

        recycler.setLayoutManager(new LinearLayoutManager(this));


        //间隔线
        Paint paint = new Paint();
        paint.setStyle(Paint.Style.STROKE);
        paint.setColor(getResources().getColor(R.color.material_deep_teal_200));
        PathEffect effects = new DashPathEffect(new float[]{5, 5, 5, 5}, 1);
        paint.setPathEffect(effects);
        paint.setStrokeWidth(dip2px(this, 5));
        recycler.addItemDecoration(new BindDecorationBuilder(adapter).setPaint(paint).setSpace(dip2px(this, 5)).builder());

        recycler.setAdapter(adapter);

    }
 
Example #13
Source File: NorthSouthChart.java    From OXChart with Apache License 2.0 5 votes vote down vote up
/**绘制X轴方向辅助网格*/
private void drawGrid(Canvas canvas){
    float yMarkSpace = (rectChart.bottom - rectChart.top)/(YMARK_NUM-1);
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeWidth(lineWidth);
    paint.setColor(defColor);
    paintEffect.setStyle(Paint.Style.STROKE);
    paintEffect.setStrokeWidth(lineWidth);
    paintEffect.setColor(defColor);
    canvas.drawLine(rectChart.left, rectChart.top, rectChart.left, rectChart.bottom, paint);
    canvas.drawLine(rectChart.right, rectChart.top, rectChart.right, rectChart.bottom, paint);
    if(chartType==ChartType.TYPE_T_SOUTH||chartType==ChartType.TYPE_T_NORTH){
        //今日图表,需要绘制x刻度线
        for(DataPoint lable : lableXPointList){
            canvas.drawLine(lable.getValueY(), rectChart.bottom, lable.getValueY(),
                    rectChart.bottom-DensityUtil.dip2px(getContext(), 3), paint);
        }
    }
    for (int i = 0; i < YMARK_NUM; i++) {
        if(i==0||i ==YMARK_NUM-1) {   //实线
            canvas.drawLine(rectChart.left, rectChart.bottom-yMarkSpace*i,
                    rectChart.right, rectChart.bottom-yMarkSpace*i, paint);
        } else {              //虚线
            Path path = new Path();
            path.moveTo(rectChart.left, rectChart.bottom-yMarkSpace*i);
            path.lineTo(rectChart.right,rectChart.bottom-yMarkSpace*i);
            PathEffect effects = new DashPathEffect(new float[]{15,8,15,8},0);
            paintEffect.setPathEffect(effects);
            canvas.drawPath(path, paintEffect);
        }
    }
}
 
Example #14
Source File: TicketView.java    From TicketView with Apache License 2.0 5 votes vote down vote up
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());
}
 
Example #15
Source File: JustContext.java    From JustDraw with MIT License 5 votes vote down vote up
public void setLineDash(V8Array intervals) {
    float[] floatIntervals = new float[intervals.length()];
    for (int i = 0; i < intervals.length(); i++) {
        floatIntervals[i] = (float)((double)intervals.getDouble(i));
    }

    PathEffect effects = new DashPathEffect(floatIntervals, 1);
    mPaintStroke.setPathEffect(effects);

    intervals.release();
}
 
Example #16
Source File: NightingaleRoseChart.java    From OXChart with Apache License 2.0 5 votes vote down vote up
public void init(Context context, AttributeSet attrs, int defStyleAttr) {
    dataList = new ArrayList<>();
    DisplayMetrics dm = getResources().getDisplayMetrics();
    ScrHeight = dm.heightPixels;
    ScrWidth = dm.widthPixels;

    //画笔初始化
    paintArc = new Paint();
    paintArc.setAntiAlias(true);

    paintLabel = new Paint();
    paintLabel.setAntiAlias(true);

    paintSelected = new Paint();
    paintSelected.setColor(Color.LTGRAY);
    paintSelected.setStyle(Paint.Style.STROKE);//设置空心
    paintSelected.setStrokeWidth(lineWidth*5);
    paintSelected.setAntiAlias(true);

    mLinePaint = new Paint();
    mLinePaint.setStyle(Paint.Style.FILL);
    mLinePaint.setStrokeWidth(lineWidth);
    mLinePaint.setAntiAlias(true);


    mlableLinePaint = new Paint();
    mlableLinePaint.setStyle(Paint.Style.STROKE);
    mlableLinePaint.setColor(Color.DKGRAY);
    mlableLinePaint.setStrokeWidth(3);
    // PathEffect是用来控制绘制轮廓(线条)的方式
    // 代码中的float数组,必须是偶数长度,且>=2,指定了多少长度的实线之后再画多少长度的空白
    // .如本代码中,绘制长度5的实线,再绘制长度5的空白,再绘制长度5的实线,再绘制长度5的空白,依次重复.1是偏移量,可以不用理会.
    PathEffect effects = new DashPathEffect(new float[]{5,5,5,5},1);
    mlableLinePaint.setPathEffect(effects);


}
 
Example #17
Source File: XYChart.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
private void a(android.graphics.Paint.Cap cap, android.graphics.Paint.Join join, float f1, android.graphics.Paint.Style style, PathEffect patheffect, Paint paint)
{
    paint.setStrokeCap(cap);
    paint.setStrokeJoin(join);
    paint.setStrokeMiter(f1);
    paint.setPathEffect(patheffect);
    paint.setStyle(style);
}
 
Example #18
Source File: WorldMapEquiazimuthal.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void drawMajorLatitudes(Canvas c, int w, int h, double[] mid, WorldMapTask.WorldMapOptions options)
{
    Paint p = new Paint(Paint.ANTI_ALIAS_FLAG);
    p.setXfermode(options.hasTransparentBaseMap ? new PorterDuffXfermode(PorterDuff.Mode.DST_OVER) : new PorterDuffXfermode(PorterDuff.Mode.SRC_OVER));

    Paint.Style prevStyle = p.getStyle();
    PathEffect prevEffect = p.getPathEffect();
    float prevStrokeWidth = p.getStrokeWidth();

    double equator = mid[1] * r_equator;
    double tropics = mid[1] * r_tropics;
    double polar = mid[1] * r_polar;

    float strokeWidth = sunStroke(c, options) * options.latitudeLineScale;
    p.setStrokeWidth(strokeWidth);
    p.setStyle(Paint.Style.STROKE);
    p.setStrokeCap(Paint.Cap.ROUND);

    p.setColor(options.latitudeColors[0]);
    p.setPathEffect((options.latitudeLinePatterns[0][0] > 0) ? new DashPathEffect(options.latitudeLinePatterns[0], 0) : null);

    c.drawCircle((int)mid[0], (int)mid[1], (int)equator, p);

    p.setColor(options.latitudeColors[1]);
    p.setPathEffect((options.latitudeLinePatterns[1][0] > 0) ? new DashPathEffect(options.latitudeLinePatterns[1], 0) : null);
    c.drawCircle((int)mid[0], (int)mid[1], (int)(equator + tropics), p);
    c.drawCircle((int)mid[0], (int)mid[1], (int)(equator - tropics), p);

    p.setColor(options.latitudeColors[2]);
    p.setPathEffect((options.latitudeLinePatterns[2][0] > 0) ? new DashPathEffect(options.latitudeLinePatterns[2], 0) : null);
    c.drawCircle((int)mid[0], (int)mid[1], (int)(equator + polar), p);
    c.drawCircle((int)mid[0], (int)mid[1], (int)(equator - polar), p);

    p.setStyle(prevStyle);
    p.setPathEffect(prevEffect);
    p.setStrokeWidth(prevStrokeWidth);
}
 
Example #19
Source File: SpanFormatter.java    From nfcard with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top,
		int y, int bottom, Paint paint) {

	canvas.save();
	canvas.translate(x, (bottom + top) / 2 - height);

	final int c = paint.getColor();
	final float w = paint.getStrokeWidth();
	final Style s = paint.getStyle();
	final PathEffect e = paint.getPathEffect();

	paint.setColor(color);
	paint.setStyle(Paint.Style.STROKE);
	paint.setStrokeWidth(height);
	paint.setPathEffect(effe);

	path.moveTo(x, 0);
	path.lineTo(x + width, 0);

	canvas.drawPath(path, paint);

	paint.setColor(c);
	paint.setStyle(s);
	paint.setStrokeWidth(w);
	paint.setPathEffect(e);

	canvas.restore();
}
 
Example #20
Source File: RVPaint.java    From RecyclerViewDecoration with Apache License 2.0 5 votes vote down vote up
public static void drawDashLine(Canvas canvas, Paint paint, int dashWidth, int dashGap
        , int startX, int startY, int stopX, int stopY) {
    if (dashWidth == 0 && dashGap == 0) {
        PathEffect effects = new DashPathEffect(new float[]{0, 0, dashWidth, paint.getStrokeWidth()}, dashGap);
        paint.setPathEffect(effects);
    }
    canvas.drawLine(startX, startY, stopX, stopY, paint);

}
 
Example #21
Source File: SpanFormatter.java    From NFCard with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top,
		int y, int bottom, Paint paint) {

	canvas.save();
	canvas.translate(x, (bottom + top) / 2 - height);

	final int c = paint.getColor();
	final float w = paint.getStrokeWidth();
	final Style s = paint.getStyle();
	final PathEffect e = paint.getPathEffect();

	paint.setColor(color);
	paint.setStyle(Paint.Style.STROKE);
	paint.setStrokeWidth(height);
	paint.setPathEffect(effe);

	path.moveTo(x, 0);
	path.lineTo(x + width, 0);

	canvas.drawPath(path, paint);

	paint.setColor(c);
	paint.setStyle(s);
	paint.setStrokeWidth(w);
	paint.setPathEffect(e);

	canvas.restore();
}
 
Example #22
Source File: DiscrollvablePathLayout.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #23
Source File: HomeDiagram.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
/**
 * 绘制竖线
 * 
 * @param c
 */
public void drawStraightLine(Canvas c) {
	paint_dottedline.setColor(fineLineColor);
	int count_line = 0;
	for (int i = 0; i < milliliter.size(); i++) {
		if (count_line == 0) {
			c.drawLine(interval_left_right * i, 0, interval_left_right * i,
					getHeight(), paint_date);
		}
		if (count_line == 2) {
			c.drawLine(interval_left_right * i, tb * 1.5f,
					interval_left_right * i, getHeight(), paint_date);
		}
		if (count_line == 1 || count_line == 3) {
			Path path = new Path();
			path.moveTo(interval_left_right * i, tb * 1.5f);
			path.lineTo(interval_left_right * i, getHeight());
			PathEffect effects = new DashPathEffect(new float[] { tb * 0.3f,
					tb * 0.3f, tb * 0.3f, tb * 0.3f }, tb * 0.1f);
			paint_dottedline.setPathEffect(effects);
			c.drawPath(path, paint_dottedline);
		}
		count_line++;
		if (count_line >= 4) {
			count_line = 0;
		}
	}
	c.drawLine(0, getHeight() - tb * 0.2f, getWidth(), getHeight() - tb
			* 0.2f, paint_brokenline_big);
}
 
Example #24
Source File: DiscrollvablePathLayout.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #25
Source File: PathView.java    From AndroidLinkup with GNU General Public License v2.0 5 votes vote down vote up
public PathView(Activity linkup) {
    this((Context) linkup);

    // 根据屏幕分辨率设置path宽度
    Display mDisplay = linkup.getWindowManager().getDefaultDisplay();
    Point size = new Point();
    mDisplay.getSize(size);
    pathWidth = size.x / 60;

    paint.setStrokeWidth(pathWidth);
    PathEffect effect = new DashPathEffect(new float[] { pathWidth, pathWidth }, 0);
    paint.setPathEffect(effect);
}
 
Example #26
Source File: PathView.java    From AndroidLinkup with GNU General Public License v2.0 5 votes vote down vote up
public PathView(Context context) {
    super(context);

    paint.setStyle(Style.STROKE);
    paint.setStrokeWidth(pathWidth);
    paint.setColor(getResources().getColor(R.color.path_color));
    PathEffect effect = new DashPathEffect(new float[] { pathWidth, pathWidth }, 0);
    paint.setPathEffect(effect);

    alphaAnim.setDuration(500);
    HideAnimation hideAnim = new HideAnimation(this);
    alphaAnim.setAnimationListener(hideAnim);

    setVisibility(View.GONE);
}
 
Example #27
Source File: SafePaint.java    From OpenMapKitAndroid with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public PathEffect setPathEffect(PathEffect effect) {
    if (effect instanceof DashPathEffect) {
        throw new RuntimeException(
                "Do not use DashPathEffect. Use SafeDashPathEffect instead.");
    }
    return super.setPathEffect(effect);
}
 
Example #28
Source File: HollowTextActivity.java    From android-graphics-demo with Apache License 2.0 5 votes vote down vote up
private PathEffect getTrianglePathEffect(int strokeWidth) {
  return new PathDashPathEffect(
      getTriangle(strokeWidth),
      strokeWidth,
      0.0f,
      PathDashPathEffect.Style.ROTATE);
}
 
Example #29
Source File: LineView.java    From SimplePomodoro-android with MIT License 5 votes vote down vote up
private void drawBackgroundLines(Canvas canvas){
        Paint paint = new Paint();
        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeWidth(MyUtils.dip2px(getContext(),1f));
        paint.setColor(BACKGROUND_LINE_COLOR);
        PathEffect effects = new DashPathEffect(
                new float[]{10,5,10,5}, 1);

        //draw vertical lines
        for(int i=0;i<xCoordinateList.size();i++){
            canvas.drawLine(xCoordinateList.get(i),
                    0,
                    xCoordinateList.get(i),
                    mViewHeight - bottomTextTopMargin - bottomTextHeight-bottomTextDescent,
                    paint);
        }

        //draw dotted lines
//        paint.setPathEffect(effects);
//        Path dottedPath = new Path();
        for(int i=0;i<yCoordinateList.size();i++){
            if((yCoordinateList.size()-1-i)%dataOfAGird == 0){
//                dottedPath.moveTo(0, yCoordinateList.get(i));
//                dottedPath.lineTo(getWidth(), yCoordinateList.get(i));
                canvas.drawLine(0,yCoordinateList.get(i),getWidth(),yCoordinateList.get(i),paint);
//                canvas.drawPath(dottedPath, paint);
            }
        }

        //draw bottom text
        if(bottomTextList != null){
            for(int i=0;i<bottomTextList.size();i++){
                canvas.drawText(bottomTextList.get(i), sideLineLength+backgroundGridWidth*i,
                        mViewHeight-bottomTextDescent, bottomTextPaint);
            }
        }
    }
 
Example #30
Source File: AbstractPaintAssert.java    From assertj-android with Apache License 2.0 5 votes vote down vote up
public S hasPathEffect(PathEffect effect) {
  isNotNull();
  PathEffect actualEffect = actual.getPathEffect();
  assertThat(actualEffect) //
      .overridingErrorMessage("Expected path effect <%s> but was <%s>.", effect, actualEffect) //
      .isSameAs(effect);
  return myself;
}