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