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