Code example for RectF

Methods: containssetEmpty

0
		float tranY = values[Matrix.MTRANS_Y];
				 
		int imageHeight = (int) (scale * mImageHeight);
		int imageWidth = (int) (scale * mImageWidth);
 
		mTraslateLimitRect.setEmpty();
		//don't think about optimize code. first, just write code case by case. 
 
		//check TOP & BOTTOM 
		if( imageHeight > getHeight() ){
			//image height is taller than view 
			mTraslateLimitRect.top = getHeight() - imageHeight - getPaddingTop() - getPaddingBottom();
			mTraslateLimitRect.bottom = 0.f;
		}else{ 
			mTraslateLimitRect.top = mTraslateLimitRect.bottom = 
					(getHeight() - imageHeight - getPaddingTop() - getPaddingBottom() ) / 2.f;
		} 
 
		//check LEFT & RIGHT 
		if( imageWidth > getWidth() ){
			//image width is longer than view 
			mTraslateLimitRect.left = getWidth() - imageWidth - getPaddingRight() - getPaddingLeft();
			mTraslateLimitRect.right = 0.f;
		}else{ 
			mTraslateLimitRect.left = mTraslateLimitRect.right =
					(getWidth() - imageWidth - getPaddingLeft() - getPaddingRight()) / 2.f;
		} 
 
		float newTranX = tranX;
		newTranX = Math.max(newTranX, mTraslateLimitRect.left);
		newTranX = Math.min(newTranX, mTraslateLimitRect.right);
 
		float newTranY = tranY;
		newTranY = Math.max(newTranY, mTraslateLimitRect.top);
		newTranY = Math.min(newTranY, mTraslateLimitRect.bottom);
		 
		values[Matrix.MTRANS_X] = newTranX;
		values[Matrix.MTRANS_Y] = newTranY;
		mCurrentMatrix.setValues(values);
		 
		if( mTraslateLimitRect.contains(tranX, tranY) == false ){
			//set new start point.  
			mStartPoint.offset(tranX - newTranX, tranY - newTranY);
		} 
	} 
	 
Contextual code suggestions in your IDE  Get Codota for Java