android.graphics.Path.Direction#android.graphics.DashPathEffect源码实例Demo

下面列出了android.graphics.Path.Direction#android.graphics.DashPathEffect 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: SmartLoadingView   文件: SmartLoadingView.java
/**
 * 绘制对勾的动画
 */
private void set_draw_ok_animation() {
    animator_draw_ok = ValueAnimator.ofFloat(1, 0);
    animator_draw_ok.setDuration(duration);
    animator_draw_ok.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            startDrawOk = true;
            isDrawLoading = false;
            float value = (Float) animation.getAnimatedValue();
            effect = new DashPathEffect(new float[]{pathMeasure.getLength(), pathMeasure.getLength()}, value * pathMeasure.getLength());
            okPaint.setPathEffect(effect);
            invalidate();

        }
    });
}
 
源代码2 项目: SegmentedButton   文件: SegmentedButton.java
/**
 * Set the border for the selected button
 *
 * @param width     Width of the border in pixels (default value is 0px or no border)
 * @param color     Color of the border (default color is black)
 * @param dashWidth Width of the dash for border, in pixels. Value of 0px means solid line (default is 0px)
 * @param dashGap   Width of the gap for border, in pixels.
 */
void setSelectedButtonBorder(int width, @ColorInt int color, int dashWidth, int dashGap)
{
    if (width > 0)
    {
        // Allocate Paint object for drawing border here
        // Used in onDraw to draw the border around the selected button
        selectedButtonBorderPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        selectedButtonBorderPaint.setStyle(Paint.Style.STROKE);
        selectedButtonBorderPaint.setStrokeWidth(width);
        selectedButtonBorderPaint.setColor(color);

        if (dashWidth > 0.0f)
        {
            selectedButtonBorderPaint.setPathEffect(new DashPathEffect(new float[] {dashWidth, dashGap}, 0));
        }
    }
    else
    {
        // If the width is 0, then disable drawing border
        selectedButtonBorderPaint = null;
    }

    invalidate();
}
 
源代码3 项目: 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;
    }
}
 
源代码4 项目: 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));
}
 
源代码5 项目: kAndroid   文件: LmeView.java
private void initView() {
    mDotPaint.setStyle(Paint.Style.FILL);   //圆点

    mDotLeftPaint.setStyle(Paint.Style.FILL);
    mDotLeftPaint.setStrokeWidth(dp2px(4));

    mTextPaint.setTextSize(sp2px(10)); //文字

    mLinePaint.setStrokeWidth(dp2px(1)); //线

    mDotRingPaint.setStrokeWidth(dp2px(2)); //圆弧
    mDotRingPaint.setStyle(Paint.Style.STROKE);
    mDotRingPaint.setColor(getColor(R.color.c6774FF));

    mImaginaryLinePaint.setColor(getColor(R.color.c67D9FF)); //虚线
    mImaginaryLinePaint.setStrokeWidth(dp2px(2));
    mImaginaryLinePaint.setStyle(Paint.Style.STROKE);
    mImaginaryLinePaint.setDither(true);
    DashPathEffect pathEffect = new DashPathEffect(new float[]{15, 15}, 1); //设置虚线
    mImaginaryLinePaint.setPathEffect(pathEffect);

}
 
源代码6 项目: ShapeView   文件: ButtonShapeView.java
@Override
protected void dispatchDraw(Canvas canvas) {
    super.dispatchDraw(canvas);

    if (defaultColor != 0 && firstDispatchDraw) {
        if (defaultDrawable == 0) {
            setBackgroundColor(defaultColor);
            firstDispatchDraw = false;
        }
    }

    if (borderWidthPx > 0) {
        borderPaint.setStrokeWidth(borderWidthPx);
        borderPaint.setColor(borderColor);
        if (borderDashGap > 0 && borderDashWidth > 0) {
            borderPaint.setPathEffect(new DashPathEffect(new float[]{borderDashWidth, borderDashGap}, 0));
        }
        canvas.drawPath(getClipHelper().mPath, borderPaint);
    }
}
 
