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