001/*
002 * To change this template, choose Tools | Templates
003 * and open the template in the editor.
004 */
005package armyc2.c2sd.JavaLineArray;
006import armyc2.c2sd.renderer.utilities.ShapeInfo;
007import armyc2.c2sd.graphics2d.*;
008import android.graphics.RectF;
009import android.graphics.Path;
010/**
011 *
012 * @author Michael Deutch
013 */
014public class Shape2 extends ShapeInfo
015{
016
017    public Shape2(int value)
018    {
019        setShapeType(value);
020        _Shape=new GeneralPath();
021        Stroke stroke=new BasicStroke();
022        this.setStroke(stroke);
023    }
024    private int style=0;  //e.g. 26 for enemy flots
025    public void set_Style(int value)
026    {
027        style = value;
028    }
029    private int fillStyle;
030    public void set_Fillstyle(int value)
031    {
032        fillStyle=value;
033    }
034    public int get_FillStyle()
035    {
036        return fillStyle;
037    }
038    public int get_Style()  //used by TacticalRenderer but not client
039    {
040        return style;
041    }
042    public void lineTo(POINT2 pt)
043    {
044        ((GeneralPath)_Shape).lineTo((int)pt.x, (int)pt.y);
045    }
046    public void moveTo(POINT2 pt)
047    {       
048        ((GeneralPath)_Shape).moveTo((int)pt.x, (int)pt.y);
049    }
050    @Override
051    public Rectangle getBounds()
052    {
053        RectF rectf=new RectF();
054        if(_Shape instanceof GeneralPath)
055        {
056            Path path=((GeneralPath)_Shape).getPath();
057            path.computeBounds(rectf, true);
058            int width=(int)rectf.right-(int)rectf.left;
059            int height=(int)rectf.bottom-(int)rectf.top;
060            Rectangle rect=new Rectangle((int)rectf.left,(int)rectf.top,width,height);        
061            return rect;
062        }
063        else
064            return this.getBounds();
065    }
066}