Java Code Examples for android.graphics.Paint.setPathEffect()

The following are Jave code examples for showing how to use setPathEffect() of the android.graphics.Paint class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Exoplayer2Radio   File: DvbParser.java   View Source Code Vote up 6 votes
/**
 * Construct an instance for the given subtitle and ancillary page ids.
 *
 * @param subtitlePageId The id of the subtitle page carrying the subtitle to be parsed.
 * @param ancillaryPageId The id of the ancillary page containing additional data.
 */
public DvbParser(int subtitlePageId, int ancillaryPageId) {
  defaultPaint = new Paint();
  defaultPaint.setStyle(Paint.Style.FILL_AND_STROKE);
  defaultPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));
  defaultPaint.setPathEffect(null);
  fillRegionPaint = new Paint();
  fillRegionPaint.setStyle(Paint.Style.FILL);
  fillRegionPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OVER));
  fillRegionPaint.setPathEffect(null);
  canvas = new Canvas();
  defaultDisplayDefinition = new DisplayDefinition(719, 575, 0, 719, 0, 575);
  defaultClutDefinition = new ClutDefinition(0, generateDefault2BitClutEntries(),
      generateDefault4BitClutEntries(), generateDefault8BitClutEntries());
  subtitleService = new SubtitleService(subtitlePageId, ancillaryPageId);
}
 
Example 2
Project: Rxjava2.0Demo   File: FalsifyHeader.java   View Source Code Vote up 6 votes
@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);
    }
}
 
Example 3
Project: GitHub   File: PaintActivity.java   View Source Code Vote up 5 votes
@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());
}
 
Example 4
Project: atlant-android   File: ChartView.java   View Source Code Vote up 5 votes
private void drawVerticalLine(Canvas canvas, int position, int percent) {
  float x = getX(position);
  float y = getY(percent);

  Paint paint = new Paint();
  paint.setColor(colorEnd);
  paint.setStrokeWidth(DimensUtils.dpToPx(getContext(), 0.5f));
  paint.setStyle(Style.STROKE);
  paint.setAntiAlias(true);
  paint.setPathEffect(new DashPathEffect(new float[]{lineDash, lineDash}, 0));
  canvas.drawLine(x, y + radius * 2, x, getY(0), paint);
}
 
Example 5
Project: DashProgress   File: DashProgressCircle.java   View Source Code Vote up 5 votes
private void init(){
        calculateDelta();

        bgpaint=new Paint();
        bgpaint.setAntiAlias(true);//抗锯齿功能
        bgpaint.setColor(bgclolor);  //设置画笔颜色
        bgpaint.setStyle(Paint.Style.FILL);//设置填充样式   Style.FILL/Style.FILL_AND_STROKE/Style.STROKE

        setLayerType( LAYER_TYPE_SOFTWARE , null);
        outpaint = new Paint();
        outpaint.setAntiAlias(true);
        outpaint.setStyle(Paint.Style.STROKE);
        outpaint.setStrokeWidth(internalStrokeWidth);
        if(dash) {
            outpaint.setPathEffect(new DashPathEffect(new float[]{uit, dashSpace},
                    0));
        }else{
            //设置线冒,这个并非不管用,而是他的颜色未达到预期
//            outpaint.setStrokeJoin(Paint.Join.ROUND);
//            outpaint.setStrokeCap(Paint.Cap.ROUND);
            //伪装的线冒哈哈
            startPaint = new Paint();
            startPaint.setColor(unitstartcolor);
            startPaint.setAntiAlias(true);
            startPaint.setStyle(Paint.Style.FILL);


            endPaint = new Paint();
            endPaint.setAntiAlias(true);
            endPaint.setStyle(Paint.Style.FILL);


        }


    }
 
Example 6
Project: Sega   File: SimpleRatingBar.java   View Source Code Vote up 5 votes
/**
 * Inits paint objects and default values.
 */
