android.graphics.DashPathEffect Java Examples

The following examples show how to use android.graphics.DashPathEffect. 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: PyxCardsGroupView.java    From PretendYoureXyzzyAndroid with GNU General Public License v3.0 6 votes vote down vote up
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));
}
 
Example #2
Source File: SegmentedButton.java    From SegmentedButton with Apache License 2.0 6 votes vote down vote up
/**
 * 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();
}
 
Example #3
Source File: SmartLoadingView.java    From SmartLoadingView with MIT License 6 votes vote down vote up
/**
 * 绘制对勾的动画
 */
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();

        }
    });
}
 
Example #4
Source File: ButtonShapeView.java    From ShapeView with Apache License 2.0 6 votes vote down vote up
@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);
    }
}
 
Example #5
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 #6
Source File: NativeLineImp.java    From Virtualview-Android with MIT License 6 votes vote down vote up
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;
    }
}
 
Example #7
Source File: LmeView.java    From kAndroid with Apache License 2.0 6 votes vote down vote up
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);

}
 
Example #8
Source File: StrokeContent.java    From atlas with Apache License 2.0 6 votes vote down vote up
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));
}
 
Example #9
Source File: WXSvgPath.java    From Svg-for-Apache-Weex with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #10
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 #11
Source File: OilTableLine.java    From OXChart with Apache License 2.0 6 votes vote down vote up
@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();
}
 
Example #12
Source File: CursorDrawing.java    From InteractiveChart with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #13
Source File: LayoutBorderView.java    From DoraemonKit with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example #14
Source File: OkView.java    From SmartLoadingView with MIT License 5 votes vote down vote up
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();
}
 
Example #15
Source File: ShapeView.java    From ShapeView with Apache License 2.0 5 votes vote down vote up
@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;
        }
    }
}
 
Example #16
Source File: UartStyle.java    From Bluefruit_LE_Connect_Android_V2 with MIT License 5 votes vote down vote up
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),  // ---  -  ---  -
    };
}
 
Example #17
Source File: ViewBorderDrawable.java    From DoraemonKit with Apache License 2.0 5 votes vote down vote up
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));
}
 
Example #18
Source File: DisplayLeakConnectorView.java    From DoraemonKit with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #19
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 #20
Source File: CourseView.java    From ClassSchedule with Apache License 2.0 5 votes vote down vote up
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));
}
 
Example #21
Source File: EditActivity.java    From homeassist with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #22
Source File: GeneralFragment.java    From homeassist with Apache License 2.0 5 votes vote down vote up
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));


    }
 
Example #23
Source File: LegendEntry.java    From android-kline with Apache License 2.0 5 votes vote down vote up
/**
 *
 * @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;
}
 
Example #24
Source File: Chart.java    From Building-Android-UIs-with-Custom-Views with MIT License 5 votes vote down vote up
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;
}
 
Example #25
Source File: LegendEntry.java    From Ticket-Analysis with MIT License 5 votes vote down vote up
/**
 *
 * @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;
}
 
Example #26
Source File: DefaultCaptchaStrategy.java    From Captcha with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #27
Source File: AxisRenderer.java    From JZAndroidChart with Apache License 2.0 5 votes vote down vote up
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);
                }
            }
        }
    }
 
Example #28
Source File: HelpDraw.java    From DS4Android with MIT License 5 votes vote down vote up
@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;
}
 
Example #29
Source File: LegendEntry.java    From StockChart-MPAndroidChart with MIT License 5 votes vote down vote up
/**
 * @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;
}
 
Example #30
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());
}