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     * Experimental feature only for use with MilStdSymbol Rendering at this time
119     */
120    public static final String UseLinePattern = "USELINEPATTERN";
121
122    /**
123     * The conversion factor and the label that you want all distances to display in. The conversion factor
124     * is converting from meters. The default unit is meters.<br><br>
125     *
126     * Must be in the form [conversionFactor],[label]. So for example converting to feet would be "3.28084,FT".
127     * The helper class {@link DistanceUnit} can be used.
128     */
129    public static final String DistanceUnits = "DISTANCEUNITS";
130
131    /**
132     * The conversion factor and the label that you want all distances to display in.
133     * Conventionally, the conversion factor is converting from meters by default,
134     * but other values could be passed, like "1,KM" to use an unaltered value in kilometers.<br><br>
135     *
136     * Must be in the form [conversionFactor],[label]. So for example converting meters to feet would be "3.28084,FT".
137     * The helper class {@link DistanceUnit} can be used.
138     * Currently only effective for multi-point graphics.
139     */
140    public static final String AltitudeUnits = "ALTITUDEUNITS";
141
142    /**
143     * If the engagement/target amplifier bar is to be used to designate targets, non-targets, and
144     * pruned or expired targets, a different coloring schema shall be used. Hostile tracks which
145     * are deemed targets shall have a red bar (RGB: 255, 0, 0) to indicate target. For hostile
146     * tracks deemed to be non-targets, white (RGB: 255, 255, 255) should be used to indicate non
147     * target. Finally, for hostile tracks which have been pruned or have expired shall be colored
148     * orange (RGB: 255, 120, 0).
149     * This attribute expects a hex string for the color
150     */
151    public static final String EngagementBarColor = "ENGAGEMENTBARCOLOR";
152
153    /**
154     * Multipoint features and patterns scale with line width ({@link MilStdAttributes#LineWidth}).
155     * {@code PatternScale} is the ratio of how much to increase features and patterns by with line width.
156     * default value is {@link RendererSettings#getPatternScale()}
157     */
158    public static final String PatternScale = "PATTERNSCALE";
159
160    public static final String FontFamily = "FONTFAMILY";
161    /**
162     * Like Typeface.BOLD
163     */
164    public static final String FontStyle = "FONTSTYLE";
165
166    public static final String FontSize = "FONTSIZE";
167
168    /**
169     * Strict ("0") for always placing their labels in the specified location
170     * even if there's empty space from other labels that weren't populated
171     * Flexible ("1") to collapse label vertically to the center to eliminate
172     * empty space from labels that weren't populated.
173     * Does not apply to Control Measures or METOCS
174     * Set with values like:
175     * RendererSettings.ModifierPlacement_STRICT ("0")
176     * RendererSettings.ModifierPlacement_FLEXIBLE ("1")
177     */
178    public static final String ModifierPlacement = "MODIFIERPLACEMENT";
179
180    /**
181     * No Longer relevant
182     * @return {@link ArrayList}
183     * @deprecated see {@link #GetAttributesList(String)}
184     */
185    public static ArrayList<String> GetModifierList()
186    {
187        ArrayList<String> list = new ArrayList<>();
188
189        list.add(LineColor);
190        list.add(FillColor);
191        //list.add(IconColor);
192        //list.add(FontSize);
193        list.add(PixelSize);
194        list.add(KeepUnitRatio);
195        list.add(Alpha);
196        list.add(OutlineSymbol);
197        list.add(OutlineColor);
198        //list.add(OutlineWidth);
199        list.add(DrawAsIcon);
200        list.add(HideOptionalLabels);
201        list.add(DistanceUnits);
202        list.add(AltitudeUnits);
203        list.add(EngagementBarColor);
204
205        return list;
206    }
207
208    public static ArrayList<String> GetAttributesList(String symbolID)
209    {
210        ArrayList<String> list = new ArrayList<>();
211
212        list.add(LineColor);
213        list.add(FillColor);
214        //list.add(IconColor);
215        list.add(PixelSize);
216
217        if(!SymbolUtilities.isMultiPoint(symbolID)) {
218            list.add(KeepUnitRatio);
219            list.add(OutlineSymbol);
220            list.add(OutlineColor);
221            list.add(DrawAsIcon);
222            if(SymbolUtilities.hasModifier(symbolID,Modifiers.AO_ENGAGEMENT_BAR))
223                list.add(EngagementBarColor);
224            list.add(FontFamily);
225            list.add(FontStyle);
226            list.add(FontSize);
227            list.add(ModifierPlacement);
228        }
229        else
230        {
231            list.add(LineWidth);
232            list.add(HideOptionalLabels);
233            list.add(DistanceUnits);
234            list.add(AltitudeUnits);
235        }
236        list.add(Alpha);
237
238        return list;
239    }
240
241    /**
242     * @param attribute constant like MilStdAttributes.LineColor
243     * @return attribute name based on attribute constants
244     */
245    public static String getAttributeName(String attribute) {
246        switch (attribute) {
247            case LineColor:
248                return "Line Color";
249            case FillColor:
250                return "Fill Color";
251            case PixelSize:
252                return "Pixel Size";
253            case KeepUnitRatio:
254                return "Keep Unit Ratio";
255            case Alpha:
256                return "Alpha";
257            case OutlineSymbol:
258                return "Outline Symbol";
259            case OutlineColor:
260                return "Outline Color";
261            case DrawAsIcon:
262                return "Draw as Icon";
263            case LineWidth:
264                return "Line Width";
265            case TextColor:
266                return "Text Color";
267            case TextBackgroundColor:
268                return "Text Background Color";
269            case UseDashArray:
270                return "Use Dash Array";
271            case AltitudeMode:
272                return "Altitude Mode";
273            case HideOptionalLabels:
274                return "Hide Optional Labels";
275            case UsePatternFill:
276                return "Use Pattern Fill";
277            case PatternFillType:
278                return "Pattern Fill Type";
279            case DistanceUnits:
280                return "Distance Units";
281            case AltitudeUnits:
282                return "Altitude Units";
283            case FontFamily:
284                return "Font Family";
285            case FontStyle:
286                return "Font Style";
287            case FontSize:
288                return "Font Size";
289            case ModifierPlacement:
290                return "Modifier Placement";
291            default:
292                return "unrecognized attribute";
293        }
294    }
295
296    /**
297     * Takes a string representation of an attribute and returns the appropriate int key value
298     * @param attribute "LINECOLOR" will return MilStdAtttributes.LineColor
299     * @return {@link Integer} value representing Attribute constant.
300     */
301    public static String getAttributeKey(String attribute) {
302        switch (attribute.toUpperCase()) {
303            case "LINECOLOR":
304                return LineColor;
305            case "FILLCOLOR":
306                return FillColor;
307            case "PIXELSIZE":
308                return PixelSize;
309            case "KEEPUNITRATIO":
310                return KeepUnitRatio;
311            case "ALPHA":
312                return Alpha;
313            case "OUTLINESYMBOL":
314                return OutlineSymbol;
315            case "OUTLINECOLOR":
316                return OutlineColor;
317            case "DRAWASICON":
318                return DrawAsIcon;
319            case "LINEWIDTH":
320                return LineWidth;
321            case "TEXTCOLOR":
322                return TextColor;
323            case "TEXTBACKGROUNDCOLOR":
324                return TextBackgroundColor;
325            case "USEDASHARRAY":
326                return UseDashArray;
327            case "ALTITUDEMODE":
328                return AltitudeMode;
329            case "HIDEOPTIONALLABELS":
330                return HideOptionalLabels;
331            case "USEPATTERNFILL":
332                return UsePatternFill;
333            case "PATTERNFILLTYPE":
334                return PatternFillType;
335            case "DISTANCEUNITS":
336                return DistanceUnits;
337            case "ALTITUDEUNITS":
338                return AltitudeUnits;
339            case "FONTFAMILY":
340                return FontFamily;
341            case "FONTSTYLE":
342                return FontStyle;
343            case "FONTSIZE":
344                return FontSize;
345            case "MODIFIERPLACEMENT":
346                return ModifierPlacement;
347            default:
348                return null;
349        }
350    }
351}