001package armyc2.c5isr.renderer.utilities;
002
003import android.graphics.Paint;
004import android.graphics.Point;
005import android.graphics.Rect;
006
007public class TextInfo {
008
009        String _text = "";
010        Point _location = null;
011        Rect _bounds = null;
012        public TextInfo(String text, int x, int y, Paint font)
013        {
014                if(text != null)
015                {
016                        _text = text;
017                }
018
019                _location = new Point(x,y);
020                _bounds = new Rect();
021
022                font.getTextBounds(_text, 0, _text.length(), _bounds);
023        
024        }
025        
026        public void setLocation(int x, int y)
027        {
028                _bounds.offset(x - _location.x, y - _location.y);
029                _location = new Point(x,y);
030                //_bounds.offsetTo(x, y - (_bounds.bottom - _bounds.top));
031        }
032        
033        public Point getLocation()
034        {
035                return _location;
036        }
037        
038        public void shift(int x, int y)
039        {
040                _location.offset(x, y);
041                _bounds.offset(x, y);
042        }
043        
044        public String getText()
045        {
046                return _text;
047        }
048        
049        public Rect getTextBounds()
050        {
051                return _bounds;
052        }
053        
054
055        public Rect getTextOutlineBounds()
056        {
057                RendererSettings RS = RendererSettings.getInstance();
058                int outlineOffset = RS.getTextOutlineWidth();
059                Rect bounds = new Rect(_bounds);
060                
061                if(outlineOffset > 0)
062                {
063                        if(RS.getTextBackgroundMethod() == RendererSettings.TextBackgroundMethod_OUTLINE)
064                                RectUtilities.grow(bounds, outlineOffset / 2);
065                        else
066                                RectUtilities.grow(bounds, outlineOffset);
067                }
068                
069                return bounds;
070        }
071}