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