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