private void initView() {
    starPath = new Path();
    cornerPathEffect = new CornerPathEffect(starCornerRadius);

    paintStarOutline = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
    paintStarOutline.setStyle(Paint.Style.FILL_AND_STROKE);
    paintStarOutline.setAntiAlias(true);
    paintStarOutline.setDither(true);
    paintStarOutline.setStrokeJoin(Paint.Join.ROUND);
    paintStarOutline.setStrokeCap(Paint.Cap.ROUND);
    paintStarOutline.setColor(Color.BLACK);
    paintStarOutline.setPathEffect(cornerPathEffect);

    paintStarBorder = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
    paintStarBorder.setStyle(Paint.Style.STROKE);
    paintStarBorder.setStrokeJoin(Paint.Join.ROUND);
    paintStarBorder.setStrokeCap(Paint.Cap.ROUND);
    paintStarBorder.setStrokeWidth(starBorderWidth);
    paintStarBorder.setPathEffect(cornerPathEffect);

    paintStarBackground = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
    paintStarBackground.setStyle(Paint.Style.FILL_AND_STROKE);
    paintStarBackground.setAntiAlias(true);
    paintStarBackground.setDither(true);
    paintStarBackground.setStrokeJoin(Paint.Join.ROUND);
    paintStarBackground.setStrokeCap(Paint.Cap.ROUND);

    paintStarFill = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
    paintStarFill.setStyle(Paint.Style.FILL_AND_STROKE);
    paintStarFill.setAntiAlias(true);
    paintStarFill.setDither(true);
    paintStarFill.setStrokeJoin(Paint.Join.ROUND);
    paintStarFill.setStrokeCap(Paint.Cap.ROUND);

    defaultStarSize = applyDimension(COMPLEX_UNIT_DIP, 30, getResources().getDisplayMetrics());
}
 
Example 7
Project: TrendChartView   File: TrendYAxisView.java   View Source Code Vote up 5 votes
private void init(Context context, AttributeSet attrs) {
    DashPathEffect mPathEffect = new DashPathEffect(new float[]{dp2px(2), dp2px(2)}, 1);
    mGradeAxisPaint = new Paint();
    mGradeAxisPaint.reset();
    mGradeAxisPaint.setStyle(Paint.Style.STROKE);
    mGradeAxisPaint.setStrokeWidth(1);
    mGradeAxisPaint.setColor(isDebug ? Color.parseColor("#000000") : Color.parseColor("#16ffffff"));
    mGradeAxisPaint.setAntiAlias(true);
    mGradeAxisPaint.setPathEffect(mPathEffect);

    mTextPaint = new TextPaint();
    mTextPaint.setColor(Color.parseColor("#ffffff"));
    mTextPaint.setTextSize(dp2px(11));
    mTextPaint.setAntiAlias(true);
}
 
Example 8
Project: DailyStudy   File: StepperIndicator.java   View Source Code Vote up 5 votes
private void initData() {
    float defaultLineStrokeWidth = getResources().getDimension(R.dimen.stpi_default_line_stroke_width);
    linePaint = new Paint();
    linePaint.setStrokeWidth(defaultLineStrokeWidth);
    linePaint.setStrokeCap(Paint.Cap.ROUND);
    linePaint.setStyle(Paint.Style.STROKE);
    linePaint.setColor(Color.parseColor("#b3bdc2"));
    linePaint.setAntiAlias(true);

    lineDoneAnimatedPaint = new Paint(linePaint);
    lineDoneAnimatedPaint.setColor(Color.parseColor("#00b47c"));

    lineDoneAnimatedPaint.setPathEffect(null);
}
 
