Java 类android.graphics.DashPathEffect 实例源码

项目:Rxjava2.0Demo    文件:FalsifyHeader.java   
@Override
@SuppressLint("DrawAllocation")
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    if (isInEditMode()) {//这段代码在运行时不会执行,只会在Studio编辑预览时运行,不用在意性能问题
        int d = DensityUtil.dp2px(5);

        Paint paint = new Paint();
        paint.setStyle(Paint.Style.STROKE);
        paint.setColor(0x44ffffff);
        paint.setStrokeWidth(DensityUtil.dp2px(1));
        paint.setPathEffect(new DashPathEffect(new float[]{d, d, d, d}, 1));
        canvas.drawRect(d, d, getWidth() - d, getBottom() - d, paint);

        TextView textView = new TextView(getContext());
        textView.setText(getClass().getSimpleName()+" 虚假区域\n运行时代表下拉Header的高度【" + DensityUtil.px2dp(getHeight()) + "dp】\n而不会显示任何东西");
        textView.setTextColor(0x44ffffff);
        textView.setGravity(Gravity.CENTER);
        textView.measure(makeMeasureSpec(getWidth(), EXACTLY), makeMeasureSpec(getHeight(), EXACTLY));
        textView.layout(0, 0, getWidth(), getHeight());
        textView.draw(canvas);
    }
}
项目:Rxjava2.0Demo    文件:FalsifyFooter.java   
@Override
@SuppressLint("DrawAllocation")
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    if (isInEditMode()) {//这段代码在运行时不会执行,只会在Studio编辑预览时运行,不用在意性能问题
        int d = DensityUtil.dp2px(5);

        Paint paint = new Paint();
        paint.setStyle(Paint.Style.STROKE);
        paint.setColor(0x44ffffff);
        paint.setStrokeWidth(DensityUtil.dp2px(1));
        paint.setPathEffect(new DashPathEffect(new float[]{d, d, d, d}, 1));
        canvas.drawRect(d, d, getWidth() - d, getBottom() - d, paint);

        TextView textView = new TextView(getContext());
        textView.setText(getClass().getSimpleName()+" 虚假区域\n运行时代表上拉Footer的高度【" + DensityUtil.px2dp(getHeight()) + "dp】\n而不会显示任何东西");
        textView.setTextColor(0x44ffffff);
        textView.setGravity(Gravity.CENTER);
        textView.measure(makeMeasureSpec(getWidth(), EXACTLY), makeMeasureSpec(getHeight(), EXACTLY));
        textView.layout(0, 0, getWidth(), getHeight());
        textView.draw(canvas);
    }
}
项目:hypertrack-live-android    文件:DashedLine.java   
public DashedLine(Context context, AttributeSet attrs) {
    super(context, attrs);
    int dashGap, dashLength, dashThickness;
    int color;

    TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.DashedLine, 0, 0);

    try {
        dashGap = a.getDimensionPixelSize(R.styleable.DashedLine_dashGap, 5);
        dashLength = a.getDimensionPixelSize(R.styleable.DashedLine_dashLength, 5);
        dashThickness = a.getDimensionPixelSize(R.styleable.DashedLine_dashThickness, 3);
        color = a.getColor(R.styleable.DashedLine_color, 0xff000000);
        orientation = a.getInt(R.styleable.DashedLine_orientation, ORIENTATION_HORIZONTAL);
    } finally {
        a.recycle();
    }

    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setColor(color);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeWidth(dashThickness);
    mPaint.setPathEffect(new DashPathEffect(new float[]{dashLength, dashGap,}, 0));
}
项目:weex-svg    文件:WXSvgPath.java   
/**
 * Sets up paint according to the props set on a shadow view. Returns {@code true}
 * if the stroke should be drawn, {@code false} if not.
 */
