Code example for RectF

Methods: height, offset, sort, width

0
		matrix.getValues( mvalues );
		final float scale = mvalues[Matrix.MSCALE_X];
 
		if ( tempLayoutRectF.left < outsideRect.left ) {
			adjusted = true;
			rect.offset( ( outsideRect.left - tempLayoutRectF.left ) / scale, 0 );
		} else if ( tempLayoutRectF.right > outsideRect.right ) {
			adjusted = true;
			rect.offset( -( tempLayoutRectF.right - outsideRect.right ) / scale, 0 );
		} 
 
		if ( tempLayoutRectF.top < outsideRect.top ) {
			adjusted = true;
			rect.offset( 0, ( outsideRect.top - tempLayoutRectF.top ) / scale );
		} else if ( tempLayoutRectF.bottom > outsideRect.bottom ) {
			adjusted = true;
			rect.offset( 0, -( tempLayoutRectF.bottom - outsideRect.bottom ) / scale );
		} 
 
		tempLayoutRectF.set( rect );
		matrix.mapRect( tempLayoutRectF );
 
		if ( tempLayoutRectF.width() > outsideRect.width() ) {
			adjusted = true;
			if ( tempLayoutRectF.left < outsideRect.left ) rect.left += ( outsideRect.left - tempLayoutRectF.left ) / scale;
			if ( tempLayoutRectF.right > outsideRect.right ) rect.right += -( tempLayoutRectF.right - outsideRect.right ) / scale;
		} 
 
		if ( tempLayoutRectF.height() > outsideRect.height() ) {
			adjusted = true;
			if ( tempLayoutRectF.top < outsideRect.top ) rect.top += ( outsideRect.top - tempLayoutRectF.top ) / scale;
			if ( tempLayoutRectF.bottom > outsideRect.bottom )
				rect.bottom += -( tempLayoutRectF.bottom - outsideRect.bottom ) / scale;
		} 
 
		if ( mMaintainAspectRatio && adjusted ) {
			if ( mInitialAspectRatio >= 1 ) { // width > height
				final double dy = rect.width() / mInitialAspectRatio;
				rect.bottom = (float) ( rect.top + dy );
			} else { // height >= width 
				final double dx = rect.height() * mInitialAspectRatio;
				rect.right = (float) ( rect.left + dx );
			} 
		} 
 
		rect.sort();
		return rect;
	} 
 
	/** 
	 * Compute and adjust the current crop layout