Example 9
Project: BubbleAlert   File: AlertDrawable.java   View Source Code Vote up 5 votes
public AlertDrawable(int outerCircleRadiusDP, int textSizeSP, int cornerArc, String drawText, Context context) {
    mContext = context;

    circleRadius = ScreenUtils.unitToPixels(context, TypedValue.COMPLEX_UNIT_DIP, outerCircleRadiusDP);
    textSize = ScreenUtils.unitToPixels(context, TypedValue.COMPLEX_UNIT_SP, textSizeSP);
    mDrawText = TextUtils.isEmpty(drawText) ? " " : drawText;
    initBitmap(mDrawText);
    mBackGroundPaint = new Paint();
    mBackGroundPaint.setAntiAlias(true);
    mBackGroundPaint.setDither(true);
    mBackGroundPaint.setColor(Color.WHITE);
    mBackGroundPaint.setStyle(Paint.Style.FILL);


    mCircleFillPaint = new Paint();
    mCircleFillPaint.setAntiAlias(true);
    mCircleFillPaint.setDither(true);
    mCircleFillPaint.setColor(ContextCompat.getColor(context, R.color.colorMultiArc));
    mCircleFillPaint.setStyle(Paint.Style.FILL);

    mOuterCircleFillPaint = new Paint();
    mOuterCircleFillPaint.setAntiAlias(true);
    mOuterCircleFillPaint.setDither(true);
    mOuterCircleFillPaint.setColor(Color.WHITE);
    mOuterCircleFillPaint.setStyle(Paint.Style.FILL);
    mOuterCircleFillPaint.setTextSize(textSize);


    borderPath = new Path();
    borderRect = new Rect();

    CornerPathEffect cornerPathEffect = new CornerPathEffect(cornerArc);
    mBackGroundPaint.setPathEffect(cornerPathEffect);

    outerCircleOffset = context.getResources().getInteger(R.integer.outerCircleOffset);
}
 
Example 10
Project: Weather-Android   File: GraphActivity.java   View Source Code Vote up 5 votes
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();
}
 
Example 11
Project: Image-Detection-Samples   File: FaceDrawer.java   View Source Code Vote up 5 votes
private void init() {
    paintMarker = new Paint();
    paintMarker.setColor(Color.RED);
    paintMarker.setStrokeWidth(10);
    paintMarker.setStyle(Paint.Style.STROKE);
    // to create a discontinuous marker
    paintMarker.setPathEffect(new DashPathEffect(new float[] {10,20}, 0));

    Drawable drawable = new BitmapDrawable(getResources(), decodeResource(getResources(),
            R.drawable.goku_supersayan));
    drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
    drawableStore.put(KEY_BITMAP_HEAD, drawable);
    rect = new Rect();
    transformation = new Matrix();
}
 
Example 12
Project: Building-Android-UIs-with-Custom-Views   File: Chart.java   View Source Code Vote up 5 votes
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 13
Project: starcor.xul   File: XulLayerRender.java   View Source Code Vote up 5 votes
@Override
public void drawBorder(XulDC dc, Rect rect, int xBase, int yBase) {
	if (_isInvisible()) {
		return;
	}
	Paint defStrokePaint = _ctx.getDefStrokePaint();
	Rect targetRc = getDrawingRect();
	if (_borderSize > 0.1f && (_borderColor & 0xFF000000) != 0) {
		float borderSize = _borderSize * _scalarX;
		defStrokePaint.setStrokeWidth(borderSize);
		defStrokePaint.setColor(_borderColor);
		if (_borderEffect != null) {
			defStrokePaint.setPathEffect(_borderEffect);
		}
		if (_clipShape != null) {
			RectF focusRect = this.getFocusRect();
			Canvas canvas = dc.getCanvas();
			_clipShape.resize(XulUtils.calRectWidth(focusRect), XulUtils.calRectHeight(focusRect));
			_clipShape.draw(canvas, defStrokePaint);
		} else if (_borderRoundX > 0.5 && _borderRoundY > 0.5) {
			float borderDelta = (borderSize / 2) - borderSize * _borderPos;
			float x = targetRc.left + borderDelta + _screenX + xBase;
			float y = targetRc.top + borderDelta + _screenY + yBase;
			float cx = XulUtils.calRectWidth(targetRc) - 2 * borderDelta;
			float cy = XulUtils.calRectHeight(targetRc) - 2 * borderDelta;
			dc.drawRoundRect(x, y, cx, cy, _borderRoundX * _scalarX, _borderRoundY * _scalarY, defStrokePaint);
		} else {
			int xStart = _screenX + xBase;
			int yStart = _screenY + yBase;
			dc.drawRect(targetRc.left + xStart, targetRc.top + yStart, targetRc.right + xStart, targetRc.bottom + yStart, defStrokePaint);
		}
		if (_borderEffect != null) {
			defStrokePaint.setPathEffect(null);
		}
	}
}
 
