Code example for Canvas

Methods: concat, drawPath, restoreToCount, save

0
		if ( mHidden ) return;
 
		RectF drawRectF = new RectF( mDrawRect );
		drawRectF.inset( -mPadding, -mPadding );
 
		final int saveCount = canvas.save();
		canvas.concat( mRotateMatrix );
 
		final Rect viewDrawingRect = new Rect();
 
		mContext.getDrawingRect( viewDrawingRect );
 
		mOutlinePath.reset();
		mOutlinePath.addRoundRect( drawRectF, mOutlineEllipse, mOutlineEllipse, Path.Direction.CW );
 
		if ( mDrawOutlineFill ) {
			canvas.drawPath( mOutlinePath, mOutlineFillPaint );
		} 
		 
		if ( mDrawOutlineStroke ) {
			canvas.drawPath( mOutlinePath, mOutlineStrokePaint );
		} 
		 
		boolean is_selected = getSelected();
		boolean is_focused = getFocused();
 
		if ( mEditableContent != null )
			mEditableContent.setBounds( mDrawRect.left, mDrawRect.top, mDrawRect.right, mDrawRect.bottom );
		else 
			mContent.setBounds( (int) mDrawRect.left, (int) mDrawRect.top, (int) mDrawRect.right, (int) mDrawRect.bottom );
 
		mContent.draw( canvas );
 
		if ( is_selected && !is_focused ) {
			 
			if ( mShowAnchors ) {
				final int left = (int) ( drawRectF.left );
				final int right = (int) ( drawRectF.right );
				final int top = (int) ( drawRectF.top );
				final int bottom = (int) ( drawRectF.bottom );
 
				if ( mAnchorRotate != null ) {
					mAnchorRotate.setBounds( right - mAnchorWidth, bottom - mAnchorHeight, right + mAnchorWidth, bottom + mAnchorHeight );
					mAnchorRotate.draw( canvas );
				} 
 
				if ( ( mAnchorDelete != null ) && mShowDeleteButton ) {
					mAnchorDelete.setBounds( left - mAnchorWidth, top - mAnchorHeight, left + mAnchorWidth, top + mAnchorHeight );
					mAnchorDelete.draw( canvas );
				} 
			} 
		} 
 
		canvas.restoreToCount( saveCount );
 
		if ( mEditableContent != null && is_selected ) {
			if ( mEditableContent.isEditing() ) {
				mContext.postInvalidateDelayed( 300 );
			}