源代码7 项目: OXChart   文件: OilTableLine.java
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    super.onSizeChanged(w, h, oldw, oldh);
    float size = Math.min(w, h) - tableWidth * 2;
    //油表的位置方框
    mTableRectF = new RectF(0, 0, size, size);
    mPath.reset();
    //在油表路径中增加一个从起始弧度
    mPath.addArc(mTableRectF, 60, 240);
    //计算路径的长度
    PathMeasure pathMeasure = new PathMeasure(mPath, false);
    float length = pathMeasure.getLength();
    float step = length / 60;
    dashPathEffect = new DashPathEffect(new float[]{step / 3, step * 2 / 3}, 0);

    float radius = size / 2;
    mColorShader = new SweepGradient(radius, radius,SWEEP_GRADIENT_COLORS,null);
    //设置指针的路径位置
    mPointerPath.reset();
    mPointerPath.moveTo(radius, radius - 20);
    mPointerPath.lineTo(radius, radius + 20);
    mPointerPath.lineTo(radius * 2 - tableWidth, radius);
    mPointerPath.close();
}
 
源代码8 项目: OXChart   文件: LinesChart.java
/**绘制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);
        }
    }
}
 
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;
  }
}
 
public PyxCardsGroupView(Context context, CardListener listener) {
    super(context);
    this.listener = listener;
    setOrientation(HORIZONTAL);
    setWillNotDraw(false);

    mPaddingSmall = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics());
    mCornerRadius = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, getResources().getDisplayMetrics());
    mLineWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1.6f, getResources().getDisplayMetrics());

    mLinePaint = new Paint();
    mLinePaint.setColor(CommonUtils.resolveAttrAsColor(context, android.R.attr.textColorSecondary));
    mLinePaint.setStrokeWidth(mLineWidth);
    mLinePaint.setStyle(Paint.Style.STROKE);
    mLinePaint.setPathEffect(new DashPathEffect(new float[]{20, 10}, 0));
}
 
源代码11 项目: Svg-for-Apache-Weex   文件: 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;
}
 
源代码12 项目: SmartLoadingView   文件: OkView.java
public void start(int duration) {
    animator_draw_ok = ValueAnimator.ofFloat(1, 0);
    animator_draw_ok.setDuration(duration);
    animator_draw_ok.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            startDrawOk = true;
            float value = (Float) animation.getAnimatedValue();
            effect = new DashPathEffect(new float[]{pathMeasure.getLength(), pathMeasure.getLength()}, value * pathMeasure.getLength());
            okPaint.setPathEffect(effect);
            invalidate();
        }
    });
    animator_draw_ok.start();
}
 
源代码13 项目: InteractiveChart   文件: CursorDrawing.java
@Override public void onInit(CandleRender render, AbsChartModule chartModule) {
  super.onInit(render, chartModule);
  this.attribute = render.getAttribute();
  DashPathEffect dashPathEffect = new DashPathEffect(new float[] { 15, 8 }, 0);
  increasingLinePaint.setStrokeWidth(attribute.lineWidth);
  increasingLinePaint.setStyle(Paint.Style.STROKE);
  increasingLinePaint.setColor(attribute.increasingColor);
  increasingLinePaint.setPathEffect(dashPathEffect);

  decreasingLinePaint.setStrokeWidth(attribute.lineWidth);
  decreasingLinePaint.setStyle(Paint.Style.STROKE);
  decreasingLinePaint.setColor(attribute.decreasingColor);
  decreasingLinePaint.setPathEffect(dashPathEffect);

  increasingTextPaint.setStrokeWidth(attribute.lineWidth);
  increasingTextPaint.setTextSize(attribute.labelSize);
  increasingTextPaint.setColor(attribute.increasingColor);
  increasingTextPaint.setTypeface(FontConfig.typeFace);

  decreasingTextPaint.setStrokeWidth(attribute.lineWidth);
  decreasingTextPaint.setTextSize(attribute.labelSize);
  decreasingTextPaint.setColor(attribute.decreasingColor);
  decreasingTextPaint.setTypeface(FontConfig.typeFace);

  increasingBorderPaint.setStrokeWidth(attribute.cursorBorderWidth);
  increasingBorderPaint.setStyle(Paint.Style.STROKE);
  increasingBorderPaint.setColor(attribute.increasingColor);

  decreasingBorderPaint.setStrokeWidth(attribute.cursorBorderWidth);
  decreasingBorderPaint.setStyle(Paint.Style.STROKE);
  decreasingBorderPaint.setColor(attribute.decreasingColor);

  cursorBackgroundPaint.setStyle(Paint.Style.FILL);
  cursorBackgroundPaint.setColor(attribute.cursorBackgroundColor);
}
 
public static @NonNull
DashPathEffect[] defaultDashPathEffects() {
    return new DashPathEffect[]{
            null,                                                   // -----------------------
            new DashPathEffect(new float[]{10, 4}, 0),       // -----  -----  -----  -----
            new DashPathEffect(new float[]{4, 6}, 0),        // --   --   --   --   --
            new DashPathEffect(new float[]{8, 8}, 0),        // ----    ----    -----
            new DashPathEffect(new float[]{2, 4}, 0),        // -  -  -  -  -  -  -  -
            new DashPathEffect(new float[]{6, 4, 2, 1}, 0),  // ---  -  ---  -
    };
}
 
源代码15 项目: DoraemonKit   文件: LayoutBorderView.java
private void initView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
    TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.LayoutBorderView);
    boolean fill = a.getBoolean(R.styleable.LayoutBorderView_dkFill, false);
    mRectPaint = new Paint();
    if (fill) {
        mRectPaint.setStyle(Paint.Style.FILL);
        mRectPaint.setColor(Color.RED);
    } else {
        mRectPaint.setStyle(Paint.Style.STROKE);
        mRectPaint.setStrokeWidth(4);
        mRectPaint.setPathEffect(new DashPathEffect(new float[]{4, 4}, 0));
        mRectPaint.setColor(Color.RED);
    }
    a.recycle();
}
 
源代码16 项目: DoraemonKit   文件: ViewBorderDrawable.java
public ViewBorderDrawable(View view) {
    rect = new Rect(0, 0, view.getWidth(), view.getHeight());
    context= view.getContext();

    paint.setStyle(Paint.Style.STROKE);
    paint.setColor(Color.RED);
    paint.setStrokeWidth(4);
    paint.setPathEffect(new DashPathEffect(new float[]{4, 4}, 0));
}
 
源代码17 项目: DoraemonKit   文件: DisplayLeakConnectorView.java
public DisplayLeakConnectorView(Context context, AttributeSet attrs) {
  super(context, attrs);

  Resources resources = getResources();

  type = Type.NODE_UNKNOWN;
  circleY = resources.getDimensionPixelSize(R.dimen.leak_canary_connector_center_y);
  strokeSize = resources.getDimensionPixelSize(R.dimen.leak_canary_connector_stroke_size);

  classNamePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
  classNamePaint.setColor(resources.getColor(R.color.leak_canary_class_name));
  classNamePaint.setStrokeWidth(strokeSize);

  leakPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
  leakPaint.setColor(resources.getColor(R.color.leak_canary_leak));
  leakPaint.setStyle(Paint.Style.STROKE);
  leakPaint.setStrokeWidth(strokeSize);
  float pathLines = resources.getDimensionPixelSize(R.dimen.leak_canary_connector_leak_dash_line);
  float pathGaps = resources.getDimensionPixelSize(R.dimen.leak_canary_connector_leak_dash_gap);
  leakPaint.setPathEffect(new DashPathEffect(new float[] { pathLines, pathGaps }, 0));

  clearPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
  clearPaint.setColor(Color.TRANSPARENT);
  clearPaint.setXfermode(CLEAR_XFER_MODE);

  referencePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
  referencePaint.setColor(resources.getColor(R.color.leak_canary_reference));
  referencePaint.setStrokeWidth(strokeSize);
}
 
源代码18 项目: ShapeView   文件: ShapeView.java
@Override
protected void dispatchDraw(Canvas canvas) {
    super.dispatchDraw(canvas);

    if (defaultColor != 0 && firstDispatchDraw) {
        if (defaultDrawable == 0) {
            setBackgroundColor(defaultColor);
            firstDispatchDraw = false;
        }
    }

    if (borderWidthPx > 0) {
        borderPaint.setStrokeWidth(borderWidthPx);
        borderPaint.setColor(borderColor);
        if (borderDashGap > 0 && borderDashWidth > 0) {
            borderPaint.setPathEffect(new DashPathEffect(new float[]{borderDashWidth, borderDashGap}, 0));
        }

        switch (shapeType) {
            case CIRCLE:
                canvas.drawCircle(getWidth() / 2f, getHeight() / 2f, Math.min((getWidth() - borderWidthPx) / 2f, (getHeight() - borderWidthPx) / 2f), borderPaint);
                break;
            case HEART:
                canvas.drawPath(getClipHelper().mPath, borderPaint);
                break;
            case POLYGON:
                canvas.drawPath(getClipHelper().mPath, borderPaint);
                break;
            case STAR:
                canvas.drawPath(getClipHelper().mPath, borderPaint);
                break;
        }
    }
}
 
源代码19 项目: OXChart   文件: NightingaleRoseChart.java
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);


}
 
源代码20 项目: android-kline   文件: 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;
}
 
public Chart(Context context, AttributeSet attrs) {
    super(context, attrs);

    linePaint = new Paint();
    linePaint.setAntiAlias(true);
    linePaint.setColor(0xffffffff);
    linePaint.setStrokeWidth(8.f);
    linePaint.setStyle(Paint.Style.STROKE);

    circlePaint = new Paint();
    circlePaint.setAntiAlias(true);
    circlePaint.setColor(0xffff2020);
    circlePaint.setStyle(Paint.Style.FILL);

    backgroundPaint = new Paint();
    backgroundPaint.setColor(0xffFFFF80);
    backgroundPaint.setStyle(Paint.Style.STROKE);
    backgroundPaint.setPathEffect(new DashPathEffect(new float[] {5, 5}, 0));
    backgroundPaint.setTextSize(20.f);

    graphPath = new Path();
    circlePath = new Path();
    backgroundPath = new Path();
    lastWidth = -1;
    lastHeight = -1;

    textBoundaries = new Rect();
    decimalFormat = new DecimalFormat("#.##");
    verticalLabels = new String[11];

    invertVerticalAxis = false;
    drawLegend = true;
}
 
源代码22 项目: Ticket-Analysis   文件: 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;
}
 
源代码23 项目: TicketView   文件: TicketView.java
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());
}
 
源代码24 项目: StockChart-MPAndroidChart   文件: 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;
}
 
源代码25 项目: DS4Android   文件: HelpDraw.java
@NonNull
public static Paint getHelpPint(int color) {
    //初始化网格画笔
    Paint paint = new Paint();
    paint.setStrokeWidth(1);
    paint.setColor(color);
    paint.setTextSize(50);
    paint.setStrokeCap(Paint.Cap.ROUND);
    paint.setStyle(Paint.Style.STROKE);
    //设置虚线效果new float[]{可见长度, 不可见长度},偏移值
    paint.setPathEffect(new DashPathEffect(new float[]{10, 5}, 0));
    return paint;
}
 
源代码26 项目: JZAndroidChart   文件: AxisRenderer.java
public void drawGridLines(Canvas canvas) {

        if (mAxis.isEnable() && mAxis.isGridLineEnable() && mAxis.getGridCount() > 0) {
            int count = mAxis.getGridCount() + 1;

            if (mAxis.getDashedGridIntervals() != null && mAxis.getDashedGridPhase() > 0) {
                mGridPaint.setPathEffect(new DashPathEffect(mAxis.getDashedGridIntervals(), mAxis.getDashedGridPhase()));
            }

            if (mAxis instanceof AxisX) {
                final float width = mContentRect.width() / ((float) count);
                for (int i = 1; i < count; i++) {
                    if (mAxis.getGirdLineColorSetter() != null) {
                        mGridPaint.setColor(mAxis.getGirdLineColorSetter().getColorByIndex(mAxis.getGridColor(), i));
                    }
                    canvas.drawLine(
                            mContentRect.left + i * width,
                            mContentRect.top,
                            mContentRect.left + i * width,
                            mContentRect.bottom,
                            mGridPaint);
                }
            }
            if (mAxis instanceof AxisY) {
                final float height = mContentRect.height() / ((float) count);
                for (int i = 1; i < count; i++) {
                    if (mAxis.getGirdLineColorSetter() != null) {
                        mGridPaint.setColor(mAxis.getGirdLineColorSetter().getColorByIndex(mAxis.getGridColor(), i));
                    }
                    canvas.drawLine(
                            mContentRect.left,
                            mContentRect.top + i * height,
                            mContentRect.right,
                            mContentRect.top + i * height,
                            mGridPaint);
                }
            }
        }
    }
 
源代码27 项目: Captcha   文件: DefaultCaptchaStrategy.java
@Override
public void decoreateSwipeBlockBitmap(Canvas canvas, Path shape) {
    Paint paint = new Paint();
    paint.setColor(Color.parseColor("#FFFFFF"));
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeWidth(10);
    paint.setPathEffect(new DashPathEffect(new float[]{20,20},10));
    Path path = new Path(shape);
    canvas.drawPath(path,paint);
}
 
源代码28 项目: homeassist   文件: GeneralFragment.java
private void initViews() {
        mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                refresh();
            }
        });

        Paint paint = new Paint();
        paint.setStrokeWidth(1);
        paint.setColor(ResourcesCompat.getColor(getResources(), R.color.colorDivider, null));
        paint.setAntiAlias(true);
        paint.setPathEffect(new DashPathEffect(new float[]{25.0f, 25.0f}, 0));

        mDivider = new HorizontalDividerItemDecoration.Builder(getActivity()).showLastDivider().paint(paint).build();
        mAdapter = new ItemAdapter(items);
        //mRecyclerView.addItemDecoration(mDivider); //.marginResId(R.dimen.leftmargin, R.dimen.rightmargin)
        mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
        mRecyclerView.setAdapter(mAdapter);

//            mRetryView = new RetryView(findViewById(android.R.id.content));
//            mRetryView.showError();

        //items.add(new Item(getString(R.string.login_id), transaction.dealerId));


    }
 
源代码29 项目: homeassist   文件: EditActivity.java
private Paint getDividerPaint() {
    Paint paint = new Paint();
    paint.setStrokeWidth(1);
    paint.setColor(ResourcesCompat.getColor(getResources(), R.color.colorDivider, null));
    paint.setAntiAlias(true);
    paint.setPathEffect(new DashPathEffect(new float[]{25.0f, 25.0f}, 0));
    return paint;
}
 
源代码30 项目: ClassSchedule   文件: CourseView.java
private void initPaint() {
    mLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mLinePaint.setColor(Color.LTGRAY);
    mLinePaint.setStrokeWidth(1);
    mLinePaint.setStyle(Paint.Style.STROKE);
    mLinePaint.setPathEffect(new DashPathEffect(new float[]{5, 5}, 0));
}