protected boolean setupStrokePaint(Paint paint, float opacity, @Nullable RectF box) {
  paint.reset();
  if (TextUtils.isEmpty(mStrokeColor)) {
    return false;
  }

  paint.setFlags(Paint.ANTI_ALIAS_FLAG);
  paint.setStyle(Paint.Style.STROKE);
  paint.setStrokeCap(mStrokeLinecap);
  paint.setStrokeJoin(mStrokeLinejoin);
  paint.setStrokeMiter(mStrokeMiterlimit * mScale);
  paint.setStrokeWidth(mStrokeWidth * mScale);
  setupPaint(paint, opacity, mStrokeColor, box);

  if (mStrokeDasharray != null && mStrokeDasharray.length > 0) {
    paint.setPathEffect(new DashPathEffect(mStrokeDasharray, mStrokeDashoffset));
  }

  return true;
}
项目:Virtualview-Android    文件:NativeLineImp.java   
public void setPaintParam(int color, int paintWidth, int style) {
    mPaint.setStrokeWidth(paintWidth);
    mPaint.setColor(color);
    mPaint.setAntiAlias(true);

    switch (style) {
        case STYLE_DASH:
            mPaint.setStyle(Paint.Style.STROKE);
            mPaint.setPathEffect(new DashPathEffect(mBase.mDashEffect, 1));

            this.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
            break;

        case STYLE_SOLID:
            mPaint.setStyle(Paint.Style.FILL);
            break;
    }
}
项目:atlas    文件:StrokeContent.java   
private void applyDashPatternIfNeeded() {
  if (dashPatternAnimations.isEmpty()) {
    return;
  }

  float scale = lottieDrawable.getScale();
  for (int i = 0; i < dashPatternAnimations.size(); i++) {
    dashPatternValues[i] = dashPatternAnimations.get(i).getValue();
    // If the value of the dash pattern or gap is too small, the number of individual sections
    // approaches infinity as the value approaches 0.
    // To mitigate this, we essentially put a minimum value on the dash pattern size of 1px
    // and a minimum gap size of 0.01.
    if (i % 2 == 0) {
      if (dashPatternValues[i] < 1f) {
        dashPatternValues[i] = 1f;
      }
    } else {
      if (dashPatternValues[i] < 0.1f) {
        dashPatternValues[i] = 0.1f;
      }
    }
    dashPatternValues[i] *= scale;
  }
  float offset = dashPatternOffsetAnimation == null ? 0f : dashPatternOffsetAnimation.getValue();
  paint.setPathEffect(new DashPathEffect(dashPatternValues, offset));
}
项目:android-study    文件:PathEffectView.java   
@Override protected void onDraw(Canvas canvas) {
  super.onDraw(canvas);
  //无效果
  mEffects[0] = null;
  //拐角处变得圆滑
  mEffects[1] = new CornerPathEffect(30);
  //线段上就会产生许多杂点
  mEffects[2] = new DiscretePathEffect(3.0F, 5.0F);
  //绘制虚线
  mEffects[3] = new DashPathEffect(new float[] { 20, 10, 5, 10 }, 0);
  Path path = new Path();
  path.addRect(0, 0, 8, 8, Path.Direction.CCW);
  //设置点的图形,即方形点的虚线,圆形点的虚线
  mEffects[4] = new PathDashPathEffect(path, 12, 0, PathDashPathEffect.Style.ROTATE);
  //组合PathEffect
  mEffects[5] = new ComposePathEffect(mEffects[3], mEffects[1]);
  for (int i = 0; i < mEffects.length; i++) {
    mPaint.setPathEffect(mEffects[i]);
    canvas.drawPath(mPath, mPaint);
    canvas.translate(0, 200);
  }
}
项目:boohee_v5.6    文件:ChartHelper.java   
private Line getTargetLine() {
    if (!needDrawTargetLine()) {
        return null;
    }
    PointValue lastRecordPoint = (PointValue) this.mPointValues.get(this.mPointValues.size()
            - 1);
    PointValue targetPoint = new PointValue(((AxisValue) this.mAxisValues.get(this
            .mAxisValues.size() - 1)).getValue(), this.mTargetWeight);
    List<PointValue> points = new ArrayList();
    points.add(lastRecordPoint);
    points.add(targetPoint);
    Line line = new Line(points);
    line.setColor(this.resources.getColor(R.color.da));
    line.setPathEffect(new DashPathEffect(new float[]{15.0f, 15.0f, 15.0f, 15.0f}, 0.0f));
    line.setHasLabels(false);
    if (this.mTypeMode > 0) {
        line.setHasPoints(false);
        return line;
    }
    line.setHasPoints(true);
    return line;
}
项目:boohee_v5.6    文件:BarChart.java   
private void init(Context context) {
    setLayerType(1, null);
    this.mContext = context;
    this.mBackgroundPaint = new Paint();
    this.mBackgroundPaint.setStrokeWidth(2.0f);
    this.mBackgroundPaint.setAntiAlias(true);
    this.mBackgroundPaint.setColor(-5056771);
    this.mBackgroundPaint.setStyle(Style.STROKE);
    this.mColumnPaint = new Paint();
    this.mColumnPaint.setAntiAlias(true);
    this.mColumnPaint.setStyle(Style.FILL);
    this.mColumnPaint.setColor(-12477447);
    this.mLinePaint = new Paint();
    this.mLinePaint.setAntiAlias(true);
    this.mLinePaint.setStyle(Style.STROKE);
    this.mLinePaint.setColor(-5056771);
    this.mLinePaint.setStrokeWidth(1.0f);
    this.mLinePaint.setPathEffect(new DashPathEffect(new float[]{aj.hA, aj.hA}, 0.0f));
    this.mBackgroundRect = new RectF();
}
项目:Rotatable-Scalable-Font    文件:WidgetTextFrame.java   
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);
}
项目:HeadlineNews    文件:UILine.java   
private void initPaint() {
    mPaint = new Paint();

    mPaint.setColor(mColor);
    mPaint.setStyle(Paint.Style.STROKE);
    /** 边界实际的位置是在边框的中间,所以都要减去边框宽度的一半,所以需要乘以2,才能得到想要的尺寸*/
    mPaint.setStrokeWidth(mThickness * 2);
    if (mLineMode == LINE_MODE_DOTTED) {
        /** 定义 虚线的一些尺寸属性 从0开始,偶数项代表 单个虚线的长度,第二个代表虚线间隔的大小,后面会依次循环*/
        float[] intervals = new float[]{mDottedSize, mDottedSpacingSize};
        /** 第二个参数是 偏移量,填0就够用了*/
        DashPathEffect dashPathEffect = new DashPathEffect(intervals, 0);
        mPaint.setPathEffect(dashPathEffect);
    }
    mPath = new Path();
}
项目:SmartRefreshLayout    文件:FalsifyHeader.java   
@Override
@SuppressLint({"DrawAllocation", "SetTextI18n"})
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    if (isInEditMode()) {//这段代码在运行时不会执行,只会在Studio编辑预览时运行,不用在意性能问题
        int d = DensityUtil.dp2px(5);

        Paint paint = new Paint();
        paint.setStyle(Paint.Style.STROKE);
        paint.setColor(0x44ffffff);
        paint.setStrokeWidth(DensityUtil.dp2px(1));
        paint.setPathEffect(new DashPathEffect(new float[]{d, d, d, d}, 1));
        canvas.drawRect(d, d, getWidth() - d, getBottom() - d, paint);

        TextView textView = new TextView(getContext());
        textView.setText(getClass().getSimpleName()+" 虚假区域\n运行时代表下拉Header的高度【" + DensityUtil.px2dp(getHeight()) + "dp】\n而不会显示任何东西");
        textView.setTextColor(0x44ffffff);
        textView.setGravity(Gravity.CENTER);
        textView.measure(makeMeasureSpec(getWidth(), EXACTLY), makeMeasureSpec(getHeight(), EXACTLY));
        textView.layout(0, 0, getWidth(), getHeight());
        textView.draw(canvas);
    }
}
项目:SmartRefreshLayout    文件:FalsifyFooter.java   
@Override
@SuppressLint({"DrawAllocation", "SetTextI18n"})
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    if (isInEditMode()) {//这段代码在运行时不会执行,只会在Studio编辑预览时运行,不用在意性能问题
        int d = DensityUtil.dp2px(5);

        Paint paint = new Paint();
        paint.setStyle(Paint.Style.STROKE);
        paint.setColor(0x44ffffff);
        paint.setStrokeWidth(DensityUtil.dp2px(1));
        paint.setPathEffect(new DashPathEffect(new float[]{d, d, d, d}, 1));
        canvas.drawRect(d, d, getWidth() - d, getBottom() - d, paint);

        TextView textView = new TextView(getContext());
        textView.setText(getClass().getSimpleName()+" 虚假区域\n运行时代表上拉Footer的高度【" + DensityUtil.px2dp(getHeight()) + "dp】\n而不会显示任何东西");
        textView.setTextColor(0x44ffffff);
        textView.setGravity(Gravity.CENTER);
        textView.measure(makeMeasureSpec(getWidth(), EXACTLY), makeMeasureSpec(getHeight(), EXACTLY));
        textView.layout(0, 0, getWidth(), getHeight());
        textView.draw(canvas);
    }
}
项目:ticket-view    文件:TicketView.java   
private void init(AttributeSet attrs) {
    eraser.setXfermode(new PorterDuffXfermode(Mode.CLEAR));

    dashPaint.setARGB(255, 200, 200, 200);
    dashPaint.setStyle(Style.STROKE);
    dashPaint.setStrokeWidth(4);
    dashPaint.setPathEffect(new DashPathEffect(new float[] { 4, 8 }, 0));

    borderPaint.setARGB(255, 200, 200, 200);
    borderPaint.setStyle(Style.STROKE);
    borderPaint.setStrokeWidth(4);

    setLayerType(LAYER_TYPE_HARDWARE, null);

    TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.TicketView);
    try {
        orientation = a.getInt(R.styleable.TicketView_tv_orientation, Orientation.VERTICAL);
        holeRadius = a.getFloat(R.styleable.TicketView_tv_holeRadius, DEFAULT_RADIUS);
        anchorViewId = a.getResourceId(R.styleable.TicketView_tv_anchor, NO_VALUE);
    } finally {
        a.recycle();
    }
}
项目:JZAndroidChart    文件:BarChartRenderer.java   
@Override
public void renderHighlighted(Canvas canvas, @NonNull Highlight[] highlights) {

    mRenderPaint.setColor(getHighlightColor());
    mRenderPaint.setStrokeWidth(2);
    mRenderPaint.setStyle(Paint.Style.STROKE);
    if (mDashedHighlightPhase > 0) {
        mRenderPaint.setPathEffect(new DashPathEffect(mDashedHighlightIntervals, mDashedHighlightPhase));
    }

    for (Highlight highlight : highlights) {

        canvas.drawLine(
                highlight.getX(),
                0,
                highlight.getX(),
                mContentRect.bottom,
                mRenderPaint);
    }

    mRenderPaint.setPathEffect(null);
}
项目:RNLearn_Project1    文件:DrawBorder.java   
@Override
protected @Nullable DashPathEffect getPathEffectForBorderStyle() {
  if (isFlagSet(BORDER_PATH_EFFECT_DIRTY)) {
    switch (mBorderStyle) {
      case BORDER_STYLE_DOTTED:
        mPathEffectForBorderStyle = createDashPathEffect(getBorderWidth());
        break;

      case BORDER_STYLE_DASHED:
        mPathEffectForBorderStyle = createDashPathEffect(getBorderWidth() * 3);
        break;

      default:
        mPathEffectForBorderStyle = null;
        break;
    }

    resetFlag(BORDER_PATH_EFFECT_DIRTY);
  }

  return mPathEffectForBorderStyle;
}
项目:RNLearn_Project1    文件:ReactViewBackgroundDrawable.java   
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;
  }
}
项目:RNLearn_Project1    文件:DrawBorder.java   
@Override
protected @Nullable DashPathEffect getPathEffectForBorderStyle() {
  if (isFlagSet(BORDER_PATH_EFFECT_DIRTY)) {
    switch (mBorderStyle) {
      case BORDER_STYLE_DOTTED:
        mPathEffectForBorderStyle = createDashPathEffect(getBorderWidth());
        break;

      case BORDER_STYLE_DASHED:
        mPathEffectForBorderStyle = createDashPathEffect(getBorderWidth() * 3);
        break;

      default:
        mPathEffectForBorderStyle = null;
        break;
    }

    resetFlag(BORDER_PATH_EFFECT_DIRTY);
  }

  return mPathEffectForBorderStyle;
}
项目:RNLearn_Project1    文件:ReactViewBackgroundDrawable.java   
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;
  }
}
项目:Coding-Android    文件:DashLine.java   
public DashLine(Context paramContext, AttributeSet paramAttributeSet) {
        super(paramContext, paramAttributeSet);
        //通过R.styleable.dashedline获得我们在attrs.xml中定义的
        //<declare-styleable name="dashedline"> TypedArray
//        TypedArray a = paramContext.obtainStyledAttributes(paramAttributeSet, R.styleable.dashedline);
        //我们在attrs.xml中<declare-styleable name="dashedline">节点下
        //添加了<attr name="lineColor" format="color" />
        //表示这个属性名为lineColor类型为color。当用户在布局文件中对它有设定值时
        //可通过TypedArray获得它的值当用户无设置值是采用默认值0XFF00000
//        int lineColor = a.getColor(R.styleable.dashedline_lineColor, 0XFF000000);
//        a.recycle();
        int lineColor = 0xffc1c1c1;
        this.paint = new Paint();
        this.path = new Path();
        this.paint.setStyle(Paint.Style.STROKE);
        this.paint.setColor(lineColor);
        this.paint.setAntiAlias(true);
        this.paint.setStrokeWidth(Global.dpToPx(2));
        float[] arrayOfFloat = new float[4];
        arrayOfFloat[0] = Global.dpToPx(3);
        arrayOfFloat[1] = Global.dpToPx(2);
        arrayOfFloat[2] = Global.dpToPx(3);
        arrayOfFloat[3] = Global.dpToPx(2);
        this.pe = new DashPathEffect(arrayOfFloat, 0);
    }
