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