Example 14
Project: GitHub   File: MultiViewTypesActivity.java   View Source Code Vote up 4 votes
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_loadmore);

        toolbar = (Toolbar) findViewById(R.id.tool_bar);
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayShowTitleEnabled(false);


        ultimateRecyclerView = (UltimateRecyclerView) findViewById(R.id.ultimate_recycler_view);
        ultimateRecyclerView.setHasFixedSize(false);
        List<String> stringList = new ArrayList<>();

        stringList.add("111");
        stringList.add("aaa");
        stringList.add("222");
        stringList.add("33");
        stringList.add("44");
        stringList.add("55");


        simpleRecyclerViewAdapter = new MultiViewTypesRecyclerViewAdapter(stringList);
        simpleRecyclerViewAdapter.setCustomLoadMoreView(
                LayoutInflater.from(this).inflate(R.layout.custom_bottom_progressbar, null));

//        stringList.add("66");
//        stringList.add("11771");
        linearLayoutManager = new LinearLayoutManager(this);
        ultimateRecyclerView.setLayoutManager(linearLayoutManager);
        // ultimateRecyclerView.setAdapter(simpleRecyclerViewAdapter);
        ultimateRecyclerView.setAdapter(simpleRecyclerViewAdapter);
        ultimateRecyclerView.setDefaultOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        simpleRecyclerViewAdapter.insert("Refresh things", 0);
                        ultimateRecyclerView.setRefreshing(false);
                        //   ultimateRecyclerView.scrollBy(0, -50);
                        linearLayoutManager.scrollToPosition(0);
                    }
                }, 1000);
            }
        });

        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));
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
            ultimateRecyclerView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
        }
        ultimateRecyclerView.addItemDecoration(new HorizontalDividerItemDecoration.Builder(this).paint(paint).build());

      //  simpleRecyclerViewAdapter.ad

    }
 
Example 15
Project: PaoMovie   File: WaveformView.java   View Source Code Vote up 4 votes
public WaveformView(Context context, AttributeSet attrs) {
       super(context, attrs);

       // We don't want keys, the markers get these
       setFocusable(false);

       mGridPaint = new Paint();
       mGridPaint.setAntiAlias(false);
       mGridPaint.setColor(
           getResources().getColor(R.drawable.grid_line));
       mSelectedLinePaint = new Paint();
       mSelectedLinePaint.setAntiAlias(false);
       mSelectedLinePaint.setColor(
           getResources().getColor(R.drawable.waveform_selected));
       mUnselectedLinePaint = new Paint();
       mUnselectedLinePaint.setAntiAlias(false);
       mUnselectedLinePaint.setColor(
           getResources().getColor(R.drawable.waveform_unselected));
       mUnselectedBkgndLinePaint = new Paint();
       mUnselectedBkgndLinePaint.setAntiAlias(false);
       mUnselectedBkgndLinePaint.setColor(
           getResources().getColor(
               R.drawable.waveform_unselected_bkgnd_overlay));
       mBorderLinePaint = new Paint();
       mBorderLinePaint.setAntiAlias(true);
       mBorderLinePaint.setStrokeWidth(1.5f);
       mBorderLinePaint.setPathEffect(
           new DashPathEffect(new float[] { 3.0f, 2.0f }, 0.0f));
       mBorderLinePaint.setColor(
           getResources().getColor(R.drawable.selection_border));
       mPlaybackLinePaint = new Paint();
       mPlaybackLinePaint.setAntiAlias(false);
       mPlaybackLinePaint.setColor(
           getResources().getColor(R.drawable.playback_indicator));
       mTimecodePaint = new Paint();
       mTimecodePaint.setTextSize(12);
       mTimecodePaint.setAntiAlias(true);
       mTimecodePaint.setColor(
           getResources().getColor(R.drawable.timecode));
       mTimecodePaint.setShadowLayer(
           2, 1, 1,
           getResources().getColor(R.drawable.timecode_shadow));

mGestureDetector = new GestureDetector(
        context,
	new GestureDetector.SimpleOnGestureListener() {
	    public boolean onFling(
		        MotionEvent e1, MotionEvent e2, float vx, float vy) {
		mListener.waveformFling(vx);
		return true;
	    }
	});

       mSoundFile = null;
       mLenByZoomLevel = null;
       mValuesByZoomLevel = null;
       mHeightsAtThisZoomLevel = null;
       mOffset = 0;
       mPlaybackPos = -1;
       mSelectionStart = 0;
       mSelectionEnd = 0;
       mDensity = 1.0f;
       mInitialized = false;
   }
 
