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