001package armyc2.c5isr.renderer.utilities;
002
003import android.graphics.Point;
004import android.graphics.PointF;
005import android.graphics.Rect;
006import android.graphics.RectF;
007
008
009public class SVGSymbolInfo implements SymbolDimensionInfo{
010
011    private String _svg = null;
012    private String _svgDataURI = null;
013
014    private float _anchorX = 0;
015    private float _anchorY = 0;
016
017    private Rect _symbolBounds = null;
018    private Rect _bounds = null;
019    private RectF _symbolBoundsF = null;
020    private RectF _boundsF = null;
021
022    public SVGSymbolInfo(String svg, Point anchorPoint, Rect symbolBounds, Rect svgBounds)
023    {
024        _svg = svg;
025        _anchorX = anchorPoint.x;
026        _anchorY = anchorPoint.y;
027        _symbolBounds = symbolBounds;
028        _bounds = svgBounds;
029        _symbolBoundsF = RectUtilities.makeRectFFromRect(symbolBounds);
030        _boundsF = RectUtilities.makeRectFFromRect(svgBounds);
031    }
032
033    public SVGSymbolInfo(String svg, PointF anchorPoint, RectF symbolBounds, RectF svgBounds)
034    {
035        _svg = svg;
036        _anchorX = anchorPoint.x;
037        _anchorY = anchorPoint.y;
038        _symbolBounds = RectUtilities.makeRectFromRectF(symbolBounds);
039        _bounds = RectUtilities.makeRectFromRectF(svgBounds);
040        _symbolBoundsF = symbolBounds;
041        _boundsF = svgBounds;
042    }
043
044    public String getSVGDataURI()
045    {
046        if(_svgDataURI==null)
047        {
048            //_svgDataURI = new String(Base64.getEncoder().encode(_svg.getBytes()));//Java
049            _svgDataURI = new String(android.util.Base64.encode(_svg.getBytes(),0));
050        }
051        return _svgDataURI;
052    }
053
054    public String getSVG(){return _svg;}
055
056    /**
057     * The x value the image should be centered on or the "anchor point".
058     * @return {@link Integer}
059     */
060    public int getCenterX()
061    {
062        return (int)_anchorX;
063    }
064
065    /**
066     * The y value the image should be centered on or the "anchor point".
067     * @return {@link Integer}
068     */
069    public int getCenterY()
070    {
071        return (int)_anchorY;
072    }
073
074    /**
075     * The point the image should be centered on or the "anchor point".
076     * @return {@link Point}
077     */
078    public Point getCenterPoint()
079    {
080        return new Point((int)_anchorX, (int)_anchorY);
081    }
082
083    /**
084     * The point the image should be centered on or the "anchor point".
085     * @return {@link PointF}
086     */
087    public PointF getCenterPointF()
088    {
089        return new PointF(_anchorX, _anchorY);
090    }
091
092    /**
093     * minimum bounding rectangle for the core symbol. Does
094     * not include modifiers, display or otherwise.
095     * @return {@link Rect}
096     */
097    public Rect getSymbolBounds()
098    {
099        return _symbolBounds;
100    }
101    /**
102     * minimum bounding rectangle for the core symbol. Does
103     * not include modifiers, display or otherwise.
104     * @return {@link RectF}
105     */
106    public RectF getSymbolBoundsF()
107    {
108        return _symbolBoundsF;
109    }
110
111    /**
112     * Dimension of the entire image.
113     * @return {@link Rect}
114     */
115
116    public Rect getImageBounds()
117    {
118        return new Rect(_bounds.left,_bounds.top,_bounds.right,_bounds.bottom);
119    }
120
121    /**
122     * Dimension of the entire image.
123     * @return {@link RectF}
124     */
125    public RectF getImageBoundsF()
126    {
127        return new RectF(_boundsF.left,_boundsF.top,_boundsF.right,_boundsF.bottom);
128    }
129
130
131}