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