Example 16
Project: SmartMath   File: FlatChart.java   View Source Code Vote up 4 votes
public void drawLine(Canvas canvas, Position3D p3PrevPoint, Position3D p3NextPoint, Paint paint, LineStyle lineStyle)	{
	if (lineStyle.menumLinePattern == LINEPATTERN.LINEPATTERN_NON)	{
		return;
	}
	int nOriginalColor = paint.getColor();
	Style styleOriginal = paint.getStyle();
	float fOriginalStrokeWidth = paint.getStrokeWidth();
	PathEffect pathEffectOriginal = paint.getPathEffect();

	if (lineStyle.mclr != null)	{
		paint.setColor(lineStyle.mclr.getARGB());
	}
	paint.setStyle(Style.STROKE);
	paint.setStrokeWidth((float)lineStyle.mdLineWidth);
	switch (lineStyle.menumLinePattern)	{
	case LINEPATTERN_DASH:
	{
		paint.setPathEffect(new DashPathEffect(new float[]{(float)mdVerySmallSize, (float)mdTinySize}, 0));
		break;
	}
	case LINEPATTERN_DOT:
	{
		paint.setPathEffect(new DashPathEffect(new float[]{(float)mdVeryTinySize, (float)mdTinySize}, 0));
		break;
	}
	case LINEPATTERN_DASH_DOT:
	{
		paint.setPathEffect(new DashPathEffect(new float[]{(float)mdVerySmallSize, (float)mdTinySize, (float)mdVeryTinySize, (float)mdTinySize}, 0));
		break;
	}
	/* case LINEPATTERN_NON:	// need not to consider LINEPATTERN_NON
	{
		paint.setPathEffect(new DashPathEffect(new float[]{0, (float)mdMediumSize}, 0));
		break;
	} */
	default:	// solid
		paint.setPathEffect(new PathEffect());
	}
	
	float fX0 = (float)p3PrevPoint.getX(), fY0 = (float)p3PrevPoint.getY(),
			fX1 = (float)p3NextPoint.getX(), fY1 = (float)p3NextPoint.getY();
	canvas.drawLine(fX0, fY0, fX1, fY1, paint);
	
	paint.setColor(nOriginalColor);
	paint.setStyle(styleOriginal);
	paint.setStrokeWidth(fOriginalStrokeWidth);
	paint.setPathEffect(pathEffectOriginal);
}
 
