function adjustTextPositionOnRect(textPosition, rect, distance) {

	        var x = rect.x;
	        var y = rect.y;

	        var height = rect.height;
	        var width = rect.width;
	        var halfHeight = height / 2;

	        var textAlign = 'left';
	        var textVerticalAlign = 'top';

	        switch (textPosition) {
	            case 'left':
	                x -= distance;
	                y += halfHeight;
	                textAlign = 'right';
	                textVerticalAlign = 'middle';
	                break;
	            case 'right':
	                x += distance + width;
	                y += halfHeight;
	                textVerticalAlign = 'middle';
	                break;
	            case 'top':
	                x += width / 2;
	                y -= distance;
	                textAlign = 'center';
	                textVerticalAlign = 'bottom';
	                break;
	            case 'bottom':
	                x += width / 2;
	                y += height + distance;
	                textAlign = 'center';
	                break;
	            case 'inside':
	                x += width / 2;
	                y += halfHeight;
	                textAlign = 'center';
	                textVerticalAlign = 'middle';
	                break;
	            case 'insideLeft':
	                x += distance;
	                y += halfHeight;
	                textVerticalAlign = 'middle';
	                break;
	            case 'insideRight':
	                x += width - distance;
	                y += halfHeight;
	                textAlign = 'right';
	                textVerticalAlign = 'middle';
	                break;
	            case 'insideTop':
	                x += width / 2;
	                y += distance;
	                textAlign = 'center';
	                break;
	            case 'insideBottom':
	                x += width / 2;
	                y += height - distance;
	                textAlign = 'center';
	                textVerticalAlign = 'bottom';
	                break;
	            case 'insideTopLeft':
	                x += distance;
	                y += distance;
	                break;
	            case 'insideTopRight':
	                x += width - distance;
	                y += distance;
	                textAlign = 'right';
	                break;
	            case 'insideBottomLeft':
	                x += distance;
	                y += height - distance;
	                textVerticalAlign = 'bottom';
	                break;
	            case 'insideBottomRight':
	                x += width - distance;
	                y += height - distance;
	                textAlign = 'right';
	                textVerticalAlign = 'bottom';
	                break;
	        }

	        return {
	            x: x,
	            y: y,
	            textAlign: textAlign,
	            textVerticalAlign: textVerticalAlign
	        };
	    }
@public
@param {stirng} textPosition
@param {Object} rect {x, y, width, height}
@param {number} distance
@return {Object} {x, y, textAlign, textVerticalAlign}