001/*
002 * To change this template, choose Tools | Templates
003 * and open the template in the editor.
004 */
005
006package armyc2.c2sd.renderer.utilities;
007
008import java.io.DataInputStream;
009import java.io.IOException;
010
011/**
012*
013* @author michael.spinelli
014*/
015public class SymbolDef {
016
017   String _strBasicSymbolId = "";
018   String _strDescription = "";
019   String _strSymbolType = "";
020   String _strGeometry = "";
021   String _strDrawCategory = "";
022   int _intDrawCategory = 99;
023   int _intMinPoints = 0;
024   int _intMaxPoints = 0;
025   String _strModifiers = "";
026   String _strHierarchy = "";
027   String _strFullPath = "";
028   
029
030
031
032   /**
033    * Just a category in the milstd hierarchy.
034    * Not something we draw.
035    * WILL NOT RENDER
036    */
037   static public final int DRAW_CATEGORY_DONOTDRAW = 0;
038
039   /**
040    * A polyline, a line with n number of points.
041    * 0 control points
042    */
043   static public final int DRAW_CATEGORY_LINE = 1;
044
045   /**
046    * An animated shape, uses the animate function to draw.
047    * 0 control points (every point shapes symbol)
048    */
049   static public final int DRAW_CATEGORY_AUTOSHAPE = 2;
050
051   /**
052    * An enclosed polygon with n points
053    * 0 control points
054    */
055   static public final int DRAW_CATEGORY_POLYGON = 3;
056   /**
057    * A polyline with n points (entered in reverse order)
058    * 0 control points
059    */
060   static public final int DRAW_CATEGORY_ARROW = 4;
061   /**
062    * A graphic with n points whose last point defines the width of the graphic.
063    * 1 control point
064    */
065   static public final int DRAW_CATEGORY_ROUTE = 5;
066   /**
067    * A line defined only by 2 points, and cannot have more.
068    * 0 control points
069    */
070   static public final int DRAW_CATEGORY_TWOPOINTLINE = 6;
071   /**
072    * Shape is defined by a single point
073    * 0 control points
074    */
075   static public final int DRAW_CATEGORY_POINT = 8;
076   /**
077    * A polyline with 2 points (entered in reverse order).
078    * 0 control points
079    */
080   static public final int DRAW_CATEGORY_TWOPOINTARROW = 9;
081   /**
082    * An animated shape, uses the animate function to draw. Super Autoshape draw
083    * in 2 phases, usually one to define length, and one to define width.
084    * 0 control points (every point shapes symbol)
085    *
086    */
087   static public final int DRAW_CATEGORY_SUPERAUTOSHAPE = 15;
088    /**
089    * Circle that requires 1 AM modifier value.
090    * See ModifiersTG.java for modifier descriptions and constant key strings.
091    */
092   static public final int DRAW_CATEGORY_CIRCULAR_PARAMETERED_AUTOSHAPE = 16;
093   /**
094    * Rectangle that requires 2 AM modifier values and 1 AN value.";
095    * See ModifiersTG.java for modifier descriptions and constant key strings.
096    */
097   static public final int DRAW_CATEGORY_RECTANGULAR_PARAMETERED_AUTOSHAPE = 17;
098   /**
099    * Requires 2 AM values and 2 AN values per sector.  
100    * The first sector can have just one AM value although it is recommended 
101    * to always use 2 values for each sector.  X values are not required
102    * as our rendering is only 2D for the Sector Range Fan symbol.
103    * See ModifiersTG.java for modifier descriptions and constant key strings.
104    */
105   static public final int DRAW_CATEGORY_SECTOR_PARAMETERED_AUTOSHAPE = 18;
106   /**
107    *  Requires at least 1 distance/AM value"
108    *  See ModifiersTG.java for modifier descriptions and constant key strings.
109    */
110   static public final int DRAW_CATEGORY_CIRCULAR_RANGEFAN_AUTOSHAPE = 19;
111   /**
112    * Requires 1 AM value.
113    * See ModifiersTG.java for modifier descriptions and constant key strings.
114    */
115   static public final int DRAW_CATEGORY_TWO_POINT_RECT_PARAMETERED_AUTOSHAPE = 20;
116   
117   /**
118    * 3D airspace, not a milstd graphic.
119    */
120   static public final int DRAW_CATEGORY_3D_AIRSPACE = 40;
121   
122   /**
123    * UNKNOWN.
124    */
125   static public final int DRAW_CATEGORY_UNKNOWN = 99;
126
127   public SymbolDef(String basicSymbolID, String description, int drawCategory, String hierarchy, int minPoints, int maxPoints, String modifiers, String fullPath)
128   {
129           _strBasicSymbolId = basicSymbolID;
130           _strDescription = description;
131           _intDrawCategory = drawCategory;
132           _strHierarchy = hierarchy;
133           _intMinPoints = minPoints;  
134           _intMaxPoints = maxPoints;
135           _strModifiers = modifiers;
136           _strFullPath = fullPath;
137              
138   }
139
140
141
142   /**
143    * The basic 15 character basic symbol Id.
144    */
145
146   public String getBasicSymbolId()
147   {
148           return _strBasicSymbolId;
149   }
150
151   /**
152    * The description of this tactical graphic.  Typically the name of the tactical graphic in MIL-STD-2525B.
153    */
154   public String getDescription()
155   {
156           return _strDescription;
157   }
158
159
160
161   /**
162    * How does this draw? (autoshape, superautoshape, polygon)
163    * 
164    */
165   public int getDrawCategory()
166   {
167           return _intDrawCategory;
168   }
169
170   
171   /**
172    * Defines the minimum points fields.
173    */
174   public int getMinPoints()
175   {
176           return _intMinPoints;
177   }
178
179   /**
180    * Defines the maximum points fields.
181    */
182   public int getMaxPoints()
183   {
184           return _intMaxPoints;
185   }
186
187   public Boolean isMultiPoint()
188   {
189       char codingScheme = _strBasicSymbolId.charAt(0);
190       Boolean returnVal = false;
191       if (codingScheme == 'G' || codingScheme == 'W') 
192       {
193
194           if(_intMaxPoints > 1)
195           {
196               returnVal = true;
197           }
198           else
199           {
200               switch(_intDrawCategory)
201               {
202                   case SymbolDef.DRAW_CATEGORY_RECTANGULAR_PARAMETERED_AUTOSHAPE:
203                   case SymbolDef.DRAW_CATEGORY_SECTOR_PARAMETERED_AUTOSHAPE:
204                   case SymbolDef.DRAW_CATEGORY_TWO_POINT_RECT_PARAMETERED_AUTOSHAPE: 
205                   case SymbolDef.DRAW_CATEGORY_CIRCULAR_PARAMETERED_AUTOSHAPE:
206                   case SymbolDef.DRAW_CATEGORY_CIRCULAR_RANGEFAN_AUTOSHAPE:
207                   case SymbolDef.DRAW_CATEGORY_ROUTE:
208                       returnVal = true;
209                       break;
210                   default:
211                       returnVal = false;
212               }
213           }
214           return returnVal;
215       } 
216       else if(_strBasicSymbolId.startsWith("BS_") || _strBasicSymbolId.startsWith("BBS_") || _strBasicSymbolId.startsWith("PBS_"))
217       {
218           return true;
219       }
220       else 
221       {
222           return false;
223       }
224   }
225   
226
227   /**
228    *
229    */
230   public String getModifiers()
231   {
232           return _strModifiers;
233   }
234
235   /**
236    * Defines where the symbol goes in the ms2525 hierarchy.
237    * 2.X.etc...
238    */
239   public String getHierarchy()
240   {
241           return _strHierarchy;
242   }
243
244    /**
245    * Defines where the symbol goes in the ms2525 hierarchy.
246     * TacticalGraphics/Areas/stuff...
247    */
248   public String getFullPath()
249   {
250           return _strFullPath;
251   }
252
253    public static SymbolDef readBinary(DataInputStream dis) throws IOException
254    {
255        String _strBasicSymbolId = dis.readUTF();
256        String _strDescription = dis.readUTF();
257        String _strSymbolType = dis.readUTF();
258        String _strGeometry = dis.readUTF();
259        String _strDrawCategory = dis.readUTF();
260        int _intDrawCategory = dis.readInt();
261        int _intMinPoints = dis.readInt();
262        int _intMaxPoints = dis.readInt();
263        String _strModifiers = dis.readUTF();
264        String _strHierarchy = dis.readUTF();
265        String _strFullPath = dis.readUTF();
266
267        return new SymbolDef(_strBasicSymbolId, _strDescription, _intDrawCategory, _strHierarchy,
268                _intMinPoints, _intMaxPoints, _strModifiers, _strFullPath);
269    }
270}