Example 17
Project: RNLearn_Project1   File: ARTShapeShadowNode.java   View Source Code Vote up 4 votes
/**
 * Sets up {@link #mPaint} 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) {
  if (mStrokeWidth == 0 || mStrokeColor == null || mStrokeColor.length == 0) {
    return false;
  }
  paint.reset();
  paint.setFlags(Paint.ANTI_ALIAS_FLAG);
  paint.setStyle(Paint.Style.STROKE);
  switch (mStrokeCap) {
    case CAP_BUTT:
      paint.setStrokeCap(Paint.Cap.BUTT);
      break;
    case CAP_SQUARE:
      paint.setStrokeCap(Paint.Cap.SQUARE);
      break;
    case CAP_ROUND:
      paint.setStrokeCap(Paint.Cap.ROUND);
      break;
    default:
      throw new JSApplicationIllegalArgumentException(
          "strokeCap " + mStrokeCap + " unrecognized");
  }
  switch (mStrokeJoin) {
    case JOIN_MITER:
      paint.setStrokeJoin(Paint.Join.MITER);
      break;
    case JOIN_BEVEL:
      paint.setStrokeJoin(Paint.Join.BEVEL);
      break;
    case JOIN_ROUND:
      paint.setStrokeJoin(Paint.Join.ROUND);
      break;
    default:
      throw new JSApplicationIllegalArgumentException(
          "strokeJoin " + mStrokeJoin + " unrecognized");
  }
  paint.setStrokeWidth(mStrokeWidth * mScale);
  paint.setARGB(
      (int) (mStrokeColor.length > 3 ? mStrokeColor[3] * opacity * 255 : opacity * 255),
      (int) (mStrokeColor[0] * 255),
      (int) (mStrokeColor[1] * 255),
      (int) (mStrokeColor[2] * 255));
  if (mStrokeDash != null && mStrokeDash.length > 0) {
    paint.setPathEffect(new DashPathEffect(mStrokeDash, 0));
  }
  return true;
}
 
Example 18
Project: OneWeather   File: SunriseSunset.java   View Source Code Vote up 4 votes
private void init(AttributeSet attrs) {
    if(attrs != null){
        TypedArray typedArray = mContext.obtainStyledAttributes(attrs,R.styleable.SunriseSunset);
        lineColor = typedArray.getColor(R.styleable.SunriseSunset_lineColor, Color.WHITE);
        sunColor = typedArray.getColor(R.styleable.SunriseSunset_sunColor,Color.YELLOW);
        timeTextColor = typedArray.getColor(R.styleable.SunriseSunset_timeTextColor,Color.GRAY);
        timeTextSize = typedArray.getDimension(R.styleable.SunriseSunset_timeTextSize,40);
        typedArray.recycle();
    }
    mCenterPoint = new Point();
    mArcPaint = new Paint();
    mArcPaint.setAntiAlias(true);
    mArcPaint.setColor(lineColor);
    mArcPaint.setStyle(Paint.Style.STROKE);
    mArcPaint.setStrokeWidth(3);
    mArcPaint.setPathEffect(new DashPathEffect(new float[]{20,15},20));
    mArcPaint.setStrokeCap(Paint.Cap.ROUND);
    mRectF = new RectF();


    mSunPaint = new Paint();
    mSunPaint.setAntiAlias(true);
    mSunPaint.setColor(sunColor);
    mSunPaint.setStyle(Paint.Style.STROKE);
    mSunPaint.setStrokeWidth(3);
    mSunPaint.setPathEffect(new DashPathEffect(new float[]{20,15},20));
    mSunriseBitmap = BitmapFactory.decodeResource(getResources(),R.drawable.ic_sunrise);
    mSunsetBitmap = BitmapFactory.decodeResource(getResources(),R.drawable.ic_sunset);
    mSunPaint.setColorFilter( new PorterDuffColorFilter(sunColor, PorterDuff.Mode.SRC_ATOP)) ;//设置后bitmap才会填充颜色

    mTimePaint = new Paint();
    mTimePaint.setColor(timeTextColor);
    mTimePaint.setTextSize(timeTextSize);
    mTimePaint.setTextAlign(Paint.Align.CENTER);



}
 
Example 19
Project: TrendChartView   File: TrendChartView.java   View Source Code Vote up 4 votes
private void initPaint() {
    mPathEffect = new DashPathEffect(new float[]{dp2, dp2}, 1);
    mGradeAxisPaint = new Paint();
    mGradeAxisPaint.reset();
    mGradeAxisPaint.setStyle(Paint.Style.STROKE);
    mGradeAxisPaint.setStrokeWidth(1);
    mGradeAxisPaint.setColor(isDebug ? Color.parseColor("#f00000") : Color.parseColor("#16ffffff"));
    mGradeAxisPaint.setAntiAlias(true);
    mGradeAxisPaint.setPathEffect(mPathEffect);

    mChartPaint = new Paint();
    mChartPaint.setStyle(Paint.Style.FILL);
    mChartPaint.setStrokeWidth(4);
    mChartPaint.setAntiAlias(true);

    mChartTestLinePaint = new Paint();
    mChartTestLinePaint.setStyle(Paint.Style.STROKE);
    mChartTestLinePaint.setStrokeWidth(dp2px(1));
    mChartTestLinePaint.setColor(Color.parseColor("#DF6A56"));
    mChartTestLinePaint.setAntiAlias(true);
    mChartTestLinePaint.setAlpha(0);
    if (isDebug) {
        mChartTestLinePaint.setAlpha(255);
    }

    mChartIndicatorPaint = new Paint();
    mChartIndicatorPaint.setStyle(Paint.Style.STROKE);
    mChartIndicatorPaint.setStrokeWidth(dp2px(1));

    mWhitePaint = new Paint();
    mWhitePaint.setStyle(Paint.Style.FILL);
    mWhitePaint.setColor(Color.parseColor("#ffffff"));

    mWhiteTextPaint = new TextPaint();
    mWhiteTextPaint.setColor(Color.parseColor("#ffffff"));
    mWhiteTextPaint.setTextSize(dp2px(11));
    mWhiteTextPaint.setAntiAlias(true);

    mWhiteTextPaintHeight = mWhiteTextPaint.descent() + mWhiteTextPaint.ascent();

    mDarkTextPaint = new TextPaint(mWhiteTextPaint);
    mDarkTextPaint.setAlpha(127);

    mPathIndicatorLine = new Path();
    mPathIndicatorLine.setFillType(Path.FillType.WINDING);

    mPathGradLine = new Path();
    mRectIndicator = new RectF();
}
 
Example 20
Project: HutHelper   File: LineChartView.java   View Source Code Vote up 4 votes
private void initPaint() {
    //虚线
    bgLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    bgLinePaint.setStyle(Paint.Style.STROKE);
    bgLinePaint.setColor(Color.parseColor("#ADADAD"));
    bgLinePaint.setStrokeWidth(2);
    PathEffect effects = new DashPathEffect(new float[]{13, 13}, 5);
    bgLinePaint.setPathEffect(effects);
    //发光线一号
    BlurMaskFilter bmf = new BlurMaskFilter(4, BlurMaskFilter.Blur.SOLID);
    linePaint1 = new Paint(Paint.ANTI_ALIAS_FLAG);
    linePaint1.setStyle(Paint.Style.STROKE);
    linePaint1.setColor(Color.parseColor("#fdeb6b"));
    linePaint1.setStrokeWidth(lineWidth);
    linePaint1.setMaskFilter(bmf);
    //发光线2号
    linePaint2 = new Paint(Paint.ANTI_ALIAS_FLAG);
    linePaint2.setStyle(Paint.Style.STROKE);
    linePaint2.setColor(Color.parseColor("#6effb6"));
    linePaint2.setStrokeWidth(lineWidth);
    linePaint2.setMaskFilter(bmf);
    //标题
    titlePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    titlePaint.setTextSize(sp14);
    titlePaint.setColor(Color.parseColor("#adadad"));
    //数值一号
    valuePaint1 = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    valuePaint1.setTextSize(sp10);
    valuePaint1.setColor(Color.parseColor(COLOR_1));
    //数值二号
    valuePaint2 = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    valuePaint2.setTextSize(sp10);
    valuePaint2.setColor(Color.parseColor(COLOR_2));
    //文本
    textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    textPaint.setTextSize(sp10);
    textPaint.setColor(Color.WHITE);
    //标注
    labelPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    labelPaint.setTextSize(sp10);
    labelPaint.setColor(Color.parseColor("#adadad"));
    //圆点
    circlePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    circlePaint.setStyle(Paint.Style.FILL);
    circlePaint.setColor(Color.WHITE);
}