001/*
002 * To change this template, choose Tools | Templates
003 * and open the template in the editor.
004 */
005package armyc2.c5isr.renderer.utilities;
006
007import java.util.ArrayList;
008import java.util.Map;
009
010/**
011 * Symbol attribute constants to be used as keys in the Map when calling {@link armyc2.c5isr.renderer.MilStdIconRenderer#RenderIcon(String, Map, Map)}
012 * or {@link armyc2.c5isr.web.render.WebRenderer#RenderSymbol(String, String, String, String, String, String, double, String, Map, Map, int)}
013 */
014public class MilStdAttributes {
015
016    /**
017     * Line color of the symbol. hex value.
018     */
019    public static final String LineColor = "LINECOLOR";
020
021    /**
022     * Fill color of the symbol. hex value
023     */
024    public static final String FillColor = "FILLCOLOR";
025
026    /**
027     * Main color of internal icon.  Only relevant to framed symbols. hex value
028     */
029    public static final String IconColor = "ICONCOLOR";
030
031
032    /**
033     * size of the single point image
034     */
035    public static final String PixelSize = "PIXELSIZE";
036
037
038    /**
039     * defaults to true
040     */
041    public static final String KeepUnitRatio = "KEEPUNITRATIO";
042
043    /**
044     * transparency value of the symbol. values from 0.0 - 1.0
045     */
046    public static final String Alpha = "ALPHA";
047
048    /**
049     * outline the symbol, true/false
050     */
051    public static final String OutlineSymbol = "OUTLINESYMBOL";
052
053    /**
054     * specify and outline color rather than letting renderer picking
055     * the best contrast color. hex value
056     */
057    public static final String OutlineColor = "OUTLINECOLOR";
058
059    /*
060     * specifies thickness of the symbol outline
061     */
062    //public static final String OutlineWidth = 9;
063
064    /**
065     * just draws the core symbol
066     */
067    public static final String DrawAsIcon = "DRAWASICON";
068
069    /**
070     * Specifies the line width of the multipoint symbology
071     */
072    public static final String LineWidth = "LINEWIDTH";
073
074    /**
075     * Specifies the color for text labels
076     */
077    public static final String TextColor = "TEXTCOLOR";
078
079    /**
080     * Specifies the color for the text background (color outline or fill)
081     */
082    public static final String TextBackgroundColor = "TEXTBACKGROUNDCOLOR";
083
084    /**
085     * If false, the renderer will create a bunch of little lines to create
086     * the "dash" effect (expensive but necessary for KML).
087     * If true, it will be on the user to create the dash effect using the
088     * DashArray from the Stroke object from the ShapeInfo object.
089     */
090    public static final String UseDashArray = "USEDASHARRAY";
091
092    /**
093     * The mode that altitude labels will be displayed in, the default value is AMSL.
094     *
095     * This value acts as a label, appending whatever string that is passed in to the end of the altitude units.
096     * Currently only effective for multi-point graphics.
097     */
098    public static final String AltitudeMode = "ALTITUDEMODE";
099
100    /**
101     * At the moment, this refers to the optional range fan labels.
102     */
103    public static final String HideOptionalLabels = "HIDEOPTIONALLABELS";
104
105    /**
106     * For internal use
107     */
108    public static final String UsePatternFill = "USEPATTERNFILL";
109
110    /**
111     * For internal use
112     */
113    public static final String PatternFillType = "PATTERNFILLTYPE";
114
115    /**
116     * The conversion factor and the label that you want all distances to display in. The conversion factor
117     * is converting from meters. The default unit is meters.<br><br>
118     *
119     * Must be in the form [conversionFactor],[label]. So for example converting to feet would be "3.28084,FT".
120     * The helper class {@link DistanceUnit} can be used.
121     */
122    public static final String DistanceUnits = "DISTANCEUNITS";
123
124    /**
125     * The conversion factor and the label that you want all distances to display in.
126     * Conventionally, the conversion factor is converting from meters by default,
127     * but other values could be passed, like "1,KM" to use an unaltered value in kilometers.<br><br>
128     *
129     * Must be in the form [conversionFactor],[label]. So for example converting meters to feet would be "3.28084,FT".
130     * The helper class {@link DistanceUnit} can be used.
131     * Currently only effective for multi-point graphics.
132     */
133    public static final String AltitudeUnits = "ALTITUDEUNITS";
134
135    /**
136     * If the engagement/target amplifier bar is to be used to designate targets, non-targets, and
137     * pruned or expired targets, a different coloring schema shall be used. Hostile tracks which
138     * are deemed targets shall have a red bar (RGB: 255, 0, 0) to indicate target. For hostile
139     * tracks deemed to be non-targets, white (RGB: 255, 255, 255) should be used to indicate non
140     * target. Finally, for hostile tracks which have been pruned or have expired shall be colored
141     * orange (RGB: 255, 120, 0).
142     * This attribute expects a hex string for the color
143     */
144    public static final String EngagementBarColor = "ENGAGEMENTBARCOLOR";
145
146    /**
147     * No Longer relevant
148     * @return {@link ArrayList}
149     * @deprecated see {@link #GetAttributesList(String)}
150     */
151    public static ArrayList<String> GetModifierList()
152    {
153        ArrayList<String> list = new ArrayList<>();
154
155        list.add(LineColor);
156        list.add(FillColor);
157        //list.add(IconColor);
158        //list.add(FontSize);
159        list.add(PixelSize);
160        list.add(KeepUnitRatio);
161        list.add(Alpha);
162        list.add(OutlineSymbol);
163        list.add(OutlineColor);
164        //list.add(OutlineWidth);
165        list.add(DrawAsIcon);
166        list.add(HideOptionalLabels);
167        list.add(DistanceUnits);
168        list.add(AltitudeUnits);
169        list.add(EngagementBarColor);
170
171        return list;
172    }
173
174    public static ArrayList<String> GetAttributesList(String symbolID)
175    {
176        ArrayList<String> list = new ArrayList<>();
177
178        list.add(LineColor);
179        list.add(FillColor);
180        //list.add(IconColor);
181        list.add(PixelSize);
182
183        if(SymbolUtilities.isMultiPoint(symbolID)==false) {
184            list.add(KeepUnitRatio);
185            list.add(OutlineSymbol);
186            list.add(OutlineColor);
187            list.add(DrawAsIcon);
188            if(SymbolUtilities.hasModifier(symbolID,Modifiers.AO_ENGAGEMENT_BAR))
189                list.add(EngagementBarColor);
190        }
191        else
192        {
193            list.add(LineWidth);
194            list.add(HideOptionalLabels);
195            list.add(DistanceUnits);
196            list.add(AltitudeUnits);
197        }
198        list.add(Alpha);
199
200        return list;
201    }
202
203    /**
204     * @param attribute constant like MilStdAttributes.LineColor
205     * @return attribute name based on attribute constants
206     */
207    public static String getAttributeName(String attribute) {
208        switch (attribute) {
209            case LineColor:
210                return "Line Color";
211            case FillColor:
212                return "Fill Color";
213            case PixelSize:
214                return "Pixel Size";
215            case KeepUnitRatio:
216                return "Keep Unit Ratio";
217            case Alpha:
218                return "Alpha";
219            case OutlineSymbol:
220                return "Outline Symbol";
221            case OutlineColor:
222                return "Outline Color";
223            case DrawAsIcon:
224                return "Draw as Icon";
225            case LineWidth:
226                return "Line Width";
227            case TextColor:
228                return "Text Color";
229            case TextBackgroundColor:
230                return "Text Background Color";
231            case UseDashArray:
232                return "Use Dash Array";
233            case AltitudeMode:
234                return "Altitude Mode";
235            case HideOptionalLabels:
236                return "Hide Optional Labels";
237            case UsePatternFill:
238                return "Use Pattern Fill";
239            case PatternFillType:
240                return "Pattern Fill Type";
241            case DistanceUnits:
242                return "Distance Units";
243            case AltitudeUnits:
244                return "Altitude Units";
245            default:
246                return "unrecognized attribute";
247        }
248    }
249
250    /**
251     * Takes a string representation of an attribute and returns the appropriate int key value
252     * @param attribute "LINECOLOR" will return MilStdAtttributes.LineColor
253     * @return {@link Integer} value representing Attribute constant.
254     */
255    public static String getAttributeKey(String attribute) {
256        switch (attribute.toUpperCase()) {
257            case "LINECOLOR":
258                return LineColor;
259            case "FILLCOLOR":
260                return FillColor;
261            case "PIXELSIZE":
262                return PixelSize;
263            case "KEEPUNITRATIO":
264                return KeepUnitRatio;
265            case "ALPHA":
266                return Alpha;
267            case "OUTLINESYMBOL":
268                return OutlineSymbol;
269            case "OUTLINECOLOR":
270                return OutlineColor;
271            case "DRAWASICON":
272                return DrawAsIcon;
273            case "LINEWIDTH":
274                return LineWidth;
275            case "TEXTCOLOR":
276                return TextColor;
277            case "TEXTBACKGROUNDCOLOR":
278                return TextBackgroundColor;
279            case "USEDASHARRAY":
280                return UseDashArray;
281            case "ALTITUDEMODE":
282                return AltitudeMode;
283            case "HIDEOPTIONALLABELS":
284                return HideOptionalLabels;
285            case "USEPATTERNFILL":
286                return UsePatternFill;
287            case "PATTERNFILLTYPE":
288                return PatternFillType;
289            case "DISTANCEUNITS":
290                return DistanceUnits;
291            case "ALTITUDEUNITS":
292                return AltitudeUnits;
293            default:
294                return null;
295        }
296    }
297}