FileDocCategorySizeDatePackage
Region.javaAPI DocAndroid 1.5 API11592Wed May 06 22:42:00 BST 2009android.graphics

Region

public class Region extends Object implements android.os.Parcelable

Fields Summary
public static final Parcelable.Creator
CREATOR
private final int
mNativeRegion
Constructors Summary
public Region()
Create an empty region

        this(nativeConstructor());
    
public Region(Region region)
Return a copy of the specified region

        this(nativeConstructor());
        nativeSetRegion(mNativeRegion, region.mNativeRegion);
    
public Region(Rect r)
Return a region set to the specified rectangle

        mNativeRegion = nativeConstructor();
        nativeSetRect(mNativeRegion, r.left, r.top, r.right, r.bottom);
    
Region(int ni)

        if (ni == 0) {
            throw new RuntimeException();
        }
        mNativeRegion = ni;
    
private Region(int ni, int dummy)

        this(ni);
    
public Region(int left, int top, int right, int bottom)
Return a region set to the specified rectangle

        mNativeRegion = nativeConstructor();
        nativeSetRect(mNativeRegion, left, top, right, bottom);
    
Methods Summary
public native booleancontains(int x, int y)
Return true if the region contains the specified point

public intdescribeContents()

    
       
        return 0;
    
protected voidfinalize()

        nativeDestructor(mNativeRegion);
    
public PathgetBoundaryPath()
Return the boundary of the region as a new Path. If the region is empty, the path will also be empty.

        Path path = new Path();
        nativeGetBoundaryPath(mNativeRegion, path.ni());
        return path;
    
public booleangetBoundaryPath(Path path)
Set the path to the boundary of the region. If the region is empty, the path will also be empty.

        return nativeGetBoundaryPath(mNativeRegion, path.ni());
    
public RectgetBounds()
Return a new Rect set to the bounds of the region. If the region is empty, the Rect will be set to [0, 0, 0, 0]

        Rect r = new Rect();
        nativeGetBounds(mNativeRegion, r);
        return r;
    
public booleangetBounds(Rect r)
Set the Rect to the bounds of the region. If the region is empty, the Rect will be set to [0, 0, 0, 0]

        if (r == null) {
            throw new NullPointerException();
        }
        return nativeGetBounds(mNativeRegion, r);
    
public native booleanisComplex()
Return true if the region contains more than one rectangle

public native booleanisEmpty()
Return true if this region is empty

public native booleanisRect()
Return true if the region contains a single rectangle

private static native intnativeConstructor()

private static native intnativeCreateFromParcel(android.os.Parcel p)

private static native voidnativeDestructor(int native_region)

private static native booleannativeGetBoundaryPath(int native_region, int native_path)

private static native booleannativeGetBounds(int native_region, Rect rect)

private static native booleannativeOp(int native_dst, int left, int top, int right, int bottom, int op)

private static native booleannativeOp(int native_dst, Rect rect, int native_region, int op)

private static native booleannativeOp(int native_dst, int native_region1, int native_region2, int op)

private static native booleannativeSetPath(int native_dst, int native_path, int native_clip)

private static native booleannativeSetRect(int native_dst, int left, int top, int right, int bottom)

private static native booleannativeSetRegion(int native_dst, int native_src)

private static native booleannativeWriteToParcel(int native_region, android.os.Parcel p)

final intni()

        return mNativeRegion;
    
public booleanop(Rect r, android.graphics.Region$Op op)
Perform the specified Op on this region and the specified rect. Return true if the result of the op is not empty.

        return nativeOp(mNativeRegion, r.left, r.top, r.right, r.bottom,
                        op.nativeInt);
    
public booleanop(int left, int top, int right, int bottom, android.graphics.Region$Op op)
Perform the specified Op on this region and the specified rect. Return true if the result of the op is not empty.

        return nativeOp(mNativeRegion, left, top, right, bottom,
                        op.nativeInt);
    
public booleanop(android.graphics.Region region, android.graphics.Region$Op op)
Perform the specified Op on this region and the specified region. Return true if the result of the op is not empty.

        return op(this, region, op);
    
public booleanop(Rect rect, android.graphics.Region region, android.graphics.Region$Op op)
Set this region to the result of performing the Op on the specified rect and region. Return true if the result is not empty.

        return nativeOp(mNativeRegion, rect, region.mNativeRegion,
                        op.nativeInt);
    
public booleanop(android.graphics.Region region1, android.graphics.Region region2, android.graphics.Region$Op op)
Set this region to the result of performing the Op on the specified regions. Return true if the result is not empty.

        return nativeOp(mNativeRegion, region1.mNativeRegion,
                        region2.mNativeRegion, op.nativeInt);
    
public booleanquickContains(Rect r)
Return true if the region is a single rectangle (not complex) and it contains the specified rectangle. Returning false is not a guarantee that the rectangle is not contained by this region, but return true is a guarantee that the rectangle is contained by this region.

        return quickContains(r.left, r.top, r.right, r.bottom);
    
public native booleanquickContains(int left, int top, int right, int bottom)
Return true if the region is a single rectangle (not complex) and it contains the specified rectangle. Returning false is not a guarantee that the rectangle is not contained by this region, but return true is a guarantee that the rectangle is contained by this region.

public booleanquickReject(Rect r)
Return true if the region is empty, or if the specified rectangle does not intersect the region. Returning false is not a guarantee that they intersect, but returning true is a guarantee that they do not.

        return quickReject(r.left, r.top, r.right, r.bottom);
    
public native booleanquickReject(int left, int top, int right, int bottom)
Return true if the region is empty, or if the specified rectangle does not intersect the region. Returning false is not a guarantee that they intersect, but returning true is a guarantee that they do not.

public native booleanquickReject(android.graphics.Region rgn)
Return true if the region is empty, or if the specified region does not intersect the region. Returning false is not a guarantee that they intersect, but returning true is a guarantee that they do not.

public booleanset(android.graphics.Region region)
Set the region to the specified region.

        return nativeSetRegion(mNativeRegion, region.mNativeRegion);
    
public booleanset(Rect r)
Set the region to the specified rectangle

        return nativeSetRect(mNativeRegion, r.left, r.top, r.right, r.bottom);
    
public booleanset(int left, int top, int right, int bottom)
Set the region to the specified rectangle

        return nativeSetRect(mNativeRegion, left, top, right, bottom);
    
public voidsetEmpty()
Set the region to the empty region

        nativeSetRect(mNativeRegion, 0, 0, 0, 0);
    
public booleansetPath(Path path, android.graphics.Region clip)
Set the region to the area described by the path and clip. Return true if the resulting region is non-empty. This produces a region that is identical to the pixels that would be drawn by the path (with no antialiasing).

        return nativeSetPath(mNativeRegion, path.ni(), clip.mNativeRegion);
    
public voidtranslate(int dx, int dy)
Translate the region by [dx, dy]. If the region is empty, do nothing.

        translate(dx, dy, null);
    
public native voidtranslate(int dx, int dy, android.graphics.Region dst)
Set the dst region to the result of translating this region by [dx, dy]. If this region is empty, then dst will be set to empty.

public final booleanunion(Rect r)

        return op(r, Op.UNION);
    
public voidwriteToParcel(android.os.Parcel p, int flags)
Write the region and its pixels to the parcel. The region can be rebuilt from the parcel by calling CREATOR.createFromParcel().

param
p Parcel object to write the region data into

        if (!nativeWriteToParcel(mNativeRegion, p)) {
            throw new RuntimeException();
        }