001/* 002 * To change this template, choose Tools | Templates 003 * and open the template in the editor. 004 */ 005 006package armyc2.c2sd.JavaLineArray; 007import armyc2.c2sd.renderer.utilities.ErrorLogger; 008import armyc2.c2sd.renderer.utilities.RendererException; 009import armyc2.c2sd.renderer.utilities.RendererSettings; 010import armyc2.c2sd.graphics2d.Rectangle2D; 011/** 012 * A class to calculate the number of pixels based points required for a line 013 * @author Michael Deutch 014 */ 015public final class countsupport 016{ 017 private static final double maxLength = 100; //max arrow size 018 private static double minLength = 2.5; //min arrow size was 5 019 private static final String _className = "countsupport"; 020 021// protected static void setMinLength(double mLength) 022// { 023// minLength=mLength; 024// } 025 /** 026 * The main function to return the number of points needed for a symbol 027 * @param vbiDrawThis the line type 028 * @param vblCounter the number of client points 029 * @param pLinePoints the client point array 030 * @return the number of points required to draw the symbol 031 */ 032 protected static int GetCountersDouble(int vbiDrawThis, 033 int vblCounter, 034 POINT2[] pLinePoints, 035 Rectangle2D clipBounds, 036 int rev) 037 { 038 int count=0; 039 try 040 { 041 //declaration section 042 int j = 0; 043 int vblSaveCounter = vblCounter; 044 POINT2[] pSquarePoints = new POINT2[4]; 045 POINT2[] pUpperLinePoints = null, 046 pLowerLinePoints = null; 047 int[] segments = null; 048 POINT2[] pNewLinePoints = null; 049 double dRadius = 0; 050 POINT2[] pointsCorner = new POINT2[2]; 051 //double saveMaxPixels = 2000;//CELineArrayGlobals.MaxPixels2; 052 053 pUpperLinePoints=new POINT2[vblCounter]; 054 pLowerLinePoints=new POINT2[vblCounter]; 055 056 for(j=0;j<vblCounter;j++) 057 { 058 pUpperLinePoints[j]=new POINT2(pLinePoints[j]); 059 pLowerLinePoints[j]=new POINT2(pLinePoints[j]); 060 } 061 lineutility.InitializePOINT2Array(pointsCorner); 062 lineutility.InitializePOINT2Array(pSquarePoints); 063 //end delcarations 064 switch (vbiDrawThis) 065 { 066 case TacticalLines.BS_ELLIPSE: 067 case TacticalLines.PBS_ELLIPSE: 068 case TacticalLines.PBS_CIRCLE: 069 count=37; 070 break; 071 case TacticalLines.BS_CROSS: 072 count=4; 073 break; 074 case TacticalLines.OVERHEAD_WIRE: 075 count=vblCounter*15; //15 points per segment 076 break; 077 case TacticalLines.OVERHEAD_WIRE_LS: 078 count=vblCounter*2; //15 points per segment 079 break; 080 case TacticalLines.ICE_DRIFT: 081 vblCounter += 3; //3 extra points for the arrow 082 count=vblCounter; 083 break; 084 case TacticalLines.REEF: 085 vblCounter = GetReefCount(pLinePoints, vblSaveCounter); 086 count=vblCounter; 087 break; 088 case TacticalLines.RESTRICTED_AREA: 089 vblCounter = GetRestrictedAreaCount(pLinePoints, vblSaveCounter); 090 count=vblCounter; 091 break; 092 case TacticalLines.TRAINING_AREA: 093 vblCounter += 30; 094 count=vblCounter; 095 break; 096 case TacticalLines.PIPE: 097 count = GetPipeCount(pLinePoints, vblSaveCounter); 098 break; 099 case TacticalLines.ANCHORAGE_AREA: 100 case TacticalLines.ANCHORAGE_LINE: 101 count = flot.GetAnchorageCountDouble(pLinePoints, vblCounter); 102 break; 103 case TacticalLines.LRO: 104 int xCount=GetXPointsCount(vbiDrawThis, pLinePoints,vblCounter); 105 int lvoCount=GetLVOCount(vbiDrawThis, pLinePoints,vblCounter); 106 count=xCount+lvoCount; 107 break; 108 case TacticalLines.LVO: 109 count=GetLVOCount(vbiDrawThis, pLinePoints,vblCounter); 110 break; 111 case TacticalLines.ICING: 112 vblCounter = GetIcingCount(pLinePoints, vblCounter); 113 count=vblCounter; 114 break; 115 case TacticalLines.FLOT: 116 case TacticalLines.MVFR: 117 case TacticalLines.UNDERCAST: 118 vblSaveCounter = vblCounter; 119 vblCounter = flot.GetFlotCountDouble(pLinePoints, vblCounter); 120 count=vblCounter; 121 break; 122 case TacticalLines.ITD: 123 vblCounter = GetITDQty(pLinePoints, vblCounter) + vblCounter; 124 count=vblCounter; 125 break; 126 case TacticalLines.CONVERGANCE: 127 vblCounter = GetConverganceQty(pLinePoints, vblCounter) + vblCounter; 128 count=vblCounter; 129 break; 130 case TacticalLines.RIDGE: 131 vblCounter = GetFORTLCountDouble(pLinePoints, vbiDrawThis, vblSaveCounter); 132 count=vblCounter; 133 break; 134 case TacticalLines.TROUGH: 135 case TacticalLines.INSTABILITY: 136 case TacticalLines.SHEAR: 137 vblCounter = GetSquallQty(pLinePoints, 6, 30, (int)vblSaveCounter); 138 count=vblCounter; 139 break; 140 case TacticalLines.SQUALL: 141 vblCounter = GetSquallQty(pLinePoints, 5, 30, (int)vblSaveCounter)+ 2 * vblSaveCounter; 142 count=vblCounter; 143 break; 144 case TacticalLines.USF: 145 case TacticalLines.SFG: 146 case TacticalLines.SFY: 147 case TacticalLines.SF: 148 vblCounter = flot.GetSFCountDouble(pLinePoints, vblCounter); 149 count=vblCounter; 150 break; 151 case TacticalLines.OFY: 152 vblSaveCounter = vblCounter; 153 vblCounter = flot.GetOFYCountDouble(pLinePoints, vblCounter, vbiDrawThis); 154 count=vblCounter; 155 break; 156 case TacticalLines.UCF: 157 case TacticalLines.CF: 158 case TacticalLines.CFG: 159 case TacticalLines.CFY: 160 count = GetFORTLCountDouble(pLinePoints, vbiDrawThis, vblSaveCounter); 161 count += vblSaveCounter; 162 break; 163 case TacticalLines.FOLLA: 164 case TacticalLines.FOLSP: 165 count=16; 166 break; 167 case TacticalLines.ROADBLK: 168 case TacticalLines.FERRY: 169 count=8; 170 break; 171 case TacticalLines.NAVIGATION: 172 case TacticalLines.IL: 173 case TacticalLines.PLANNED: 174 case TacticalLines.ESR1: 175 case TacticalLines.ESR2: 176 case TacticalLines.FORDSITE: 177 case TacticalLines.FOXHOLE: 178 case TacticalLines.DECEIVE: 179 count = 4; 180 break; 181 case TacticalLines.TRIP: 182 count = 35; 183 break; 184 case TacticalLines.AMBUSH: //extra 3 for open arrow, extra 26 for the tail arc, 185 //and an extra 22 for the tail line segments 186 count = 53;//vblCounter+51; 187 break; 188 case TacticalLines.CLUSTER: 189 count = 28; 190 break; 191 case TacticalLines.DUMMY: 192 count=vblCounter+3; //commented 5-3-10 193 break; 194 case TacticalLines.CONTAIN: 195 count = 40; 196 break; 197 case TacticalLines.BYIMP: 198 count = 18; 199 break; 200 case TacticalLines.SPTBYFIRE: 201 count = 16; 202 break; 203 case TacticalLines.BLOCK: 204 case TacticalLines.MNFLDBLK: 205 count = 4; 206 break; 207 case TacticalLines.PAA_RECTANGULAR: 208 count = 5; 209 break; 210 case TacticalLines.PENETRATE: 211 count = 7; 212 break; 213 case TacticalLines.ASLTXING: //double for the channel type plus 4 for the hash marks 214 case TacticalLines.BRIDGE: 215 case TacticalLines.GAP: 216 case TacticalLines.BYPASS: 217 case TacticalLines.EASY: 218 case TacticalLines.BREACH: 219 case TacticalLines.CANALIZE: 220 count = 12; 221 break; 222 case TacticalLines.MNFLDDIS: 223 count = 22; 224 break; 225 case TacticalLines.WITHDRAW: 226 case TacticalLines.WDRAWUP: 227 case TacticalLines.DELAY: //extra four points for hash marks on last segment 228 case TacticalLines.RETIRE: 229 count = 23; 230 break; 231 case TacticalLines.SEIZE: 232 case TacticalLines.SEIZE_REVC: 233 count = 37; 234 break; 235 case TacticalLines.RIP: 236 count = 29; 237 break; 238 case TacticalLines.DIRATKSPT: 239 count = vblCounter + 3; 240 break; 241 case TacticalLines.ABATIS: 242 count = vblCounter + 3; 243 break; 244 case TacticalLines.FPF: //extra two points for blocks at each end 245 case TacticalLines.LINTGT: //extra two points for blocks at each end 246 case TacticalLines.LINTGTS: 247 count = vblCounter + 4; 248 break; 249 case TacticalLines.CHANNEL: 250 case TacticalLines.CHANNEL_FLARED: 251 case TacticalLines.CHANNEL_DASHED: 252 //pvblCounters[0]=2*lElements; 253 //pvblCounters[1]=lElements; 254 count=2*vblCounter; 255 break; 256 case TacticalLines.SARA: 257 count = 16; //same for DISM 258 break; 259 case TacticalLines.COVER: //vblSaveCounter = vblCounter; 260 case TacticalLines.SCREEN: 261 case TacticalLines.GUARD: 262 case TacticalLines.COVER_REVC: //vblSaveCounter = vblCounter; 263 case TacticalLines.SCREEN_REVC: 264 case TacticalLines.GUARD_REVC: 265 case TacticalLines.PDF: 266 case TacticalLines.ATKBYFIRE: 267 count = 14; //same for DISM 268 break; 269 case TacticalLines.RAFT: 270 case TacticalLines.MFLANE: //extra eight points for hash marks at either end 271 count = 8; 272 break; 273 case TacticalLines.DIRATKGND: 274 count = vblCounter + 10; 275 break; 276 case TacticalLines.DIRATKAIR: 277 count = vblCounter + 9; 278 break; 279 case TacticalLines.DISRUPT: 280 case TacticalLines.CLEAR: 281 count = 20; 282 break; 283 case TacticalLines.UAV_USAS: 284 case TacticalLines.MRR_USAS: 285 vblCounter = 6 * (vblSaveCounter - 1); //6 per segment 286 count = vblCounter + 26 * vblSaveCounter*2; //26 for each circle and potentially two circles at each endpoint 287 break; 288 case TacticalLines.UAV: 289 case TacticalLines.MRR: 290 if(rev==RendererSettings.Symbology_2525C) 291 { 292 vblCounter = 6 * (vblSaveCounter - 1); //6 per segment 293 count = vblCounter + 26 * vblSaveCounter*2; //26 for each circle and potentially two circles at each endpoint 294 } 295 else 296 count=6; 297 break; 298 case TacticalLines.DIRATKFNT: //extra three for arrow plus extra three for the feint 299 count = vblCounter + 6; 300 break; 301 case TacticalLines.MSDZ: 302 count = 300; 303 break; 304 case TacticalLines.CONVOY: 305 case TacticalLines.HCONVOY: 306 count = 10; 307 break; 308 case TacticalLines.ISOLATE: 309 case TacticalLines.CORDONKNOCK: 310 case TacticalLines.CORDONSEARCH: 311 count = 50; 312 break; 313 case TacticalLines.OCCUPY: 314 count = 32; 315 break; 316 case TacticalLines.SECURE: 317 count = 29; 318 break; 319 case TacticalLines.RETAIN: 320 count = 75; 321 break; 322 case TacticalLines.TURN: 323 count = 29; 324 break; 325 case TacticalLines.AIRFIELD: 326 count = vblCounter + 5; 327 break; 328 case TacticalLines.DMA: 329 count=vblCounter + 4; 330 break; 331 case TacticalLines.DMAF: 332 count=vblCounter + 3; 333 break; 334 case TacticalLines.ALT: 335 count = vblCounter * 9; 336 break; 337 case TacticalLines.TWOWAY: 338 count = vblCounter * 11; 339 break; 340 case TacticalLines.ONEWAY: 341 count = vblCounter * 6; 342 break; 343 case TacticalLines.WF: 344 case TacticalLines.UWF: 345 vblCounter = flot.GetFlotCount2Double(pLinePoints, vblCounter, vbiDrawThis); 346 vblCounter += vblSaveCounter; 347 count=vblCounter; 348 break; 349 case TacticalLines.WFG: 350 case TacticalLines.WFY: 351 vblCounter = flot.GetFlotCount2Double(pLinePoints, vblCounter, vbiDrawThis); 352 count=vblCounter; 353 break; 354 case TacticalLines.FORDIF: 355 dRadius = lineutility.CalcDistanceToLineDouble(pLinePoints[0], pLinePoints[1], pLinePoints[2]); 356 count=(int)( (dRadius/5)*3) + 6; 357 if(clipBounds != null) 358 { 359 double width=clipBounds.getWidth(); 360 double height=clipBounds.getHeight(); 361 dRadius=Math.sqrt(width*width+height*height); 362 count = (int)(dRadius / 5) + 6; 363 } 364 365 366 break; 367 case TacticalLines.ATDITCH: //call function to determine the array size 368 case TacticalLines.ATDITCHC: //call function to determine the array size 369 case TacticalLines.ATDITCHM: 370 count = GetDitchCountDouble(pLinePoints, vblSaveCounter, vbiDrawThis); 371 break; 372 case TacticalLines.CATK: 373 case TacticalLines.AXAD: 374 case TacticalLines.MAIN: 375 case TacticalLines.MAIN_STRAIGHT: 376 case TacticalLines.AAFNT: 377 case TacticalLines.AAFNT_STRAIGHT: 378 case TacticalLines.AIRAOA: 379 case TacticalLines.SPT: 380 case TacticalLines.SPT_STRAIGHT: 381 //points for these need not be bounded 382 //they have an extra 8 points for the arrowhead 383 count=2*vblCounter+8; 384 break; 385 case TacticalLines.CATKBYFIRE: 386 count=2*vblCounter+17; 387 break; 388 case TacticalLines.AAAAA: 389 count=2*vblCounter+19; 390 break; 391 case TacticalLines.FEBA: //double for the shortened user line plus quadruple for 392 // X's, plus 26 times for the circles 393 count = 32 * vblCounter; 394 break; 395 case TacticalLines.LLTR: //added 5-4-07 396 case TacticalLines.SAAFR: 397 case TacticalLines.AC: 398 vblCounter = 6 * (vblSaveCounter - 1); //6 per segment 399 count = vblCounter + 26 * vblSaveCounter*2; //26 for each circle and potentially two circles at each endpoint 400 break; 401 case TacticalLines.ATWALL: 402 case TacticalLines.LINE: 403 case TacticalLines.OBSAREA: 404 case TacticalLines.OBSFAREA: 405 case TacticalLines.STRONG: 406 case TacticalLines.ZONE: 407 case TacticalLines.BELT: //add per change 2 408 case TacticalLines.ENCIRCLE: 409 case TacticalLines.FORT: 410 case TacticalLines.FORTL: 411 count = GetFORTLCountDouble(pLinePoints, vbiDrawThis, vblSaveCounter); 412 break; 413 case TacticalLines.BELT1: 414 pUpperLinePoints = new POINT2[vblCounter]; 415 pLowerLinePoints = new POINT2[vblCounter]; 416 POINT2[]pUpperLowerLinePoints = new POINT2[2 * vblCounter]; 417 for (j = 0; j < vblCounter; j++) 418 pLowerLinePoints[j] = pLinePoints[j]; 419 for (j = 0; j < vblCounter; j++) 420 pUpperLinePoints[j] = pLinePoints[j]; 421 pUpperLinePoints = Channels.CoordIL2Double(1, pUpperLinePoints, 1, vblCounter, vbiDrawThis,30); 422 pLowerLinePoints = Channels.CoordIL2Double(1, pLowerLinePoints, 0, vblCounter, vbiDrawThis,30); 423 for (j = 0; j < vblCounter; j++) 424 pUpperLowerLinePoints[j] = pUpperLinePoints[j]; 425 for (j = 0; j < vblCounter; j++) 426 pUpperLowerLinePoints[j + vblCounter] = pLowerLinePoints[vblCounter - j - 1]; 427 vblSaveCounter = 2 * vblCounter; 428 count = GetFORTLCountDouble(pUpperLowerLinePoints, vbiDrawThis, 2 * vblCounter); 429 break; 430 case TacticalLines.TRIPLE: 431 case TacticalLines.DOUBLEC: 432 case TacticalLines.SINGLEC: 433 case TacticalLines.HWFENCE: 434 case TacticalLines.LWFENCE: 435 case TacticalLines.UNSP: 436 case TacticalLines.DOUBLEA: 437 case TacticalLines.SFENCE: 438 case TacticalLines.DFENCE: 439 count = Channels.GetTripleCountDouble(pLinePoints, vblCounter, vbiDrawThis); 440 break; 441 case TacticalLines.BBS_LINE: 442 count=2*vblCounter; 443 break; 444 case TacticalLines.LC: 445 pUpperLinePoints = Channels.GetChannelArray2Double(1,pUpperLinePoints,1,vblCounter,vbiDrawThis,20); 446 pLowerLinePoints = Channels.GetChannelArray2Double(1,pLowerLinePoints,0,vblCounter,vbiDrawThis,20); 447 int lUpperFlotCount= flot.GetFlotCountDouble(pUpperLinePoints,vblCounter); 448 int lLowerFlotCount= flot.GetFlotCountDouble(pLowerLinePoints,vblCounter); 449 count=lUpperFlotCount+lLowerFlotCount; 450 break; 451 case TacticalLines.OCCLUDED: 452 case TacticalLines.UOF: 453 vblSaveCounter = vblCounter; 454 vblCounter = flot.GetOccludedCountDouble(pLinePoints, vblCounter); 455 vblCounter += vblSaveCounter; 456 count=vblCounter; 457 break; 458 case TacticalLines.FIX: 459 case TacticalLines.MNFLDFIX: 460 if(pLinePoints.length>1) 461 count = GetDISMFixCountDouble(pLinePoints[0], pLinePoints[1],clipBounds); 462 else count=0; 463 break; 464 case TacticalLines.BYDIF: 465 if(clipBounds != null) 466 { 467 GetByDifSegment(pLinePoints, pointsCorner); 468 POINT2 ul=new POINT2(clipBounds.getMinX(),clipBounds.getMinY()); //-100,1000 469 POINT2 lr=new POINT2(clipBounds.getMaxX(),clipBounds.getMaxY()); //-100,1000 470 POINT2[] ptsCorner=lineutility.BoundOneSegment(pointsCorner[0],pointsCorner[1], ul, lr); 471 472 if(ptsCorner != null) 473 count = GetDISMFixCountDouble(ptsCorner[0], ptsCorner[1],clipBounds); 474 else 475 count=20; 476 } 477 else 478 count = GetDISMFixCountDouble(pLinePoints[0], pLinePoints[1],clipBounds); 479 480 break; 481 default: 482 count=vblCounter; 483 break; 484 } 485 } 486 catch(Exception exc) 487 { 488 ErrorLogger.LogException(_className ,"GetCountersDouble", 489 new RendererException("Failed inside GetCountersDouble " + Integer.toString(vbiDrawThis), exc)); 490 } 491 return count; 492 } 493 private static int GetReefCount(POINT2[] pLinePoints, 494 int vblCounter) { 495 int count = 0; 496 try { 497 double d = 0; 498 for (int j = 0; j < vblCounter - 1; j++) { 499 d = lineutility.CalcDistanceDouble(pLinePoints[j], pLinePoints[j + 1]); 500 count += 5 * (int) d / 40; 501 } 502 count += 2 * (int) vblCounter; 503 } catch (Exception exc) { 504 ErrorLogger.LogException(_className ,"GetReefCount", 505 new RendererException("Failed inside GetReefCount", exc)); 506 } 507 return count; 508 } 509 private static int GetRestrictedAreaCount(POINT2[] pLinePoints, 510 int vblCounter) { 511 int count = 0; 512 try { 513 double d = 0; 514 for (int j = 0; j < vblCounter - 1; j++) { 515 d = lineutility.CalcDistanceDouble(pLinePoints[j], pLinePoints[j + 1]); 516 count += 4 * (int) d / 15; 517 } 518 count += 2 * (int) vblCounter; 519 } catch (Exception exc) { 520 ErrorLogger.LogException(_className ,"GetRestrictedAreaCount", 521 new RendererException("Failed inside GetRestrictedAreaCount", exc)); 522 } 523 return count; 524 } 525 526 private static int GetPipeCount(POINT2[] pLinePoints, 527 int vblCounter) { 528 int count = 0; 529 try { 530 double d = 0; 531 for (int j = 0; j < vblCounter - 1; j++) { 532 d = lineutility.CalcDistanceDouble(pLinePoints[j], pLinePoints[j + 1]); 533 count += 3 * (int) d / 20; 534 } 535 count += 2 * (int) vblCounter; 536 } catch (Exception exc) { 537 ErrorLogger.LogException(_className ,"GetPipeCount", 538 new RendererException("Failed inside GetPipeCount", exc)); 539 } 540 return count; 541 } 542 543 protected static int GetXPointsCount(int linetype, POINT2[] pOriginalLinePoints, int vblCounter) 544 { 545 int xCounter=0; 546 try 547 { 548 int j=0; 549 double d=0; 550 //POINT2 pt0,pt1,pt2,pt3=new POINT2(),pt4=new POINT2(),pt5=new POINT2(),pt6=new POINT2(); 551 int numThisSegment=0; 552 for(j=0;j<vblCounter-1;j++) 553 { 554 d=lineutility.CalcDistanceDouble(pOriginalLinePoints[j],pOriginalLinePoints[j+1]); 555 numThisSegment=(int)((d-10)/20); 556 if(linetype==TacticalLines.LRO) 557 numThisSegment=(int)((d-15)/30); 558 xCounter += 4*numThisSegment; 559 } 560 } 561 catch(Exception exc) 562 { 563 ErrorLogger.LogException(_className ,"GetXPointsCount", 564 new RendererException("Failed inside GetXPointsCount", exc)); 565 } 566 return xCounter; 567 } 568 569 protected static int GetLVOCount(int linetype, POINT2[] pOriginalLinePoints, int vblCounter) 570 { 571 int lEllipseCounter = 0; 572 try { 573 double d = 0; 574 int lHowManyThisSegment = 0, j = 0; 575 //end declarations 576 for (j = 0; j < vblCounter - 1; j++) 577 { 578 d = lineutility.CalcDistanceDouble(pOriginalLinePoints[j], pOriginalLinePoints[j + 1]); 579 //lHowManyThisSegment = (int) ((d - 20) / 20); 580 lHowManyThisSegment = (int) ((d - 20) / 20)+1; 581 if(linetype==TacticalLines.LRO) 582 lHowManyThisSegment = (int) ((d - 30) / 30)+1; 583 lEllipseCounter += lHowManyThisSegment*37; 584 } 585 } catch (Exception exc) { 586 ErrorLogger.LogException(_className ,"GetLVOCount", 587 new RendererException("Failed inside GetLVOCount", exc)); 588 } 589 return lEllipseCounter; 590 } 591 592 private static int GetIcingCount(POINT2[] points, int vblCounter) { 593 int total = 2 * vblCounter; 594 try { 595 double length = 0; 596 for (int j = 0; j < vblCounter - 1; j++) { 597 length = lineutility.CalcDistanceDouble(points[j], points[j + 1]); 598 length = (length / 15) * 4; 599 total += length; 600 } 601 } catch (Exception exc) { 602 ErrorLogger.LogException(_className ,"GetIcingCount", 603 new RendererException("Failed inside GetIcingCount", exc)); 604 } 605 return total; 606 } 607 608 protected static int GetITDQty(POINT2[] pLinePoints, int vblCounter) { 609 int total = 0; 610 try { 611 int j = 0; 612 double d = 0; 613 int n=0; 614 for (j = 0; j < vblCounter - 1; j++) { 615 d = lineutility.CalcDistanceDouble(pLinePoints[j], pLinePoints[j + 1]); 616 n= 2 * (int) (d / 15); 617 if(n<2) 618 n=2; 619 total += n; 620 } 621 } catch (Exception exc) { 622 ErrorLogger.LogException(_className ,"GetITDQty", 623 new RendererException("Failed inside GetITDQty", exc)); 624 } 625 return total; 626 } 627 628 protected static int GetConverganceQty(POINT2[] pLinePoints, int vblCounter) { 629 int total = vblCounter; 630 try 631 { 632 int j = 0; 633 double d = 0; 634 for (j = 0; j < vblCounter - 1; j++) 635 { 636 d = lineutility.CalcDistanceDouble(pLinePoints[j], pLinePoints[j + 1]); 637 total += 4 * (int) (d / 10); 638 } 639 } catch (Exception exc) { 640 ErrorLogger.LogException(_className ,"GetConverganceQty", 641 new RendererException("Failed inside GetConverganceQty", exc)); 642 } 643 return total; 644 } 645 646 /** 647 * Calculates the points for ATDITCH, ATDITCHC, ATDITCHM 648 * @param pLinePoints the client point array 649 * @param vblCounter the number of client points 650 * @param vbiDrawThis the line type 651 * @return 652 */ 653 private static int GetDitchCountDouble(POINT2[] pLinePoints, 654 int vblCounter, 655 int vbiDrawThis) { 656 int vblXCounter = 0; 657 try { 658 //declarations 659 int j = 0; 660 int nHowManyThisSegment = 0; 661 double dHowFar = 0; 662 //dPrinter = (double) nPrinter; 663 664 vblXCounter = vblCounter; 665 666 for (j = 0; j < vblCounter - 1; j++) { 667 dHowFar = lineutility.CalcDistanceDouble(pLinePoints[j], pLinePoints[j + 1]); 668 nHowManyThisSegment = (int) ( (dHowFar-1) / 12); 669 if (dHowFar > 24) { 670 switch (vbiDrawThis) { 671 //case TacticalLines.FORT: 672 // break; 673 case TacticalLines.ATDITCHM: 674 vblXCounter += 5 * nHowManyThisSegment+1;//was 4 * nHowManyThisSegment 675 break; 676 default: 677 vblXCounter += 4 * nHowManyThisSegment;//was 3 * nHowManyThisSegment 678 break; 679 } //end switch 680 } //end if 681 else { 682 vblXCounter += 2; 683 } 684 } //end for 685 } catch (Exception exc) { 686 ErrorLogger.LogException(_className ,"GetDitchcountDouble", 687 new RendererException("Failed inside GetDitchCountDouble " + Integer.toString(vbiDrawThis), exc)); 688 } 689 return vblXCounter; 690 } 691 protected static int GetSquallQty(POINT2[] pLinePoints, 692 int quantity, 693 int length, 694 int numPoints) { 695 int counter = 0; 696 try { 697 int j = 0; 698 double dist = 0; 699 int numCurves = 0; 700 //end declarations 701 702 for (j = 0; j < numPoints-1; j++) { 703 dist = lineutility.CalcDistanceDouble(pLinePoints[j], pLinePoints[j + 1]); 704 numCurves = (int) (dist / (double) length); 705 counter += numCurves * quantity; 706 if (numCurves == 0) { 707 counter += 2; 708 } 709 } 710 711 if (counter < numPoints) { 712 counter = numPoints; 713 } 714 715 } catch (Exception exc) { 716 ErrorLogger.LogException(_className ,"GetSquallQty", 717 new RendererException("Failed inside GetSquallQty", exc)); 718 } 719 return counter; 720 } 721 722 protected static int GetSquallSegQty(POINT2 StartPt, 723 POINT2 EndPt, 724 int quantity, 725 int length) { 726 int qty = 0; 727 try { 728 double dist = lineutility.CalcDistanceDouble(StartPt, EndPt); 729 int numCurves = (int) (dist / (double) length); 730 qty = numCurves * quantity; 731 } catch (Exception exc) { 732 ErrorLogger.LogException(_className ,"GetSquallSegQty", 733 new RendererException("Failed inside GetSquallSegQty", exc)); 734 } 735 return qty; 736 } 737 738 /** 739 * returns number of points required for ATWALL, FORT and other symbols 740 * @param pLinePoints the client points 741 * @param linetype the line type 742 * @param vblCounter the number of client points 743 * @return 744 */ 745 protected static int GetFORTLCountDouble(POINT2[] pLinePoints, 746 int linetype, 747 int vblCounter) { 748 int lCounter = 0; 749 try { 750 //declarations 751 int j = 0; 752 double dCounter = 0, dIncrement = 0; 753 //end declarations 754 755 switch (linetype) { 756 case TacticalLines.UCF: 757 case TacticalLines.CF: 758 case TacticalLines.CFG: 759 case TacticalLines.CFY: 760 dIncrement = 60; 761 break; 762 case TacticalLines.RIDGE: 763 dIncrement = 20; 764 break; 765 default: 766 dIncrement = 20; 767 break; 768 } 769 770 for (j = 0; j < vblCounter - 1; j++) { 771 dCounter = lineutility.CalcDistanceDouble(pLinePoints[j], pLinePoints[j + 1]); 772 773 switch (linetype) { 774 case TacticalLines.CFG: 775 dCounter = (dCounter / dIncrement) * 13; 776 break; 777 case TacticalLines.CFY: 778 dCounter = (dCounter / dIncrement) * 17; 779 break; 780 default: 781 dCounter = (dCounter / dIncrement) * 10; 782 break; 783 } 784 785 if (dCounter < 4) { 786 dCounter = 4; 787 } 788 lCounter += (long) dCounter; 789 } 790 lCounter += 10 + vblCounter; 791 792 } catch (Exception exc) { 793 ErrorLogger.LogException(_className ,"GetFORTLCountDouble", 794 new RendererException("Failed inside GetFORTLCountDouble", exc)); 795 } 796 return lCounter; 797 } 798 799 private static void GetByDifSegment(POINT2[] points, POINT2[] pointsCorner) { 800 try { 801 // draw open-ended rectangle 802 POINT2 point_mid = new POINT2(); 803 //int j=0; 804 // POINT1 pts[4]; 805 if (pointsCorner == null) { 806 pointsCorner = new POINT2[2]; 807 lineutility.InitializePOINT2Array(pointsCorner); 808 } 809 point_mid.x = (points[0].x + points[1].x) / 2; 810 point_mid.y = (points[0].y + points[1].y) / 2; 811 pointsCorner[0].x = points[0].x - point_mid.x + points[2].x; 812 pointsCorner[0].y = points[0].y - point_mid.y + points[2].y; 813 pointsCorner[1].x = points[1].x - point_mid.x + points[2].x; 814 pointsCorner[1].y = points[1].y - point_mid.y + points[2].y; 815 } catch (Exception exc) { 816 ErrorLogger.LogException(_className ,"GetByDifSegment", 817 new RendererException("Failed inside GetByDifSegment", exc)); 818 } 819 } 820 /** 821 * clipBounds is used because of the glyphs on one segment 822 * @param FirstLinePoint 823 * @param LastLinePoint 824 * @param clipBounds 825 * @return 826 */ 827 protected static int GetDISMFixCountDouble(POINT2 FirstLinePoint, 828 POINT2 LastLinePoint, 829 Rectangle2D clipBounds) { 830 int counter = 0; 831 try { 832 POINT2[] savepoints = new POINT2[2]; 833 //double dAngle1 = 0; 834 double dLength = 0; 835 double dJaggyHalfAmp = 0; 836 double dJaggyHalfPeriod = 0; 837 int iNumJaggies = 0; 838 839 savepoints[0] = new POINT2(FirstLinePoint); 840 savepoints[1] = new POINT2(LastLinePoint); 841 842 //Boolean drawJaggies=true; 843 if(clipBounds != null) 844 { 845 POINT2 ul=new POINT2(clipBounds.getMinX(),clipBounds.getMinY()); 846 POINT2 lr=new POINT2(clipBounds.getMaxX(),clipBounds.getMaxY()); 847 savepoints=lineutility.BoundOneSegment(FirstLinePoint, LastLinePoint, ul, lr); 848 } 849 850 if(savepoints==null) 851 return 0; 852 853 dLength = Math.sqrt((savepoints[1].x - savepoints[0].x) * (savepoints[1].x - savepoints[0].x) + 854 (savepoints[1].y - savepoints[0].y) * (savepoints[1].y - savepoints[0].y)); 855 dJaggyHalfAmp = dLength / 15; // half the amplitude of the "jaggy function" 856 857 if (dJaggyHalfAmp > maxLength) { 858 dJaggyHalfAmp = maxLength; 859 } 860 if (dJaggyHalfAmp < minLength) { 861 dJaggyHalfAmp = minLength; 862 } 863 864 dJaggyHalfPeriod = dJaggyHalfAmp / 1.5; // half the period of the "jaggy function" 865 iNumJaggies = (int) (dLength / dJaggyHalfPeriod) - 3; 866 if (iNumJaggies < 0) { 867 iNumJaggies = 0; 868 } 869 870 savepoints = null; 871 counter = 20 + iNumJaggies * 3; 872 } catch (Exception exc) { 873 ErrorLogger.LogException(_className ,"GetDISMFixCount", 874 new RendererException("Failed inside GetDISMFixCount", exc)); 875 } 876 return counter; 877 } 878 879}