Java Code Examples for android.graphics.Region#Op

The following examples show how to use android.graphics.Region#Op . 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: PieSeries.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
 */
protected void drawClippedArc(@NonNull Canvas canvas, @NonNull Path path, int color, @NonNull Region.Op combine) {
    canvas.save();

    try {
        canvas.clipPath(path, combine);
    } catch (UnsupportedOperationException e) {
        Log.w(TAG, "clipPath unavailable on API 11 - 17 without disabling hardware acceleration. (EdgeDetail functionality requires clipPath). Call DecoView.enableCompatibilityMode() to enable");
        canvas.restore();
        return;
    }

    int colorOld = mPaint.getColor();
    Shader shaderOld = mPaint.getShader();
    mPaint.setColor(color);
    mPaint.setShader(null);
    drawArc(canvas);
    mPaint.setColor(colorOld);
    mPaint.setShader(shaderOld);
    canvas.restore();
}
 
Example 2
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
 */
protected void drawClippedArc(@NonNull Canvas canvas, @NonNull Path path, int color, @NonNull Region.Op combine) {
    canvas.save();

    try {
        canvas.clipPath(path, combine);
    } catch (UnsupportedOperationException e) {
        Log.w(TAG, "clipPath unavailable on API 11 - 17 without disabling hardware acceleration. (EdgeDetail functionality requires clipPath). Call DecoView.enableCompatibilityMode() to enable");
        canvas.restore();
        return;
    }

    int colorOld = mPaint.getColor();
    mPaint.setColor(color);
    drawArc(canvas);
    mPaint.setColor(colorOld);
    canvas.restore();
}
 
Example 3
Source File: FolderIcon.java    From LaunchEnr with GNU General Public License v3.0 4 votes vote down vote up
private void clipCanvasSoftware(Canvas canvas, Region.Op op) {
    mPath.reset();
    float r = getScaledRadius();
    mPath.addCircle(r + getOffsetX(), r + getOffsetY(), r, Path.Direction.CW);
    canvas.clipPath(mPath, op);
}
 
Example 4
Source File: ViewRevealManager.java    From CircularReveal with MIT License 4 votes vote down vote up
/** @see Canvas#clipPath(Path, Region.Op) */
public Region.Op op() {
  return op;
}
 
Example 5
Source File: DelegateCanvas.java    From madge with Apache License 2.0 4 votes vote down vote up
@Override public boolean clipRect(RectF rect, Region.Op op) {
  return delegate.clipRect(rect, op);
}
 
Example 6
Source File: DelegateCanvas.java    From madge with Apache License 2.0 4 votes vote down vote up
@Override public boolean clipRect(Rect rect, Region.Op op) {
  return delegate.clipRect(rect, op);
}
 
Example 7
Source File: DelegateCanvas.java    From madge with Apache License 2.0 4 votes vote down vote up
@Override
public boolean clipRect(float left, float top, float right, float bottom, Region.Op op) {
  return delegate.clipRect(left, top, right, bottom, op);
}
 
Example 8
Source File: DelegateCanvas.java    From madge with Apache License 2.0 4 votes vote down vote up
@Override public boolean clipPath(Path path, Region.Op op) {
  return delegate.clipPath(path, op);
}
 
Example 9
Source File: DelegateCanvas.java    From madge with Apache License 2.0 4 votes vote down vote up
@Override public boolean clipRegion(Region region, Region.Op op) {
  return delegate.clipRegion(region, op);
}
 
Example 10
Source File: ISafeCanvas.java    From OpenMapKitAndroid with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Modify the current clip with the specified rectangle, which is expressed in local
 * coordinates.
 *
 * @param rect The rectangle to intersect with the current clip.
 * @param op How the clip is modified
 * @return true if the resulting clip is non-empty
 */
public abstract boolean clipRect(Rect rect, Region.Op op);
 
Example 11
Source File: ISafeCanvas.java    From OpenMapKitAndroid with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Modify the current clip with the specified rectangle, which is expressed in local
 * coordinates.
 *
 * @param left The left side of the rectangle to intersect with the current clip
 * @param top The top of the rectangle to intersect with the current clip
 * @param right The right side of the rectangle to intersect with the current clip
 * @param bottom The bottom of the rectangle to intersect with the current clip
 * @param op How the clip is modified
 * @return true if the resulting clip is non-empty
 */
public abstract boolean clipRect(double left, double top, double right, double bottom,
        Region.Op op);
 
Example 12
Source File: ISafeCanvas.java    From OpenMapKitAndroid with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Modify the current clip with the specified path.
 *
 * @param path The path to operate on the current clip
 * @param op How the clip is modified
 * @return true if the resulting is non-empty
 */
public abstract boolean clipPath(SafeTranslatedPath path, Region.Op op);
 
Example 13
Source File: ISafeCanvas.java    From OpenMapKitAndroid with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Modify the current clip with the specified region. Note that unlike clipRect() and
 * clipPath()
 * which transform their arguments by the current matrix, clipRegion() assumes its argument is
 * already in the coordinate system of the current layer's bitmap, and so not transformation is
 * performed.
 *
 * @param region The region to operate on the current clip, based on op
 * @param op How the clip is modified
 * @return true if the resulting is non-empty
 */
public abstract boolean clipRegion(Region region, Region.Op op);