Code example for RectF

Methods: height, offset, set, width

0
			r.offset(0F, mImageRect.top - r.top);
		} else if (r.bottom > mImageRect.bottom) {
			r.offset(0F, -(r.bottom - mImageRect.bottom));
		} 
 
		mCropRect.set(r);
		mDrawRect = computeLayout();
		mContext.invalidate();
	} 
 
	// Handles motion (dx, dy) in screen space. 
	// The "edge" parameter specifies which edges the user is dragging. 
	void handleMotion(int edge, float dx, float dy) {
		Rect r = computeLayout();
		if (edge == GROW_NONE) {
			return; 
		} else if (edge == MOVE) {
			// Convert to image space before sending to moveBy(). 
			moveBy(dx * (mCropRect.width() / r.width()), dy * (mCropRect.height() / r.height()));
		} else { 
			if (((GROW_LEFT_EDGE | GROW_RIGHT_EDGE) & edge) == 0) {
				dx = 0;
			} 
 
			if (((GROW_TOP_EDGE | GROW_BOTTOM_EDGE) & edge) == 0) {
				dy = 0;
			} 
 
			// Convert to image space before sending to growBy(). 
			float xDelta = dx * (mCropRect.width() / r.width());
			float yDelta = dy * (mCropRect.height() / r.height());
			growBy((((edge & GROW_LEFT_EDGE) != 0) ? -1 : 1) * xDelta, (((edge & GROW_TOP_EDGE) != 0) ? -1 : 1)
					* yDelta);
		} 
	} 
 
	// Grows the cropping rectange by (dx, dy) in image space. 
	void moveBy(float dx, float dy) {
		Rect invalRect = new Rect(mDrawRect);
 
		mCropRect.offset(dx, dy);
 
		// Put the cropping rectangle inside image rectangle. 
		mCropRect.offset(Math.max(0, mImageRect.left - mCropRect.left), Math.max(0, mImageRect.top - mCropRect.top));
 
		mCropRect.offset(Math.min(0, mImageRect.right - mCropRect.right),
				Math.min(0, mImageRect.bottom - mCropRect.bottom));
 
		mDrawRect = computeLayout();
		invalRect.union(mDrawRect);
		invalRect.inset(-10, -10);