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
008
009
010/*
011<SYMBOL>
012  <SYMBOLID>S*G*UCRX--*****</SYMBOLID>
013  <DESCRIPTION>Reconnaissance Long Range Surveillance (LRS)</DESCRIPTION>
014  <MAPPING1U>1457</MAPPING1U>
015  <MAPPING1F>1458</MAPPING1F>
016  <MAPPING1N>1459</MAPPING1N>
017  <MAPPING1H>1460</MAPPING1H>
018  <MAPPING1COLOR/>
019  <MAPPING2/>
020  <MAPPING2COLOR/>
021</SYMBOL>
022*/
023
024import java.io.DataInputStream;
025import java.io.IOException;
026
027/**
028 *
029 * @author Michael.Spinelli
030 */
031public class UnitFontLookupInfo {
032
033    public String _SymbolID = "";
034    public String _Description = "";
035    public int _mapping1 = 0;
036    public int _mapping1U = 0;
037    public int _mapping1F = 0;
038    public int _mapping1N = 0;
039    public int _mapping1H = 0;
040    public int _mapping2 = 0;
041    public Color _color1 = Color.BLACK;
042    public Color _color2 = Color.BLACK;
043
044    public UnitFontLookupInfo(String SymbolID, String Description, 
045            int M1U, int M1F, int M1N, int M1H, Color Color1, int M2, Color Color2 )
046    {
047        _SymbolID = SymbolID;
048        _Description = Description;
049
050        _mapping1U = M1U;
051        _mapping1F = M1F;
052        _mapping1N = M1N;
053        _mapping1H = M1H;
054        _mapping2 = M2;
055
056        _color1 = Color1;
057        _color2 = Color2;
058    }
059
060        public UnitFontLookupInfo(String SymbolID, String Description, 
061            String M1U, String M1F, String M1N, String M1H, String Color1, 
062            String M2, String Color2)
063    {
064        _SymbolID = SymbolID;
065        _Description = Description;
066
067        if(M1U != null && !M1U.equals(""))
068            _mapping1U = Integer.valueOf(M1U);
069        if(M1F != null && !M1F.equals(""))
070            _mapping1F = Integer.valueOf(M1F);
071        if(M1N != null && !M1N.equals(""))
072            _mapping1N = Integer.valueOf(M1N);
073        if(M1H != null && !M1H.equals(""))
074            _mapping1H = Integer.valueOf(M1H);
075        if(M2 != null && !M2.equals(""))
076            _mapping2 = Integer.valueOf(M2);
077
078        Color temp = null;
079        if(Color1 != null && !Color1.equals(""))
080            temp = SymbolUtilities.getColorFromHexString(Color1);
081        if(temp != null)
082            _color1 = temp;
083        if(Color2 != null && !Color2.equals(""))
084            _color2 = SymbolUtilities.getColorFromHexString(Color2);
085    }
086
087    private UnitFontLookupInfo(){
088
089    }
090
091    public String getBasicSymbolID()
092    {
093        return _SymbolID;
094    }
095
096    public String getDescription()
097    {
098        return _Description;
099    }
100
101    /**
102     * gives correct mapping given the full
103     * @param SymbolID
104     * @return
105     */
106    public int getMapping1(String SymbolID)
107    {
108        char affiliation = SymbolID.charAt(1);
109        if(affiliation == 'F' ||
110                          affiliation == 'A' ||
111                          affiliation == 'D' ||
112                          affiliation == 'M' ||
113                          affiliation == 'J' ||
114                          affiliation == 'K')
115            return _mapping1F;
116        else if(affiliation == 'H' || affiliation == 'S')
117            return _mapping1H;
118        if(affiliation == 'N' || affiliation == 'L')
119            return _mapping1N;
120        else /*(affiliation == 'P' ||
121                     affiliation == 'U' ||
122                     affiliation == 'G' ||
123                     affiliation == 'W')*/
124            return _mapping1U;
125    }
126
127    public int getMapping2()
128    {
129        return _mapping2;
130    }
131
132    public Color getColor1()
133    {
134        return _color1;
135    }
136
137    public Color getColor2()
138    {
139        return _color2;
140    }
141
142    public static UnitFontLookupInfo readBinary(DataInputStream dis) throws IOException
143    {
144        UnitFontLookupInfo info = new UnitFontLookupInfo();
145        info._SymbolID = dis.readUTF();
146        info._Description = dis.readUTF();
147        info._mapping1 = dis.readInt();
148        info._mapping1U = dis.readInt();
149        info._mapping1F = dis.readInt();
150        info._mapping1N = dis.readInt();
151        info._mapping1H = dis.readInt();
152        info._mapping2 = dis.readInt();
153
154        if(dis.readBoolean()) {
155            info._color1 = SymbolUtilities.getColorFromHexString(dis.readUTF());
156        }
157        if(dis.readBoolean()) {
158            info._color2 = SymbolUtilities.getColorFromHexString(dis.readUTF());
159        }
160        return info;
161    }
162}