项目:react-native-ibeacon-android    文件:ReactViewBackgroundDrawable.java   
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;
  }
}
项目:weex    文件:WXBackgroundDrawable.java   
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;
  }
}
项目:weex-analyzer-android    文件:CSSBoxModelView.java   
private void init() {
    mShapePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mShapePaint.setStrokeWidth(ViewUtils.dp2px(getContext(),1));
    mShapePaint.setDither(true);
    mShapePaint.setColor(COLOR_TEXT);

    mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mTextPaint.setDither(true);
    mTextPaint.setTextSize(ViewUtils.sp2px(getContext(), 12));
    mTextPaint.setColor(COLOR_TEXT);
    mTextPaint.setTypeface(Typeface.DEFAULT);

    Paint.FontMetrics metrics = mTextPaint.getFontMetrics();
    mTextOffsetY = -(metrics.descent+metrics.ascent)/2.0f;
    mTextOffsetX = (metrics.descent-metrics.ascent)/2.0f;

    mCachedTextBounds = new Rect();

    mViewMinWidth = DEFAULT_VIEW_WIDTH;
    mViewMinHeight = DEFAULT_VIEW_HEIGHT;

    mPathEffect = new DashPathEffect(new float[]{5,5,5,5},1);
}
项目:react-native-box-loaders    文件:ReactViewBackgroundDrawable.java   
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;
  }
}
项目:AndroidAPS    文件:GraphData.java   
public void addNowLine(GraphView graph, long now) {
    LineGraphSeries<DataPoint> seriesNow;
    DataPoint[] nowPoints = new DataPoint[]{
            new DataPoint(now, 0),
            new DataPoint(now, maxY)
    };

    seriesNow = new LineGraphSeries<>(nowPoints);
    seriesNow.setDrawDataPoints(false);
    // custom paint to make a dotted line
    Paint paint = new Paint();
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeWidth(2);
    paint.setPathEffect(new DashPathEffect(new float[]{10, 20}, 0));
    paint.setColor(Color.WHITE);
    seriesNow.setCustomPaint(paint);

    addSeriesWithoutInvalidate(graph, seriesNow);
}
项目:Ironman    文件:ReactViewBackgroundDrawable.java   
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;
  }
}
项目:GitHub    文件:LegendEntry.java   
/**
 *
 * @param label The legend entry text. A `null` label will start a group.
 * @param form The form to draw for this entry.
 * @param formSize Set to NaN to use the legend's default.
 * @param formLineWidth Set to NaN to use the legend's default.
 * @param formLineDashEffect Set to nil to use the legend's default.
 * @param formColor The color for drawing the form.
 */
