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); }
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)); }
@Override public void setBorderCornerRadius(int borderCornersRadius) { mBorderPaint.setPathEffect(new CornerPathEffect(borderCornersRadius)); }
Paint fgPaintSel = new Paint(); fgPaintSel.setARGB(255, 0, 0,0); fgPaintSel.setStyle(Style.STROKE); fgPaintSel.setPathEffect(new DashPathEffect(new float[] {10,20}, 0));
protected void setupGridPaint() { mGridPaint.setColor(mXAxis.getGridColor()); mGridPaint.setStrokeWidth(mXAxis.getGridLineWidth()); mGridPaint.setPathEffect(mXAxis.getGridDashPathEffect()); }
public void renderLimitLineLine(Canvas c, LimitLine limitLine, float[] position) { mLimitLineSegmentsBuffer[0] = position[0]; mLimitLineSegmentsBuffer[1] = mViewPortHandler.contentTop(); mLimitLineSegmentsBuffer[2] = position[0]; mLimitLineSegmentsBuffer[3] = mViewPortHandler.contentBottom(); mLimitLinePath.reset(); mLimitLinePath.moveTo(mLimitLineSegmentsBuffer[0], mLimitLineSegmentsBuffer[1]); mLimitLinePath.lineTo(mLimitLineSegmentsBuffer[2], mLimitLineSegmentsBuffer[3]); mLimitLinePaint.setStyle(Paint.Style.STROKE); mLimitLinePaint.setColor(limitLine.getLineColor()); mLimitLinePaint.setStrokeWidth(limitLine.getLineWidth()); mLimitLinePaint.setPathEffect(limitLine.getDashPathEffect()); c.drawPath(mLimitLinePath, mLimitLinePaint); }
@Override protected void dispatchDraw(Canvas canvas) { super.dispatchDraw(canvas); final View thisView = this; if (thisView.isInEditMode()) {//这段代码在运行时不会执行,只会在Studio编辑预览时运行,不用在意性能问题 int d = DensityUtil.dp2px(5); Paint paint = new Paint(); paint.setStyle(Paint.Style.STROKE); paint.setColor(0xcccccccc); paint.setStrokeWidth(DensityUtil.dp2px(1)); paint.setPathEffect(new DashPathEffect(new float[]{d, d, d, d}, 1)); canvas.drawRect(d, d, thisView.getWidth() - d, thisView.getBottom() - d, paint); TextView textView = new TextView(thisView.getContext()); textView.setText(thisView.getResources().getString(R.string.srl_component_falsify, getClass().getSimpleName(), DensityUtil.px2dp(thisView.getHeight()))); textView.setTextColor(0xcccccccc); textView.setGravity(Gravity.CENTER); //noinspection UnnecessaryLocalVariable View view = textView; view.measure(makeMeasureSpec(thisView.getWidth(), EXACTLY), makeMeasureSpec(thisView.getHeight(), EXACTLY)); view.layout(0, 0, thisView.getWidth(), thisView.getHeight()); view.draw(canvas); } }
@Override protected void dispatchDraw(Canvas canvas) { super.dispatchDraw(canvas); final View thisView = this; if (thisView.isInEditMode()) {//这段代码在运行时不会执行,只会在Studio编辑预览时运行,不用在意性能问题 int d = DensityUtil.dp2px(5); Paint paint = new Paint(); paint.setStyle(Paint.Style.STROKE); paint.setColor(0xcccccccc); paint.setStrokeWidth(DensityUtil.dp2px(1)); paint.setPathEffect(new DashPathEffect(new float[]{d, d, d, d}, 1)); canvas.drawRect(d, d, thisView.getWidth() - d, thisView.getBottom() - d, paint); TextView textView = new TextView(thisView.getContext()); textView.setText(thisView.getResources().getString(R.string.srl_component_falsify, getClass().getSimpleName(), DensityUtil.px2dp(thisView.getHeight()))); textView.setTextColor(0xcccccccc); textView.setGravity(Gravity.CENTER); //noinspection UnnecessaryLocalVariable View view = textView; view.measure(makeMeasureSpec(thisView.getWidth(), EXACTLY), makeMeasureSpec(thisView.getHeight(), EXACTLY)); view.layout(0, 0, thisView.getWidth(), thisView.getHeight()); view.draw(canvas); } } //</editor-fold>
/** * 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); }
private void drawStroke(Canvas canvas, long elapsedTime) { float phase = MathUtil.constrain(0, 1, elapsedTime * 1f / strokeDrawingDuration); float distance = animInterpolator.getInterpolation(phase) * pathData.length; dashPaint.setPathEffect(getDashPathForDistance(distance)); canvas.drawPath(pathData.path, dashPaint); }
public ENPlayView(Context context, AttributeSet attrs) { super(context, attrs); TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.play); int lineColor = ta.getColor(R.styleable.play_play_line_color, DEFAULT_LINE_COLOR); int bgLineColor = ta.getColor(R.styleable.play_play_bg_line_color, DEFAULT_BG_LINE_COLOR); int lineWidth = ta.getInteger(R.styleable.play_play_line_width, dp2px(DEFAULT_LINE_WIDTH)); int bgLineWidth = ta.getInteger(R.styleable.play_play_bg_line_width, dp2px(DEFAULT_BG_LINE_WIDTH)); ta.recycle(); setLayerType(View.LAYER_TYPE_SOFTWARE, null); mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeCap(Paint.Cap.ROUND); mPaint.setColor(lineColor); mPaint.setStrokeWidth(lineWidth); mPaint.setPathEffect(new CornerPathEffect(1)); mBgPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mBgPaint.setStyle(Paint.Style.STROKE); mBgPaint.setStrokeCap(Paint.Cap.ROUND); mBgPaint.setColor(bgLineColor); mBgPaint.setStrokeWidth(bgLineWidth); mPath = new Path(); mDstPath = new Path(); mPathMeasure = new PathMeasure(); mDuration = DEFAULT_DURATION; }
mHighlightPaint.setPathEffect(set.getDashPathEffectHighlight());
protected void drawDataSet(Canvas c, ILineDataSet dataSet) { if (dataSet.getEntryCount() < 1) return; mRenderPaint.setStrokeWidth(dataSet.getLineWidth()); mRenderPaint.setPathEffect(dataSet.getDashPathEffect()); switch (dataSet.getMode()) { default: case LINEAR: case STEPPED: drawLinear(c, dataSet); break; case CUBIC_BEZIER: drawCubicBezier(dataSet); break; case HORIZONTAL_BEZIER: drawHorizontalBezier(dataSet); break; } mRenderPaint.setPathEffect(null); }
@Override public void renderGridLines(Canvas c) { if (!mYAxis.isEnabled()) return; if (mYAxis.isDrawGridLinesEnabled()) { int clipRestoreCount = c.save(); c.clipRect(getGridClippingRect()); float[] positions = getTransformedPositions(); mGridPaint.setColor(mYAxis.getGridColor()); mGridPaint.setStrokeWidth(mYAxis.getGridLineWidth()); mGridPaint.setPathEffect(mYAxis.getGridDashPathEffect()); Path gridLinePath = mRenderGridLinesPath; gridLinePath.reset(); // draw the grid for (int i = 0; i < positions.length; i += 2) { // draw a path because lines don't support dashing on lower android versions c.drawPath(linePath(gridLinePath, i, positions), mGridPaint); gridLinePath.reset(); } c.restoreToCount(clipRestoreCount); } if (mYAxis.isDrawZeroLineEnabled()) { drawZeroLine(c); } }
mLimitLinePaint.setPathEffect(null); mLimitLinePaint.setColor(limitLine.getTextColor()); mLimitLinePaint.setStrokeWidth(0.5f);
private void applyDashPatternIfNeeded(Matrix parentMatrix) { L.beginSection("StrokeContent#applyDashPattern"); if (dashPatternAnimations.isEmpty()) { L.endSection("StrokeContent#applyDashPattern"); return; } float scale = Utils.getScale(parentMatrix); 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)); L.endSection("StrokeContent#applyDashPattern"); }
mLimitLinePaint.setPathEffect(l.getDashPathEffect()); mLimitLinePaint.setStrokeWidth(l.getLineWidth());
@Override public void renderAxisLine(Canvas c) { if (!mXAxis.isDrawAxisLineEnabled() || !mXAxis.isEnabled()) return; mAxisLinePaint.setColor(mXAxis.getAxisLineColor()); mAxisLinePaint.setStrokeWidth(mXAxis.getAxisLineWidth()); mAxisLinePaint.setPathEffect(mXAxis.getAxisLineDashPathEffect()); if (mXAxis.getPosition() == XAxisPosition.TOP || mXAxis.getPosition() == XAxisPosition.TOP_INSIDE || mXAxis.getPosition() == XAxisPosition.BOTH_SIDED) { c.drawLine(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop(), mViewPortHandler.contentRight(), mViewPortHandler.contentTop(), mAxisLinePaint); } if (mXAxis.getPosition() == XAxisPosition.BOTTOM || mXAxis.getPosition() == XAxisPosition.BOTTOM_INSIDE || mXAxis.getPosition() == XAxisPosition.BOTH_SIDED) { c.drawLine(mViewPortHandler.contentLeft(), mViewPortHandler.contentBottom(), mViewPortHandler.contentRight(), mViewPortHandler.contentBottom(), mAxisLinePaint); } }
mRenderPaint.setPathEffect(null);
mRenderPaint.setPathEffect(null);