Java Code Examples for android.graphics.Path#addOval()

The following examples show how to use android.graphics.Path#addOval() . 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: LineArcSeries.java    From android-DecoView-charting with Apache License 2.0 6 votes vote down vote up
/**
 * Draw the {@link EdgeDetail} for this View. Note that on API 11 - 17 clipPath is only available
 * if HardwareAcceleration is disable. A function {@link DecoView#enableCompatibilityMode()}
 * is provided which will disable on affected platforms however this needs to be explicitly
 * called by the user, otherwise EdgeDetails will not be drawn
 *
 * @param canvas Canvas to draw to
 */
private void drawArcEdgeDetail(@NonNull Canvas canvas) {
    ArrayList<EdgeDetail> edgeDetailList = getSeriesItem().getEdgeDetail();
    if (edgeDetailList == null) {
        return;
    }

    for (EdgeDetail edgeDetail : edgeDetailList) {
        final boolean drawInner = edgeDetail.getEdgeType() == EdgeDetail.EdgeType.EDGE_INNER;
        if (edgeDetail.getClipPath() == null) {
            float inset = (edgeDetail.getRatio() - 0.5f) * mSeriesItem.getLineWidth();
            if (drawInner) {
                inset = -inset;
            }

            Path clipPath = new Path();
            RectF clipRect = new RectF(mBoundsInset);
            clipRect.inset(inset, inset);
            clipPath.addOval(clipRect, Path.Direction.CW);
            edgeDetail.setClipPath(clipPath);
        }
        drawClippedArc(canvas, edgeDetail.getClipPath(), edgeDetail.getColor(),
                drawInner ? Region.Op.INTERSECT : Region.Op.DIFFERENCE);
    }
}
 
Example 2
Source File: WXSvgEllipse.java    From Svg-for-Apache-Weex with Apache License 2.0 5 votes vote down vote up
@Override
protected Path getPath(Canvas canvas, Paint paint) {
  Path path = new Path();
  float cx = ParserHelper.fromPercentageToFloat(mCx, mCanvasWidth, 0, mScale);
  float cy = ParserHelper.fromPercentageToFloat(mCy, mCanvasHeight, 0, mScale);
  float rx = ParserHelper.fromPercentageToFloat(mRx, mCanvasWidth, 0, mScale);
  float ry = ParserHelper.fromPercentageToFloat(mRy, mCanvasHeight, 0, mScale);
  RectF oval = new RectF(cx - rx, cy - ry, cx + rx, cy + ry);
  path.addOval(oval, Path.Direction.CW);
  return path;
}
 
Example 3
Source File: PieSeries.java    From android-DecoView-charting with Apache License 2.0 5 votes vote down vote up
/**
 * Draw the {@link EdgeDetail} for this View. Note that on API 11 - 17 clipPath is only available
 * if HardwareAcceleration is disable. A function {@link DecoView#enableCompatibilityMode()}
 * is provided which will disable on affected platforms however this needs to be explicitly
 * called by the user, otherwise EdgeDetails will not be drawn
 *
 * @param canvas Canvas to draw to
 */
private void drawArcEdgeDetail(@NonNull Canvas canvas) {
    ArrayList<EdgeDetail> edgeDetailList = getSeriesItem().getEdgeDetail();
    if (edgeDetailList == null) {
        return;
    }

    for (EdgeDetail edgeDetail : edgeDetailList) {
        final boolean drawInner = edgeDetail.getEdgeType() == EdgeDetail.EdgeType.EDGE_INNER;
        if (drawInner) {
            //TODO: Implement EDGE_INNER for pie
            Log.w(TAG, "EDGE_INNER Not Yet Implemented for pie chart");
            continue;
        }
        if (edgeDetail.getClipPath() == null) {
            float inset = (edgeDetail.getRatio() - 0.5f) * mPaint.getStrokeWidth();

            Path clipPath = new Path();
            RectF clipRect = new RectF(mBoundsInset);
            clipRect.inset(inset, inset);
            clipPath.addOval(clipRect, Path.Direction.CW);
            edgeDetail.setClipPath(clipPath);
        }
        //noinspection ConstantConditions
        drawClippedArc(canvas, edgeDetail.getClipPath(), edgeDetail.getColor(),
                drawInner ? Region.Op.INTERSECT : Region.Op.DIFFERENCE);
    }
}
 
Example 4
Source File: Compat.java    From ProjectX with Apache License 2.0 5 votes vote down vote up
@Override
public void addOval(Path path, float left, float top, float right, float bottom,
                    Path.Direction dir) {
    final RectF oval = get();
    oval.set(left, top, right, bottom);
    path.addOval(oval, dir);
    put(oval);
}
 
Example 5
Source File: Compat.java    From ProjectX with Apache License 2.0 5 votes vote down vote up
@Override
public void addOval(Path path, float left, float top, float right, float bottom,
                    Path.Direction dir) {
    final RectF oval = get();
    oval.set(left, top, right, bottom);
    path.addOval(oval, dir);
    put(oval);
}
 
Example 6
Source File: PXEllipse.java    From pixate-freestyle-android with Apache License 2.0 5 votes vote down vote up
@Override
protected Path newPath() {
    Path path = ObjectPool.pathPool.checkOut();
    RectF rect = new RectF(center.x - radiusX, center.y - radiusY, center.x + radiusX, center.y
            + radiusY);
    path.addOval(rect, Direction.CW);
    return path;
}
 
Example 7
Source File: OvalElement.java    From cidrawing with Apache License 2.0 4 votes vote down vote up
@Override
protected Path createShapePath() {
    Path path = new Path();
    path.addOval(shapeBox, Path.Direction.CW);
    return path;
}
 
Example 8
Source File: CircleDrawable.java    From ticdesign with Apache License 2.0 4 votes vote down vote up
@Override
protected void onResetPath(Path path, Rect bounds) {
    path.reset();
    path.addOval(bounds.left, bounds.top, bounds.right, bounds.bottom, Path.Direction.CW);
}
 
Example 9
Source File: WindowUtils.java    From ticdesign with Apache License 2.0 4 votes vote down vote up
@Override
protected void onResetPath(Path path, Rect bounds) {
    path.reset();
    path.addOval(bounds.left - 1, bounds.top - 1, bounds.right + 1, bounds.bottom + 1, Path.Direction.CW);
}
 
Example 10
Source File: Compat.java    From ProjectX with Apache License 2.0 4 votes vote down vote up
@Override
public void addOval(Path path, float left, float top, float right, float bottom,
                    Path.Direction dir) {
    path.addOval(left, top, right, bottom, dir);
}
 
Example 11
Source File: Compat.java    From ProjectX with Apache License 2.0 4 votes vote down vote up
@Override
public void addOval(Path path, float left, float top, float right, float bottom,
                    Path.Direction dir) {
    path.addOval(left, top, right, bottom, dir);
}
 
Example 12
Source File: PathUtilties.java    From mil-sym-android with Apache License 2.0 4 votes vote down vote up
public static void addEllipse(Path path, float x, float y, float w, float h)
{
	path.addOval(new RectF(x, y, x + w, y + h), Direction.CW);
}
 
Example 13
Source File: PathUtilties.java    From mil-sym-android with Apache License 2.0 4 votes vote down vote up
public static void addEllipse(Path path, float x, float y, float w, float h, Direction dir)
{
	path.addOval(new RectF(x, y, x + w, y + h), dir);
}