public LegendEntry(String label,
                   Legend.LegendForm form,
                   float formSize,
                   float formLineWidth,
                   DashPathEffect formLineDashEffect,
                   int formColor)
{
    this.label = label;
    this.form = form;
    this.formSize = formSize;
    this.formLineWidth = formLineWidth;
    this.formLineDashEffect = formLineDashEffect;
    this.formColor = formColor;
}
项目:GitHub    文件:FishLoadingRenderer.java   
private void setupPaint() {
    mPaint.setAntiAlias(true);
    mPaint.setStrokeWidth(mRiverBankWidth);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeJoin(Paint.Join.MITER);
    mPaint.setPathEffect(new DashPathEffect(new float[]{mPathFullLineSize, mPathDottedLineSize}, mPathDottedLineSize));
}
项目:GitHub    文件:ComplexAdapter.java   
@Override
public Paint dividerPaint(int position, RecyclerView parent) {
    Paint paint = new Paint();
    switch (position % 10) {
        case 0:
            paint.setColor(Color.RED);
            paint.setStrokeWidth(30);
            break;
        case 1:
            paint.setColor(Color.MAGENTA);
            paint.setStrokeWidth(10);
            break;
        default:
            if (position % 2 == 0) {
                paint.setColor(Color.BLUE);
                paint.setAntiAlias(true);
                paint.setPathEffect(new DashPathEffect(new float[]{25.0f, 25.0f}, 0));
            } else {
                paint.setColor(Color.GREEN);

            }
            paint.setStrokeWidth(2 + position);
            break;
    }

    return paint;
}
项目:GitHub    文件:PaintActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sample);

    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.main_recyclerview);
    // Workaround for dash path effect
    // https://code.google.com/p/android/issues/detail?id=29944
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        recyclerView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }

    SimpleAdapter adapter = new SimpleAdapter(this);
    LinearLayoutManager manager = new LinearLayoutManager(this);
    manager.setOrientation(OrientationHelper.VERTICAL);
    recyclerView.setLayoutManager(manager);
    recyclerView.setAdapter(adapter);

    Paint paint = new Paint();
    paint.setStrokeWidth(5);
    paint.setColor(Color.BLUE);
    paint.setAntiAlias(true);
    paint.setPathEffect(new DashPathEffect(new float[]{25.0f, 25.0f}, 0));
    recyclerView.addItemDecoration(new HorizontalDividerItemDecoration.Builder(this)
            .paint(paint)
            .showLastDivider()
            .build());
}
项目:GitHub    文件:WoWoPathView.java   
private void initPaint() {
    paint = new Paint();
    paint.setColor(pathColor);
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeWidth(pathWidth);
    paint.setAntiAlias(true);

    setPath(new Path());

    if (dashPath) {
        pathEffect = new DashPathEffect(new float[]{dashSegmentLength, dashPaddingLength}, dynamicalPathPhase);
        paint.setPathEffect(pathEffect);
    }
}
项目:mapbox-navigation-android    文件:ManeuversStyleKit.java   
DashPathEffect get(float dash, float gap, float phase) {
  if (this.dash != dash || this.gap != gap || this.phase != phase) {
    this.dash = dash;
    this.gap = gap;
    this.phase = phase;
    this.effect = new DashPathEffect(new float[] {dash, gap}, phase);
  }
  return this.effect;
}
项目:RunHDU    文件:GradeProgressView.java   
private void setup() {

        mRectF = new RectF();
        mOuterRectF = new RectF();

        mOuterPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mOuterPaint.setStrokeWidth(outLineWidth);
        mOuterPaint.setColor(mBackgroundColor);
        mOuterPaint.setStyle(Paint.Style.STROKE);

        mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mPaint.setStrokeWidth(lineWidth);
        mPaint.setColor(mBackgroundColor);
        mPaint.setStyle(Paint.Style.STROKE);
        mPaint.setPathEffect(new DashPathEffect(new float[]{dashWith, dashSpace}, dashSpace));

        mProgressPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mProgressPaint.setStrokeWidth(lineWidth);
        mProgressPaint.setColor(mProgressColor);
        mProgressPaint.setStyle(Paint.Style.STROKE);
        mProgressPaint.setPathEffect(new DashPathEffect(new float[]{dashWith, dashSpace}, dashSpace));

        mPointerPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mPointerPaint.setStrokeWidth(pointLineWidth / 2);
        mPointerPaint.setColor(mProgressColor);
        mPointerPaint.setStyle(Paint.Style.FILL_AND_STROKE);
        mPointerPaint.setStrokeCap(Paint.Cap.ROUND);
        mPointerPaint.setShadowLayer(4, 3, 0, 0x20000000);

        mInnerCirclePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mInnerCirclePaint.setStrokeWidth(pointLineWidth);
        mInnerCirclePaint.setColor(mProgressColor);
        mInnerCirclePaint.setStyle(Paint.Style.STROKE);
        mInnerCirclePaint.setShadowLayer(4, 3, 0, 0x20000000);
    }
