Code example for RectF

Methods: centerXcenterYcontainsinset

0
	 *           the y 
	 * @return the hit 
	 */ 
	public int getHit( float x, float y ) {
 
		final RectF rect = new RectF( mDrawRect );
		rect.inset( -mPadding, -mPadding );
 
		final float pts[] = new float[] { x, y };
 
		final Matrix rotateMatrix = new Matrix();
		rotateMatrix.postTranslate( -rect.centerX(), -rect.centerY() );
		rotateMatrix.postRotate( -mRotation );
		rotateMatrix.postTranslate( rect.centerX(), rect.centerY() );
		rotateMatrix.mapPoints( pts );
 
		x = pts[0];
		y = pts[1];
 
		mContext.invalidate();
 
		int retval = DrawableHighlightView.GROW_NONE;
		final boolean verticalCheck = ( y >= ( rect.top - DrawableHighlightView.HIT_TOLERANCE ) )
				&& ( y < ( rect.bottom + DrawableHighlightView.HIT_TOLERANCE ) );
		final boolean horizCheck = ( x >= ( rect.left - DrawableHighlightView.HIT_TOLERANCE ) )
				&& ( x < ( rect.right + DrawableHighlightView.HIT_TOLERANCE ) );
		 
		// if horizontal and vertical checks are good then 
		// at least the move edge is selected 
		if( verticalCheck && horizCheck ){
			retval = DrawableHighlightView.MOVE;
		} 
 
		if ( !mRotateAndScale ) {
			if ( ( Math.abs( rect.left - x ) < DrawableHighlightView.HIT_TOLERANCE ) && verticalCheck )
				retval |= DrawableHighlightView.GROW_LEFT_EDGE;
			if ( ( Math.abs( rect.right - x ) < DrawableHighlightView.HIT_TOLERANCE ) && verticalCheck )
				retval |= DrawableHighlightView.GROW_RIGHT_EDGE;
			if ( ( Math.abs( rect.top - y ) < DrawableHighlightView.HIT_TOLERANCE ) && horizCheck )
				retval |= DrawableHighlightView.GROW_TOP_EDGE;
			if ( ( Math.abs( rect.bottom - y ) < DrawableHighlightView.HIT_TOLERANCE ) && horizCheck )
				retval |= DrawableHighlightView.GROW_BOTTOM_EDGE;
		} 
 
		if ( ( Math.abs( rect.right - x ) < DrawableHighlightView.HIT_TOLERANCE )
				&& ( Math.abs( rect.bottom - y ) < DrawableHighlightView.HIT_TOLERANCE ) && verticalCheck && horizCheck )
			retval = DrawableHighlightView.ROTATE;
 
		if ( ( retval == DrawableHighlightView.GROW_NONE ) && rect.contains( (int) x, (int) y ) )
			retval = DrawableHighlightView.MOVE;
		return retval;
	} 
 
	/** 
Connect your IDE to all the code out there  Get Codota for Java