Java Code Examples for android.graphics.Paint#setStrokeMiter()
The following examples show how to use
android.graphics.Paint#setStrokeMiter() .
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: WXSvgPath.java From Svg-for-Apache-Weex with Apache License 2.0 | 6 votes |
/** * 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 2
Source File: myView.java From reader with MIT License | 6 votes |
public void Pcanvas(Canvas canvas) { Paint mPaint = new Paint(); mPaint.setStyle(Style.STROKE); mPaint.setStrokeMiter(6); mPaint.setStrokeWidth(3); mPaint.setColor(Color.RED); canvas.drawRect(l, t, r, b, mPaint); tuodongH = b - t; tuodongW = r - l; Paint mPaint1 = new Paint(); mPaint1.setColor(Color.BLACK); mPaint1.setAlpha(100); canvas.drawRect(0, 0, 480, t, mPaint1);// 1111 canvas.drawRect(0, b, 480, 800, mPaint1); canvas.drawRect(0, t, l, b, mPaint1); canvas.drawRect(r, t, 480, b, mPaint1); }
Example 3
Source File: CnSvgBigRenderer.java From ChinaMapInfoView with Apache License 2.0 | 5 votes |
private void renderGo(Canvas canvas, ColorFilter filter, Paint paint, int i) { if (i >= 0 && i <= 8) { renderByProvince1(i); } else if (i >= 9 && i <= 19) { renderByProvince2(i); } else if (i >= 20 && i <= 29) { renderByProvince3(i); } else if (i >= 29 && i <= 33) { renderByProvince4(i); } mRenderPath.addPath(mPath, mFinalPathMatrix); paint.setStrokeJoin(Paint.Join.MITER); paint.setStrokeCap(Paint.Cap.BUTT); paint.setStrokeMiter(4.0f); paint.setColorFilter(filter); canvas.drawPath(mRenderPath, paint); // Region mRegion = mRegionList.get(i); mRegion.setPath(mRenderPath, mGlobalRegion); mRegionList.set(i, mRegion); mPath.reset(); mRenderPath.reset(); mFinalPathMatrix.setValues( new float[]{1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f} ); mFinalPathMatrix.postScale(scaleX, scaleY); }
Example 4
Source File: XYChart.java From MiBandDecompiled with Apache License 2.0 | 5 votes |
private void a(android.graphics.Paint.Cap cap, android.graphics.Paint.Join join, float f1, android.graphics.Paint.Style style, PathEffect patheffect, Paint paint) { paint.setStrokeCap(cap); paint.setStrokeJoin(join); paint.setStrokeMiter(f1); paint.setPathEffect(patheffect); paint.setStyle(style); }
Example 5
Source File: PXStroke.java From pixate-freestyle-android with Apache License 2.0 | 5 votes |
/** * Returns a stroke {@link Paint}. Note that this method does not check into * the pool any Paint that may have been pulled from it. The responsibility * here is up to the caller. * * @param p * @param useOriginal Indicate that the given {@link Paint} instance should * be applied with the stroke information. * @return A {@link Paint} reference (a new Paint in case the useOriginal * was false) */ public Paint getStrokedPaint(Paint p, boolean useOriginal) { Paint paint = useOriginal ? p : ObjectPool.paintPool.checkOut(p); paint.setStyle(Style.STROKE); paint.setStrokeWidth(width); if (dashArray != null && dashArray.length > 0) { paint.setPathEffect(new DashPathEffect(dashArray, dashOffset)); } paint.setStrokeCap(this.lineCap); paint.setStrokeJoin(this.lineJoin); paint.setStrokeMiter(this.miterLimit); return paint; }
Example 6
Source File: LanesStyleKit.java From graphhopper-navigation-android with MIT License | 4 votes |
public static void drawLaneRight(Canvas canvas, RectF targetFrame, ResizingBehavior resizing, int primaryColor, PointF size) { // General Declarations Stack<Matrix> currentTransformation = new Stack<Matrix>(); currentTransformation.push(new Matrix()); Paint paint = CacheForLaneRight.paint; // Local Variables float expression = Math.min(size.x / 30f, size.y / 30f); // Resize to Target Frame canvas.save(); RectF resizedFrame = CacheForLaneRight.resizedFrame; LanesStyleKit.resizingBehaviorApply(resizing, CacheForLaneRight.originalFrame, targetFrame, resizedFrame); canvas.translate(resizedFrame.left, resizedFrame.top); canvas.scale(resizedFrame.width() / 30f, resizedFrame.height() / 30f); // Frame RectF frame = CacheForLaneRight.frame; frame.set(0f, 0f, size.x, size.y); // Group { RectF group = CacheForLaneRight.group; group.set(0f, 0f, 14.85f, 23f); canvas.save(); canvas.translate(9f, 4f); currentTransformation.peek().postTranslate(9f, 4f); canvas.scale(expression, expression); currentTransformation.peek().postScale(expression, expression); // Bezier RectF bezierRect = CacheForLaneRight.bezierRect; bezierRect.set(5.87f, 0f, 14.85f, 12.02f); Path bezierPath = CacheForLaneRight.bezierPath; bezierPath.reset(); bezierPath.moveTo(group.left + group.width() * 0.50217f, group.top + group.height() * 0.00014f); bezierPath.cubicTo(group.left + group.width() * 0.50834f, group.top + group.height() * 0.00007f, group.left + group.width() * 0.51727f, group.top + group.height() * 0.0027f, group.left + group.width() * 0.52351f, group.top + group.height() * 0.00697f); bezierPath.cubicTo(group.left + group.width() * 0.53419f, group.top + group.height() * 0.01264f, group.left + group.width(), group.top + group.height() * 0.26153f, group.left + group.width(), group.top + group.height() * 0.26153f); bezierPath.cubicTo(group.left + group.width(), group.top + group.height() * 0.26153f, group.left + group.width() * 0.53007f, group.top + group.height() * 0.50996f, group.left + group.width() * 0.51955f, group.top + group.height() * 0.51553f); bezierPath.cubicTo(group.left + group.width() * 0.51301f, group.top + group.height() * 0.51993f, group.left + group.width() * 0.50386f, group.top + group.height() * 0.52258f, group.left + group.width() * 0.49391f, group.top + group.height() * 0.52258f); bezierPath.cubicTo(group.left + group.width() * 0.47472f, group.top + group.height() * 0.52258f, group.left + group.width() * 0.45924f, group.top + group.height() * 0.51254f, group.left + group.width() * 0.45924f, group.top + group.height() * 0.50014f); bezierPath.cubicTo(group.left + group.width() * 0.45924f, group.top + group.height() * 0.49721f, group.left + group.width() * 0.46007f, group.top + group.height() * 0.4944f, group.left + group.width() * 0.46169f, group.top + group.height() * 0.49183f); bezierPath.cubicTo(group.left + group.width() * 0.46455f, group.top + group.height() * 0.48682f, group.left + group.width() * 0.52572f, group.top + group.height() * 0.37804f, group.left + group.width() * 0.52837f, group.top + group.height() * 0.37334f); bezierPath.cubicTo(group.left + group.width() * 0.52866f, group.top + group.height() * 0.35658f, group.left + group.width() * 0.5129f, group.top + group.height() * 0.34823f, group.left + group.width() * 0.49331f, group.top + group.height() * 0.34823f); bezierPath.cubicTo(group.left + group.width() * 0.48889f, group.top + group.height() * 0.34823f, group.left + group.width() * 0.48416f, group.top + group.height() * 0.34806f, group.left + group.width() * 0.48011f, group.top + group.height() * 0.34805f); bezierPath.cubicTo(group.left + group.width() * 0.4746f, group.top + group.height() * 0.34798f, group.left + group.width() * 0.39493f, group.top + group.height() * 0.34818f, group.left + group.width() * 0.39493f, group.top + group.height() * 0.34818f); bezierPath.lineTo(group.left + group.width() * 0.39911f, group.top + group.height() * 0.1744f); bezierPath.cubicTo(group.left + group.width() * 0.39911f, group.top + group.height() * 0.1744f, group.left + group.width() * 0.4782f, group.top + group.height() * 0.1746f, group.left + group.width() * 0.48401f, group.top + group.height() * 0.17461f); bezierPath.cubicTo(group.left + group.width() * 0.48839f, group.top + group.height() * 0.17452f, group.left + group.width() * 0.49309f, group.top + group.height() * 0.17435f, group.left + group.width() * 0.49748f, group.top + group.height() * 0.17435f); bezierPath.cubicTo(group.left + group.width() * 0.51708f, group.top + group.height() * 0.17435f, group.left + group.width() * 0.53283f, group.top + group.height() * 0.166f, group.left + group.width() * 0.53283f, group.top + group.height() * 0.15335f); bezierPath.cubicTo(group.left + group.width() * 0.5299f, group.top + group.height() * 0.14453f, group.left + group.width() * 0.46873f, group.top + group.height() * 0.03576f, group.left + group.width() * 0.466f, group.top + group.height() * 0.03091f); bezierPath.cubicTo(group.left + group.width() * 0.46431f, group.top + group.height() * 0.02818f, group.left + group.width() * 0.46341f, group.top + group.height() * 0.02537f, group.left + group.width() * 0.46341f, group.top + group.height() * 0.02243f); bezierPath.cubicTo(group.left + group.width() * 0.46341f, group.top + group.height() * 0.01013f, group.left + group.width() * 0.47875f, group.top + group.height() * 0.00014f, group.left + group.width() * 0.49775f, group.top); bezierPath.lineTo(group.left + group.width() * 0.50217f, group.top + group.height() * 0.00014f); bezierPath.close(); paint.reset(); paint.setFlags(Paint.ANTI_ALIAS_FLAG); paint.setStyle(Paint.Style.FILL); paint.setColor(primaryColor); canvas.drawPath(bezierPath, paint); // Bezier 2 RectF bezier2Rect = CacheForLaneRight.bezier2Rect; bezier2Rect.set(0f, 6.03f, 11.03f, 23f); Path bezier2Path = CacheForLaneRight.bezier2Path; bezier2Path.reset(); bezier2Path.moveTo(group.left, group.top + group.height() * 1f); bezier2Path.lineTo(group.left + group.width() * 0.00417f, group.top + group.height() * 0.41572f); bezier2Path.cubicTo(group.left + group.width() * 0.00417f, group.top + group.height() * 0.41572f, group.left + group.width() * 0.02316f, group.top + group.height() * 0.26219f, group.left + group.width() * 0.26516f, group.top + group.height() * 0.26219f); bezier2Path.lineTo(group.left + group.width() * 0.74277f, group.top + group.height() * 0.26219f); paint.reset(); paint.setFlags(Paint.ANTI_ALIAS_FLAG); paint.setStrokeWidth(4f); paint.setStrokeMiter(10f); canvas.save(); paint.setStyle(Paint.Style.STROKE); paint.setColor(primaryColor); canvas.drawPath(bezier2Path, paint); canvas.restore(); canvas.restore(); } canvas.restore(); }
Example 7
Source File: LanesStyleKit.java From graphhopper-navigation-android with MIT License | 4 votes |
public static void drawLaneUturn(Canvas canvas, RectF targetFrame, ResizingBehavior resizing, int primaryColor, PointF size) { // General Declarations Stack<Matrix> currentTransformation = new Stack<Matrix>(); currentTransformation.push(new Matrix()); Paint paint = CacheForLaneUturn.paint; // Local Variables float expression = Math.min(size.x / 30f, size.y / 30f); // Resize to Target Frame canvas.save(); RectF resizedFrame = CacheForLaneUturn.resizedFrame; LanesStyleKit.resizingBehaviorApply(resizing, CacheForLaneUturn.originalFrame, targetFrame, resizedFrame); canvas.translate(resizedFrame.left, resizedFrame.top); canvas.scale(resizedFrame.width() / 30f, resizedFrame.height() / 30f); // Frame RectF frame = CacheForLaneUturn.frame; frame.set(0f, 0f, size.x, size.y); // Group { RectF group = CacheForLaneUturn.group; group.set(0f, 0f, 16f, 22f); canvas.save(); canvas.translate(9f, 5f); currentTransformation.peek().postTranslate(9f, 5f); canvas.scale(expression, expression); currentTransformation.peek().postScale(expression, expression); // Bezier RectF bezierRect = CacheForLaneUturn.bezierRect; bezierRect.set(0f, 0f, 10f, 22f); Path bezierPath = CacheForLaneUturn.bezierPath; bezierPath.reset(); bezierPath.moveTo(group.left + group.width() * 0.62498f, group.top + group.height() * 0.68182f); bezierPath.lineTo(group.left + group.width() * 0.62498f, group.top + group.height() * 0.28459f); bezierPath.cubicTo(group.left + group.width() * 0.62498f, group.top + group.height() * 0.20995f, group.left + group.width() * 0.62498f, group.top, group.left + group.width() * 0.31249f, group.top); bezierPath.cubicTo(group.left, group.top, group.left, group.top + group.height() * 0.27273f, group.left, group.top + group.height() * 0.27273f); bezierPath.lineTo(group.left, group.top + group.height()); paint.reset(); paint.setFlags(Paint.ANTI_ALIAS_FLAG); paint.setStrokeWidth(4f); paint.setStrokeMiter(10f); canvas.save(); paint.setStyle(Paint.Style.STROKE); paint.setColor(primaryColor); canvas.drawPath(bezierPath, paint); canvas.restore(); // Bezier 2 RectF bezier2Rect = CacheForLaneUturn.bezier2Rect; bezier2Rect.set(4.01f, 12.99f, 16f, 21.97f); Path bezier2Path = CacheForLaneUturn.bezier2Path; bezier2Path.reset(); bezier2Path.moveTo(group.left + group.width() * 0.75119f, group.top + group.height() * 0.59306f); bezier2Path.cubicTo(group.left + group.width() * 0.75119f, group.top + group.height() * 0.59306f, group.left + group.width() * 0.7509f, group.top + group.height() * 0.64646f, group.left + group.width() * 0.75088f, group.top + group.height() * 0.65038f); bezier2Path.cubicTo(group.left + group.width() * 0.75102f, group.top + group.height() * 0.65333f, group.left + group.width() * 0.75125f, group.top + group.height() * 0.65651f, group.left + group.width() * 0.75125f, group.top + group.height() * 0.65947f); bezier2Path.cubicTo(group.left + group.width() * 0.75125f, group.top + group.height() * 0.6727f, group.left + group.width() * 0.76325f, group.top + group.height() * 0.68334f, group.left + group.width() * 0.78144f, group.top + group.height() * 0.68334f); bezier2Path.cubicTo(group.left + group.width() * 0.79411f, group.top + group.height() * 0.68135f, group.left + group.width() * 0.95046f, group.top + group.height() * 0.64006f, group.left + group.width() * 0.95744f, group.top + group.height() * 0.63822f); bezier2Path.cubicTo(group.left + group.width() * 0.96136f, group.top + group.height() * 0.63708f, group.left + group.width() * 0.9654f, group.top + group.height() * 0.63647f, group.left + group.width() * 0.96962f, group.top + group.height() * 0.63647f); bezier2Path.cubicTo(group.left + group.width() * 0.98363f, group.top + group.height() * 0.63647f, group.left + group.width() * 0.99555f, group.top + group.height() * 0.64296f, group.left + group.width() * 1f, group.top + group.height() * 0.65204f); bezier2Path.lineTo(group.left + group.width() * 0.99996f, group.top + group.height() * 0.65989f); bezier2Path.lineTo(group.left + group.width() * 0.99996f, group.top + group.height() * 0.6679f); bezier2Path.cubicTo(group.left + group.width() * 0.99829f, group.top + group.height() * 0.67142f, group.left + group.width() * 0.99548f, group.top + group.height() * 0.67455f, group.left + group.width() * 0.99185f, group.top + group.height() * 0.67704f); bezier2Path.cubicTo(group.left + group.width() * 0.98369f, group.top + group.height() * 0.68425f, group.left + group.width() * 0.62595f, group.top + group.height() * 0.9987f, group.left + group.width() * 0.62595f, group.top + group.height() * 0.9987f); bezier2Path.cubicTo(group.left + group.width() * 0.62595f, group.top + group.height() * 0.9987f, group.left + group.width() * 0.49849f, group.top + group.height() * 0.88548f, group.left + group.width() * 0.39416f, group.top + group.height() * 0.7928f); bezier2Path.cubicTo(group.left + group.width() * 0.32387f, group.top + group.height() * 0.73035f, group.left + group.width() * 0.26407f, group.top + group.height() * 0.67723f, group.left + group.width() * 0.26085f, group.top + group.height() * 0.67437f); bezier2Path.cubicTo(group.left + group.width() * 0.25452f, group.top + group.height() * 0.66996f, group.left + group.width() * 0.25071f, group.top + group.height() * 0.66378f, group.left + group.width() * 0.25071f, group.top + group.height() * 0.65706f); bezier2Path.cubicTo(group.left + group.width() * 0.25071f, group.top + group.height() * 0.64411f, group.left + group.width() * 0.26515f, group.top + group.height() * 0.63365f, group.left + group.width() * 0.28296f, group.top + group.height() * 0.63365f); bezier2Path.cubicTo(group.left + group.width() * 0.28718f, group.top + group.height() * 0.63365f, group.left + group.width() * 0.29122f, group.top + group.height() * 0.63422f, group.left + group.width() * 0.29491f, group.top + group.height() * 0.63531f); bezier2Path.cubicTo(group.left + group.width() * 0.30212f, group.top + group.height() * 0.63724f, group.left + group.width() * 0.45847f, group.top + group.height() * 0.67854f, group.left + group.width() * 0.46523f, group.top + group.height() * 0.68032f); bezier2Path.cubicTo(group.left + group.width() * 0.48933f, group.top + group.height() * 0.68052f, group.left + group.width() * 0.50133f, group.top + group.height() * 0.66988f, group.left + group.width() * 0.50133f, group.top + group.height() * 0.65665f); bezier2Path.cubicTo(group.left + group.width() * 0.50133f, group.top + group.height() * 0.65368f, group.left + group.width() * 0.50157f, group.top + group.height() * 0.65048f, group.left + group.width() * 0.50158f, group.top + group.height() * 0.64775f); bezier2Path.cubicTo(group.left + group.width() * 0.50168f, group.top + group.height() * 0.64403f, group.left + group.width() * 0.50139f, group.top + group.height() * 0.59025f, group.left + group.width() * 0.50139f, group.top + group.height() * 0.59025f); bezier2Path.lineTo(group.left + group.width() * 0.75119f, group.top + group.height() * 0.59306f); bezier2Path.close(); paint.reset(); paint.setFlags(Paint.ANTI_ALIAS_FLAG); paint.setStyle(Paint.Style.FILL); paint.setColor(primaryColor); canvas.drawPath(bezier2Path, paint); canvas.restore(); } canvas.restore(); }
Example 8
Source File: LanesStyleKit.java From graphhopper-navigation-android with MIT License | 4 votes |
public static void drawLaneSlightRight(Canvas canvas, RectF targetFrame, ResizingBehavior resizing, int primaryColor, PointF size) { // General Declarations Stack<Matrix> currentTransformation = new Stack<Matrix>(); currentTransformation.push(new Matrix()); Paint paint = CacheForLaneSlightRight.paint; // Local Variables float expression = Math.min(size.x / 30f, size.y / 30f); // Resize to Target Frame canvas.save(); RectF resizedFrame = CacheForLaneSlightRight.resizedFrame; LanesStyleKit.resizingBehaviorApply(resizing, CacheForLaneSlightRight.originalFrame, targetFrame, resizedFrame); canvas.translate(resizedFrame.left, resizedFrame.top); canvas.scale(resizedFrame.width() / 30f, resizedFrame.height() / 30f); // Frame RectF frame = CacheForLaneSlightRight.frame; frame.set(0f, 0f, size.x, size.y); // Group { canvas.save(); canvas.translate(9.28f, -0.86f); currentTransformation.peek().postTranslate(9.28f, -0.86f); canvas.scale(expression, expression); currentTransformation.peek().postScale(expression, expression); // Bezier 3 RectF bezier3Rect = CacheForLaneSlightRight.bezier3Rect; bezier3Rect.set(0f, 10.61f, 7.17f, 27.6f); Path bezier3Path = CacheForLaneSlightRight.bezier3Path; bezier3Path.reset(); bezier3Path.moveTo(7.17f, 10.61f); bezier3Path.lineTo(1.47f, 15.89f); bezier3Path.cubicTo(0.6f, 17.21f, 0f, 18.82f, 0f, 20.47f); bezier3Path.lineTo(0f, 27.6f); paint.reset(); paint.setFlags(Paint.ANTI_ALIAS_FLAG); paint.setStrokeWidth(4f); paint.setStrokeJoin(Paint.Join.ROUND); paint.setStrokeMiter(10f); canvas.save(); paint.setStyle(Paint.Style.STROKE); paint.setColor(primaryColor); canvas.drawPath(bezier3Path, paint); canvas.restore(); // Bezier canvas.save(); canvas.translate(10.25f, 0f); currentTransformation.peek().postTranslate(10.25f, 0f); canvas.rotate(49f); currentTransformation.peek().postRotate(49f); RectF bezierRect = CacheForLaneSlightRight.bezierRect; bezierRect.set(0f, 0f, 12.02f, 9.99f); Path bezierPath = CacheForLaneSlightRight.bezierPath; bezierPath.reset(); bezierPath.moveTo(4.01f, 9.92f); bezierPath.lineTo(4.02f, 8.66f); bezierPath.lineTo(4.01f, 8.66f); bezierPath.cubicTo(4.01f, 8.6f, 4.01f, 8.53f, 4.01f, 8.46f); bezierPath.cubicTo(4.01f, 8.17f, 3.82f, 7.94f, 3.53f, 7.94f); bezierPath.cubicTo(3.5f, 7.94f, 3.46f, 7.94f, 3.43f, 7.94f); bezierPath.lineTo(3.44f, 7.94f); bezierPath.lineTo(0.71f, 8.93f); bezierPath.lineTo(0.71f, 8.93f); bezierPath.cubicTo(0.65f, 8.96f, 0.58f, 8.97f, 0.52f, 8.97f); bezierPath.cubicTo(0.23f, 8.97f, 0f, 8.74f, 0f, 8.45f); bezierPath.cubicTo(0f, 8.3f, 0.06f, 8.17f, 0.16f, 8.07f); bezierPath.lineTo(0.16f, 8.08f); bezierPath.lineTo(6.02f, 0f); bezierPath.lineTo(11.86f, 8.14f); bezierPath.lineTo(11.86f, 8.14f); bezierPath.cubicTo(11.96f, 8.23f, 12.02f, 8.37f, 12.02f, 8.52f); bezierPath.cubicTo(12.02f, 8.8f, 11.79f, 9.03f, 11.5f, 9.03f); bezierPath.cubicTo(11.43f, 9.03f, 11.37f, 9.02f, 11.31f, 8.99f); bezierPath.lineTo(11.31f, 8.99f); bezierPath.lineTo(8.58f, 8f); bezierPath.lineTo(8.59f, 8.01f); bezierPath.cubicTo(8.56f, 8f, 8.52f, 8f, 8.49f, 8f); bezierPath.cubicTo(8.2f, 8f, 8.01f, 8.23f, 8.01f, 8.53f); bezierPath.cubicTo(8.01f, 8.59f, 8f, 8.66f, 8f, 8.73f); bezierPath.lineTo(8f, 8.72f); bezierPath.lineTo(8.01f, 9.99f); paint.reset(); paint.setFlags(Paint.ANTI_ALIAS_FLAG); bezierPath.setFillType(Path.FillType.EVEN_ODD); paint.setStyle(Paint.Style.FILL); paint.setColor(primaryColor); canvas.drawPath(bezierPath, paint); canvas.restore(); canvas.restore(); } canvas.restore(); }