001/*
002 * To change this template, choose Tools | Templates
003 * and open the template in the editor.
004 */
005
006package armyc2.c5isr.JavaLineArray;
007//import java.awt.Color;
008import armyc2.c5isr.JavaTacticalRenderer.TGLight;
009import armyc2.c5isr.renderer.utilities.Color;
010import java.util.ArrayList;
011import armyc2.c5isr.renderer.utilities.ErrorLogger;
012import armyc2.c5isr.renderer.utilities.RendererException;
013import armyc2.c5isr.renderer.utilities.RendererSettings;
014
015/**
016 * CELineArray Channels class calculates the channel points
017 */
018public final class Channels {
019    private static final double maxLength=100;//max arrow size
020    private static final double minLength=5;    //max arrow size
021    private static final String _className="Channels";
022    private static String _client="";
023    public static void setClient(String value)
024    {
025        _client=value;
026    }
027//    private static String _affiliation="";
028//    public static void setAffiliation(String value)
029//    {
030//        _affiliation=value;
031//    }
032    private static boolean _shiftLines=true;
033//    public static void setShiftLines(boolean value)
034//    {
035//        _shiftLines=value;
036//    }
037    public static boolean getShiftLines()
038    {
039        return _shiftLines;
040    }
041    private static CChannelPoints2[] ConnectArrayTrueDouble(int  nWidth,
042                                                    int  nCounter,
043                                                    POINT2[] pLinePoints,
044                                                    CChannelPoints2[] pResultChannelPoints)
045
046    {
047        try
048        {
049            //declarations
050            int  nPointCounter = 0;
051            double      nDiff1X = 0,
052                    nDiff2X = 0,
053                    nDiff1Y = 0,
054                    nDiff2Y = 0;
055            int nLast = 0;
056            int lOrient=0;
057            POINT2  LinePoint1 = new POINT2(pLinePoints[0]),
058                    LinePoint2 = new POINT2(pLinePoints[0]),
059                    LinePoint3 = new POINT2(pLinePoints[0]);
060
061            //POINT2 EndPoint1=new POINT2(pLinePoints[0]);
062            //POINT2 EndPoint2=new POINT2(pLinePoints[0]);
063            CChannelPoints2  ResultChannelPoint=new CChannelPoints2();
064            //end declarations
065
066            //must establish nLast before we get the first channel end point
067            //put first GetEndPoint into the pResultChannelPoints array
068            LinePoint1 = new POINT2(pLinePoints[0]);
069            LinePoint2 = new POINT2(pLinePoints[1]);
070            nDiff1X = LinePoint2.x - LinePoint1.x;
071            nDiff1Y = LinePoint2.y - LinePoint1.y;
072            if(nDiff1X==0)
073            {
074                if(nDiff1Y>0)
075                    nLast=6;
076                if(nDiff1Y<0)
077                    nLast=4;
078            }
079            if(nDiff1Y==0)
080            {
081                if(nDiff1X>0)
082                    nLast=0;
083                if(nDiff1X<0)
084                    nLast=2;
085            }
086            if(nDiff1X<0 && nDiff1Y>0)
087                nLast=3;
088            if(nDiff1X>0 && nDiff1Y>0)
089                nLast=0;
090            if(nDiff1X<0 && nDiff1Y<0)
091                nLast=3;
092            if(nDiff1X>0 && nDiff1Y<0)
093                nLast=0;
094
095            ResultChannelPoint = GetTrueEndPointDouble(nWidth,pLinePoints[0],pLinePoints[1],nLast);
096            pResultChannelPoints[0] = new CChannelPoints2(ResultChannelPoint);
097            //initialize nLast depending on the first 1 or 2 segments
098
099            //stuff the array
100            //nLast needs to indicate if the last segment2 had line1 above or below it
101            for(nPointCounter=1;nPointCounter < nCounter;nPointCounter++)
102            {
103                LinePoint1 = new POINT2(pLinePoints[nPointCounter-1]);
104                LinePoint2 = new POINT2(pLinePoints[nPointCounter]);
105                LinePoint3 = new POINT2(pLinePoints[nPointCounter+1]);
106                nDiff1X = LinePoint2.x - LinePoint1.x;
107                nDiff2X = LinePoint3.x - LinePoint2.x;
108                nDiff1Y = LinePoint2.y - LinePoint1.y;
109                nDiff2Y = LinePoint3.y - LinePoint2.y;
110
111                //determine nLast to use in the next iteration
112                //nLast=0: last segment2 was left to right and line1 above it
113                //nLast=1: last segment2 was left to right and line1 below it
114                //nLast=2: last segment2 was right to left and line1 above it
115                //nLast=3: last segment2 was right to left and line1 below it
116                //nLast=4: last segment2 was vertical upward and line1 above (to the left of it)
117                //nLast=5: last segment2 was vertical upward and line1 below (to the right of it)
118                //nLast=6: last segment2 was vertical downward and line1 above (to the left of it)
119                //nLast=7: last segment2 was vertical downward and line1 below (to the right of it)
120                if(nDiff1X>0 && nDiff2X>0)      //pt1------pt2------pt3
121                {
122                    switch(nLast)
123                    {
124                        case 0:
125                        case 3:
126                        case 4:
127                        case 7:
128                            lOrient=0;  //above & above
129                            break;
130                        case 1:
131                        case 2:
132                        case 5:
133                        case 6:
134                            lOrient=3;  //below & below
135                            break;
136                        default:
137                            break;
138                    }
139                }
140
141                //                                                              pt1-----pt2    or                  pt3
142                //                                                                              |                                       |
143                //                                                                              |                                       |
144                //                                                                              |                                       |
145                //                                                                              pt3                pt1-----pt2
146                if(nDiff1X>0 && nDiff2X==0)
147                {
148                    switch(nLast)
149                    {
150                        case 0:
151                        case 3:
152                        case 4:
153                        case 7:
154                            if(nDiff2Y>0)
155                                lOrient=1;      //above & below
156                            if(nDiff2Y<0)
157                                lOrient=0;      //above & above
158                            break;
159                        case 1:
160                        case 2:
161                        case 5:
162                        case 6:
163                            if(nDiff2Y>0)
164                                lOrient=2;
165                            if(nDiff2Y<0)
166                                lOrient=3;
167                            break;
168                        default:
169                            break;
170                    }
171                }
172
173                //                                                              pt2-----pt1    or   pt3
174                //                                                              |                                       |
175                //                                                              |                                       |
176                //                                                              |                                       |
177                //                                                              pt3                                     pt2-----pt1
178                if(nDiff1X<0 && nDiff2X==0)
179                {
180                    switch(nLast)
181                    {
182                        case 0:
183                        case 3:
184                        case 4:
185                        case 7:
186                            if(nDiff2Y>0)
187                                lOrient=3;
188                            if(nDiff2Y<0)
189                                lOrient=2;
190                            break;
191                        case 1:
192                        case 2:
193                        case 5:
194                        case 6:
195                            if(nDiff2Y>0)
196                                lOrient=0;
197                            if(nDiff2Y<0)
198                                lOrient=1;
199                            break;
200                        default:
201                            break;
202                    }
203                }
204
205                //                                                              pt2-----pt3    or   pt1
206                //                                                              |                                       |
207                //                                                              |                                       |
208                //                                                              |                                       |
209                //                                                              pt1                                     pt2-----pt3
210                if(nDiff1X==0 && nDiff2X>0)
211                {
212                    switch(nLast)
213                    {
214                        case 0:
215                        case 3:
216                        case 4:
217                        case 7:
218                            if(nDiff1Y>0)
219                                lOrient=2;
220                            if(nDiff1Y<0)
221                                lOrient=0;
222                            break;
223                        case 1:
224                        case 2:
225                        case 5:
226                        case 6:
227                            if(nDiff1Y>0)
228                                lOrient=1;
229                            if(nDiff1Y<0)
230                                lOrient=3;
231                            break;
232                        default:
233                            break;
234                    }
235                }
236
237                //                                              pt3-----pt2    or                       pt1
238                //                                                              |                                       |
239                //                                                              |                                       |
240                //                                                              |                                       |
241                //                                                              pt1                     pt3-----pt2
242                if(nDiff1X==0 && nDiff2X<0)
243                {
244                    switch(nLast)
245                    {
246                        case 0:
247                        case 3:
248                        case 4:
249                        case 7:
250                            if(nDiff1Y>0)
251                                lOrient=3;
252                            if(nDiff1Y<0)
253                                lOrient=1;
254                            break;
255                        case 1:
256                        case 2:
257                        case 5:
258                        case 6:
259                            if(nDiff1Y>0)
260                                lOrient=0;
261                            if(nDiff1Y<0)
262                                lOrient=2;
263                            break;
264                        default:
265                            break;
266                    }
267                }
268
269
270                if(nDiff1X<0 && nDiff2X<0)      //pt3-----pt2------pt1
271                {
272                    switch(nLast)
273                    {
274                        case 0:
275                        case 3:
276                        case 4:
277                        case 7:
278                            lOrient=3;  //below & below
279                            break;
280                        case 1:
281                        case 2:
282                        case 5:
283                        case 6:
284                            lOrient=0;  //above & above
285                            break;
286                        default:
287                            break;
288                    }
289                }
290
291                //      pt1\
292                //               \
293                //                 \pt2
294                //                 /
295                //           /
296                //  pt3/
297                if(nDiff1X>0 & nDiff2X<0)
298                {
299                    switch(nLast)
300                    {
301                        case 0:
302                        case 3:
303                        case 4:
304                        case 7:
305                            lOrient=1;  //above & below
306                            break;
307                        case 1:
308                        case 2:
309                        case 5:
310                        case 6:
311                            lOrient=2;  //below & above
312                            break;
313                        default:
314                            break;
315                    }
316                }
317
318                //                       pt1
319                //                 /
320                //               /
321                //      pt2/
322                //              \
323                //            \
324                //                  \pt3
325                if(nDiff1X<0 & nDiff2X>0)
326                {
327                    switch(nLast)
328                    {
329                        case 0:
330                        case 3:
331                        case 4:
332                        case 7:
333                            lOrient=2;  //below & above
334                            break;
335                        case 1:
336                        case 2:
337                        case 5:
338                        case 6:
339                            lOrient=1;  //above & below
340                            break;
341                        default:
342                            break;
343                    }   //end switch(nLast)
344                }       //end if
345
346
347                //                       pt1    or   pt3
348                //                    |                   |
349                //                        |               |
350                //                       pt2             pt2
351                //                    |                   |
352                //                |                       |
353                //                   pt3                 pt1
354                if(nDiff1X==0 && nDiff2X==0)
355                {
356                    switch(nLast)
357                    {
358                        case 4:
359                            if(nDiff2Y<0)
360                                lOrient=0;
361                            break;
362                        case 6:
363                            if(nDiff2Y>0)
364                                lOrient=0;
365                            break;
366                        case 5:
367                            if(nDiff2Y<0)
368                                lOrient=3;
369                            break;
370                        case 7:
371                            if(nDiff2Y>0)
372                                lOrient=3;
373                            break;
374                        default:
375                                break;
376                    }
377                }
378
379                //get the channel points based on the desired orientation
380                pResultChannelPoints[nPointCounter] = ConnectTrueDouble2(nWidth,LinePoint1,
381                        LinePoint2,LinePoint3,lOrient);
382
383                //2nd segment vertical
384                if(nDiff2X==0)
385                {
386                    switch (lOrient) {
387                        case 0:
388                            if (nDiff2Y > 0) {
389                                nLast = 6;
390                            }
391                            if (nDiff2Y < 0) {
392                                nLast = 4;
393                            }
394                            break;
395                        case 1:
396                            if (nDiff2Y > 0) {
397                                nLast = 7;
398                            }
399                            if (nDiff2Y < 0) {
400                                nLast = 5;
401                            }
402                            break;
403                        case 2:
404                            if (nDiff2Y > 0) {
405                                nLast = 6;
406                            }
407                            if (nDiff2Y < 0) {
408                                nLast = 4;
409                            }
410                            break;
411                        case 3:
412                            if (nDiff2Y > 0) {
413                                nLast = 7;
414                            }
415                            if (nDiff2Y < 0) {
416                                nLast = 5;
417                            }
418                            break;
419                        default:
420                            break;
421                    }
422                }
423                //pt2--------pt3
424                if (nDiff2X > 0) {
425                    switch (lOrient) {
426                        case 0: //above & above
427                            nLast = 0;
428                            break;
429                        case 1: //above & below
430                            nLast = 1;
431                            break;
432                        case 2: //below & above
433                            nLast = 0;
434                            break;
435                        case 3: //below & below
436                            nLast = 1;
437                            break;
438                        default:
439                            break;
440                    }
441                    //break;
442                }
443                //pt3--------pt2
444                if (nDiff2X < 0) {
445                    switch (lOrient) {
446                        case 0: //above & above
447                            nLast = 2;
448                            break;
449                        case 1: //above & below
450                            nLast = 3;
451                            break;
452                        case 2: //below & above
453                            nLast = 2;
454                            break;
455                        case 3: //below & below
456                            nLast = 3;
457                            break;
458                        default:
459                            break;
460                    }
461                }
462            }   //end for
463
464            ResultChannelPoint = GetTrueEndPointDouble(nWidth, pLinePoints[nCounter],
465                pLinePoints[nCounter - 1],nLast);
466
467            pResultChannelPoints[nCounter] = new CChannelPoints2(ResultChannelPoint);
468        }
469        catch(Exception exc)
470        {
471            //System.out.println(e.getMessage());
472            ErrorLogger.LogException(_className ,"ConnectArrayTrueDouble",
473                    new RendererException("Failed inside ConnectArrayTrueDouble", exc));
474        }
475        return pResultChannelPoints;
476    }
477    private static CChannelPoints2[] GetChannel2Double(long nChannelWidth,
478            long vblCounter,
479            POINT2[] pLinePoints,
480            CChannelPoints2[] pResultChannelPoints) {
481        try {
482            pResultChannelPoints = ConnectArrayTrueDouble((int) nChannelWidth / 2, (int) vblCounter - 1,
483                    pLinePoints, pResultChannelPoints);
484
485        }
486        catch (Exception exc) {
487            ErrorLogger.LogException(_className ,"GetChannel2Double",
488                    new RendererException("Failed inside GetChannel2Double", exc));
489        }
490        return pResultChannelPoints;
491    }
492    
493    private static POINT2[] GetLowerChannelLineDouble(CChannelPoints2[] pChannelPoints,
494            int vblCounter,
495            POINT2[] pResultLinePoints) throws Exception
496    {
497        try {
498            int j = 0;
499
500            for (j = 0; j < vblCounter; j++) {
501                pResultLinePoints[j] = new POINT2(pChannelPoints[j].m_Line1);
502            }
503
504        } catch (Exception exc) {
505            ErrorLogger.LogException(_className ,"GetLowerChannelLineDouble",
506                    new RendererException("GetLowerChannelLineDouble", exc));
507        }
508        return pResultLinePoints;
509    }
510    private static POINT2[] GetUpperChannelLineDouble(CChannelPoints2[] pChannelPoints,
511            int vblCounter,
512            POINT2[] pResultLinePoints) {
513        try {
514            int j;
515            for (j = 0; j < vblCounter; j++) {
516                pResultLinePoints[j] = new POINT2(pChannelPoints[j].m_Line2);
517            }
518
519        } catch (Exception exc) {
520            ErrorLogger.LogException(_className ,"GetUpperChannelLineDouble",
521                    new RendererException("Failed inside GetUpperChannelLineDouble", exc));
522        }
523        return pResultLinePoints;
524    }
525    private static int FenceType(int linetype) {
526        int bolResult = 0;
527        try {
528            switch (linetype) {
529                case TacticalLines.TRIPLE:
530                case TacticalLines.DOUBLEC:
531                case TacticalLines.SINGLEC:
532                case TacticalLines.HWFENCE:
533                case TacticalLines.LWFENCE:
534                case TacticalLines.UNSP:
535                case TacticalLines.DOUBLEA:
536                case TacticalLines.SFENCE:
537                case TacticalLines.DFENCE:
538                    bolResult = 1;
539                    break;
540                default:
541                    bolResult = 0;
542                    break;
543            }
544        } catch (Exception exc) {
545            ErrorLogger.LogException(_className ,"FenceType",
546                    new RendererException("Failed inside FenceType " + Integer.toString(linetype), exc));
547        }
548        return bolResult;
549    }
550    /**
551    * Calculates the point count for the concertina wire and fence channels.
552    *
553    * @param pLinePoints client points
554    * @param vblCounter the client point count
555    * @param linetype the line type
556    *
557    * @return the number of points required to render the symbol
558    */
559    protected static int GetTripleCountDouble(POINT2[] pLinePoints,
560            int vblCounter,
561            int linetype) {
562        int lTotal = 0;
563        try {
564            //declarations
565            int j = 0;
566            int lHowManyThisSegment = 0;
567            double d = 0;
568            //end declarations
569
570            for (j = 0; j < vblCounter - 1; j++) {
571                d = lineutility.CalcDistanceDouble(pLinePoints[j], pLinePoints[j + 1]);
572                if (d <= 10) {
573                    lHowManyThisSegment = 0;
574                } else {
575                    lHowManyThisSegment = (int) ((d - 10) / 10);
576                }
577
578                lTotal += lHowManyThisSegment;
579            }
580
581            switch (linetype) {
582                case TacticalLines.SINGLEC:
583                case TacticalLines.DOUBLEC:
584                case TacticalLines.TRIPLE:
585                    lTotal = 6 * vblCounter + 37 * lTotal;  //was 2*vblCounter+37*lTotal
586                    break;
587                case TacticalLines.HWFENCE:
588                case TacticalLines.LWFENCE:
589                case TacticalLines.UNSP:
590                case TacticalLines.DOUBLEA:
591                case TacticalLines.SFENCE:
592                case TacticalLines.DFENCE:
593                    lTotal = 4 * vblCounter + 4 * lTotal;
594                    break;
595                case TacticalLines.BBS_LINE:
596                    lTotal = 2 * vblCounter + 1;
597                    break;
598                default:
599                    lTotal = 2 * vblCounter;
600                    break;
601            }
602        } catch (Exception exc) {
603            ErrorLogger.LogException(_className ,"GetTripleCountDouble",
604                    new RendererException("Failed inside GetTripleCountDouble " + Integer.toString(linetype), exc));
605        }
606        return lTotal;
607    }
608
609    protected static POINT2[] CoordIL2Double(int nPrinter,
610            POINT2[] pLinePoints,
611            int nUpperLower,
612            int vblCounter,
613            int linetype,
614            int vblChannelWidth) {
615            POINT2[]pLinePoints2=new POINT2[vblCounter];
616        try {
617            //declarations
618            int j, channelWidth = 20;
619            POINT2[] pNewLinePoints = new POINT2[vblCounter];
620            CChannelPoints2[] pChannelPoints = new CChannelPoints2[vblCounter];
621            //end declarations
622
623            lineutility.InitializePOINT2Array(pLinePoints2);
624            for (j = 0; j < vblCounter; j++) {
625                pNewLinePoints[j] = new POINT2(pLinePoints[j]);
626            }
627
628            channelWidth = vblChannelWidth;
629
630            if (linetype != (long) TacticalLines.LC) {
631                channelWidth /= 2;
632            }
633
634            pChannelPoints = GetChannel2Double(channelWidth * nPrinter,
635                    vblCounter,
636                    pNewLinePoints,
637                    pChannelPoints);
638
639            if (nUpperLower == 1) {
640                pNewLinePoints = GetUpperChannelLineDouble(pChannelPoints,
641                        vblCounter,
642                        pNewLinePoints);
643
644                for (j = 0; j < vblCounter; j++) {
645                    pLinePoints2[j] = new POINT2(pNewLinePoints[j]);
646                }
647            }
648
649            if (nUpperLower == 0) {
650                pNewLinePoints = GetLowerChannelLineDouble(pChannelPoints,
651                        vblCounter,
652                        pNewLinePoints);
653
654                for (j = 0; j < vblCounter; j++) {
655                    pLinePoints2[j] = new POINT2(pNewLinePoints[j]);
656                }
657            }
658
659            //clean up
660            pNewLinePoints = null;
661            pChannelPoints = null;
662        } catch (Exception exc) {
663            ErrorLogger.LogException(_className ,"CoordIL2Double",
664                    new RendererException("Failed inside CoordIL2Double", exc));
665        }
666        return pLinePoints2;
667    }
668
669    /**
670     * gets the axis of advance arrowhead
671     * @param dPrinter
672     * @param pLowerLinePoints
673     * @param lLowerCounter
674     * @param pUpperLinePoints
675     * @param lUpperCounter
676     * @param ArrowLinePoint
677     * @param pLinePoints
678     * @param vbiDrawThis
679     * @param dOffsetFactor
680     */
681    private static void GetAXADDouble(double dPrinter,
682            POINT2[] pLowerLinePoints,
683            int lLowerCounter,
684            POINT2[] pUpperLinePoints,
685            int lUpperCounter,
686            POINT2 ArrowLinePoint,
687            POINT2[] pLinePoints,
688            int vbiDrawThis,
689            double dOffsetFactor) {
690        try {            
691            int j = 0,
692                    lCounter = lLowerCounter + lUpperCounter + 8;
693            double x = 0, y = 0;
694            POINT2 OuterTipLinePoint = new POINT2(pUpperLinePoints[0]),
695                    InnerTipLinePoint = new POINT2(pUpperLinePoints[0]),
696                    EndLinePoint = new POINT2(pUpperLinePoints[0]),
697                    TempLinePoint = new POINT2(pUpperLinePoints[0]);
698            POINT2 pt0 = new POINT2(), pt1 = new POINT2();
699            //double dOffsetFactor = 10;
700            //end declarations
701            
702            //10-19-12
703            //we must do this for catkbyfire because the rotary arrow tip now has to match the
704            //anchor point, i.e. the rotary feature can no longer stick out past the anchor point
705            //45 pixels shift here matches the 45 pixels shift for catkbyfire found in 
706            //lineutility.adjustCATKBYFIREControlPoint as called by clsChannelUtility.DrawChannel
707            POINT2 origArrowPt=new POINT2(ArrowLinePoint);
708            POINT2 ptUpper0=new POINT2(pUpperLinePoints[lUpperCounter-1]);
709            POINT2 ptLower0=new POINT2(pLowerLinePoints[lLowerCounter-1]);
710            double dist=lineutility.CalcDistanceDouble(pLowerLinePoints[lLowerCounter-1], pLowerLinePoints[lLowerCounter-2]);
711            if(vbiDrawThis==TacticalLines.CATKBYFIRE)
712            {
713                if(dist>45)
714                {
715                    POINT2 midPt=lineutility.MidPointDouble(pLowerLinePoints[lLowerCounter-2], pUpperLinePoints[lUpperCounter-2], 0);
716                    ArrowLinePoint=lineutility.ExtendAlongLineDouble(ArrowLinePoint, midPt, 45);
717                    pLowerLinePoints[lLowerCounter-1]=lineutility.ExtendAlongLineDouble(pLowerLinePoints[lLowerCounter-1], pLowerLinePoints[lLowerCounter-2], 45);//will be 45 if Oculus adjusts control point
718                    pUpperLinePoints[lUpperCounter-1]=lineutility.ExtendAlongLineDouble(pUpperLinePoints[lUpperCounter-1], pUpperLinePoints[lUpperCounter-2], 45);//will be 45 if Oculus adjusts control point
719                }
720            }
721            //end section
722
723            for (j = 0; j < lLowerCounter; j++) {
724                pLinePoints[j] = new POINT2(pLowerLinePoints[j]);
725            }
726
727            pLinePoints[lLowerCounter - 1].style = 5;
728
729            for (j = 0; j < lUpperCounter; j++) {
730                pLinePoints[lLowerCounter + j] = new POINT2(pUpperLinePoints[j]);
731            }
732
733            for (j = lCounter - 8; j < lCounter; j++) //initializations
734            {
735                pLinePoints[j] = new POINT2(pUpperLinePoints[0]);
736            }
737
738            EndLinePoint.x = (int) ((double) (pLowerLinePoints[lLowerCounter - 1].x +
739                    pUpperLinePoints[lUpperCounter - 1].x) / 2);
740
741            EndLinePoint.y = (int) ((double) (pLowerLinePoints[lLowerCounter - 1].y +
742                    pUpperLinePoints[lUpperCounter - 1].y) / 2);
743
744
745            x = (double) (pLowerLinePoints[lLowerCounter - 1].x - pUpperLinePoints[lUpperCounter - 1].x);
746            y = (double) (pLowerLinePoints[lLowerCounter - 1].y - pUpperLinePoints[lUpperCounter - 1].y);
747            x = x * x;
748            y = y * y;
749            //nBase = (int) Math.sqrt(x + y);
750
751            //nBase *= (int) dPrinter;
752
753            OuterTipLinePoint = new POINT2(ArrowLinePoint);
754            InnerTipLinePoint = lineutility.GetOffsetPointDouble(EndLinePoint, OuterTipLinePoint, -(int) (dOffsetFactor * dPrinter));
755            pLinePoints[lCounter - 9].style = 5;
756            pLinePoints[lCounter - 8] = new POINT2(OuterTipLinePoint);
757
758            pt0.x = pUpperLinePoints[lUpperCounter - 1].x;
759            pt0.y = pUpperLinePoints[lUpperCounter - 1].y;
760            pt1.x = pLowerLinePoints[lLowerCounter - 1].x;
761            pt1.y = pLowerLinePoints[lLowerCounter - 1].y;
762            TempLinePoint = lineutility.GetOffsetPointDouble(pt0, pt1, (int) (dOffsetFactor * dPrinter));
763
764            pLinePoints[lCounter - 7] = new POINT2(TempLinePoint);
765            pLinePoints[lCounter - 6] = new POINT2( pLowerLinePoints[lLowerCounter - 1]);
766            pLinePoints[lCounter - 5] =  new POINT2(InnerTipLinePoint);
767            pLinePoints[lCounter - 4] =  new POINT2(pUpperLinePoints[lUpperCounter - 1]);
768
769            pt0.x = pLowerLinePoints[lLowerCounter - 1].x;
770            pt0.y = pLowerLinePoints[lLowerCounter - 1].y;
771            pt1.x = pUpperLinePoints[lUpperCounter - 1].x;
772            pt1.y = pUpperLinePoints[lUpperCounter - 1].y;
773            TempLinePoint = lineutility.GetOffsetPointDouble(pt0, pt1, (int) (dOffsetFactor * dPrinter));
774
775            pLinePoints[lCounter - 3] =  new POINT2(TempLinePoint);
776            pLinePoints[lCounter - 2] =  new POINT2(OuterTipLinePoint);
777            pLinePoints[lCounter - 1] =  new POINT2(OuterTipLinePoint);
778            pLinePoints[lCounter - 1].style = 5;
779
780            switch (vbiDrawThis) {
781                case TacticalLines.SPT_STRAIGHT:
782                case TacticalLines.SPT:
783                case TacticalLines.FRONTAL_ATTACK:
784                case TacticalLines.TURNING_MOVEMENT:
785                case TacticalLines.MOVEMENT_TO_CONTACT:
786                case TacticalLines.AAAAA:
787                case TacticalLines.AIRAOA:
788                case TacticalLines.CATK:
789                case TacticalLines.CATKBYFIRE:
790                    pLinePoints[lCounter - 6].style = 5;
791                    pLinePoints[lCounter - 5].style = 5;
792                    break;
793                default:
794                    break;
795            }
796            
797            //10-19-12
798            //reset the original points after the hack for catkbyfire
799            if(vbiDrawThis==TacticalLines.CATKBYFIRE && dist>45)
800            {
801                pUpperLinePoints[lUpperCounter-1].x=ptUpper0.x;
802                pUpperLinePoints[lUpperCounter-1].y=ptUpper0.y;
803                pLowerLinePoints[lLowerCounter-1].x=ptLower0.x;
804                pLowerLinePoints[lLowerCounter-1].y=ptLower0.y;
805                ArrowLinePoint.x=origArrowPt.x;
806                ArrowLinePoint.y=origArrowPt.y;
807            }
808            //end section
809        } catch (Exception exc) {
810            ErrorLogger.LogException(_className ,"GetAXADDouble",
811                    new RendererException("Failed inside GetAXADDouble " + Integer.toString(vbiDrawThis), exc));
812        }
813    }
814    /**
815     * Calculates a channel line and is called once each time for lower and upper channel lines.
816     *
817     * @param nPrinter always 1
818     * @param pLinePoints client points
819     * @param nUpperLower 0 for lower channel line, 1 for upper channel line
820     * @param vblCounter the client point count
821     * @param vbiDrawThis the line type
822     * @param vblChannelWidth the channel width
823     *
824     * @return the channel line array as POINT2
825     */
826    protected static POINT2[] GetChannelArray2Double(int nPrinter,
827            POINT2[] pLinePoints,
828            int nUpperLower,
829            int vblCounter,
830            int vbiDrawThis,
831            int vblChannelWidth) {
832        try {
833            //get the upper or lower channel array for the specified channel type
834            switch (vbiDrawThis) {
835                case TacticalLines.LC:
836                case TacticalLines.AIRAOA:
837                case TacticalLines.AAAAA:
838                case TacticalLines.CATK:
839                case TacticalLines.CATKBYFIRE:
840                case TacticalLines.MAIN:
841                case TacticalLines.MAIN_STRAIGHT:
842                case TacticalLines.SPT:
843                case TacticalLines.SPT_STRAIGHT:
844                case TacticalLines.FRONTAL_ATTACK:
845                case TacticalLines.TURNING_MOVEMENT:
846                case TacticalLines.MOVEMENT_TO_CONTACT:
847                case TacticalLines.TRIPLE:
848                case TacticalLines.DOUBLEC:
849                case TacticalLines.SINGLEC:
850                case TacticalLines.HWFENCE:
851                case TacticalLines.BBS_LINE:
852                case TacticalLines.LWFENCE:
853                case TacticalLines.DOUBLEA:
854                case TacticalLines.UNSP:
855                case TacticalLines.SFENCE:
856                case TacticalLines.DFENCE:
857                case TacticalLines.CHANNEL:
858                case TacticalLines.CHANNEL_FLARED:
859                case TacticalLines.CHANNEL_DASHED:
860                    pLinePoints = CoordIL2Double(nPrinter, pLinePoints, nUpperLower, vblCounter, vbiDrawThis, vblChannelWidth);
861                    break;
862                default:
863                    //do nothing if it's not a channel type
864                    break;
865            }   //end switch
866
867        } catch (Exception exc) {
868            ErrorLogger.LogException(_className ,"GetChannelArray2Double",
869                    new RendererException("Failed inside GetChannelArray2Double " + Integer.toString(vbiDrawThis), exc));
870        }
871        return pLinePoints;
872    }
873
874    private static CChannelPoints2 GetTrueEndPointDouble(int nWidth,
875                                        POINT2 EndLinePoint,
876                                        POINT2 NextLinePoint,
877                                        int lLast)
878    {
879        CChannelPoints2 cAnswers=new CChannelPoints2();
880        try
881        {
882            //declarations
883            POINT2 LinePoint1=new POINT2(),LinePoint2=new POINT2();
884            double m = 0,
885                    b = 0,
886                    bPerpendicular = 0,
887                    Upperb = 0,
888                    Lowerb = 0,
889                    dWidth=(double)nWidth;
890            int bolVertical=0;
891            ref<double[]> pdResult=new ref();// double[6];
892            //end declarations
893
894            bolVertical=lineutility.CalcTrueLinesDouble(nWidth,EndLinePoint,NextLinePoint,pdResult);
895            m = pdResult.value[0];
896            b = pdResult.value[1];
897            Upperb = pdResult.value[3];
898            Lowerb = pdResult.value[5];
899
900            if(bolVertical==0)  //lines are vertical
901            {
902                switch(lLast)
903                {
904                    case 4:
905                    case 6:
906                        cAnswers.m_Line1.x=EndLinePoint.x-dWidth;
907                        cAnswers.m_Line1.y=EndLinePoint.y;
908                        cAnswers.m_Line2.x=EndLinePoint.x+dWidth;
909                        cAnswers.m_Line2.y=EndLinePoint.y;
910                        break;
911                    case 5:
912                    case 7:
913                        cAnswers.m_Line1.x=EndLinePoint.x+dWidth;
914                        cAnswers.m_Line1.y=EndLinePoint.y;
915                        cAnswers.m_Line2.x=EndLinePoint.x-dWidth;
916                        cAnswers.m_Line2.y=EndLinePoint.y;
917                        break;
918                    default:    //cases 0-3 should not occur if line is vertical
919                        break;
920                }
921            }
922
923            if(m==0)
924            {
925                switch(lLast)
926                {
927                    case 0:     //line1 is above segment2
928                    case 2:
929                        cAnswers.m_Line1.x=EndLinePoint.x;
930                        cAnswers.m_Line1.y=EndLinePoint.y-dWidth;
931                        cAnswers.m_Line2.x=EndLinePoint.x;
932                        cAnswers.m_Line2.y=EndLinePoint.y+dWidth;
933                        break;
934                    case 1:     //line1 is above segment2
935                    case 3:
936                        cAnswers.m_Line1.x=EndLinePoint.x;
937                        cAnswers.m_Line1.y=EndLinePoint.y+dWidth;
938                        cAnswers.m_Line2.x=EndLinePoint.x;
939                        cAnswers.m_Line2.y=EndLinePoint.y-dWidth;
940                        break;
941                    default:    //cases 4-7 should not be passed since line not vertical
942                        break;
943                }
944            }
945
946            //remaining cases, line is neither vertical nor horizontal
947            if(bolVertical!=0 && m!=0)  //lines are neither vertical nor horizontal
948            {
949                bPerpendicular = EndLinePoint.y + EndLinePoint.x / m;
950                LinePoint1=lineutility.CalcTrueIntersectDouble2(m,Upperb,-1/m,bPerpendicular,1,1,0,0);
951                LinePoint2=lineutility.CalcTrueIntersectDouble2(m,Lowerb,-1/m,bPerpendicular,1,1,0,0);
952
953                switch(lLast)
954                {
955                    case 0:     //line1 is above segment2
956                    case 2:
957                        if(LinePoint1.y<LinePoint2.y)
958                        {
959                            cAnswers.m_Line1=LinePoint1;
960                            cAnswers.m_Line2=LinePoint2;
961                        }
962                        else
963                        {
964                            cAnswers.m_Line1=LinePoint2;
965                            cAnswers.m_Line2=LinePoint1;
966                        }
967                        break;
968                    case 1:     //line1 is below segment2
969                    case 3:
970                        if(LinePoint1.y>LinePoint2.y)
971                        {
972                            cAnswers.m_Line1=LinePoint1;
973                            cAnswers.m_Line2=LinePoint2;
974                        }
975                        else
976                        {
977                            cAnswers.m_Line1=LinePoint2;
978                            cAnswers.m_Line2=LinePoint1;
979                        }
980                        break;
981                    default:    //cases1-4 should not occur since line is not vertical
982                        break;
983                }
984            }
985            pdResult=null;
986        }
987        catch(Exception exc)
988        {
989            ErrorLogger.LogException(_className ,"GetTrueEndPointDouble",
990                    new RendererException("Failed inside GetTrueEndPointDouble", exc));
991        }
992        return cAnswers;
993    }
994    private static CChannelPoints2 ConnectTrueDouble2(int nWidth,
995            POINT2  LinePoint1,
996            POINT2  LinePoint2,
997            POINT2  LinePoint3,
998            int  lOrient)
999    {
1000        CChannelPoints2 pAnswerLinePoints=new CChannelPoints2();
1001        try
1002        {
1003            //declarations
1004            double  m1 = 0,
1005                    b1 = 0,
1006                    m2 = 0,
1007                    b2 = 0,
1008                    Lowerb1 = 0,
1009                    Upperb1 = 0,
1010                    Lowerb2 = 0,
1011                    Upperb2 = 0,
1012                    dWidth=(double)nWidth;
1013
1014            ref<double[]> pdResult=new ref();//double[6];
1015            //pdResult.value=new double[6];
1016            //POINT2 AnswerLinePoint=new POINT2();
1017            int bolVerticalSlope1=0,bolVerticalSlope2=0;
1018            ref<double[]> x=new ref(),y=new ref();
1019            //end declarations
1020
1021            //Call CalcLines function for first two points (LinePoint1, LinePoint2)
1022            //and put parameters into the proper variables
1023            bolVerticalSlope1 = lineutility.CalcTrueLinesDouble(nWidth, LinePoint1, LinePoint2, pdResult);
1024            if(bolVerticalSlope1!=0)    //line is not vertical
1025            {
1026                m1 = pdResult.value[0];
1027                b1 = pdResult.value[1];
1028                Upperb1 = pdResult.value[5];
1029                Lowerb1 = pdResult.value[3];
1030            }
1031
1032            //Call CalcLines function for next two points (LinePoint2, LinePoint3)
1033            bolVerticalSlope2 = lineutility.CalcTrueLinesDouble(nWidth, LinePoint2, LinePoint3, pdResult);
1034            if(bolVerticalSlope2!=0)    //line is not vertical
1035            {
1036                m2 = pdResult.value[0];
1037                b2 = pdResult.value[1];
1038                Upperb2 = pdResult.value[5];
1039                Lowerb2 = pdResult.value[3];
1040            }
1041
1042            //must alter dWidth from the standard if bolVerticalSlope is 0.
1043            switch(lOrient)
1044            {
1045                case 0:
1046                    //line1 is above segment1 and above segment2
1047                    //use 0 for the orientation for Line 1
1048                    lineutility.CalcTrueIntersectDouble(m1,Upperb1,m2,Upperb2,LinePoint2,bolVerticalSlope1,bolVerticalSlope2,dWidth,0,x,y);
1049                    pAnswerLinePoints.m_Line1.x=x.value[0];
1050                    pAnswerLinePoints.m_Line1.y=y.value[0];
1051                    //line 2 point:     line2 is below segment1 and below segment2
1052                    //use 3 for the orientation for Line 2
1053                    lineutility.CalcTrueIntersectDouble(m1,Lowerb1,m2,Lowerb2,LinePoint2,bolVerticalSlope1,bolVerticalSlope2,dWidth,3,x,y);
1054                    pAnswerLinePoints.m_Line2.x=x.value[0];
1055                    pAnswerLinePoints.m_Line2.y=y.value[0];
1056                    break;
1057                case 1:
1058                    //line1 is above segment1 and below segment2
1059                    //use 1 for the orientation for Line 1
1060                    lineutility.CalcTrueIntersectDouble(m1,Upperb1,m2,Lowerb2,LinePoint2,bolVerticalSlope1,bolVerticalSlope2,dWidth,1,x,y);
1061                    pAnswerLinePoints.m_Line1.x=x.value[0];
1062                    pAnswerLinePoints.m_Line1.y=y.value[0];
1063                    //line2 is below segment1 and above segment2
1064                    //use 2 for the orientation for Line 2
1065                    lineutility.CalcTrueIntersectDouble(m1,Lowerb1,m2,Upperb2,LinePoint2,bolVerticalSlope1,bolVerticalSlope2,dWidth,2,x,y);
1066                    pAnswerLinePoints.m_Line2.x=x.value[0];
1067                    pAnswerLinePoints.m_Line2.y=y.value[0];
1068                    break;
1069                case 2:
1070                    //line1 is below segment1 and above segment2
1071                    //use 2 for the orientation for Line 1
1072                    lineutility.CalcTrueIntersectDouble(m1,Lowerb1,m2,Upperb2,LinePoint2,bolVerticalSlope1,bolVerticalSlope2,dWidth,2,x,y);
1073                    pAnswerLinePoints.m_Line1.x=x.value[0];
1074                    pAnswerLinePoints.m_Line1.y=y.value[0];
1075                    //line2 is above segment1 and below segment2
1076                    //use 1 for the orientation for Line 1
1077                    lineutility.CalcTrueIntersectDouble(m1,Upperb1,m2,Lowerb2,LinePoint2,bolVerticalSlope1,bolVerticalSlope2,dWidth,1,x,y);
1078                    pAnswerLinePoints.m_Line2.x=x.value[0];
1079                    pAnswerLinePoints.m_Line2.y=y.value[0];
1080                    break;
1081                case 3:
1082                    //line1 is below segment1 and below segment2
1083                    //use 3 for the orientation for Line 1
1084                    lineutility.CalcTrueIntersectDouble(m1,Lowerb1,m2,Lowerb2,LinePoint2,bolVerticalSlope1,bolVerticalSlope2,dWidth,3,x,y);
1085                    pAnswerLinePoints.m_Line1.x=x.value[0];
1086                    pAnswerLinePoints.m_Line1.y=y.value[0];
1087                    //line2 is above segment1 and above segment2
1088                    //use 0 for the orientation for Line 2
1089                    lineutility.CalcTrueIntersectDouble(m1,Upperb1,m2,Upperb2,LinePoint2,bolVerticalSlope1,bolVerticalSlope2,dWidth,0,x,y);
1090                    pAnswerLinePoints.m_Line2.x=x.value[0];
1091                    pAnswerLinePoints.m_Line2.y=y.value[0];
1092                    break;
1093                default:
1094                    break;
1095            }
1096            pdResult=null;
1097        }
1098        catch(Exception exc)
1099        {
1100            ErrorLogger.LogException(_className ,"ConnectTrueDouble2",
1101                    new RendererException("Failed inside ConnectTrueDouble2", exc));
1102        }
1103        return pAnswerLinePoints;
1104    }
1105    /*
1106     * Shift CounterAttack By Fire to not extend past the first point
1107     * @param vbiDrawThis
1108     * @param lpsaUpperVBPoints
1109     * @param vblLowerCounter
1110     * @param lpsaLowerVBPoints
1111     * @param vblUpperCounter 
1112     */
1113//    private static void shiftCATKBYFIREPoints(int vbiDrawThis,
1114//            double[] lpsaUpperVBPoints,
1115//            int vblLowerCounter,
1116//            double[] lpsaLowerVBPoints,
1117//            int vblUpperCounter)
1118//    {
1119//        try
1120//        {
1121//            if(vbiDrawThis != TacticalLines.CATKBYFIRE)
1122//                return;
1123//
1124//            POINT2 nextToLastPoint=new POINT2(lpsaUpperVBPoints[vblUpperCounter-4],lpsaUpperVBPoints[vblUpperCounter-3]);
1125//            POINT2 lastPoint=new POINT2(lpsaUpperVBPoints[vblUpperCounter-2],lpsaUpperVBPoints[vblUpperCounter-1]);
1126//            double dist=lineutility.CalcDistanceDouble(lastPoint, nextToLastPoint);
1127//            
1128//            if(dist<45)
1129//            {
1130//                nextToLastPoint=lineutility.ExtendAlongLineDouble(lastPoint,nextToLastPoint,45+2*dist);
1131//                lastPoint=lineutility.ExtendLineDouble(nextToLastPoint,lastPoint, -45);
1132//                lpsaUpperVBPoints[vblUpperCounter-4]=nextToLastPoint.x;
1133//                lpsaUpperVBPoints[vblUpperCounter-3]=nextToLastPoint.y;
1134//                lpsaLowerVBPoints[vblLowerCounter-4]=nextToLastPoint.x;
1135//                lpsaLowerVBPoints[vblLowerCounter-3]=nextToLastPoint.y;                                    
1136//            }
1137//            //lastPoint=lineutility.ExtendAlongLineDouble(lastPoint, nextToLastPoint, 45);
1138//            else
1139//                lastPoint=lineutility.ExtendLineDouble(nextToLastPoint,lastPoint, -45);
1140//            
1141//            lpsaUpperVBPoints[vblUpperCounter-2]=lastPoint.x;
1142//            lpsaUpperVBPoints[vblUpperCounter-1]=lastPoint.y;
1143//            lpsaLowerVBPoints[vblLowerCounter-2]=lastPoint.x;
1144//            lpsaLowerVBPoints[vblLowerCounter-1]=lastPoint.y;                                    
1145//        }
1146//        catch(Exception exc)
1147//        {
1148//            ErrorLogger.LogException(_className ,"ShiftCATKBYFIREPoints",
1149//                    new RendererException("Failed inside ShiftCATKBYFIREPoints", exc));
1150//        }
1151//    }
1152    /*
1153     * tester function to shift counterattack by fire point back to account for
1154     * aligning the rotary arrow tip with the anchor point. the feature used to extend past 
1155     * the anchor so the control point was shove forward. Intended to be called by the tester.
1156     * note: this function is not used by the CPOF client, it is for tester use only
1157     * @param linetype line type
1158     * @param pLinePoints
1159     * @param shift amount to shift back the existing control point
1160     */
1161//    public static void shiftCATKBYFIREControlPoint(
1162//            int linetype,
1163//            ArrayList<POINT2>pLinePoints,
1164//            double shift)
1165//    {
1166//        try
1167//        {
1168//            if(linetype != TacticalLines.CATKBYFIRE)
1169//                return;
1170//            int controlPtIndex=pLinePoints.size()-1;
1171//            POINT2 pt0=pLinePoints.get(0);
1172//            POINT2 pt1=pLinePoints.get(1);
1173//            double dist=lineutility.CalcDistanceDouble(pLinePoints.get(0), pLinePoints.get(1));
1174//            if(dist<=45)
1175//                return;
1176//            POINT2 controlPt=pLinePoints.get(controlPtIndex);
1177//            //pt3 is the point on parallel line which contains the control point and corresponds to,
1178//            //i.e. is perpendicular to, pt0.
1179//            POINT2 pt3=lineutility.PointRelativeToLine(pt0, pt1, pt0, controlPt);
1180//            //pt4 will be the shifted control point
1181//            POINT2 pt4=lineutility.ExtendLineDouble(pt3, controlPt, shift);
1182//            //set the control point as the new shifted control point
1183//            pLinePoints.set(controlPtIndex, pt4);
1184//        }
1185//        catch(Exception exc)
1186//        {
1187//            ErrorLogger.LogException(_className ,"shiftCATKBYFIREControlPoint",
1188//                    new RendererException("Failed inside shiftCATKBYFIREControlPoint", exc));
1189//        }
1190//    }
1191    /**
1192     * Calculates the channel points
1193     * @param lpsaUpperVBPoints the client points as 2-tuples
1194     * @param lpsaLowerVBPoints the client points as 2 tuples
1195     * @param resultVBPoints the result points as 3-tuples x,y,linestyle
1196     * @param vblUpperCounter the number of client 2-tuples
1197     * @param vblLowerCounter the number of client 2-tuples
1198     * @param vblChannelWidth the channel width in pixels
1199     * @param useptr the distance in pixels from the arrow tip to the back of the arrowhead
1200     * @param shapes the ShapeInfo array, each object contains the GeneralPath
1201     * @return
1202     */
1203    public static int GetChannel1Double(TGLight tg,
1204            double[] lpsaUpperVBPoints,
1205            double[] lpsaLowerVBPoints,
1206            double[] resultVBPoints,
1207            int vblUpperCounter,
1208            int vblLowerCounter,
1209            int vblChannelWidth,
1210            int useptr,
1211            ArrayList<Shape2>shapes) {
1212        int lResult = -1;
1213        try {
1214            int vbiDrawThis = tg.get_LineType();
1215            int k = 0, vblCounter = 0;
1216            int nPrinter = 1,
1217                    nArrowSize = 40 * nPrinter,
1218                    max = 0;
1219            double dist = 0,remainder=0;
1220            int vblUpperCounter2 = vblUpperCounter, vblLowerCounter2 = vblLowerCounter;
1221            int nReverseUpper = 0;
1222            int lUpperFlotCount = 0, lLowerFlotCount = 0;
1223            int nLowerCounter = 0, lUpperCounter = 0, lResultCounter = 0;
1224            int XCounter = 0;
1225            int j = 0, lHowManyThisSegment = 0, l = 0, t = 0;
1226            double pi = Math.PI, dAngle = 0, d = 0;
1227            double a = 13;//13;
1228            double b = 6;  //6;
1229            double dFactor = 0;
1230            int lEllipseCounter = 0;
1231            //double arrowOffsetFactor = 10;
1232            double arrowOffsetFactor = vblChannelWidth/4;  //diagnostic was 10
1233            POINT2[] pLowerLinePoints = new POINT2[vblLowerCounter],
1234                    pUpperLinePoints = new POINT2[vblUpperCounter],
1235                    pArrowLinePoints = new POINT2[1],
1236                    pLinePoints = null,
1237                    pUpperFlotPoints = null, pLowerFlotPoints = null, pOriginalLinePoints = null, pOriginalLinePoints2 = null;
1238            lineutility.InitializePOINT2Array(pLowerLinePoints);
1239            lineutility.InitializePOINT2Array(pUpperLinePoints);
1240            lineutility.InitializePOINT2Array(pArrowLinePoints);
1241
1242            POINT2 pt1 = new POINT2(), pt2 = new POINT2(), pt3 = new POINT2(), pt4 = new POINT2(), midPt1 = new POINT2(), midPt2 = new POINT2(), pt0 = new POINT2();
1243            POINT2[] arrowPts = new POINT2[3];
1244            //POINT2 startLinePoint = new POINT2();
1245            POINT2[] XPoints = new POINT2[4], pEllipsePoints2 = new POINT2[37];
1246            lineutility.InitializePOINT2Array(XPoints);
1247            lineutility.InitializePOINT2Array(pEllipsePoints2);
1248
1249            //POINT2 endLinePoint = new POINT2();
1250            POINT2 temp1LinePoint = new POINT2(), ptCenter = new POINT2(pLowerLinePoints[0]),
1251                    temp2LinePoint = new POINT2();
1252            POINT2 lastPoint = new POINT2(), nextToLastPoint = new POINT2();    //used by CATKBYFIRE
1253            //end declarations
1254
1255            //initializations
1256            if (vblChannelWidth < 5 && vbiDrawThis != TacticalLines.BBS_LINE) {
1257                vblChannelWidth = 5;
1258            }
1259
1260            if (vblLowerCounter < 2 || vblUpperCounter < 2) {
1261                return -1;
1262            }
1263
1264            //shiftCATKBYFIREPoints(vbiDrawThis,lpsaUpperVBPoints,lpsaUpperVBPoints.length,lpsaLowerVBPoints,lpsaLowerVBPoints.length);
1265            //load client points
1266            for (k = 0; k < (long) vblLowerCounter; k++) {
1267                pLowerLinePoints[k].x = lpsaLowerVBPoints[nLowerCounter];
1268                nLowerCounter++;
1269                pLowerLinePoints[k].y = lpsaLowerVBPoints[nLowerCounter];
1270                nLowerCounter++;
1271                if (k == vblLowerCounter - 2) {
1272                    nextToLastPoint.x = pLowerLinePoints[k].x;
1273                    nextToLastPoint.y = pLowerLinePoints[k].y;
1274                }
1275                if (k == vblLowerCounter - 1) {
1276                    lastPoint.x = pLowerLinePoints[k].x;
1277                    lastPoint.y = pLowerLinePoints[k].y;
1278                }
1279                pLowerLinePoints[k].style = 0;
1280            }
1281            nLowerCounter = 0;
1282
1283            double lastSegmentLength = lineutility.CalcDistanceDouble(lastPoint, nextToLastPoint);
1284
1285            for (k = 0; k < (long) vblUpperCounter; k++) {
1286                pUpperLinePoints[k].x = lpsaUpperVBPoints[lUpperCounter];
1287                lUpperCounter++;
1288                pUpperLinePoints[k].y = lpsaUpperVBPoints[lUpperCounter];
1289                lUpperCounter++;
1290                pUpperLinePoints[k].style = 0;
1291            }
1292            lUpperCounter = 0;
1293            pArrowLinePoints[0] = new POINT2(pUpperLinePoints[vblUpperCounter - 1]);
1294            //end load client points
1295
1296            pt0 = new POINT2(pLowerLinePoints[0]);
1297            //diagnostic 1-7-13            
1298            boolean shiftLines=_shiftLines;
1299            switch(vbiDrawThis)
1300            {
1301                case TacticalLines.LC:
1302                case TacticalLines.UNSP:
1303                case TacticalLines.LWFENCE:
1304                case TacticalLines.HWFENCE:
1305                case TacticalLines.SINGLEC:
1306                case TacticalLines.DOUBLEC:
1307                case TacticalLines.TRIPLE:
1308                    break;
1309                default:
1310                    shiftLines=false;
1311                    break;
1312            }
1313            //end section
1314            
1315            switch (vbiDrawThis) {
1316                case TacticalLines.CATK:
1317                case TacticalLines.AIRAOA:
1318                case TacticalLines.AAAAA:
1319                case TacticalLines.SPT:
1320                case TacticalLines.SPT_STRAIGHT:
1321                case TacticalLines.FRONTAL_ATTACK:
1322                case TacticalLines.TURNING_MOVEMENT:
1323                case TacticalLines.MOVEMENT_TO_CONTACT:
1324                case TacticalLines.MAIN:
1325                case TacticalLines.MAIN_STRAIGHT:
1326                case TacticalLines.CATKBYFIRE:  //80
1327                    dist = (double) useptr;
1328
1329                    nArrowSize = (int) Math.sqrt(dist * dist + vblChannelWidth / 2 * vblChannelWidth / 2);
1330                    //nArrowSize = (int) Math.sqrt(dist * dist + vblChannelWidth * vblChannelWidth);
1331                    //lineutility.WriteFile(Integer.toString(nArrowSize));
1332                    
1333                    pUpperLinePoints[vblUpperCounter - 1] = lineutility.ExtendAlongLineDouble(pUpperLinePoints[vblUpperCounter - 1], pUpperLinePoints[vblUpperCounter - 2], dist);
1334                    pLowerLinePoints[vblLowerCounter - 1] = lineutility.ExtendAlongLineDouble(pLowerLinePoints[vblLowerCounter - 1], pLowerLinePoints[vblLowerCounter - 2], dist);
1335                    break;
1336                default:
1337                    break;
1338            }
1339            //end section
1340
1341            temp1LinePoint = new POINT2(pLowerLinePoints[0]);
1342            temp2LinePoint = new POINT2(pUpperLinePoints[0]);
1343
1344            //get the channel array
1345            switch (vbiDrawThis) {
1346                case TacticalLines.MAIN:
1347                case TacticalLines.MAIN_STRAIGHT:
1348                case TacticalLines.SPT:
1349                case TacticalLines.SPT_STRAIGHT:
1350                case TacticalLines.FRONTAL_ATTACK:
1351                case TacticalLines.TURNING_MOVEMENT:
1352                case TacticalLines.MOVEMENT_TO_CONTACT:
1353                case TacticalLines.CATK:
1354                case TacticalLines.CATKBYFIRE:
1355                case TacticalLines.TRIPLE:
1356                case TacticalLines.DOUBLEC:
1357                case TacticalLines.SINGLEC:
1358                case TacticalLines.HWFENCE:
1359                case TacticalLines.BBS_LINE:
1360                case TacticalLines.LWFENCE:
1361                case TacticalLines.UNSP:
1362                case TacticalLines.DOUBLEA:
1363                case TacticalLines.DFENCE:
1364                case TacticalLines.SFENCE:
1365                case TacticalLines.CHANNEL:
1366                case TacticalLines.CHANNEL_FLARED:
1367                case TacticalLines.CHANNEL_DASHED:
1368                    vblCounter = GetTripleCountDouble(pUpperLinePoints, vblUpperCounter, vbiDrawThis);
1369                    //save the original line points for later
1370                    pOriginalLinePoints = new POINT2[vblUpperCounter];
1371                    for (k = 0; k < vblUpperCounter; k++) {
1372                        pOriginalLinePoints[k] = new POINT2(pUpperLinePoints[k]);
1373                    }
1374                    pOriginalLinePoints2 = new POINT2[vblUpperCounter];
1375                    for (k = 0; k < vblUpperCounter; k++) {
1376                        pOriginalLinePoints2[k] = new POINT2(pUpperLinePoints[k]);
1377                    }
1378                    //bound the points
1379                    switch (vbiDrawThis) {
1380                        case TacticalLines.TRIPLE:
1381                        case TacticalLines.DOUBLEC:
1382                        case TacticalLines.SINGLEC:
1383                        case TacticalLines.HWFENCE:
1384                        case TacticalLines.BBS_LINE:
1385                        case TacticalLines.LWFENCE:
1386                        case TacticalLines.UNSP:
1387                        case TacticalLines.DOUBLEA:
1388                        case TacticalLines.DFENCE:
1389                        case TacticalLines.SFENCE:
1390                            pLowerLinePoints = new POINT2[vblLowerCounter];
1391                            for (k = 0; k < vblLowerCounter2; k++) {
1392                                pLowerLinePoints[k] = new POINT2(pOriginalLinePoints[k]);
1393                            }
1394
1395                            pUpperLinePoints = new POINT2[vblUpperCounter];
1396                            for (k = 0; k < vblUpperCounter2; k++) {
1397                                pUpperLinePoints[k] = new POINT2(pOriginalLinePoints[k]);
1398                            }
1399                            pOriginalLinePoints = new POINT2[vblUpperCounter];
1400                            for (k = 0; k < vblUpperCounter2; k++) {
1401                                pOriginalLinePoints[k] = new POINT2(pOriginalLinePoints2[k]);
1402                            }                            
1403                            break;
1404                        default:
1405                            //do not bound the points
1406                            break;
1407                    }
1408                    lineutility.moveSingleCPixels(vbiDrawThis, pUpperLinePoints);
1409                    lineutility.moveSingleCPixels(vbiDrawThis, pLowerLinePoints);
1410                    lineutility.MoveChannelPixels(pUpperLinePoints);
1411                    lineutility.MoveChannelPixels(pLowerLinePoints);
1412                    
1413                    //diagnostic 1-7-13
1414                    //if(_shiftLines && vbiDrawThis != TacticalLines.DOUBLEC)
1415                    if(shiftLines)
1416                        vblChannelWidth *=2;
1417                    //end section
1418                    
1419                    pUpperLinePoints = GetChannelArray2Double(nPrinter, pUpperLinePoints, 1, vblUpperCounter, vbiDrawThis, vblChannelWidth);
1420                    pLowerLinePoints = GetChannelArray2Double(nPrinter, pLowerLinePoints, 0, vblLowerCounter, vbiDrawThis, vblChannelWidth);
1421                    
1422                    //diagnostic 1-7-13
1423                    if(shiftLines)
1424                    {
1425                        //if(vbiDrawThis != TacticalLines.SINGLEC && vbiDrawThis != TacticalLines.DOUBLEC)
1426                          //  pUpperLinePoints=pOriginalLinePoints;
1427                        if(vbiDrawThis == TacticalLines.SINGLEC)                        
1428                            pLowerLinePoints=pOriginalLinePoints;                        
1429                        else if(vbiDrawThis == TacticalLines.DOUBLEC)                        
1430                        {
1431                            for(j=0;j<pUpperLinePoints.length;j++)
1432                            {
1433                                pUpperLinePoints[j]=lineutility.MidPointDouble(pLowerLinePoints[j], pOriginalLinePoints[j], 0);
1434                            }
1435                            //pOriginalLinePoints=pLowerLinePoints.clone();
1436                        }
1437                        else if(vbiDrawThis == TacticalLines.TRIPLE)                        
1438                            pUpperLinePoints=pOriginalLinePoints;                        
1439                        else
1440                            pUpperLinePoints=pOriginalLinePoints;                        
1441                    }
1442                    break;
1443                case TacticalLines.LC:
1444                    if(shiftLines) {
1445                        pOriginalLinePoints = new POINT2[vblUpperCounter];
1446                        for (k = 0; k < vblUpperCounter; k++) {
1447                            pOriginalLinePoints[k] = new POINT2(pUpperLinePoints[k]);
1448                        }
1449                        vblChannelWidth *= 2;
1450                    }
1451                    
1452                    pUpperLinePoints = GetChannelArray2Double(nPrinter, pUpperLinePoints, 1, vblUpperCounter, vbiDrawThis, vblChannelWidth);
1453                    pLowerLinePoints = GetChannelArray2Double(nPrinter, pLowerLinePoints, 0, vblLowerCounter, vbiDrawThis, vblChannelWidth);
1454                    
1455                    if(shiftLines)   
1456                    {                        
1457                        pUpperLinePoints=pOriginalLinePoints;
1458                    }
1459                    
1460                    if ((pUpperLinePoints[0].x > pUpperLinePoints[1].x) && (pUpperLinePoints[0].y != pUpperLinePoints[1].y)) {
1461                        nReverseUpper = 1;
1462                        lineutility.ReversePointsDouble2(pLowerLinePoints, vblLowerCounter);
1463                    } else if ((pUpperLinePoints[0].x > pUpperLinePoints[1].x) && (pUpperLinePoints[0].y == pUpperLinePoints[1].y)) {
1464                        nReverseUpper = 0;
1465                        lineutility.ReversePointsDouble2(pUpperLinePoints, vblUpperCounter);
1466                    } else if (pUpperLinePoints[0].x < pUpperLinePoints[1].x) {
1467                        nReverseUpper = 1;
1468                        lineutility.ReversePointsDouble2(pLowerLinePoints, vblLowerCounter);
1469                    } else if ((pUpperLinePoints[0].y > pUpperLinePoints[1].y) && (pUpperLinePoints[0].x == pUpperLinePoints[1].x)) {
1470                        nReverseUpper = 1;
1471                        lineutility.ReversePointsDouble2(pLowerLinePoints, vblLowerCounter);
1472                    } else if ((pUpperLinePoints[0].y < pUpperLinePoints[1].y) && (pUpperLinePoints[0].x == pUpperLinePoints[1].x)) {
1473                        nReverseUpper = 0;
1474                        lineutility.ReversePointsDouble2(pUpperLinePoints, vblUpperCounter);
1475                    }
1476                    break;
1477                case TacticalLines.AAAAA:
1478                case TacticalLines.AIRAOA:
1479                    pOriginalLinePoints = new POINT2[vblUpperCounter];
1480                    for (k = 0; k < vblUpperCounter; k++) {
1481                        pOriginalLinePoints[k] = new POINT2(pUpperLinePoints[k]);
1482                    }
1483                    pUpperLinePoints = GetChannelArray2Double(nPrinter, pUpperLinePoints, 1, vblUpperCounter, vbiDrawThis, vblChannelWidth);
1484                    pLowerLinePoints = GetChannelArray2Double(nPrinter, pLowerLinePoints, 0, vblLowerCounter, vbiDrawThis, vblChannelWidth);
1485
1486
1487            //end section
1488                    //only allow the lines to cross if there is enough room
1489                    //if (lastSegmentLength > vblChannelWidth / 2)
1490                    //{
1491                        temp1LinePoint = new POINT2(pLowerLinePoints[vblLowerCounter - 1]);
1492                        temp2LinePoint = new POINT2(pUpperLinePoints[vblUpperCounter - 1]);
1493                        pLowerLinePoints[vblLowerCounter - 1] = new POINT2(temp2LinePoint);
1494                        pUpperLinePoints[vblUpperCounter - 1] = new POINT2(temp1LinePoint);
1495                    //}
1496                    break;
1497                default:
1498                    break;
1499            }   //end get channel array
1500            //load channel array into pLinePoints
1501            switch (vbiDrawThis) {
1502                case TacticalLines.LC:
1503                    lUpperFlotCount = flot.GetFlotCountDouble(pUpperLinePoints, arraysupport.getScaledSize(20, tg.get_LineThickness(), tg.get_patternScale()), vblUpperCounter);
1504                    lLowerFlotCount = flot.GetFlotCountDouble(pLowerLinePoints, arraysupport.getScaledSize(20, tg.get_LineThickness(), tg.get_patternScale()), vblLowerCounter);
1505                    if (lUpperFlotCount <= 0 || lLowerFlotCount <= 0) {
1506                        return 0;
1507                    }
1508                    //vblCounter = lUpperFlotCount + lLowerFlotCount;
1509
1510                    max = vblUpperCounter;
1511                    if (max < lUpperFlotCount) {
1512                        max = lUpperFlotCount;
1513                    }
1514                    pUpperFlotPoints = new POINT2[max];
1515                    lineutility.InitializePOINT2Array(pUpperFlotPoints);
1516                    max = vblLowerCounter;
1517                    if (max < lLowerFlotCount) {
1518                        max = lLowerFlotCount;
1519                    }
1520                    pLowerFlotPoints = new POINT2[max];
1521                    lineutility.InitializePOINT2Array(pLowerFlotPoints);
1522                    for (k = 0; k < vblUpperCounter; k++) {
1523                        pUpperFlotPoints[k] = new POINT2(pUpperLinePoints[k]);
1524                    }
1525                    for (k = 0; k < vblLowerCounter; k++) {
1526                        pLowerFlotPoints[k] = new POINT2(pLowerLinePoints[k]);
1527                    }
1528
1529                    lUpperFlotCount = flot.GetFlotDouble(pUpperFlotPoints, arraysupport.getScaledSize(20, tg.get_LineThickness(), tg.get_patternScale()), vblUpperCounter);     //6/24/04
1530                    lLowerFlotCount = flot.GetFlotDouble(pLowerFlotPoints, arraysupport.getScaledSize(20, tg.get_LineThickness(), tg.get_patternScale()), vblLowerCounter);     //6/24/04
1531                    pLinePoints = new POINT2[lUpperFlotCount + lLowerFlotCount];
1532                    lineutility.InitializePOINT2Array(pLinePoints);
1533
1534                    vblCounter = lLowerFlotCount + lUpperFlotCount;
1535
1536                    if (nReverseUpper == 1) {
1537                        for (k = 0; k < lUpperFlotCount; k++) {
1538                            pLinePoints[k] = new POINT2(pUpperFlotPoints[k]);
1539                            pLinePoints[k].style = 25;  //was 26
1540                        }
1541                        //added one line M. Deutch 4-22-02
1542                        if (lUpperFlotCount > 0) {
1543                            pLinePoints[lUpperFlotCount - 1].style = 5;
1544                        }
1545                        for (k = 0; k < lLowerFlotCount; k++) {
1546                            pLinePoints[k + lUpperFlotCount] = new POINT2(pLowerFlotPoints[k]);
1547                            pLinePoints[k + lUpperFlotCount].style = 26;    //was 0
1548                        }
1549                        if (lUpperFlotCount+lLowerFlotCount > 0) {
1550                            pLinePoints[lUpperFlotCount+lLowerFlotCount - 1].style = 5;}
1551                    }
1552                    if (nReverseUpper == 0) {
1553                        for (k = 0; k < lUpperFlotCount; k++) {
1554                            pLinePoints[k] = new POINT2(pUpperFlotPoints[k]);
1555                            pLinePoints[k].style = 26;  //was 0
1556                        }
1557                        if(lUpperFlotCount>0)
1558                            pLinePoints[lUpperFlotCount - 1].style = 5;
1559
1560                        for (k = 0; k < lLowerFlotCount; k++) {
1561                            pLinePoints[k + lUpperFlotCount] = new POINT2(pLowerFlotPoints[k]);
1562                            pLinePoints[k + lUpperFlotCount].style = 25;    //was 26
1563                        }
1564                        if(lUpperFlotCount+lLowerFlotCount>0)
1565                            pLinePoints[lUpperFlotCount+lLowerFlotCount - 1].style = 5;
1566                    }
1567                    break;
1568                case TacticalLines.TRIPLE:
1569                case TacticalLines.DOUBLEC:
1570                case TacticalLines.SINGLEC:
1571                case TacticalLines.HWFENCE:
1572                case TacticalLines.LWFENCE:
1573                case TacticalLines.UNSP:
1574                case TacticalLines.DOUBLEA:
1575                case TacticalLines.SFENCE:
1576                case TacticalLines.DFENCE:
1577                case TacticalLines.CHANNEL:
1578                case TacticalLines.CHANNEL_FLARED:
1579                case TacticalLines.CHANNEL_DASHED:
1580                    //load the channel points
1581                    pLinePoints = new POINT2[vblCounter];
1582                    lineutility.InitializePOINT2Array(pLinePoints);
1583                    //initialize points
1584                    for (j = 0; j < pLinePoints.length; j++) {
1585                        pLinePoints[j].x = lpsaUpperVBPoints[0];
1586                        pLinePoints[j].y = lpsaUpperVBPoints[1];
1587                    }
1588                    switch (vbiDrawThis) {
1589                        case TacticalLines.TRIPLE:
1590                        case TacticalLines.HWFENCE:
1591                        case TacticalLines.CHANNEL:
1592                        case TacticalLines.CHANNEL_FLARED:
1593                        case TacticalLines.CHANNEL_DASHED:
1594                        case TacticalLines.SINGLEC:   //added 7-10-07
1595                            for (k = 0; k < vblLowerCounter; k++) 
1596                            {
1597                                pLinePoints[k] = new POINT2(pLowerLinePoints[k]);   //don't shift here
1598                            }
1599                            break;
1600                        case TacticalLines.DOUBLEC:
1601                            if (pOriginalLinePoints[0].x < pOriginalLinePoints[1].x) 
1602                            {
1603                                for (k = 0; k < vblLowerCounter; k++) 
1604                                {
1605                                    pLinePoints[k] = new POINT2(pOriginalLinePoints[k]);
1606                                }
1607                            } 
1608                            else 
1609                            {
1610                                for (k = 0; k < vblLowerCounter; k++) 
1611                                {
1612                                    pLinePoints[k] = new POINT2(pUpperLinePoints[k]);
1613                                }
1614                            }
1615                            break;
1616
1617                        case TacticalLines.LWFENCE:
1618                            for (k = 0; k < vblLowerCounter; k++) {
1619                                pLinePoints[k] = new POINT2(pOriginalLinePoints[k]);
1620                                pLinePoints[k].style = 5;
1621                                }
1622                            break;
1623                        case TacticalLines.UNSP:
1624                            for (k = 0; k < vblLowerCounter; k++) {
1625                                pLinePoints[k] = new POINT2(pOriginalLinePoints[k]);
1626                                pLinePoints[k].style = 5;
1627                            }
1628                            break;
1629                        case TacticalLines.DOUBLEA:
1630                            for (k = 0; k < vblLowerCounter; k++) {
1631                                pLinePoints[k] = new POINT2(pOriginalLinePoints[k]);
1632                            }
1633                            break;
1634                        default:
1635                            for (k = 0; k < vblLowerCounter; k++) {
1636                                pLinePoints[k] = new POINT2(pOriginalLinePoints[k]);
1637                            }
1638                            break;
1639                    }
1640                    pLinePoints[vblLowerCounter - 1].style = 5;
1641
1642                    switch (vbiDrawThis) {
1643                        case TacticalLines.TRIPLE:
1644                        case TacticalLines.HWFENCE:
1645                        case TacticalLines.CHANNEL:
1646                        case TacticalLines.CHANNEL_FLARED:
1647                        case TacticalLines.CHANNEL_DASHED:
1648                            for (k = 0; k < vblUpperCounter; k++) {
1649                                pLinePoints[vblLowerCounter + k] = new POINT2(pUpperLinePoints[k]);
1650                            }
1651                            break;
1652                        case TacticalLines.DOUBLEC:
1653                            if (pOriginalLinePoints[0].x < pOriginalLinePoints[1].x) 
1654                            {
1655                                for (k = 0; k < vblUpperCounter; k++) 
1656                                {
1657                                    pLinePoints[vblLowerCounter + k] = new POINT2(pUpperLinePoints[k]);
1658                                }
1659                            } 
1660                            else 
1661                            {
1662                                for (k = 0; k < vblUpperCounter; k++) 
1663                                {
1664                                    pLinePoints[vblLowerCounter + k] = new POINT2(pOriginalLinePoints[k]);
1665                                }
1666                            }
1667                            break;
1668                        case TacticalLines.SINGLEC:
1669                            for (k = 0; k < vblUpperCounter; k++) {
1670                                //pLinePoints[vblLowerCounter + k] = pOriginalLinePoints[k];    //revised 7-10-07
1671                                pLinePoints[vblLowerCounter + k] = new POINT2(pLowerLinePoints[k]);
1672                            }
1673                            break;
1674                        case TacticalLines.LWFENCE:
1675                            //remove block to make channel line aoways below the X
1676                                for (k = 0; k < vblUpperCounter; k++) 
1677                                {
1678                                    pLinePoints[vblLowerCounter + k] = new POINT2(pUpperLinePoints[k]);
1679                                }
1680                            break;
1681                        case TacticalLines.UNSP:
1682                            for (k = 0; k < vblUpperCounter; k++) 
1683                            {
1684                                pLinePoints[vblLowerCounter + k] = new POINT2(pOriginalLinePoints[k]);
1685                                pLinePoints[vblLowerCounter + k].style = 5;
1686                            }
1687                            break;
1688                        case TacticalLines.DOUBLEA:
1689                            for (k = 0; k < vblUpperCounter; k++) {
1690                                pLinePoints[vblLowerCounter + k] = new POINT2(pOriginalLinePoints[k]);
1691                            }
1692                            break;
1693                        default:
1694                            for (k = 0; k < vblUpperCounter; k++) {
1695                                pLinePoints[vblLowerCounter + k] = new POINT2(pOriginalLinePoints[k]);
1696                            }
1697                            break;
1698                    }
1699
1700                    pLinePoints[vblLowerCounter + vblUpperCounter - 1].style = 5;
1701
1702                    lEllipseCounter = vblLowerCounter + vblUpperCounter;
1703                    //following section only for lines with repeating features, e.g. DOUBLEA
1704                    //if(segments!=null &&
1705                    if (vbiDrawThis != TacticalLines.BBS_LINE &&
1706                            vbiDrawThis != TacticalLines.CHANNEL &&
1707                            vbiDrawThis != TacticalLines.CHANNEL_DASHED &&
1708                            vbiDrawThis != TacticalLines.CHANNEL_FLARED &&
1709                            vbiDrawThis != TacticalLines.SPT_STRAIGHT &&
1710                            vbiDrawThis != TacticalLines.MAIN_STRAIGHT)
1711                    {
1712                        int xSize;
1713                        if (shiftLines)
1714                            xSize = vblChannelWidth / 8;
1715                        else
1716                            xSize = vblChannelWidth / 4;
1717                        for (j = 0; j < vblUpperCounter - 1; j++) {
1718                            double dIncrement = xSize + arraysupport.getScaledSize(2, tg.get_LineThickness() / 2d, tg.get_patternScale());
1719                            d = lineutility.CalcDistanceDouble(pOriginalLinePoints[j], pOriginalLinePoints[j + 1]);
1720                            lHowManyThisSegment = (int) (d/dIncrement);
1721                            remainder=d-dIncrement*lHowManyThisSegment;
1722                            dAngle = lineutility.CalcSegmentAngleDouble(pOriginalLinePoints[j], pOriginalLinePoints[j + 1]);
1723                            dAngle = dAngle + pi / 2;
1724                            for (k = 0; k < lHowManyThisSegment; k++) {
1725                                
1726                                if(vbiDrawThis==TacticalLines.SFENCE)
1727                                {
1728                                    if(k%4==0)
1729                                        continue;
1730                                }
1731                                else
1732                                {
1733                                    if(k%2==0)
1734                                        continue;
1735                                }
1736
1737                                double f=k;
1738                                f*=(1d+remainder/d);
1739                                                                
1740                                //diagnostic 1-7-13                                
1741                                //note: for shiftLines upper line points were set to original line points ealier
1742                                //ptCenter.x = pOriginalLinePoints[j].x + (int) ((double) (f) * ((double) pOriginalLinePoints[j + 1].x - (double) pOriginalLinePoints[j].x) / (double) lHowManyThisSegment);
1743                                //ptCenter.y = pOriginalLinePoints[j].y + (int) ((double) (f) * ((double) pOriginalLinePoints[j + 1].y - (double) pOriginalLinePoints[j].y) / (double) lHowManyThisSegment);                                
1744                                if(shiftLines==true && vbiDrawThis==TacticalLines.DOUBLEC)
1745                                {
1746                                    ptCenter.x = pUpperLinePoints[j].x + (int) ((double) (f) * ((double) pUpperLinePoints[j + 1].x - (double) pUpperLinePoints[j].x) / (double) lHowManyThisSegment);
1747                                    ptCenter.y = pUpperLinePoints[j].y + (int) ((double) (f) * ((double) pUpperLinePoints[j + 1].y - (double) pUpperLinePoints[j].y) / (double) lHowManyThisSegment);
1748                                }
1749                                else if(shiftLines==false)
1750                                {
1751                                    ptCenter.x = pOriginalLinePoints[j].x + (int) ((double) (f) * ((double) pOriginalLinePoints[j + 1].x - (double) pOriginalLinePoints[j].x) / (double) lHowManyThisSegment);
1752                                    ptCenter.y = pOriginalLinePoints[j].y + (int) ((double) (f) * ((double) pOriginalLinePoints[j + 1].y - (double) pOriginalLinePoints[j].y) / (double) lHowManyThisSegment);
1753                                }
1754                                else
1755                                {
1756                                    ptCenter.x = pUpperLinePoints[j].x + (int) ((double) (f) * ((double) pUpperLinePoints[j + 1].x - (double) pUpperLinePoints[j].x) / (double) lHowManyThisSegment);
1757                                    ptCenter.y = pUpperLinePoints[j].y + (int) ((double) (f) * ((double) pUpperLinePoints[j + 1].y - (double) pUpperLinePoints[j].y) / (double) lHowManyThisSegment);
1758                                    POINT2 ptCenter2=new POINT2();
1759                                    ptCenter2.x = pLowerLinePoints[j].x + (int) ((double) (f) * ((double) pLowerLinePoints[j + 1].x - (double) pLowerLinePoints[j].x) / (double) lHowManyThisSegment);
1760                                    ptCenter2.y = pLowerLinePoints[j].y + (int) ((double) (f) * ((double) pLowerLinePoints[j + 1].y - (double) pLowerLinePoints[j].y) / (double) lHowManyThisSegment);
1761                                    ptCenter=lineutility.MidPointDouble(ptCenter, ptCenter2, 0);
1762                                }
1763                                //end section
1764                                
1765                                switch (vbiDrawThis) {
1766                                    case TacticalLines.SINGLEC:
1767                                    case TacticalLines.DOUBLEC:
1768                                    case TacticalLines.TRIPLE:
1769                                        for (l = 1; l < 37; l++) {
1770                                            dFactor = (10d * (double)l) * pi / 180d;
1771                                            pEllipsePoints2[l - 1].x = ptCenter.x + xSize * Math.cos(dFactor);
1772                                            pEllipsePoints2[l - 1].y = ptCenter.y + xSize / 2 * Math.sin(dFactor);
1773                                            pEllipsePoints2[l - 1].style = 0;
1774                                        }
1775                                        lineutility.RotateGeometryDouble(pEllipsePoints2, 36, dAngle * 180d / pi);
1776                                        pEllipsePoints2[36] = new POINT2(pEllipsePoints2[35]);
1777                                        pEllipsePoints2[36].style = 5;
1778                                        for (l = 0; l < 37; l++) {
1779                                            pLinePoints[lEllipseCounter] = new POINT2(pEllipsePoints2[l]);
1780                                            lEllipseCounter++;
1781                                        }
1782                                        break;
1783                                    case TacticalLines.HWFENCE:
1784                                    case TacticalLines.LWFENCE:
1785                                    case TacticalLines.DOUBLEA:
1786                                    case TacticalLines.UNSP:
1787                                    case TacticalLines.SFENCE:
1788                                    case TacticalLines.DFENCE:
1789                                        XPoints[0].x = ptCenter.x - xSize;//was 4
1790                                        XPoints[0].y = ptCenter.y - xSize;
1791                                        XPoints[0].style = 0;
1792                                        XPoints[1].x = ptCenter.x + xSize;
1793                                        XPoints[1].y = ptCenter.y + xSize;
1794                                        XPoints[1].style = 5;
1795                                        XPoints[2].x = ptCenter.x - xSize;
1796                                        XPoints[2].y = ptCenter.y + xSize;
1797                                        XPoints[2].style = 0;
1798                                        XPoints[3].x = ptCenter.x + xSize;
1799                                        XPoints[3].y = ptCenter.y - xSize;
1800                                        XPoints[3].style = 5;
1801                                        XCounter++;
1802                                        lineutility.RotateGeometryDouble(XPoints, 4, (int) (dAngle * 180 / pi));
1803                                        for (l = 0; l < 4; l++) {
1804                                            pLinePoints[lEllipseCounter] = new POINT2(XPoints[l]);
1805                                            switch (vbiDrawThis) {
1806                                                case TacticalLines.SFENCE:
1807                                                    if (XCounter == 2 || XCounter == 3 || XCounter == 4 || XCounter == 5) {
1808                                                        pLinePoints[lEllipseCounter].style = 5;
1809                                                    }
1810                                                    break;
1811                                                case TacticalLines.DFENCE:
1812                                                    if (XCounter == 3 || XCounter == 4 || XCounter == 5) {  //was 2,3 OR 4
1813                                                        pLinePoints[lEllipseCounter].style = 5;
1814                                                    }
1815                                                    break;
1816                                                default:
1817                                                    break;
1818                                            }
1819                                            lEllipseCounter++;
1820                                        }
1821                                        if (XCounter == 5) {
1822                                            XCounter = 0;
1823                                        }
1824                                        break;
1825                                    default:
1826                                        break;
1827                                }
1828                            }//end how many this segment loop
1829                            if (lHowManyThisSegment == 0) {
1830                                if(pLinePoints.length>lEllipseCounter)
1831                                {
1832                                    pLinePoints[lEllipseCounter] = new POINT2(pOriginalLinePoints[j]);
1833                                    lEllipseCounter++;
1834                                    pLinePoints[lEllipseCounter] = new POINT2(pOriginalLinePoints[j + 1]);
1835                                    pLinePoints[lEllipseCounter].style=5;
1836                                    lEllipseCounter++;
1837                                }
1838                            }
1839                        }
1840                        pLinePoints=lineutility.ResizeArray(pLinePoints, lEllipseCounter);
1841                        vblCounter=pLinePoints.length;  //added 11-2-09 M. Deutch
1842                    }
1843
1844                    //if none of the segments were long enough to have features
1845                    //then make the style solid
1846                    if (FenceType(vbiDrawThis) == 1) {
1847                        if (lEllipseCounter <= vblLowerCounter + vblUpperCounter) {
1848                            for (k = 0; k < vblLowerCounter + vblUpperCounter; k++) 
1849                            {
1850                                if(pLinePoints[k].style != 5)   //added 2-8-13
1851                                    pLinePoints[k].style = 0;
1852                            }
1853                        } 
1854                        else 
1855                        {
1856                            for (k = lEllipseCounter - 1; k < pLinePoints.length; k++) {
1857                                pLinePoints[k].style = 5;
1858                            }
1859                        }
1860                    }
1861                    break;
1862                case TacticalLines.BBS_LINE:
1863                    pLinePoints=new POINT2[vblLowerCounter+vblUpperCounter+1];
1864                    for(j=0;j<vblLowerCounter;j++)
1865                        pLinePoints[j]=pLowerLinePoints[j];
1866                    for(j=0;j<vblUpperCounter;j++)
1867                        pLinePoints[j+vblLowerCounter]=pUpperLinePoints[vblUpperCounter-1-j];
1868                    pLinePoints[pLinePoints.length-1]=pLinePoints[0];
1869                    break;
1870                case TacticalLines.SPT:
1871                case TacticalLines.SPT_STRAIGHT:
1872                case TacticalLines.FRONTAL_ATTACK:
1873                case TacticalLines.TURNING_MOVEMENT:
1874                case TacticalLines.MOVEMENT_TO_CONTACT:
1875                case TacticalLines.CATK:
1876                case TacticalLines.CATKBYFIRE:
1877                case TacticalLines.AIRAOA:
1878                case TacticalLines.AAAAA:
1879                case TacticalLines.MAIN:
1880                case TacticalLines.MAIN_STRAIGHT:
1881                    if (vbiDrawThis != (long) TacticalLines.CATKBYFIRE) {
1882                        vblCounter = vblLowerCounter + vblUpperCounter + 8;
1883                    } else {
1884                        vblCounter = vblLowerCounter + vblUpperCounter + 17;
1885                    }
1886                    //diagnostic
1887                    if (vbiDrawThis == (long) TacticalLines.AAAAA) {
1888                        vblCounter = vblLowerCounter + vblUpperCounter + 19;
1889                    } else if (vbiDrawThis == (long) TacticalLines.FRONTAL_ATTACK) {
1890                        vblCounter = vblLowerCounter + vblUpperCounter + 15;
1891                    } else if (vbiDrawThis ==  TacticalLines.TURNING_MOVEMENT) {
1892                        vblCounter = vblLowerCounter + vblUpperCounter + 14;
1893                    } else if (vbiDrawThis == (long) TacticalLines.MOVEMENT_TO_CONTACT) {
1894                        vblCounter = vblLowerCounter + vblUpperCounter + 24;
1895                    }
1896
1897                    pLinePoints = new POINT2[vblCounter];
1898                    lineutility.InitializePOINT2Array(pLinePoints);
1899                    //initialize points
1900                    for (j = 0; j < pLinePoints.length; j++) {
1901                        pLinePoints[j].x = lpsaUpperVBPoints[0];
1902                        pLinePoints[j].y = lpsaUpperVBPoints[1];
1903                    }
1904
1905                    if (vbiDrawThis != (long) TacticalLines.CATK &&
1906                            vbiDrawThis != (long) TacticalLines.CATKBYFIRE) 
1907                    {
1908                        for (k = 0; k < vblCounter; k++) 
1909                        {
1910                            pLinePoints[k].style = 0;
1911                        }
1912                    }
1913                    GetAXADDouble(nPrinter, pLowerLinePoints,
1914                            vblLowerCounter, pUpperLinePoints,
1915                            vblUpperCounter, pArrowLinePoints[0],
1916                            pLinePoints, vbiDrawThis, arrowOffsetFactor);
1917
1918                    if (vbiDrawThis == (long) TacticalLines.CATK ||
1919                            vbiDrawThis == (long) TacticalLines.CATKBYFIRE) {
1920                        for (k = 0; k < vblCounter; k++) {
1921                            if (pLinePoints[k].style != 5) {
1922                                pLinePoints[k].style = 1;
1923                            }
1924                        }
1925                    }
1926
1927                    //get the rotary symbol for AAAAA
1928                    if (vbiDrawThis == (long) TacticalLines.AAAAA)
1929                    {
1930                        Boolean rotaryTooShort=false;
1931                        ref<double[]> mUpper = new ref(), mLower = new ref();
1932                        int bolVerticalUpper = 0, bolVerticalLower = 0;
1933                        double bUpper = 0, bLower = 0;
1934
1935                        pt0 = new POINT2(pLowerLinePoints[vblLowerCounter - 2]);
1936                        pt1 = new POINT2(pLowerLinePoints[vblLowerCounter - 1]);
1937                        double dist1 = lineutility.CalcDistanceDouble(pt0, pt1);
1938
1939                        bolVerticalLower = lineutility.CalcTrueSlopeDouble(pt0, pt1, mLower);
1940                        bLower = pt0.y - mLower.value[0] * pt0.x;
1941
1942                        pt0 = new POINT2(pUpperLinePoints[vblUpperCounter - 2]);
1943                        pt1 = new POINT2(pUpperLinePoints[vblUpperCounter - 1]);
1944                        bolVerticalUpper = lineutility.CalcTrueSlopeDouble(pt0, pt1, mUpper);
1945                        bUpper = pt0.y - mUpper.value[0] * pt0.x;
1946                        double dist2 = lineutility.CalcDistanceDouble(pt0, pt1);
1947
1948                        //if (dist1 > vblChannelWidth && dist2 > vblChannelWidth)
1949                        //{
1950                        midPt1 = lineutility.CalcTrueIntersectDouble2(mLower.value[0], bLower, mUpper.value[0], bUpper, bolVerticalLower, bolVerticalUpper, pt0.x, pt0.y);
1951
1952                        //both sides of the channel need to be long enough
1953                        //or the rotary sides will not work, but we still
1954                        //include the arrow by using a simpler midpoint
1955                        if (dist1 <= vblChannelWidth || dist2 <= vblChannelWidth)
1956                        {
1957                            rotaryTooShort=true;
1958                            midPt1=lineutility.MidPointDouble(pt0, pt1, 0);
1959                        }
1960
1961                            a = lineutility.CalcDistanceDouble(pt0, pt1);
1962                            b = 30;
1963                            if (a < 90) {
1964                                b = a / 3;
1965                            }
1966
1967                            pt3 = new POINT2(pOriginalLinePoints[vblUpperCounter - 2]);
1968                            pt4 = new POINT2(pOriginalLinePoints[vblUpperCounter - 1]);
1969                            d = vblChannelWidth / 4;
1970                            double DPIScaleFactor = RendererSettings.getInstance().getDeviceDPI() / 96.0;
1971                            if (d > maxLength * DPIScaleFactor) {
1972                                d = maxLength * DPIScaleFactor;
1973                            }
1974                            if (d < minLength * DPIScaleFactor) {
1975                                d = minLength * DPIScaleFactor;
1976                            }
1977
1978                            //for non-vertical lines extend above or below the line
1979                            if (pt3.x != pt4.x) {
1980                                //extend below the line
1981                                pt0 = lineutility.ExtendDirectedLine(pt3, pt4, midPt1, 3, 2 * d);
1982                                pLinePoints[vblLowerCounter + vblUpperCounter + 8] = pt0;
1983                                pLinePoints[vblLowerCounter + vblUpperCounter + 8].style = 0;
1984                                //extend above the line
1985                                pt1 = lineutility.ExtendDirectedLine(pt3, pt4, midPt1, 2, 2 * d);
1986                                pLinePoints[vblLowerCounter + vblUpperCounter + 9] = pt1;
1987                                pLinePoints[vblLowerCounter + vblUpperCounter + 9].style = 5;
1988                            }
1989                            else //for vertical lines arrow points to the left
1990                            {
1991                                //extend right of the line
1992                                pt0 = lineutility.ExtendDirectedLine(pt3, pt4, midPt1, 1, 2 * d);
1993                                pLinePoints[vblLowerCounter + vblUpperCounter + 8] = pt0;
1994                                pLinePoints[vblLowerCounter + vblUpperCounter + 8].style = 0;
1995                                //extend left of the line
1996                                pt1 = lineutility.ExtendDirectedLine(pt3, pt4, midPt1, 0, 2 * d);
1997                                pLinePoints[vblLowerCounter + vblUpperCounter + 9] = pt1;
1998                                pLinePoints[vblLowerCounter + vblUpperCounter + 9].style = 5;
1999                                midPt1 = lineutility.MidPointDouble(pt0, pt1, 0);
2000                            }
2001                            //get the rotary symbol arrow
2002                            lineutility.GetArrowHead4Double(pt0, pt1, (int) d, (int) d, arrowPts, 0);
2003
2004                            for (k = 0; k < 3; k++) {
2005                                pLinePoints[vblLowerCounter + vblUpperCounter + 10 + k] = arrowPts[k];
2006                            }
2007
2008                            pLinePoints[vblLowerCounter + vblUpperCounter + 12].style = 5;
2009
2010                            //get the base points
2011                            pt3 = lineutility.ExtendTrueLinePerpDouble(pt0, pt1, pt0, d / 2, 0);
2012                            pt4 = lineutility.ExtendTrueLinePerpDouble(pt0, pt1, pt0, -d / 2, 0);
2013
2014                            pLinePoints[vblLowerCounter + vblUpperCounter + 13] = pt3;
2015                            pLinePoints[vblLowerCounter + vblUpperCounter + 14] = pt4;
2016
2017                            //the side lines
2018                            //first point
2019                            pLinePoints[vblLowerCounter + vblUpperCounter + 14].style = 5;
2020                            pt0 = new POINT2(pLowerLinePoints[vblLowerCounter - 2]);
2021                            pt1 = new POINT2(pLowerLinePoints[vblLowerCounter - 1]);
2022                            pt3 = lineutility.ExtendLine2Double(pt0, midPt1, b, 0);     //line distance from midpt, a was 30
2023                            pLinePoints[vblLowerCounter + vblUpperCounter + 15] = new POINT2(pt3);
2024
2025                            //second point
2026                            pt0 = new POINT2(pUpperLinePoints[vblLowerCounter - 2]);
2027                            pt1 = new POINT2(pUpperLinePoints[vblLowerCounter - 1]);
2028                            pt3 = lineutility.ExtendLine2Double(pt0, midPt1, b, 5);     //line distance from midpt, a was 30
2029                            pLinePoints[vblLowerCounter + vblUpperCounter + 16] = new POINT2(pt3);
2030
2031                            //third point
2032                            pt0 = new POINT2(pLowerLinePoints[vblLowerCounter - 2]);
2033                            pt1 = new POINT2(pLowerLinePoints[vblLowerCounter - 1]);
2034                            pt3 = lineutility.ExtendLine2Double(pt1, midPt1, b, 0);     //line distance from midpt, a was 30
2035                            pLinePoints[vblLowerCounter + vblUpperCounter + 17] = new POINT2(pt3);
2036
2037                            //fourth point
2038                            pt0 = new POINT2(pUpperLinePoints[vblLowerCounter - 2]);
2039                            pt1 = new POINT2(pUpperLinePoints[vblLowerCounter - 1]);
2040                            pt3 = lineutility.ExtendLine2Double(pt1, midPt1, b, 5);     //line distance from midpt, a was 30
2041                            pLinePoints[vblLowerCounter + vblUpperCounter + 18] = new POINT2(pt3);
2042                        //}
2043                        //else
2044                        //{   //if last segment too short then don't draw the rotary features
2045                            //if last segment too short then no side points
2046                            if(rotaryTooShort)
2047                            {
2048                                for (l = vblLowerCounter + vblUpperCounter + 14; l < vblLowerCounter + vblLowerCounter + 19; l++)
2049                                {
2050                                    pLinePoints[l].style = 5;
2051                                }
2052                            }
2053                        //}
2054                    }//end if (vbiDrawThis == (long) TacticalLines.AAAAA)
2055                    
2056                    double dFeature=0;
2057                    double dist2=0;
2058                    if (vbiDrawThis == TacticalLines.CATKBYFIRE) 
2059                    {       //dist is the distance to the back of the arrowhead                        
2060                        //10-19-12
2061                        //this line is part of the new requirement that the rotary feature must align 
2062                        //with the anchor point, it can  no longer stick out beond the anchor point
2063                        //so the points have to be shifted by 45 pixels.
2064                        
2065                        //dist-=45;
2066                        //end section
2067                        dist2 = lineutility.CalcDistanceDouble(nextToLastPoint, lastPoint);
2068                        if(dist2>45)
2069                            dist-=45;
2070                        if (dist2 > 20) 
2071                        {                                                                                       //was 20+dist
2072                            pt1 = lineutility.ExtendLineDouble(pUpperLinePoints[vblUpperCounter - 2], pUpperLinePoints[vblUpperCounter - 1], 5+dist);//distance from tip to back of rotary
2073                            pt2 = lineutility.ExtendLineDouble(pLowerLinePoints[vblLowerCounter - 2], pLowerLinePoints[vblLowerCounter - 1], 5+dist);//distance from tip to back of rotary
2074                        } 
2075                        else 
2076                        {
2077                            pt1 = lineutility.ExtendLineDouble(pUpperLinePoints[vblUpperCounter - 2], pUpperLinePoints[vblUpperCounter - 1], -50);//was -40
2078                            pt2 = lineutility.ExtendLineDouble(pLowerLinePoints[vblLowerCounter - 2], pLowerLinePoints[vblLowerCounter - 1], -50);//was -40
2079                        }
2080                        //was dist
2081                        pt3 = lineutility.ExtendLine2Double(pt2, pt1, 10 + Math.abs(dist/2), 18); //vert height of rotary from horiz segment was dist/2.5
2082                        pt4 = lineutility.ExtendLine2Double(pt1, pt2, 10 + Math.abs(dist/2), 5); //vert height of rotary from horiz segment was dist/2.5
2083                        midPt1 = lineutility.MidPointDouble(pt1, pt2, 17);
2084                        pLinePoints[vblCounter - 9] = new POINT2(pt3);
2085                        pLinePoints[vblCounter - 6] = new POINT2(pt4);
2086
2087                        if (dist2 > 20) {                                                                                               //was 30+dist
2088                            pt1 = lineutility.ExtendLineDouble(pUpperLinePoints[vblUpperCounter - 2], pUpperLinePoints[vblUpperCounter - 1], 15 + dist);//distance from tip to back of rotary
2089                            pt2 = lineutility.ExtendLineDouble(pLowerLinePoints[vblLowerCounter - 2], pLowerLinePoints[vblLowerCounter - 1], 15 + dist);//distance from tip to back of rotary
2090                        } else {
2091                            pt1 = lineutility.ExtendLineDouble(pUpperLinePoints[vblUpperCounter - 2], pUpperLinePoints[vblUpperCounter - 1], -50);//was -50
2092                            pt2 = lineutility.ExtendLineDouble(pLowerLinePoints[vblLowerCounter - 2], pLowerLinePoints[vblLowerCounter - 1], -50);//was -50
2093                        }
2094
2095                        pt3 = lineutility.ExtendLine2Double(pt2, pt1, Math.abs(dist/2), 18);//vert height of rotary from horiz segment was dist/2.5
2096                        pt4 = lineutility.ExtendLine2Double(pt1, pt2, Math.abs(dist/2), 18);//vert height of rotary from horiz segment was dist/2.5
2097                                                
2098                        midPt2 = lineutility.MidPointDouble(pt1, pt2, 18);
2099                        pLinePoints[vblCounter - 8] = new POINT2(pt3);
2100                        pLinePoints[vblCounter - 7] = new POINT2(pt4);
2101                        pLinePoints[vblCounter - 5] = new POINT2(midPt2);
2102                        if (midPt1.x == midPt2.x && midPt1.y == midPt2.y) //last segment too short
2103                        {
2104                            //diagnostic 2-27-13
2105                            if(_client.startsWith("cpof"))
2106                                dFeature=30;
2107                            else                            
2108                                dFeature=15;
2109                            
2110                            
2111                            midPt1 = lineutility.ExtendLine2Double(nextToLastPoint, pArrowLinePoints[0], 10, 17);
2112                            //pt1 = lineutility.ExtendTrueLinePerpDouble(lastPoint, midPt1, midPt1, 30, 18);
2113                            //pt2 = lineutility.ExtendTrueLinePerpDouble(lastPoint, midPt1, midPt1, -30, 5);                            
2114                            pt1 = lineutility.ExtendTrueLinePerpDouble(lastPoint, midPt1, midPt1, dFeature, 18);
2115                            pt2 = lineutility.ExtendTrueLinePerpDouble(lastPoint, midPt1, midPt1, -dFeature, 5);
2116                            //end section
2117                            pLinePoints[vblCounter - 9] = new POINT2(pt1);
2118                            pLinePoints[vblCounter - 6] = new POINT2(pt2);
2119                            
2120                            if(_client.startsWith("cpof"))
2121                                midPt2 = lineutility.ExtendLine2Double(nextToLastPoint, pArrowLinePoints[0], 20, 17);
2122                            else
2123                            {
2124                                if(dist2>30)
2125                                    midPt2 = lineutility.ExtendLine2Double(nextToLastPoint, pArrowLinePoints[0], 20, 17);
2126                                else
2127                                    midPt2 = lineutility.ExtendLine2Double(nextToLastPoint, pArrowLinePoints[0], dFeature, 17);
2128                            }
2129                            //end section
2130                            
2131                            //diagnostic 2-27-13                            
2132                            //pt1 = lineutility.ExtendTrueLinePerpDouble(lastPoint, midPt2, midPt2, 20, 18);
2133                            //pt2 = lineutility.ExtendTrueLinePerpDouble(lastPoint, midPt2, midPt2, -20, 18);
2134                            dFeature -=10;
2135                            pt1 = lineutility.ExtendTrueLinePerpDouble(lastPoint, midPt2, midPt2, dFeature, 18);
2136                            pt2 = lineutility.ExtendTrueLinePerpDouble(lastPoint, midPt2, midPt2, -dFeature, 18);
2137                            pLinePoints[vblCounter - 8] = new POINT2(pt1);
2138                            pLinePoints[vblCounter - 7] = new POINT2(pt2);
2139                            pLinePoints[vblCounter - 5] = new POINT2(midPt2);
2140                        }
2141                        if(_client.startsWith("cpof"))
2142                            dFeature=30;
2143                        else
2144                        {
2145                            if(dist2>30)
2146                                dFeature=30;
2147                            else if(dist2>20)
2148                                dFeature=10;
2149                            else
2150                                dFeature=10;
2151                        }
2152
2153                        pt1 = lineutility.ExtendLine2Double(midPt1, midPt2, dFeature, (int)dFeature); //30, then 5
2154                        pLinePoints[vblCounter - 4] = new POINT2(pt1);
2155                        lineutility.GetArrowHead4Double(midPt2, pt1, (int)dFeature/2, (int)dFeature/2, arrowPts, 18);//15,15
2156                        //end section
2157                        for (k = 0; k < 3; k++) {
2158                            pLinePoints[vblCounter - k - 1] = new POINT2(arrowPts[k]);
2159                            pLinePoints[vblCounter - k - 1].style = 18;
2160                        }
2161                    }
2162
2163                    if (vbiDrawThis == TacticalLines.FRONTAL_ATTACK) {
2164                        // Add line on perpendicular to arrow head
2165                        pt0 = new POINT2(pLinePoints[vblLowerCounter + vblUpperCounter + 1]); // arrow head left
2166                        ptCenter = new POINT2(pLinePoints[vblLowerCounter + vblUpperCounter + 6]); // arrow head tip
2167                        pt1 = new POINT2(pLinePoints[vblLowerCounter + vblUpperCounter + 5]); // arrow right
2168
2169                        // Make distance between pt0 and pt1 vblChannelWidth * 2
2170                        midPt1 = lineutility.MidPointDouble(pt0, pt1, 0);
2171                        pt0 = lineutility.ExtendAlongLineDouble(pt1, midPt1, vblChannelWidth);
2172                        pt1 = lineutility.ExtendAlongLineDouble(pt0, midPt1, vblChannelWidth);
2173
2174                        pLinePoints[vblLowerCounter + vblUpperCounter + 8] = lineutility.PointRelativeToLine(pt0, pt1, pt0, ptCenter);
2175                        pLinePoints[vblLowerCounter + vblUpperCounter + 8].style = 0;
2176                        pLinePoints[vblLowerCounter + vblUpperCounter + 9] = lineutility.PointRelativeToLine(pt0, pt1, pt1, ptCenter);
2177                        pLinePoints[vblLowerCounter + vblUpperCounter + 9].style = 5;
2178                    }
2179
2180                    if (vbiDrawThis == TacticalLines.TURNING_MOVEMENT) {
2181                        if (tg.Pixels.size() == 3) {
2182                            pt0 = tg.Pixels.get(1);
2183                            pt1 = lineutility.ClosestPointOnLine(tg.Pixels.get(0), tg.Pixels.get(1), tg.Pixels.get(2));
2184                        } else { // tg.Pixels.size() > 3
2185                            pt0 = tg.Pixels.get(tg.Pixels.size() - 2);
2186                            pt1 = tg.Pixels.get(tg.Pixels.size() - 3);
2187                        }
2188                        midPt1 = lineutility.MidPointDouble(pt0, pt1, 0);
2189                        pLinePoints[vblLowerCounter + vblUpperCounter + 8] = lineutility.ExtendDirectedLine(pt0, pt1, midPt1, lineutility.extend_above, vblChannelWidth / 2, 0);
2190                        pLinePoints[vblLowerCounter + vblUpperCounter + 9] = lineutility.ExtendDirectedLine(pt0, pt1, midPt1, lineutility.extend_below, vblChannelWidth / 2, 5);
2191                    }
2192
2193                    if (vbiDrawThis == TacticalLines.MOVEMENT_TO_CONTACT) {
2194                        pt0 = new POINT2(pLinePoints[vblLowerCounter + vblUpperCounter + 1]); // arrow head left
2195                        ptCenter = new POINT2(pLinePoints[vblLowerCounter + vblUpperCounter + 6]); // arrow head tip
2196                        pt1 = new POINT2(pLinePoints[vblLowerCounter + vblUpperCounter + 5]); // arrow right
2197
2198                        int direction1 = lineutility.reverseDirection(lineutility.CalcDirectionFromLine(pt0, ptCenter, pt1));
2199                        int direction2 = lineutility.reverseDirection(lineutility.CalcDirectionFromLine(pt1, ptCenter, pt0));
2200
2201                        midPt1 = lineutility.MidPointDouble(pt0, ptCenter, 0);
2202                        midPt1 = lineutility.ExtendDirectedLine(pt0, ptCenter, midPt1, direction1, vblChannelWidth / 8.0);
2203                        midPt2 = lineutility.MidPointDouble(pt1, ptCenter, 0);
2204                        midPt2 = lineutility.ExtendDirectedLine(pt1, ptCenter, midPt2, direction2, vblChannelWidth / 8.0);
2205
2206                        POINT2[] DISMPts = new POINT2[16];
2207                        lineutility.InitializePOINT2Array(DISMPts);
2208                        DISMPts[0] = lineutility.ExtendDirectedLine(pt0, ptCenter, midPt1, direction1, vblChannelWidth);
2209                        DISMPts[1] = midPt1;
2210                        DISMPts[2] = midPt2;
2211                        DISMPts[3] = lineutility.ExtendDirectedLine(pt1, ptCenter, midPt2, direction2, vblChannelWidth);
2212
2213                        lHowManyThisSegment = DISMSupport.GetDISMCoverDoubleRevC(DISMPts, vbiDrawThis, 4);
2214                        for (int i = 0; i < lHowManyThisSegment; i++) {
2215                            pLinePoints[vblLowerCounter + vblUpperCounter + 8 + i] = DISMPts[i];
2216                        }
2217                    }
2218
2219                    if (vbiDrawThis == TacticalLines.FRONTAL_ATTACK || vbiDrawThis == TacticalLines.TURNING_MOVEMENT) {
2220                        pt0 = new POINT2(pLinePoints[vblLowerCounter + vblUpperCounter+2]); // top left
2221                        pt1 = lineutility.MidPointDouble(pLinePoints[vblLowerCounter + vblUpperCounter + 1], pLinePoints[vblLowerCounter + vblUpperCounter + 6], 0); // top right
2222                        pt2 = new POINT2(pLinePoints[vblLowerCounter + vblUpperCounter+4]); // bottom left
2223                        pt3 = lineutility.MidPointDouble(pLinePoints[vblLowerCounter + vblUpperCounter + 5], pLinePoints[vblLowerCounter + vblUpperCounter + 6], 0); // bottom right
2224
2225                        // Shrink vertically to add spacing between arrow lines
2226                        dist = lineutility.CalcDistanceDouble(pt0, pt2) / 4;
2227                        pt0 = lineutility.ExtendAlongLineDouble2(pt0, pt2, dist);
2228                        pt1 = lineutility.ExtendAlongLineDouble2(pt1, pt3, dist);
2229                        pt2 = lineutility.ExtendAlongLineDouble2(pt2, pt0, dist);
2230                        pt3 = lineutility.ExtendAlongLineDouble2(pt3, pt1, dist);
2231
2232                        // Make height twice size of width
2233                        if (lineutility.CalcDistanceDouble(pt0, pt2) > 2 * lineutility.CalcDistanceDouble(pt0, pt1)) {
2234                            // Shrink vertical
2235                            dist = lineutility.CalcDistanceDouble(pt0, pt1);
2236
2237                            midPt1 = lineutility.MidPointDouble(pt0, pt2, 0);
2238                            pt0 = lineutility.ExtendAlongLineDouble2(midPt1, pt0, dist);
2239                            pt2 = lineutility.ExtendAlongLineDouble2(midPt1, pt2, dist);
2240
2241                            midPt1 = lineutility.MidPointDouble(pt1, pt3, 0);
2242                            pt1 = lineutility.ExtendAlongLineDouble2(midPt1, pt1, dist);
2243                            pt3 = lineutility.ExtendAlongLineDouble2(midPt1, pt3, dist);
2244                        } else if (2 * lineutility.CalcDistanceDouble(pt0, pt1) > lineutility.CalcDistanceDouble(pt0, pt2)) {
2245                            //Shrink horizontal
2246                            dist = lineutility.CalcDistanceDouble(pt0, pt2) / 2;
2247                            pt1 = lineutility.ExtendAlongLineDouble2(pt0, pt1, dist);
2248                            pt3 = lineutility.ExtendAlongLineDouble2(pt2, pt3, dist);
2249                        }
2250
2251                        // Want actual top / left if arrow head is rotated
2252                        if (pt0.y > pt2.y && pt1.y > pt3.y) {
2253                            pt4 = pt0;
2254                            pt0 = pt2;
2255                            pt2 = pt4;
2256
2257                            pt4 = pt1;
2258                            pt1 = pt3;
2259                            pt3 = pt4;
2260                        }
2261                        if (pt0.x > pt1.x && pt2.x > pt3.x) {
2262                            pt4 = pt0;
2263                            pt0 = pt1;
2264                            pt1 = pt4;
2265
2266                            pt4 = pt2;
2267                            pt2 = pt3;
2268                            pt3 = pt4;
2269                        }
2270
2271                        if (vbiDrawThis == TacticalLines.FRONTAL_ATTACK) {
2272                            // Draw "A"
2273                            pLinePoints[vblLowerCounter + vblUpperCounter + 10] = new POINT2(pt2);
2274                            pLinePoints[vblLowerCounter + vblUpperCounter + 10].style = 0;
2275                            pLinePoints[vblLowerCounter + vblUpperCounter + 11] = lineutility.MidPointDouble(pt0, pt1, 0);
2276                            pLinePoints[vblLowerCounter + vblUpperCounter + 11].style = 0;
2277                            pLinePoints[vblLowerCounter + vblUpperCounter + 12] = new POINT2(pt3);
2278                            pLinePoints[vblLowerCounter + vblUpperCounter + 12].style = 5;
2279                            pLinePoints[vblLowerCounter + vblUpperCounter + 13] = lineutility.MidPointDouble(pLinePoints[vblLowerCounter + vblUpperCounter + 10], pLinePoints[vblLowerCounter + vblUpperCounter + 11], 0);
2280                            pLinePoints[vblLowerCounter + vblUpperCounter + 13].style = 0;
2281                            pLinePoints[vblLowerCounter + vblUpperCounter + 14] = lineutility.MidPointDouble(pLinePoints[vblLowerCounter + vblUpperCounter + 11], pLinePoints[vblLowerCounter + vblUpperCounter + 12], 5);
2282                            pLinePoints[vblLowerCounter + vblUpperCounter + 14].style = 5;
2283                        } else {
2284                            // Draw "T"
2285                            pLinePoints[vblLowerCounter + vblUpperCounter + 10] = lineutility.MidPointDouble(pt0, pt1, 0);
2286                            pLinePoints[vblLowerCounter + vblUpperCounter + 10].style = 0;
2287                            pLinePoints[vblLowerCounter + vblUpperCounter + 11] = lineutility.MidPointDouble(pt2, pt3, 5);
2288                            pLinePoints[vblLowerCounter + vblUpperCounter + 11].style = 5;
2289                            pLinePoints[vblLowerCounter + vblUpperCounter + 12] = new POINT2(pt0);
2290                            pLinePoints[vblLowerCounter + vblUpperCounter + 12].style = 0;
2291                            pLinePoints[vblLowerCounter + vblUpperCounter + 13] = new POINT2(pt1);
2292                            pLinePoints[vblLowerCounter + vblUpperCounter + 13].style = 5;
2293                        }
2294                    }
2295
2296                    break;
2297                default:
2298                    break;
2299            }   //end load channel array ino pLinePoints
2300            if (vbiDrawThis == (long) TacticalLines.CHANNEL_DASHED) {
2301                for (k = 0; k < vblCounter; k++) {
2302                    if (pLinePoints[k].style != 5) {
2303                        pLinePoints[k].style = 18;
2304                    }
2305                }
2306            }
2307
2308            //if shapes is null it is not a CPOF client
2309            if(shapes==null)
2310            {
2311                //load result points because client is using points, not shapes
2312                for(j=0;j<pLinePoints.length;j++)
2313                {
2314                    resultVBPoints[3*j]=pLinePoints[j].x;
2315                    resultVBPoints[3*j+1]=pLinePoints[j].y;
2316                    resultVBPoints[3*j+2]=(double)pLinePoints[j].style;
2317                }
2318                return pLinePoints.length;
2319            }
2320
2321            //the shapes
2322            Shape2 shape=null;
2323            //Shape2 outline=null;
2324            boolean beginLine=true;
2325            boolean beginPath=true;
2326
2327            for (k = 0; k < vblCounter; k++)
2328            {
2329                //use shapes instead of pixels
2330
2331                if(shape==null)
2332                {
2333                    shape=new Shape2(Shape2.SHAPE_TYPE_POLYLINE);
2334                }
2335
2336                switch(vbiDrawThis)
2337                {
2338                    case TacticalLines.CATK:
2339                    case TacticalLines.CATKBYFIRE:
2340                        shape.set_Style(1);
2341                        break;
2342                }
2343
2344                switch(vbiDrawThis)
2345                {
2346                    case TacticalLines.LC:
2347                        if(beginPath==false)
2348                        {
2349                            if(k>0)
2350                            {   //if the linestyle is changes on the next point then this point is end of the current path
2351                                //because it's changing between friendly and enemy ellipses
2352                                if(  pLinePoints[k].style == 5)
2353                                {
2354                                    //add the last point to the current path
2355                                    shape.lineTo(pLinePoints[k]);
2356                                    //add the shape
2357                                    if(shape !=null && shape.getShape() != null)
2358                                    {
2359                                        shapes.add(shape);
2360                                    }
2361
2362                                    beginPath=true;
2363                                }
2364                                else    //continue the current path
2365                                {
2366                                    shape.lineTo(pLinePoints[k]);
2367                                }
2368                            }
2369                            else    //k=0
2370                            {
2371                                shape.moveTo(pLinePoints[k]);
2372                            }
2373                        }
2374                        else    //start a new path
2375                        {
2376                            shape=new Shape2(Shape2.SHAPE_TYPE_POLYLINE);
2377                            shape.moveTo(pLinePoints[k]);
2378                            shape.set_Style(pLinePoints[k].style);
2379                            //assume friendly
2380                            if(pLinePoints[k].style==25)
2381                               shape.setLineColor(Color.RED);
2382                            
2383                            beginPath=false;
2384                        }
2385                        //if(k==vblCounter-1) //LC should have 2 shapes
2386                          //  if(shape !=null && shape.get_Shape() != null)
2387                            //    shapes.add(shape);
2388                        break;
2389                    case TacticalLines.CATK:    //same as default except these have doubled 5's
2390                    case TacticalLines.CATKBYFIRE:
2391                    case TacticalLines.AAAAA:
2392                    case TacticalLines.SPT:
2393                    case TacticalLines.SPT_STRAIGHT:
2394                    case TacticalLines.AIRAOA:
2395                    case TacticalLines.FRONTAL_ATTACK:
2396                    case TacticalLines.TURNING_MOVEMENT:
2397                        if(beginLine)
2398                        {
2399                            if(k>0) //doubled points with linestyle=5
2400                            {
2401                                if(pLinePoints[k].style==5 && pLinePoints[k-1].style==5 && k != vblCounter-1)
2402                                    continue;
2403                            }
2404
2405                            shape.moveTo(pLinePoints[k]);
2406                            beginLine=false;
2407                        }
2408                        else
2409                        {
2410                            shape.lineTo(pLinePoints[k]);
2411                            if(pLinePoints[k].style==5)
2412                            {
2413                                beginLine=true;
2414                                //unless there are doubled points with style=5
2415                            }
2416                        }
2417                        if(k==vblCounter-1) //non-LC should only have one shape
2418                        {
2419                            if(shape !=null && shape.getShape() != null)
2420                            {
2421                                shapes.add(shape);
2422                            }
2423                        }
2424                        break;
2425                    case TacticalLines.MOVEMENT_TO_CONTACT:
2426                        if(beginLine)
2427                        {
2428                            if(k>0)
2429                            {
2430                                if(pLinePoints[k].style==5 && pLinePoints[k-1].style==5 && k != vblCounter-1)
2431                                    continue;
2432                            }
2433
2434                            if (pLinePoints[k].style == 9 && pLinePoints[k - 1].style != 9)
2435                            {
2436                                if (!shape.getPoints().isEmpty())
2437                                    shapes.add(shape);
2438                                shape = new Shape2(Shape2.SHAPE_TYPE_FILL);
2439                                shape.set_Style(pLinePoints[k].style);
2440                                shape.setFillColor(tg.get_LineColor());
2441                                shape.set_Fillstyle(1);
2442                            }
2443
2444                            shape.moveTo(pLinePoints[k]);
2445                            beginLine=false;
2446                        }
2447                        else
2448                        {
2449                            shape.lineTo(pLinePoints[k]);
2450                            if(pLinePoints[k].style==5)
2451                            {
2452                                beginLine=true;
2453                            }
2454                            else if (pLinePoints[k].style == 10)
2455                            {
2456                                if (shape != null && shape.getShape() != null)
2457                                {
2458                                    shapes.add(0, shape);
2459                                    shape = new Shape2(Shape2.SHAPE_TYPE_POLYLINE);
2460                                }
2461                                beginLine = true;
2462                            }
2463                        }
2464                        if(k==vblCounter-1)
2465                        {
2466                            if(shape !=null && shape.getShape() != null)
2467                            {
2468                                shapes.add(shape);
2469                            }
2470                        }
2471                        break;
2472                    case TacticalLines.UNSP:
2473                    case TacticalLines.SFENCE:
2474                    case TacticalLines.DFENCE:
2475                    case TacticalLines.LWFENCE:
2476                    case TacticalLines.HWFENCE:
2477                        if(k==0)
2478                        {
2479                            shape.moveTo(pLinePoints[k]);
2480                            if(pLinePoints[k].style==5)
2481                            {
2482                                continue;
2483                            }
2484                        }
2485                        if(k>0 && k < vblCounter-1)
2486                        {
2487                            if(pLinePoints[k-1].style==5)
2488                                shape.moveTo(pLinePoints[k]);
2489                            else if(pLinePoints[k-1].style==0)
2490                                shape.lineTo(pLinePoints[k]);
2491
2492                            if(pLinePoints[k].style==5)
2493                              shape.moveTo(pLinePoints[k]);
2494
2495                            if(k==vblCounter-2 && pLinePoints[k].style==0)
2496                            {
2497                                shape.moveTo(pLinePoints[k]);
2498                                shape.lineTo(pLinePoints[k+1]);
2499                            }
2500                        }
2501
2502                        if(k==vblCounter-1) //non-LC should only have one shape
2503                        {
2504                            if(shape !=null && shape.getShape() != null)
2505                                shapes.add(shape);
2506                        }
2507                        break;
2508                    default:                        
2509                        if(beginLine)
2510                        {
2511                            if(k==0)
2512                                shape.set_Style(pLinePoints[k].style);
2513
2514                            shape.moveTo(pLinePoints[k]);
2515                            beginLine=false;
2516                        }
2517                        else
2518                        {
2519                            shape.lineTo(pLinePoints[k]);
2520                            if(pLinePoints[k].style==5)
2521                            {
2522                                beginLine=true;
2523                                //unless there are doubled points with style=5
2524                            }
2525                        }
2526                        if(k==vblCounter-1) //non-LC should only have one shape
2527                        {
2528                            if(shape !=null && shape.getShape() != null)
2529                                shapes.add(shape);
2530                        }
2531                        break;
2532                }//end switch
2533            }   //end for
2534            //a requirement was added to enable fill for the axis of advance line types
2535            ArrayList<Shape2>fillShapes=getAXADFillShapes(vbiDrawThis, pLinePoints);
2536            if(fillShapes != null && fillShapes.size()>0)
2537                shapes.addAll(0,fillShapes);
2538
2539            //diagnostic
2540            if(vbiDrawThis==TacticalLines.BBS_LINE)
2541            {
2542                //shapes.remove(1);
2543                shape=new Shape2(Shape2.SHAPE_TYPE_POLYLINE);
2544                shape.moveTo(pOriginalLinePoints[0]);
2545                for(j=1;j<pOriginalLinePoints.length;j++)
2546                    shape.lineTo(pOriginalLinePoints[j]);
2547                shapes.add(shape);
2548            }
2549            //end section
2550
2551            lResult=lResultCounter;
2552            //FillPoints(pLinePoints,pLinePoints.length);
2553            //clean up
2554            pLinePoints = null;
2555            pLowerLinePoints = null;
2556            pUpperLinePoints = null;
2557            pArrowLinePoints = null;
2558            pUpperFlotPoints = null;
2559            arrowPts = null;
2560            XPoints = null;
2561            pEllipsePoints2 = null;
2562            pOriginalLinePoints = null;
2563            pOriginalLinePoints2 = null;
2564        }
2565        catch (Exception exc) {
2566            ErrorLogger.LogException(_className ,"GetChannel1Double",
2567                    new RendererException("Failed inside GetChannel1Double " + Integer.toString(tg.get_LineType()), exc));
2568        }
2569        return lResult;
2570    }
2571    /**
2572     * They decided that axis of advance must enable fill
2573     * @param lineType
2574     * @param pLinePoints
2575     * @return
2576     */
2577    private static ArrayList<Shape2> getAXADFillShapes(int lineType, POINT2[]pLinePoints)
2578    {
2579        ArrayList<Shape2>shapes=null;
2580        try
2581        {
2582            ArrayList<POINT2>newPts=new ArrayList();
2583            int j=0;
2584            Shape2 shape=null;
2585            int n=pLinePoints.length;
2586            switch(lineType)
2587            {
2588                case TacticalLines.BBS_LINE:
2589                    shape=new Shape2(Shape2.SHAPE_TYPE_FILL);
2590                    shape.moveTo(pLinePoints[0]);
2591                    //for(j=1;j<pLinePoints.length;j++)
2592                    for(j=1;j<n;j++)
2593                    {
2594                        shape.lineTo(pLinePoints[j]);
2595                    }
2596                    break;
2597                case TacticalLines.CHANNEL:
2598                case TacticalLines.CHANNEL_FLARED:
2599                case TacticalLines.CHANNEL_DASHED:
2600                    for(j=0;j<n/2;j++)
2601                    {
2602                        newPts.add(pLinePoints[j]);
2603                    }
2604                    for(j=n-1;j>=n/2;j--)
2605                    {
2606                        newPts.add(pLinePoints[j]);
2607                    }
2608                    shape=new Shape2(Shape2.SHAPE_TYPE_FILL);
2609                    shape.moveTo(newPts.get(0));
2610                    int t=newPts.size();
2611                    //for(j=1;j<newPts.size();j++)
2612                    for(j=1;j<t;j++)
2613                    {
2614                        shape.lineTo(newPts.get(j));
2615                    }
2616                    break;
2617                case TacticalLines.AIRAOA:
2618                case TacticalLines.SPT:
2619                case TacticalLines.CATK:
2620                case TacticalLines.SPT_STRAIGHT:
2621                    //add the upper (lower) channel points
2622                    //for(j=0;j<(pLinePoints.length-8)/2;j++)
2623                    for(j=0;j<(n-8)/2;j++)
2624                    {
2625                        newPts.add(pLinePoints[j]);
2626                    }
2627                    //add the arrow outline
2628                    newPts.add(pLinePoints[n-6]);
2629                    newPts.add(pLinePoints[n-7]);
2630                    newPts.add(pLinePoints[n-8]);
2631                    newPts.add(pLinePoints[n-3]);
2632                    newPts.add(pLinePoints[n-4]);
2633                    //add the upper (lower) channel points
2634                    for(j=n-9;j>=(n-8)/2;j--)
2635                    {
2636                        newPts.add(pLinePoints[j]);
2637                    }
2638                    //newPts.add(pLinePoints[0]);
2639                    shape=new Shape2(Shape2.SHAPE_TYPE_FILL);
2640                    //shape.moveTo(newPts.get(0).x,newPts.get(0).y);
2641                    shape.moveTo(newPts.get(0));
2642                    t=newPts.size();
2643                    //for(j=1;j<newPts.size();j++)
2644                    for(j=1;j<t;j++)
2645                    {
2646                        shape.lineTo(newPts.get(j));
2647                    }
2648                    break;
2649                case TacticalLines.MAIN_STRAIGHT:
2650                case TacticalLines.MAIN:
2651                    //for(j=0;j<(pLinePoints.length-8)/2;j++)
2652                    for(j=0;j<(n-8)/2;j++)
2653                    {
2654                        newPts.add(pLinePoints[j]);
2655                    }
2656                    //add the arrow outline
2657                    newPts.add(pLinePoints[n-6]);
2658                    newPts.add(pLinePoints[n-5]);
2659                    for(j=n-9;j>=(n-8)/2;j--)
2660                    {
2661                        newPts.add(pLinePoints[j]);
2662                    }
2663                    shape=new Shape2(Shape2.SHAPE_TYPE_FILL);
2664                    shape.moveTo(newPts.get(0));
2665                    t=newPts.size();
2666                    //for(j=1;j<newPts.size();j++)
2667                    for(j=1;j<t;j++)
2668                    {
2669                        shape.lineTo(newPts.get(j));
2670                    }
2671                    break;
2672                case TacticalLines.AAAAA:
2673                    //for(j=0;j<(pLinePoints.length-19)/2;j++)
2674                    for(j=0;j<(n-19)/2;j++)
2675                    {
2676                        newPts.add(pLinePoints[j]);
2677                    }
2678                    //add the arrow outline
2679                    newPts.add(pLinePoints[n-17]);
2680                    newPts.add(pLinePoints[n-18]);
2681                    newPts.add(pLinePoints[n-19]);
2682                    newPts.add(pLinePoints[n-14]);
2683                    newPts.add(pLinePoints[n-15]);
2684
2685                    for(j=n-20;j>=(n-19)/2;j--)
2686                    {
2687                        newPts.add(pLinePoints[j]);
2688                    }
2689                    shape=new Shape2(Shape2.SHAPE_TYPE_FILL);
2690                    shape.moveTo(newPts.get(0));
2691                    t=newPts.size();
2692                    //for(j=1;j<newPts.size();j++)
2693                    for(j=1;j<t;j++)
2694                    {
2695                        shape.lineTo(newPts.get(j));
2696                    }
2697                    break;
2698                case TacticalLines.FRONTAL_ATTACK:
2699                case TacticalLines.TURNING_MOVEMENT:
2700                    for(j=0;j<(n-10)/2;j++)
2701                    {
2702                        newPts.add(pLinePoints[j]);
2703                    }
2704                    //add the arrow outline
2705                    newPts.add(pLinePoints[n-8]);
2706                    newPts.add(pLinePoints[n-9]);
2707                    newPts.add(pLinePoints[n-10]);
2708                    newPts.add(pLinePoints[n-5]);
2709                    newPts.add(pLinePoints[n-6]);
2710
2711                    for(j=n-11;j>=(n-10)/2;j--)
2712                    {
2713                        newPts.add(pLinePoints[j]);
2714                    }
2715                    shape=new Shape2(Shape2.SHAPE_TYPE_FILL);
2716                    shape.moveTo(newPts.get(0));
2717                    t=newPts.size();
2718                    for(j=1;j<t;j++)
2719                    {
2720                        shape.lineTo(newPts.get(j));
2721                    }
2722                    break;
2723                case TacticalLines.MOVEMENT_TO_CONTACT:
2724                    for(j=0;j<(n-24)/2;j++)
2725                    {
2726                        newPts.add(pLinePoints[j]);
2727                    }
2728                    //add the arrow outline
2729                    newPts.add(pLinePoints[n-22]);
2730                    newPts.add(pLinePoints[n-23]);
2731                    newPts.add(pLinePoints[n-24]);
2732                    newPts.add(pLinePoints[n-19]);
2733                    newPts.add(pLinePoints[n-20]);
2734
2735                    for(j=n-25;j>=(n-24)/2;j--)
2736                    {
2737                        newPts.add(pLinePoints[j]);
2738                    }
2739                    shape=new Shape2(Shape2.SHAPE_TYPE_FILL);
2740                    shape.moveTo(newPts.get(0));
2741                    t=newPts.size();
2742                    for(j=1;j<t;j++)
2743                    {
2744                        shape.lineTo(newPts.get(j));
2745                    }
2746                    break;
2747                case TacticalLines.CATKBYFIRE:
2748                    //for(j=0;j<(pLinePoints.length-17)/2;j++)
2749                    for(j=0;j<(n-17)/2;j++)
2750                    {
2751                        newPts.add(pLinePoints[j]);
2752                    }
2753                    //add the arrow outline
2754                    newPts.add(pLinePoints[n-15]);
2755                    newPts.add(pLinePoints[n-16]);
2756                    newPts.add(pLinePoints[n-17]);
2757                    newPts.add(pLinePoints[n-12]);
2758                    newPts.add(pLinePoints[n-13]);
2759                    for(j=n-18;j>=(n-17)/2;j--)
2760                    {
2761                        newPts.add(pLinePoints[j]);
2762                    }
2763                    shape=new Shape2(Shape2.SHAPE_TYPE_FILL);
2764                    shape.moveTo(newPts.get(0));
2765                    t=newPts.size();
2766                    //for(j=1;j<newPts.size();j++)
2767                    for(j=1;j<t;j++)
2768                    {
2769                        shape.lineTo(newPts.get(j));
2770                    }
2771                    break;
2772                default:
2773                    break;
2774            }
2775            if(shape!=null)
2776            {
2777                shapes=new ArrayList();
2778                shape.setLineColor(null);
2779                shapes.add(shape);
2780            }
2781        }
2782        catch (Exception exc) {
2783            ErrorLogger.LogException(_className ,"getAXADfillShapes",
2784                    new RendererException("Failed inside getAXADFillShapes", exc));
2785        }
2786        return shapes;
2787    }
2788    /*
2789     * sets shape2 properties to those of shape1
2790     * @param shape1
2791     * @param shape2
2792     */
2793//    private static void SetShapeProperties(Shape2 shape1, Shape2 shape2)
2794//    {
2795//        try
2796//        {
2797//            shape2.setLineColor(shape1.getLineColor());
2798//            shape2.setStroke(shape1.getStroke());
2799//            shape2.setFillColor(shape1.getFillColor());
2800//        }
2801//        catch (Exception exc) {
2802//            ErrorLogger.LogException(_className ,"GetChannel1Double",
2803//                    new RendererException("Failed inside SetShapeProperties", exc));
2804//        }
2805//    }
2806}