Code example for RectF

Methods: height, inset, offset, sort, width

0
	 */ 
	private void adjustCropRect( RectF r ) {
		// Log.i( LOG_TAG, "adjustCropRect: " + r + ", mImageRect: " + mImageRect ); 
 
		if ( r.left < mImageRect.left ) {
			r.offset( mImageRect.left - r.left, 0F );
		} else if ( r.right > mImageRect.right ) {
			r.offset( -( r.right - mImageRect.right ), 0 );
		} 
 
		if ( r.top < mImageRect.top ) {
			r.offset( 0F, mImageRect.top - r.top );
		} else if ( r.bottom > mImageRect.bottom ) {
			r.offset( 0F, -( r.bottom - mImageRect.bottom ) );
		} 
 
		double diffx = -1, diffy = -1;
 
		if ( r.width() > mImageRect.width() ) {
 
			if ( r.left < mImageRect.left ) {
				diffx = mImageRect.left - r.left;
				r.left += diffx;
			} else if ( r.right > mImageRect.right ) {
				diffx = ( r.right - mImageRect.right );
				r.right += -diffx;
			} 
 
		} else if ( r.height() > mImageRect.height() ) {
			if ( r.top < mImageRect.top ) {
				// top 
				diffy = mImageRect.top - r.top;
				r.top += diffy;
 
			} else if ( r.bottom > mImageRect.bottom ) {
				// bottom 
				diffy = ( r.bottom - mImageRect.bottom );
				r.bottom += -diffy;
			} 
		} 
 
		if ( mMaintainAspectRatio ) {
			// Log.d( LOG_TAG, "diffx: " + diffx + ", diffy: " + diffy ); 
			if ( diffy != -1 ) {
				diffx = diffy * mInitialAspectRatio;
				r.inset( (float) ( diffx / 2.0 ), 0 );
			} else if ( diffx != -1 ) {
				diffy = diffx / mInitialAspectRatio;
				r.inset( 0, (float) ( diffy / 2.0 ) );
			} 
		} 
 
		r.sort();
	} 
 
	/** 
	 * Adjust real crop rect. 
	 *