001/*
002 * To change this template, choose Tools | Templates
003 * and open the template in the editor.
004 */
005
006package armyc2.c5isr.renderer.utilities;
007
008//import android.graphics.Color;
009import android.graphics.Paint;
010import android.graphics.Paint.Cap;
011import android.graphics.Paint.Join;
012import android.graphics.Typeface;
013
014import java.util.ArrayList;
015import java.util.List;
016import java.util.logging.Level;
017
018
019/**
020 *Static class that holds the setting for the JavaRenderer.
021 * Allows different parts of the renderer to know what
022 * values are being used.
023 */
024public class RendererSettings{
025
026    private static RendererSettings _instance = null;
027    
028    private static List<SettingsChangedEventListener> _listeners = new ArrayList<SettingsChangedEventListener>();  
029
030    //outline approach.  none, filled rectangle, outline (default),
031    //outline quick (outline will not exceed 1 pixels).
032    private static int _TextBackgroundMethod = 2;
033    /**
034     * There will be no background for text
035     */
036    public static final int TextBackgroundMethod_NONE = 0;
037
038    /**
039     * There will be a colored box behind the text
040     */
041    public static final int TextBackgroundMethod_COLORFILL = 1;
042
043    /**
044     * There will be an adjustable outline around the text
045     * Outline width of 4 is recommended.
046     */
047    public static final int TextBackgroundMethod_OUTLINE = 2;
048
049    /**
050     * A different approach for outline which is quicker and seems to use
051     * less memory.  Also, you may do well with a lower outline thickness setting
052     * compared to the regular outlining approach.  Outline Width of 2 is
053     * recommended.
054     * @deprecated - useful on java port, actually slower on android
055     */
056    public static final int TextBackgroundMethod_OUTLINE_QUICK = 3;
057
058    /**
059     * Value from 0 to 255. The closer to 0 the lighter the text color has to be
060     * to have the outline be black. Default value is 160.
061     */
062    private static int _TextBackgroundAutoColorThreshold = 160;
063
064    //if TextBackgroundMethod_OUTLINE is set, This value determines the width of that outline.
065    private static int _TextOutlineWidth = 4;
066
067    //label foreground color, uses line color of symbol if null.
068    private static int _ColorLabelForeground =  android.graphics.Color.BLACK;
069    //label background color, used if TextBackGroundMethod = TextBackgroundMethod_COLORFILL && not null
070    private static int _ColorLabelBackground =  android.graphics.Color.WHITE;
071
072    private static int _SymbolRenderMethod = 1;
073    private static int _UnitRenderMethod = 1;
074    private static int _TextRenderMethod = 1;
075    
076    @Deprecated
077    private static int _SymbolOutlineWidth = 3;
078
079    private static boolean _OutlineSPControlMeasures = true;
080
081    private static boolean _ActionPointDefaultFill = true;
082
083    /**
084     * Collapse labels for fire support areas when the symbol isn't large enough to show all
085     * the labels.
086     */
087    private static boolean _AutoCollapseModifiers = true;
088
089    /**
090     * If true (default), when HQ Staff is present, location will be indicated by the free
091     * end of the staff
092     */
093    private static Boolean _CenterOnHQStaff = true;
094
095    /**
096     * Everything that comes back from the Renderer is a Java Shape.  Simpler,
097     * but can be slower when rendering modifiers or a large number of single
098     * point symbols. Not recommended
099     */
100    public static final int RenderMethod_SHAPES = 0;
101    /**
102     * Adds a level of complexity to the rendering but is much faster for 
103     * certain objects.  Modifiers and single point graphics will render faster.
104     * MultiPoints will still be shapes.  Recommended
105     */
106    public static final int RenderMethod_NATIVE = 1;
107
108    /**
109     * Text modifiers/amplifiers are placed where they belong even if there's empty space
110     * from other modifiers that weren't populated
111     */
112    public static int ModifierPlacement_STRICT = 0;
113    /**
114     * Text modifiers/amplifiers will collapse vertically towards the center to eliminate
115     * empty space from modifiers that weren't populated.
116     */
117    public static int ModifierPlacement_FLEXIBLE = 1;
118    /**
119     * Same as flexible but the modifier letter is put at the beginning of the value string
120     * to prevent confusion from modifiers not being in their strict location.
121     * if P (IFF/SIF) is set to "2:1234", it would be rendered as "P:2:1234"
122     */
123    //public static int ModifierPlacement_FLEXIBLE_PREFIX = 2;
124    private static int _ModifierPlacementApproach = 0;
125
126    public static int OperationalConditionModifierType_SLASH = 0;
127    public static int OperationalConditionModifierType_BAR = 1;
128    private static int _OCMType = 1;
129
130    public static final int SeaMineRenderMethod_MEDAL = 1;
131    public static final int SeaMineRenderMethod_ALT = 2;
132    public static int _SeaMineRenderMethod = 1;
133
134
135    private static boolean _UseLineInterpolation = true;
136
137        //single points
138    //private static Font _ModifierFont = new Font("arial", Font.TRUETYPE_FONT, 12);
139    private static String _ModifierFontName = "arial";
140    //private static int _ModifierFontType = Font.TRUETYPE_FONT;
141    private static int _ModifierFontType = Typeface.BOLD;
142    private static int _ModifierFontSize = 18;
143    private static int _ModifierFontKerning = 0;//0=off, 1=on (TextAttribute.KERNING_ON)
144    //private static float _ModifierFontTracking = TextAttribute.TRACKING_LOOSE;//loose=0.4f;
145    
146        //multi points
147    private static String _MPLabelFontName = "arial";
148    //private static int _ModifierFontType = Font.TRUETYPE_FONT;
149    private static int _MPLabelFontType = Typeface.BOLD;
150    private static int _MPLabelFontSize = 18;
151    private static int _MPLabelFontKerning = 0;//0=off, 1=on (TextAttribute.KERNING_ON)
152    //private static float _ModifierFontTracking = TextAttribute.TRACKING_LOOSE;//loose=0.4f;
153    private static float _KMLLabelScale = 1.0f;
154    
155    private boolean _scaleEchelon = false;
156    private boolean _DrawAffiliationModifierAsLabel = false;
157    
158    private float _SPFontSize = 60f;
159    private float _UnitFontSize = 50f;
160    private int _PixelSize = 75;
161    private int _DPI = 90;
162
163    // Height and width are based on device orientation during init
164    private int _PixelHeight = 1080;
165    private int _PixelWidth = 1920;
166
167    private static int _CacheSize = 1024;
168    private static int _VMSize = 10240;
169    private static boolean _CacheEnabled = true;
170    
171    //acevedo - 11/29/2017 - adding option to render only 2 labels.
172    private boolean _TwoLabelOnly = false;
173
174    private boolean _scaleMainIconWithoutSectorMods = true;
175
176    private double _patternScale = 1.0;
177
178    //acevedo - 12/8/17 - allow the setting of affiliation colors.
179    private   Color _friendlyUnitFillColor = AffiliationColors.FriendlyUnitFillColor;
180    /// <summary>
181    /// Hostile Unit Fill Color.
182    /// </summary>
183    private   Color _hostileUnitFillColor = AffiliationColors.HostileUnitFillColor;//new Color(255,130,132);//Color.RED;
184    /// <summary>
185    /// Neutral Unit Fill Color.
186    /// </summary>
187    private   Color _neutralUnitFillColor = AffiliationColors.NeutralUnitFillColor;//new Color(144,238,144);//Color.GREEN;//new Color(0,255,0);//new Color(144,238,144);//light green//Color.GREEN;new Color(0,226,0);
188    /// <summary>
189    /// Unknown Unit Fill Color.
190    /// </summary>
191    private Color _unknownUnitFillColor = AffiliationColors.UnknownUnitFillColor;// new Color(255,255,128);//Color.YELLOW;
192
193    /// <summary>
194    /// Friendly Graphic Fill Color.
195    /// </summary>
196    private   Color _friendlyGraphicFillColor = AffiliationColors.FriendlyGraphicFillColor;//Crystal Blue //Color.CYAN;
197    /// <summary>
198    /// Hostile Graphic Fill Color.
199    /// </summary>
200    private Color _hostileGraphicFillColor = AffiliationColors.HostileGraphicFillColor;//salmon
201    /// <summary>
202    /// Neutral Graphic Fill Color.
203    /// </summary>
204    private   Color _neutralGraphicFillColor = AffiliationColors.NeutralGraphicFillColor;//Bamboo Green //new Color(144,238,144);//light green
205    /// <summary>
206    /// Unknown Graphic Fill Color.
207    /// </summary>
208    private   Color _unknownGraphicFillColor = AffiliationColors.UnknownGraphicFillColor;//light yellow  new Color(255,255,224);//light yellow
209
210    /// <summary>
211    /// Friendly Unit Line Color.
212    /// </summary>
213    private   Color _friendlyUnitLineColor = AffiliationColors.FriendlyUnitLineColor;
214    /// <summary>
215    /// Hostile Unit Line Color.
216    /// </summary>
217    private   Color _hostileUnitLineColor = AffiliationColors.HostileUnitLineColor;
218    /// <summary>
219    /// Neutral Unit Line Color.
220    /// </summary>
221    private   Color _neutralUnitLineColor = AffiliationColors.NeutralUnitLineColor;
222    /// <summary>
223    /// Unknown Unit Line Color.
224    /// </summary>
225    private   Color _unknownUnitLineColor = AffiliationColors.UnknownUnitLineColor;
226
227    /// <summary>
228    /// Friendly Graphic Line Color.
229    /// </summary>
230    private   Color _friendlyGraphicLineColor = AffiliationColors.FriendlyGraphicLineColor;
231    /// <summary>
232    /// Hostile Graphic Line Color.
233    /// </summary>
234    private   Color _hostileGraphicLineColor = AffiliationColors.HostileGraphicLineColor;
235    /// <summary>
236    /// Neutral Graphic Line Color.
237    /// </summary>
238    private   Color _neutralGraphicLineColor = AffiliationColors.NeutralGraphicLineColor;
239    /// <summary>
240    /// Unknown Graphic Line Color.
241    /// </summary>
242    private   Color _unknownGraphicLineColor = AffiliationColors.UnknownGraphicLineColor;
243
244    /*private   Color WeatherRed = new Color(198,16,33);//0xC61021;// 198,16,33
245    private   Color WeatherBlue = new Color(0,0,255);//0x0000FF;// 0,0,255
246
247    private   Color WeatherPurpleDark = new Color(128,0,128);//0x800080;// 128,0,128 Plum Red
248    private   Color WeatherPurpleLight = new Color(226,159,255);//0xE29FFF;// 226,159,255 Light Orchid
249
250    private   Color WeatherBrownDark = new Color(128,98,16);//0x806210;// 128,98,16 Safari
251    private   Color WeatherBrownLight = new Color(210,176,106);//0xD2B06A;// 210,176,106 Khaki
252    */
253
254    private RendererSettings()
255    {
256        Init();
257    }
258
259
260    public static synchronized RendererSettings getInstance()
261    {
262        if(_instance == null)
263        {
264            _instance = new RendererSettings();
265        }
266
267        return _instance;
268    }
269
270    private void Init()
271    {
272        try
273        {
274            _VMSize = (int)Runtime.getRuntime().maxMemory();
275            _CacheSize = Math.round(_VMSize * 0.03f);//set cache to 3% of available memory
276        }
277        catch(Exception exc)
278        {
279            ErrorLogger.LogException("RendererSettings", "Init", exc, Level.WARNING);
280        }
281    }
282
283    private void throwEvent(SettingsChangedEvent sce)
284    {
285        for (SettingsChangedEventListener listener : _listeners) {
286                listener.onSettingsChanged(sce);
287                }
288    }
289    
290    public void addEventListener(SettingsChangedEventListener scel)
291    {
292        _listeners.add(scel);
293    }
294
295
296
297
298    /**
299     * None, outline (default), or filled background.
300     * If set to OUTLINE, TextOutlineWidth changed to default of 4.
301     * If set to OUTLINE_QUICK, TextOutlineWidth changed to default of 2.
302     * Use setTextOutlineWidth if you'd like a different value.
303     * @param textBackgroundMethod
304     */
305    synchronized public void setTextBackgroundMethod(int textBackgroundMethod)
306    {
307        _TextBackgroundMethod = textBackgroundMethod;
308        if(_TextBackgroundMethod == TextBackgroundMethod_OUTLINE)
309        {
310            //_TextOutlineWidth = 8;//441 DPI
311            _TextOutlineWidth = Math.max(_DPI/50,4);
312            //_TextOutlineWidth = Math.round((4.0f/96.0f)*(float)_DPI);
313        }
314        else if(_TextBackgroundMethod == TextBackgroundMethod_OUTLINE_QUICK)
315            _TextOutlineWidth = 1;
316    }
317
318    /**
319     * None, outline (default), or filled background.
320     * @return method like RenderSettings.TextBackgroundMethod_NONE
321     */
322    synchronized public int getTextBackgroundMethod()
323    {
324        return _TextBackgroundMethod;
325    }
326    
327
328    /*public void setUnitFontSize(float size)
329    {
330        _UnitFontSize = size;
331    }//*/
332
333    /**
334     *
335     * @return
336     * @deprecated
337     */
338    public float getUnitFontSize()
339    {
340        return _UnitFontSize;
341    }
342    
343    /*public void setSPFontSize(float size)
344    {
345        _SPFontSize = size;
346    }//*/
347
348    /**
349     *
350     * @return
351     * @deprecated
352     */
353    public float getSPFontSize()
354    {
355        return _SPFontSize;
356    }
357    
358    public void setDefaultPixelSize(int size)
359    {
360        _PixelSize = size;
361    }
362    
363    public int getDefaultPixelSize()
364    {
365        return _PixelSize;
366    }
367    
368    public int getDeviceDPI()
369    {
370        return _DPI;
371    }
372    
373    public void setDeviceDPI(int size)
374    {
375        _DPI = size;
376        if(getTextBackgroundMethod()==TextBackgroundMethod_OUTLINE)
377        {
378            //_TextOutlineWidth = 8;//441 DPI
379            _TextOutlineWidth = Math.max(_DPI/50,4);
380            //_TextOutlineWidth = Math.round((4.0f/96.0f)*(float)_DPI);
381        }
382    }
383
384    public int getDeviceHeight()
385    {
386        return _PixelHeight;
387    }
388
389    public void setDeviceHeight(int height)
390    {
391        _PixelHeight = height;
392    }
393
394    public int getDeviceWidth()
395    {
396        return _PixelWidth;
397    }
398
399    public void setDeviceWidth(int width)
400    {
401        _PixelWidth = width;
402    }
403
404    /**
405     * Set the operational condition modifier to be slashes or bars
406     * @param value like RendererSettings.OperationalConditionModifierType_SLASH
407     */
408    public void setOperationalConditionModifierType(int value)
409    {
410        _OCMType = value;
411    }
412
413
414    public void setSeaMineRenderMethod(int method)
415    {
416        _SeaMineRenderMethod = method;
417    }
418    public int getSeaMineRenderMethod()
419    {
420        return _SeaMineRenderMethod;
421    }
422
423    public int getOperationalConditionModifierType()
424    {
425        return _OCMType;
426    }
427
428    /**
429     * For lines symbols with "decorations" like FLOT or LOC, when points are 
430     * too close together, we will start dropping points until we get enough 
431     * space between 2 points to draw the decoration.  Without this, when points
432     * are too close together, you run the chance that the decorated line will
433     * look like a plain line because there was no room between points to
434     * draw the decoration.
435     * @param value 
436     */
437    public void setUseLineInterpolation(boolean value)
438    {
439        _UseLineInterpolation = value;
440    }
441    
442    /**
443     * Returns the current setting for Line Interpolation.
444     * @return 
445     */
446    public boolean getUseLineInterpolation()
447    {
448        return _UseLineInterpolation;
449    }
450
451    /**
452     * Collapse Modifiers for fire support areas when the symbol isn't large enough to show all
453     * the labels.  Identifying label will always be visible.  Zooming in, to make the symbol larger,
454     * will make more modifiers visible.  Resizing the symbol can also make more modifiers visible.
455     * @param value
456     */
457    public void setAutoCollapseModifiers(boolean value) {_AutoCollapseModifiers = value;}
458
459    public boolean getAutoCollapseModifiers() {return _AutoCollapseModifiers;}
460
461
462    /**
463     * if RenderSettings.TextBackgroundMethod_OUTLINE is used,
464     * the outline will be this many pixels wide.
465     * @param width
466     * @deprecated
467     */
468    /*synchronized public void setTextOutlineWidth(int width)
469    {
470        _TextOutlineWidth = width;
471    }*/
472
473    /**
474     * if RenderSettings.TextBackgroundMethod_OUTLINE is used,
475     * the outline will be this many pixels wide.
476     * @return
477     */
478    synchronized public int getTextOutlineWidth()
479    {
480        return _TextOutlineWidth;
481    }
482
483 /*    *//**
484     * Refers to text color of modifier labels
485     * @return
486      *  
487     *//*
488    public int getLabelForegroundColor()
489    {
490        return _ColorLabelForeground;
491    }
492
493    *//**
494     * Refers to text color of modifier labels
495     * Default Color is Black.  If NULL, uses line color of symbol
496     * @param value
497     * 
498     *//*
499    synchronized public void setLabelForegroundColor(int value)
500    {
501       _ColorLabelForeground = value;
502    }
503
504    *//**
505     * Refers to background color of modifier labels
506     * @return
507     * 
508     *//*
509    public int getLabelBackgroundColor()
510    {
511        return _ColorLabelBackground;
512    }
513
514    *//**
515     * Refers to text color of modifier labels
516     * Default Color is White.
517     * Null value means the optimal background color (black or white)
518     * will be chose based on the color of the text.
519     * @param value
520     * 
521     *//*
522    synchronized public void setLabelBackgroundColor(int value)
523    {
524        _ColorLabelBackground = value;
525    }
526
527    *//**
528     * Value from 0 to 255. The closer to 0 the lighter the text color has to be
529     * to have the outline be black. Default value is 160.
530     * @param value
531     */
532    public void setTextBackgroundAutoColorThreshold(int value)
533    {
534        _TextBackgroundAutoColorThreshold = value;
535    }
536
537    /**
538     * Value from 0 to 255. The closer to 0 the lighter the text color has to be
539     * to have the outline be black. Default value is 160.
540     * @return
541     */
542    public int getTextBackgroundAutoColorThreshold()
543    {
544        return _TextBackgroundAutoColorThreshold;
545    }
546    
547    /**
548     * This applies to Single Point Tactical Graphics.
549     * Setting this will determine the default value for milStdSymbols when created.
550     * 0 for no outline,
551     * 1 for outline thickness of 1 pixel, 
552     * 2 for outline thickness of 2 pixels,
553     * greater than 2 is not currently recommended.
554     * @param width
555     * @deprecated
556     */
557
558    /*synchronized public void setSinglePointSymbolOutlineWidth(int width)
559    {
560        _SymbolOutlineWidth = width;
561    }*/
562
563    /**
564     * This applies to Single Point Tactical Graphics.
565     * @return
566     */
567    @Deprecated
568    synchronized public int getSinglePointSymbolOutlineWidth()
569    {
570        return _SymbolOutlineWidth;
571    }
572
573    public void setOutlineSPControlMeasures(boolean value)
574    {
575        _OutlineSPControlMeasures = value;
576    }
577
578    public boolean getOutlineSPControlMeasures()
579    {
580        return _OutlineSPControlMeasures;
581    }
582
583    //
584
585    /**
586     * If true, set fill based on affiliation color for Action Points, Sonobuoys, ACP, CCP, PUP.
587     * False means there is no fill.
588     * @param value
589     */
590    public void setActionPointDefaultFill(boolean value)
591    {
592        _ActionPointDefaultFill = value;
593    }
594
595    public boolean getActionPointDefaultFill()
596    {
597        return _ActionPointDefaultFill;
598    }
599
600     /**
601     * Determines how to draw the Affiliation modifier.
602     * True to draw as modifier label in the "E/F" location.
603     * False to draw at the top right corner of the symbol
604     */
605    public void setDrawAffiliationModifierAsLabel(boolean value)
606    {
607        _DrawAffiliationModifierAsLabel = value;
608    }
609    /**
610     * True to draw as modifier label in the "E/F" location.
611     * False to draw at the top right corner of the symbol
612     */
613    public boolean getDrawAffiliationModifierAsLabel()
614    {
615        return _DrawAffiliationModifierAsLabel;
616    }    
617    /**
618     * 
619     * @param name Like "arial"
620     * @param type Like Font.BOLD
621     * @param size Like 12
622     * @param kerning - default false. The default advances of single characters are not
623     * appropriate for some character sequences, for example "To" or
624     * "AWAY".  Without kerning the adjacent characters appear to be
625     * separated by too much space.  Kerning causes selected sequences
626     * of characters to be spaced differently for a more pleasing
627     * visual appearance. 
628     * @param tracking - default 0.04 (TextAttribute.TRACKING_LOOSE).
629     * The tracking value is multiplied by the font point size and
630     * passed through the font transform to determine an additional
631     * amount to add to the advance of each glyph cluster.  Positive
632     * tracking values will inhibit formation of optional ligatures.
633     * Tracking values are typically between <code>-0.1</code> and
634     * <code>0.3</code>; values outside this range are generally not
635     * desireable.
636     * @deprecated
637     */
638    public void setModifierFont(String name, int type, int size, Boolean kerning, float tracking)
639    {
640        if(!(_ModifierFontName.equals(name) &&
641                _ModifierFontType == type &&
642                _ModifierFontSize == size))
643        {
644            _ModifierFontName = name;
645            _ModifierFontType = type;
646            _ModifierFontSize = size;
647            throwEvent(new SettingsChangedEvent(SettingsChangedEvent.EventType_FontChanged));
648        }
649        /*if(kerning==false)
650            _ModifierFontKerning = 0;
651        else
652            _ModifierFontKerning = TextAttribute.KERNING_ON;
653        _ModifierFontTracking = tracking;//*/
654    }
655    
656    /**
657     * 
658     * @param name
659     * @param type Typeface
660     * @param size
661     */
662    public void setModifierFont(String name, int type, int size)
663    {
664        if(!(_ModifierFontName.equals(name) &&
665                _ModifierFontType == type &&
666                _ModifierFontSize == size))
667        {
668            _ModifierFontName = name;
669            _ModifierFontType = type;
670            _ModifierFontSize = size;
671            throwEvent(new SettingsChangedEvent(SettingsChangedEvent.EventType_FontChanged));
672        }
673    }
674    
675    
676    /**
677     * Sets the font to be used for multipoint modifier labels
678     * @param name Like "arial"
679     * @param type Like Font.TRUETYPE_FONT
680     * @param size Like 12
681     */
682    public void setMPLabelFont(String name, int type, int size)
683    {
684        _MPLabelFontName = name;
685        _MPLabelFontType = type;
686        _MPLabelFontSize = size;
687        _KMLLabelScale = 1.0f;
688        throwEvent(new SettingsChangedEvent(SettingsChangedEvent.EventType_MPFontChanged));
689    }
690    
691    /**
692     * Sets the font to be used for multipoint modifier labels
693     * @param name Like "arial"
694     * @param type Like Font.TRUETYPE_FONT
695     * @param size Like 12
696     * @param kmlScale only set if you're rendering in KML (default 1.0)
697     */
698    public void setMPLabelFont(String name, int type, int size, float kmlScale)
699    {
700        _MPLabelFontName = name;
701        _MPLabelFontType = type;
702        _MPLabelFontSize = Math.round(size * kmlScale);
703        _KMLLabelScale = kmlScale;
704        throwEvent(new SettingsChangedEvent(SettingsChangedEvent.EventType_MPFontChanged));
705    }
706
707
708    public String[] getModiferFontProps()
709    {
710        String[] props = {_ModifierFontName, String.valueOf(_ModifierFontType),String.valueOf(_ModifierFontSize)};
711        return props;
712    }
713
714    /**
715     * get font object used for labels
716     * @return Font object
717     */
718    public Paint getModiferFont()
719    {
720        Paint p = null;
721        try
722        {
723                //need to create a paint and set it's typeface along with it's properties
724                Typeface tf = Typeface.create(_ModifierFontName, _ModifierFontType);
725                p = new Paint();
726                p.setTextSize(_ModifierFontSize);
727                p.setAntiAlias(true);
728                p.setColor(_ColorLabelForeground);
729                        //p.setTextAlign(Align.CENTER);
730                p.setTypeface(tf);
731                
732                        p.setStrokeCap(Cap.BUTT);
733                        p.setStrokeJoin(Join.MITER);
734                        p.setStrokeMiter(3f);
735                
736        }
737        catch(Exception exc)
738        {
739            String message = "font creation error, returning \"" + _ModifierFontName + "\" font, " + _ModifierFontSize + "pt. Check font name and type.";
740            ErrorLogger.LogMessage("RendererSettings", "getLabelFont", message);
741            ErrorLogger.LogMessage("RendererSettings", "getLabelFont", exc.getMessage());
742            try
743            {
744                Typeface tf = Typeface.create("arial", Typeface.BOLD);
745                        p = new Paint();
746                        p.setTextSize(12);
747                        p.setAntiAlias(true);
748                        p.setColor(android.graphics.Color.BLACK);
749                        p.setTypeface(tf);
750                        
751                        p.setStrokeCap(Cap.BUTT);
752                                p.setStrokeJoin(Join.MITER);
753                                p.setStrokeMiter(3f);
754            }
755            catch(Exception exc2)
756            {
757                //failed to make a default font, return null
758                p=null;
759            }
760        }
761        return p;
762    }
763    
764    /**
765     * get font object used for labels
766     * @return Font object
767     */
768    public Paint getMPLabelFont()
769    {
770        Paint p = null;
771        try
772        {
773                //need to create a paint and set it's typeface along with it's properties
774                Typeface tf = Typeface.create(_MPLabelFontName, _MPLabelFontType);
775                p = new Paint();
776                p.setTextSize(_MPLabelFontSize);
777                p.setAntiAlias(true);
778                p.setColor(_ColorLabelForeground);
779                        //p.setTextAlign(Align.CENTER);
780                p.setTypeface(tf);
781                
782        }
783        catch(Exception exc)
784        {
785            String message = "font creation error, returning \"" + _MPLabelFontName + "\" font, " + _MPLabelFontSize + "pt. Check font name and type.";
786            ErrorLogger.LogMessage("RendererSettings", "getLabelFont", message);
787            ErrorLogger.LogMessage("RendererSettings", "getLabelFont", exc.getMessage());
788            try
789            {
790                Typeface tf = Typeface.create("arial", Typeface.BOLD);
791                        p = new Paint();
792                        p.setTextSize(12);
793                        p.setAntiAlias(true);
794                        p.setColor(android.graphics.Color.BLACK);
795                        p.setTypeface(tf);
796            }
797            catch(Exception exc2)
798            {
799                //failed to make a default font, return null
800                p=null;
801            }
802        }
803        return p;
804    }
805    
806    /**
807     * the font name to be used for modifier labels
808     * @return name of the label font
809     */
810    public String getMPLabelFontName()
811    {
812        return _MPLabelFontName;
813    }
814    /**
815     * Like Font.BOLD
816     * @return type of the label font
817     */
818    public int getMPLabelFontType()
819    {
820        return _MPLabelFontType;
821    }
822    /**
823     * get font point size
824     * @return size of the label font
825     */
826    public int getMPLabelFontSize()
827    {
828        return _MPLabelFontSize;
829    }
830
831    /**
832     *
833     * @deprecated use {@link #setMPLabelFont(String, int, int)}
834     */
835    public void setMPModifierFont(String name, int type, int size){
836        setMPLabelFont(name, type, size);
837    }
838    /**
839     *
840     * @deprecated use {@link #setMPLabelFont(String, int, int, float)}
841     */
842    public void setMPModifierFont(String name, int type, int size, float kmlScale){
843        setMPLabelFont(name, type, size, kmlScale);
844    }
845
846    /**
847     *
848     * @deprecated use {@link #getMPLabelFont()}
849     */
850    public Paint getMPModifierFont() {
851        return getMPLabelFont();
852    }
853    /**
854     *
855     * @deprecated use {@link #getMPLabelFontName()}
856     */
857    public String getMPModifierFontName()
858    {
859        return getMPLabelFontName();
860    }
861    /**
862     *
863     * @deprecated use {@link #getMPLabelFontType()}}
864     */
865    public int getMPModifierFontType()
866    {
867        return getMPLabelFontType();
868    }
869    /**
870     *
871     * @deprecated use {@link #getMPLabelFontSize()}
872     */
873    public int getMPModifierFontSize()
874    {
875        return getMPLabelFontSize();
876    }
877    
878    public float getKMLLabelScale()
879    {
880        return _KMLLabelScale;
881    }
882
883    public int getSPModifierPlacement()
884    {
885        return _ModifierPlacementApproach;
886    }
887
888    /**
889     * Strict (0) for always placing their labels in the specified location
890     * even if there's empty space from other labels that weren't populated
891     * Flexible (1) to collapse label vertically to the center to eliminate
892     * empty space from labels that weren't populated.
893     * Does not apply to Control Measures or METOCS
894     * Set with values like:
895     * RendererSettings.ModifierPlacement_STRICT (0)
896     * RendererSettings.ModifierPlacement_FLEXIBLE (1)
897     * @param modifierPlacementApproach 0 for strict, 1 for flexible
898     */
899    public void setSPModifierPlacement(int modifierPlacementApproach)
900    {
901        _ModifierPlacementApproach = modifierPlacementApproach;
902    }
903
904    /**
905     * Set the cache size as a percentage of VM memory available to the app.
906     * Default is 3%.
907     * Renderer won't let you set a value greater than 10% of the available VM memory.
908     * @param percentage 
909     */
910    public void setCacheSize(float percentage)
911    {
912        if(percentage > 0.10f)
913            percentage = 0.10f;
914        _CacheSize = Math.round(_VMSize * percentage);
915        throwEvent(new SettingsChangedEvent(SettingsChangedEvent.EventType_CacheSizeChanged));
916    }
917    
918    /**
919     * Set the cache size in bytes.
920     * Renderer won't let you set a value greater than 10% of the available VM memory.
921     * @param bytes 
922     */
923    public void setCacheSize(int bytes)
924    {
925        if(bytes > _VMSize / 10)
926            bytes = _VMSize / 10;
927        _CacheSize = bytes;
928        throwEvent(new SettingsChangedEvent(SettingsChangedEvent.EventType_CacheSizeChanged));
929    }
930
931    /**
932     *
933     * @return Cache size in bytes
934     */
935    public int getCacheSize()
936    {
937        return _CacheSize;
938    }
939
940    public void setCacheEnabled(boolean active)
941    {
942        if(_CacheEnabled != active)
943        {
944            _CacheEnabled = active;
945            throwEvent(new SettingsChangedEvent(SettingsChangedEvent.EventType_CacheToggled));
946        }
947    }
948
949    public boolean getCacheEnabled()
950    {
951        return _CacheEnabled;
952    }
953    
954    /**
955         ** Get a boolean indicating between the use of supply routes labels in all segments (false) or
956         * to only set 2 labels one at the north and the other one at the south of the graphic (true).
957         * @return {boolean}
958     * @deprecated
959         */
960        public boolean getTwoLabelOnly()
961        {
962                        return _TwoLabelOnly;
963        }
964        
965        /**
966         * Set a boolean indicating between the use of supply routes labels in all segments (false) or
967         * to only set 2 labels one at the north and the other one at the south of the graphic (true).
968         * @param TwoLabelOnly
969     * @deprecated functionally disabled
970         */
971        public void setTwoLabelOnly(boolean TwoLabelOnly )
972        {
973                // _TwoLabelOnly = TwoLabelOnly;
974        }
975
976    /**
977     * When true, if the main icon is normally small to allow room for sector modifiers,
978     * make it larger when no sector modifiers are present for better visibility.
979     * @param scaleMainIcon
980     */
981    public void setScaleMainIcon(boolean scaleMainIcon )
982    {
983        _scaleMainIconWithoutSectorMods = scaleMainIcon;
984    }
985    /**
986     * When true, if the main icon is normally small to allow room for sector modifiers,
987     * main icon is made larger when no sector modifiers are present for better visibility.
988     */
989    public boolean getScaleMainIcon()
990    {
991        return _scaleMainIconWithoutSectorMods;
992    }
993
994    /**
995     * Multipoint features and patterns scale with line width ({@link MilStdAttributes#LineWidth}).
996     * {@code patternScale} is the ratio of how much to increase features and patterns by with line width.
997     * default value is 1.0. Can be overwritten on render with {@link MilStdAttributes#PatternScale}
998     * @param patternScale
999     */
1000    public void setPatternScale(double patternScale) {
1001        _patternScale = patternScale;
1002    }
1003
1004    public double getPatternScale() {
1005        return _patternScale;
1006    }
1007
1008    /**
1009     * get the preferred fill affiliation color for units.
1010     *
1011     * @return Color like  Color(255, 255, 255)
1012     *
1013     * */
1014/*    public Color getFriendlyUnitFillColor() {
1015        return _friendlyUnitFillColor;
1016    }
1017    *//**
1018     * Set the preferred fill affiliation color for units
1019     *
1020     * @param friendlyUnitFillColor Color like  Color(255, 255, 255)
1021     *
1022     * *//*
1023    public void setFriendlyUnitFillColor(Color friendlyUnitFillColor) {
1024            if (friendlyUnitFillColor != null)
1025        _friendlyUnitFillColor = friendlyUnitFillColor;
1026    }
1027    *//**
1028     * get the preferred fill affiliation color for units.
1029     *
1030     * @return Color like  Color(255, 255, 255)
1031     *
1032     * *//*
1033    public Color getHostileUnitFillColor() {
1034        return _hostileUnitFillColor;
1035    }
1036    *//**
1037     * Set the preferred fill affiliation color for units
1038     *
1039     * @param hostileUnitFillColor Color like  Color(255, 255, 255)
1040     *
1041     * *//*
1042    public void setHostileUnitFillColor(Color hostileUnitFillColor) {
1043        if (hostileUnitFillColor != null)
1044            _hostileUnitFillColor = hostileUnitFillColor;
1045    }
1046    *//**
1047     * get the preferred fill affiliation color for units.
1048     *
1049     * @return Color like  Color(255, 255, 255)
1050     *
1051     * *//*
1052    public Color getNeutralUnitFillColor() {
1053        return _neutralUnitFillColor;
1054    }
1055    *//**
1056     * Set the preferred line affiliation color for units
1057     *
1058     * @param neutralUnitFillColor Color like  Color(255, 255, 255)
1059     *
1060     * *//*
1061    public void setNeutralUnitFillColor(Color neutralUnitFillColor) {
1062        if (neutralUnitFillColor != null)
1063            _neutralUnitFillColor = neutralUnitFillColor;
1064    }
1065    *//**
1066     * get the preferred fill affiliation color for units.
1067     *
1068     * @return Color like  Color(255, 255, 255)
1069     *
1070     * *//*
1071    public Color getUnknownUnitFillColor() {
1072        return _unknownUnitFillColor;
1073    }
1074    *//**
1075     * Set the preferred fill affiliation color for units
1076     *
1077     * @param unknownUnitFillColor Color like  Color(255, 255, 255)
1078     *
1079     * *//*
1080    public void setUnknownUnitFillColor(Color unknownUnitFillColor) {
1081        if (unknownUnitFillColor != null)
1082            _unknownUnitFillColor = unknownUnitFillColor;
1083    }
1084    *//**
1085     * get the preferred fill affiliation color for graphics.
1086     *
1087     * @return Color like  Color(255, 255, 255)
1088     *
1089     * *//*
1090    public   Color getHostileGraphicFillColor() {
1091        return _hostileGraphicFillColor;
1092    }
1093    *//**
1094     * Set the preferred fill affiliation color for graphics
1095     *
1096     * @param hostileGraphicFillColor Color like  Color(255, 255, 255)
1097     *
1098     * *//*
1099    public  void setHostileGraphicFillColor(Color hostileGraphicFillColor) {
1100        if (hostileGraphicFillColor != null)
1101            _hostileGraphicFillColor = hostileGraphicFillColor;
1102    }
1103    *//**
1104     * get the preferred fill affiliation color for graphics.
1105     *
1106     * @return Color like  Color(255, 255, 255)
1107     *
1108     * *//*
1109    public Color getFriendlyGraphicFillColor() {
1110        return _friendlyGraphicFillColor;
1111    }
1112    *//**
1113     * Set the preferred fill affiliation color for graphics
1114     *
1115     * @param friendlyGraphicFillColor Color like  Color(255, 255, 255)
1116     *
1117     * *//*
1118    public void setFriendlyGraphicFillColor(Color friendlyGraphicFillColor) {
1119        if (friendlyGraphicFillColor != null)
1120            _friendlyGraphicFillColor = friendlyGraphicFillColor;
1121    }
1122    *//**
1123     * get the preferred fill affiliation color for graphics.
1124     *
1125     * @return Color like  Color(255, 255, 255)
1126     *
1127     * *//*
1128    public Color getNeutralGraphicFillColor() {
1129        return _neutralGraphicFillColor;
1130    }
1131    *//**
1132     * Set the preferred fill affiliation color for graphics
1133     *
1134     * @param neutralGraphicFillColor Color like  Color(255, 255, 255)
1135     *
1136     * *//*
1137    public void setNeutralGraphicFillColor(Color neutralGraphicFillColor) {
1138        if (neutralGraphicFillColor != null)
1139            _neutralGraphicFillColor = neutralGraphicFillColor;
1140    }
1141    *//**
1142     * get the preferred fill affiliation color for graphics.
1143     *
1144     * @return Color like  Color(255, 255, 255)
1145     *
1146     * *//*
1147    public Color getUnknownGraphicFillColor() {
1148        return _unknownGraphicFillColor;
1149    }
1150    *//**
1151     * Set the preferred fill affiliation color for graphics
1152     *
1153     * @param unknownGraphicFillColor Color like  Color(255, 255, 255)
1154     *
1155     * *//*
1156    public void setUnknownGraphicFillColor(Color unknownGraphicFillColor) {
1157        if (unknownGraphicFillColor != null)
1158            _unknownGraphicFillColor = unknownGraphicFillColor;
1159    }
1160    *//**
1161     * get the preferred line affiliation color for units.
1162     *
1163     * @return Color like  Color(255, 255, 255)
1164     *
1165     * *//*
1166    public Color getFriendlyUnitLineColor() {
1167        return _friendlyUnitLineColor;
1168    }
1169    *//**
1170     * Set the preferred line affiliation color for units
1171     *
1172     * @param friendlyUnitLineColor Color like  Color(255, 255, 255)
1173     *
1174     * *//*
1175    public void setFriendlyUnitLineColor(Color friendlyUnitLineColor) {
1176        if (friendlyUnitLineColor != null)
1177            this._friendlyUnitLineColor = friendlyUnitLineColor;
1178    }
1179    *//**
1180     * get the preferred line   affiliation color for units.
1181     *
1182     * @return Color like  Color(255, 255, 255)
1183     *
1184     * *//*
1185    public Color getHostileUnitLineColor() {
1186        return _hostileUnitLineColor;
1187    }
1188    *//**
1189     * Set the preferred line affiliation color for units
1190     *
1191     * @param hostileUnitLineColor Color like  Color(255, 255, 255)
1192     *
1193     * *//*
1194    public void setHostileUnitLineColor(Color hostileUnitLineColor) {
1195        if (hostileUnitLineColor != null)
1196            this._hostileUnitLineColor = hostileUnitLineColor;
1197    }
1198    *//**
1199     * get the preferred line affiliation color for units.
1200     *
1201     * @return Color like  Color(255, 255, 255)
1202     *
1203     * *//*
1204    public Color getNeutralUnitLineColor() {
1205        return _neutralUnitLineColor;
1206    }
1207    *//**
1208     * Set the preferred line affiliation color for units
1209     *
1210     * @param neutralUnitLineColor Color like  Color(255, 255, 255)
1211     *
1212     * *//*
1213    public void setNeutralUnitLineColor(Color neutralUnitLineColor) {
1214        if (neutralUnitLineColor != null)
1215            this._neutralUnitLineColor = neutralUnitLineColor;
1216    }
1217    *//**
1218     * get the preferred line affiliation color for units.
1219     *
1220     * @return Color like  Color(255, 255, 255)
1221     *
1222     * *//*
1223    public Color getUnknownUnitLineColor() {
1224        return _unknownUnitLineColor;
1225    }
1226    *//**
1227     * Set the preferred line affiliation color for units
1228     *
1229     * @param unknownUnitLineColor Color like  Color(255, 255, 255)
1230     *
1231     * *//*
1232    public void setUnknownUnitLineColor(Color unknownUnitLineColor) {
1233        if (unknownUnitLineColor != null)
1234            this._unknownUnitLineColor = unknownUnitLineColor;
1235    }
1236    *//**
1237     * get the preferred line affiliation color for graphics.
1238     *
1239     * @return Color like  Color(255, 255, 255)
1240     *
1241     * *//*
1242    public Color getFriendlyGraphicLineColor() {
1243        return _friendlyGraphicLineColor;
1244    }
1245    *//**
1246     * Set the preferred line affiliation color for graphics
1247     *
1248     * @param friendlyGraphicLineColor Color like  Color(255, 255, 255)
1249     *
1250     * *//*
1251    public void setFriendlyGraphicLineColor(Color friendlyGraphicLineColor) {
1252        if (friendlyGraphicLineColor != null)
1253            this._friendlyGraphicLineColor = friendlyGraphicLineColor;
1254    }
1255    *//**
1256     * get the preferred line affiliation color for graphics.
1257     *
1258     * @return Color like  Color(255, 255, 255)
1259     *
1260     * *//*
1261    public Color getHostileGraphicLineColor() {
1262        return _hostileGraphicLineColor;
1263    }
1264    *//**
1265     * Set the preferred line affiliation color for graphics
1266     *
1267     * @param hostileGraphicLineColor Color like  Color(255, 255, 255)
1268     *
1269     * *//*
1270    public void setHostileGraphicLineColor(Color hostileGraphicLineColor) {
1271        if (hostileGraphicLineColor != null)
1272            this._hostileGraphicLineColor = hostileGraphicLineColor;
1273    }
1274    *//**
1275     * get the preferred line affiliation color for graphics.
1276     *
1277     * @return Color like  Color(255, 255, 255)
1278     *
1279     * *//*
1280    public Color getNeutralGraphicLineColor() {
1281        return _neutralGraphicLineColor;
1282    }
1283    *//**
1284     * Set the preferred line affiliation color for graphics
1285     *
1286     * @param neutralGraphicLineColor Color like  Color(255, 255, 255)
1287     *
1288     * *//*
1289    public void setNeutralGraphicLineColor(Color neutralGraphicLineColor) {
1290        if (neutralGraphicLineColor != null)
1291            this._neutralGraphicLineColor = neutralGraphicLineColor;
1292    }
1293    *//**
1294     * get the preferred line affiliation color for graphics.
1295     *
1296     * @return Color like  Color(255, 255, 255)
1297     *
1298     * *//*
1299    public Color getUnknownGraphicLineColor() {
1300        return _unknownGraphicLineColor;
1301    }
1302    *//**
1303     * Set the preferred line affiliation color for graphics
1304     *
1305     * @param unknownGraphicLineColor Color like  Color(255, 255, 255)
1306     *
1307     * *//*
1308    public void setUnknownGraphicLineColor(Color unknownGraphicLineColor) {
1309        if (unknownGraphicLineColor != null)
1310            this._unknownGraphicLineColor = unknownGraphicLineColor;
1311    }
1312
1313    *//**
1314     * Set the preferred line and fill affiliation color for tactical graphics.
1315     *
1316     * @param friendlyGraphicLineColor Color
1317     * @param hostileGraphicLineColor Color
1318     * @param neutralGraphicLineColor Color
1319     * @param unknownGraphicLineColor Color
1320     * @param friendlyGraphicFillColor Color
1321     * @param hostileGraphicFillColor Color
1322     * @param neutralGraphicFillColor Color
1323     * @param unknownGraphicFillColor Color
1324     *//*
1325    public void setGraphicPreferredAffiliationColors(Color friendlyGraphicLineColor,
1326                                                     Color hostileGraphicLineColor,
1327                                                     Color neutralGraphicLineColor,
1328                                                     Color unknownGraphicLineColor,
1329                                                     Color friendlyGraphicFillColor,
1330                                                     Color hostileGraphicFillColor,
1331                                                     Color neutralGraphicFillColor,
1332                                                     Color unknownGraphicFillColor) {
1333
1334
1335          setFriendlyGraphicLineColor(friendlyGraphicLineColor);
1336          setHostileGraphicLineColor(hostileGraphicLineColor);
1337          setNeutralGraphicLineColor(neutralGraphicLineColor);
1338          setUnknownGraphicLineColor(unknownGraphicLineColor);
1339          setFriendlyGraphicFillColor(friendlyGraphicFillColor);
1340          setHostileGraphicFillColor(hostileGraphicFillColor);
1341          setNeutralGraphicFillColor(neutralGraphicFillColor);
1342          setUnknownGraphicFillColor(unknownGraphicFillColor);
1343    }
1344
1345    *//**
1346     * Set the preferred line and fill affiliation color for units and tactical graphics.
1347     *
1348     * @param friendlyUnitLineColor Color like  Color(255, 255, 255). Set to null to ignore setting
1349     * @param hostileUnitLineColor Color
1350     * @param neutralUnitLineColor Color
1351     * @param unknownUnitLineColor Color
1352     * @param friendlyUnitFillColor Color
1353     * @param hostileUnitFillColor Color
1354     * @param neutralUnitFillColor Color
1355     * @param unknownUnitFillColor Color
1356     *//*
1357    public void setUnitPreferredAffiliationColors(   Color friendlyUnitLineColor,
1358                                                     Color hostileUnitLineColor,
1359                                                     Color neutralUnitLineColor,
1360                                                     Color unknownUnitLineColor,
1361                                                     Color friendlyUnitFillColor,
1362                                                     Color hostileUnitFillColor,
1363                                                     Color neutralUnitFillColor,
1364                                                     Color unknownUnitFillColor) {
1365
1366        setFriendlyUnitLineColor(friendlyUnitLineColor);
1367        setHostileUnitLineColor(hostileUnitLineColor);
1368        setNeutralUnitLineColor(neutralUnitLineColor);
1369        setUnknownUnitLineColor(unknownUnitLineColor);
1370        setFriendlyUnitFillColor(friendlyUnitFillColor);
1371        setHostileUnitFillColor(hostileUnitFillColor);
1372        setNeutralUnitFillColor(neutralUnitFillColor);
1373        setUnknownUnitFillColor(unknownUnitFillColor);
1374    }*/
1375
1376}