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     * Multipoint features and patterns scale with line width ({@link MilStdAttributes#LineWidth}).
148     * {@code PatternScale} is the ratio of how much to increase features and patterns by with line width.
149     * default value is {@link RendererSettings#getPatternScale()}
150     */
151    public static final String PatternScale = "PATTERNSCALE";
152
153    /**
154     * No Longer relevant
155     * @return {@link ArrayList}
156     * @deprecated see {@link #GetAttributesList(String)}
157     */
158    public static ArrayList<String> GetModifierList()
159    {
160        ArrayList<String> list = new ArrayList<>();
161
162        list.add(LineColor);
163        list.add(FillColor);
164        //list.add(IconColor);
165        //list.add(FontSize);
166        list.add(PixelSize);
167        list.add(KeepUnitRatio);
168        list.add(Alpha);
169        list.add(OutlineSymbol);
170        list.add(OutlineColor);
171        //list.add(OutlineWidth);
172        list.add(DrawAsIcon);
173        list.add(HideOptionalLabels);
174        list.add(DistanceUnits);
175        list.add(AltitudeUnits);
176        list.add(EngagementBarColor);
177
178        return list;
179    }
180
181    public static ArrayList<String> GetAttributesList(String symbolID)
182    {
183        ArrayList<String> list = new ArrayList<>();
184
185        list.add(LineColor);
186        list.add(FillColor);
187        //list.add(IconColor);
188        list.add(PixelSize);
189
190        if(SymbolUtilities.isMultiPoint(symbolID)==false) {
191            list.add(KeepUnitRatio);
192            list.add(OutlineSymbol);
193            list.add(OutlineColor);
194            list.add(DrawAsIcon);
195            if(SymbolUtilities.hasModifier(symbolID,Modifiers.AO_ENGAGEMENT_BAR))
196                list.add(EngagementBarColor);
197        }
198        else
199        {
200            list.add(LineWidth);
201            list.add(HideOptionalLabels);
202            list.add(DistanceUnits);
203            list.add(AltitudeUnits);
204        }
205        list.add(Alpha);
206
207        return list;
208    }
209
210    /**
211     * @param attribute constant like MilStdAttributes.LineColor
212     * @return attribute name based on attribute constants
213     */
214    public static String getAttributeName(String attribute) {
215        switch (attribute) {
216            case LineColor:
217                return "Line Color";
218            case FillColor:
219                return "Fill Color";
220            case PixelSize:
221                return "Pixel Size";
222            case KeepUnitRatio:
223                return "Keep Unit Ratio";
224            case Alpha:
225                return "Alpha";
226            case OutlineSymbol:
227                return "Outline Symbol";
228            case OutlineColor:
229                return "Outline Color";
230            case DrawAsIcon:
231                return "Draw as Icon";
232            case LineWidth:
233                return "Line Width";
234            case TextColor:
235                return "Text Color";
236            case TextBackgroundColor:
237                return "Text Background Color";
238            case UseDashArray:
239                return "Use Dash Array";
240            case AltitudeMode:
241                return "Altitude Mode";
242            case HideOptionalLabels:
243                return "Hide Optional Labels";
244            case UsePatternFill:
245                return "Use Pattern Fill";
246            case PatternFillType:
247                return "Pattern Fill Type";
248            case DistanceUnits:
249                return "Distance Units";
250            case AltitudeUnits:
251                return "Altitude Units";
252            default:
253                return "unrecognized attribute";
254        }
255    }
256
257    /**
258     * Takes a string representation of an attribute and returns the appropriate int key value
259     * @param attribute "LINECOLOR" will return MilStdAtttributes.LineColor
260     * @return {@link Integer} value representing Attribute constant.
261     */
262    public static String getAttributeKey(String attribute) {
263        switch (attribute.toUpperCase()) {
264            case "LINECOLOR":
265                return LineColor;
266            case "FILLCOLOR":
267                return FillColor;
268            case "PIXELSIZE":
269                return PixelSize;
270            case "KEEPUNITRATIO":
271                return KeepUnitRatio;
272            case "ALPHA":
273                return Alpha;
274            case "OUTLINESYMBOL":
275                return OutlineSymbol;
276            case "OUTLINECOLOR":
277                return OutlineColor;
278            case "DRAWASICON":
279                return DrawAsIcon;
280            case "LINEWIDTH":
281                return LineWidth;
282            case "TEXTCOLOR":
283                return TextColor;
284            case "TEXTBACKGROUNDCOLOR":
285                return TextBackgroundColor;
286            case "USEDASHARRAY":
287                return UseDashArray;
288            case "ALTITUDEMODE":
289                return AltitudeMode;
290            case "HIDEOPTIONALLABELS":
291                return HideOptionalLabels;
292            case "USEPATTERNFILL":
293                return UsePatternFill;
294            case "PATTERNFILLTYPE":
295                return PatternFillType;
296            case "DISTANCEUNITS":
297                return DistanceUnits;
298            case "ALTITUDEUNITS":
299                return AltitudeUnits;
300            default:
301                return null;
302        }
303    }
304}