项目:Weather-Android    文件:GraphActivity.java   
private void temperatureGraph() {
    LineChartView lineChartView = (LineChartView) findViewById(R.id.graph_temperature);

    // Data
    LineSet dataset = new LineSet();
    for (int i = 0; i < weatherList.size(); i++) {
        float temperature = UnitConvertor.convertTemperature(Float.parseFloat(weatherList.get(i).getTemperature()), sp);

        if (temperature < minTemp) {
            minTemp = temperature;
        }

        if (temperature > maxTemp) {
            maxTemp = temperature;
        }

        dataset.addPoint(getDateLabel(weatherList.get(i), i), (float) ((Math.ceil(temperature / 2)) * 2));
    }
    dataset.setSmooth(false);
    dataset.setColor(Color.parseColor("#FF5722"));
    dataset.setThickness(4);

    lineChartView.addData(dataset);

    // Grid
    Paint paint = new Paint();
    paint.setStyle(Paint.Style.STROKE);
    paint.setAntiAlias(true);
    paint.setColor(Color.parseColor("#333333"));
    paint.setPathEffect(new DashPathEffect(new float[]{10, 10}, 0));
    paint.setStrokeWidth(1);
    lineChartView.setGrid(ChartView.GridType.HORIZONTAL, paint);
    lineChartView.setBorderSpacing(Tools.fromDpToPx(10));
    lineChartView.setAxisBorderValues((int) minTemp - 2, (int) maxTemp + 2);
    lineChartView.setStep(2);
    lineChartView.setXAxis(false);
    lineChartView.setYAxis(false);

    lineChartView.show();
}
项目:Weather-Android    文件:GraphActivity.java   
private void rainGraph() {
    LineChartView lineChartView = (LineChartView) findViewById(R.id.graph_rain);

    // Data
    LineSet dataset = new LineSet();
    for (int i = 0; i < weatherList.size(); i++) {
        float rain = Float.parseFloat(weatherList.get(i).getRain());

        if (rain < minRain) {
            minRain = rain;
        }

        if (rain > maxRain) {
            maxRain = rain;
        }

        dataset.addPoint(getDateLabel(weatherList.get(i), i), rain);
    }
    dataset.setSmooth(false);
    dataset.setColor(Color.parseColor("#2196F3"));
    dataset.setThickness(4);

    lineChartView.addData(dataset);

    // Grid
    Paint paint = new Paint();
    paint.setStyle(Paint.Style.STROKE);
    paint.setAntiAlias(true);
    paint.setColor(Color.parseColor("#333333"));
    paint.setPathEffect(new DashPathEffect(new float[]{10, 10}, 0));
    paint.setStrokeWidth(1);
    lineChartView.setGrid(ChartView.GridType.HORIZONTAL, paint);
    lineChartView.setBorderSpacing(Tools.fromDpToPx(10));
    lineChartView.setAxisBorderValues((int) minRain - 1, (int) maxRain + 2);
    lineChartView.setStep(1);
    lineChartView.setXAxis(false);
    lineChartView.setYAxis(false);

    lineChartView.show();
}
项目:Weather-Android    文件:GraphActivity.java   
private void pressureGraph() {
    LineChartView lineChartView = (LineChartView) findViewById(R.id.graph_pressure);

    // Data
    LineSet dataset = new LineSet();
    for (int i = 0; i < weatherList.size(); i++) {
        float pressure = UnitConvertor.convertPressure(Float.parseFloat(weatherList.get(i).getPressure()), sp);

        if (pressure < minPressure) {
            minPressure = pressure;
        }

        if (pressure > maxPressure) {
            maxPressure = pressure;
        }

        dataset.addPoint(getDateLabel(weatherList.get(i), i), pressure);
    }
    dataset.setSmooth(true);
    dataset.setColor(Color.parseColor("#4CAF50"));
    dataset.setThickness(4);

    lineChartView.addData(dataset);

    // Grid
    Paint paint = new Paint();
    paint.setStyle(Paint.Style.STROKE);
    paint.setAntiAlias(true);
    paint.setColor(Color.parseColor("#333333"));
    paint.setPathEffect(new DashPathEffect(new float[]{10, 10}, 0));
    paint.setStrokeWidth(1);
    lineChartView.setGrid(ChartView.GridType.HORIZONTAL, paint);
    lineChartView.setBorderSpacing(Tools.fromDpToPx(10));
    lineChartView.setAxisBorderValues((int) minPressure - 1, (int) maxPressure + 1);
    lineChartView.setStep(2);
    lineChartView.setXAxis(false);
    lineChartView.setYAxis(false);

    lineChartView.show();
}
项目:YiZhi    文件:HistoryChartView.java   
/**
 * 开启动画
 */
private void startAnimation() {
    if (mValueAnimator != null) {
        mValueAnimator.cancel();
    }
    final float targetTempLength = mTargetTempPathMeasure.getLength();
    final float roomTempLength = mRoomTempPathMeasure.getLength();
    mValueAnimator = ValueAnimator.ofFloat(1, 0);
    mValueAnimator.setDuration(ANIM_DURATION);
    // 减速插值器
    mValueAnimator.setInterpolator(new DecelerateInterpolator());
    mValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float fraction = (Float) animation.getAnimatedValue();
            // 更新mtargetTempEffect
            mtargetTempEffect = new DashPathEffect(new float[]{
                    targetTempLength, targetTempLength}, fraction
                    * targetTempLength);
            targetTempPaint.setPathEffect(mtargetTempEffect);
            // 更新mRoomTempEffect
            mRoomTempEffect = new DashPathEffect(new float[]{
                    roomTempLength, roomTempLength}, fraction
                    * roomTempLength);
            roomTempPaint.setPathEffect(mRoomTempEffect);
            // 更新rect绘制fraction进度
            mRectFration = 1 - fraction;// fraction是1->0 我们需要的柱形图绘制比例是0->1
            postInvalidate();
        }
    });
    mValueAnimator.start();
}