001/*
002 * To change this template, choose Tools | Templates
003 * and open the template in the editor.
004 */
005
006package armyc2.c2sd.JavaLineArray;
007import armyc2.c2sd.renderer.utilities.ErrorLogger;
008import armyc2.c2sd.renderer.utilities.RendererException;
009import armyc2.c2sd.graphics2d.Rectangle2D;
010/**
011 * A class which imported many of the C++ functions from Trident
012 * Systems Dismounted Intelligence Situational Awareness System (DISM) for
013 * rendering Mil-Standard-2525 tactical lines. This class does not get instantiated
014 * Much of the code is still the original DISM code.
015 * @author Michael Deutch
016 */
017public final class DISMSupport
018{
019    private static final int LEFT_SIDE=0;
020    private static final int RIGHT_SIDE=1;
021    private static final int COLINEAR=2;
022
023    private static final double CONST_PI = Math.PI;
024    private static final double maxLength=100;
025    private static double minLength=2.5;    //was 5    
026    private static final String _className="DISMSupport";
027    
028//    protected static void setMinLength(double mLength)
029//    {
030//        minLength=mLength;
031//    }
032    private static double GetTGFontSize(double iLength)
033    {
034        double result=-1;
035        try
036        {
037            if (iLength < 20)
038                result = 0;
039            else if (iLength < 50)
040                result = 1;
041            else if (iLength > 250)
042                result = 3;
043            else
044                result = 2;
045        }
046        catch(Exception exc)
047        {
048            ErrorLogger.LogException(_className ,"GetTGFontSize",
049                    new RendererException("Failed inside GetTGFontSize", exc));
050        }
051        return result;
052    }
053    private static void ArcApproximationDouble(double left, double top, double right, double bottom,
054            double startx, double starty, double endx, double endy, POINT2[] lpoints)
055    {
056
057        try
058        {
059            double dstartx = startx;
060            double dstarty = starty;
061            double dendx = endx;
062            double dendy = endy;
063            double a = 0;
064            double b = 0;
065            double ctrX = 0;
066            double ctrY = 0;
067            double x1, y1, x2, y2;
068            double startAngle, endAngle;
069            double angleIncrement = 0;
070            double t=0;
071
072            int i = 0;
073            if (left > right)
074            {
075                double temp = left;
076                left = right;
077                right = temp;
078            }
079            if (top > bottom)
080            {
081                double temp = top;
082                top = bottom;
083                bottom = temp;
084            }
085
086            a = (right - left) / 2.0;
087            b = (bottom - top) / 2.0;
088            ctrX = left + a;
089            ctrY = top + b;
090
091            x1 = dstartx - ctrX;
092            x2 = dendx - ctrX;
093            y1 = ctrY - dstarty;
094            y2 = ctrY - dendy;
095
096            if (y1 == 0)
097            {
098                if (x1 > 0) startAngle = 0;
099                else startAngle = CONST_PI;
100            }
101            else if (x1 == 0)
102            {
103                if (y1 > 0) startAngle = CONST_PI * 0.5;
104                else startAngle = CONST_PI * -0.5;
105            }
106            else startAngle = Math.atan2(y1, x1);
107
108            if (y2 == 0)
109            {
110                if (x2 > 0) endAngle = 0;
111                else endAngle = CONST_PI;
112            }
113            else if (x2 == 0)
114            {
115                if (y2 > 0) endAngle = CONST_PI * 0.5;
116                else endAngle = CONST_PI * -0.5;
117            }
118            else endAngle = Math.atan2(y2, x2);
119
120            if (endAngle <= startAngle) endAngle += 2 * CONST_PI;
121            angleIncrement = (endAngle - startAngle) / 16.0;
122
123            for (t = startAngle; i < 17; t += angleIncrement, i++)
124            {
125                lpoints[i].x = ctrX + a * Math.cos(t);
126                lpoints[i].y = ctrY - b * Math.sin(t);
127            }
128            return;
129        }
130        catch(Exception exc)
131        {
132            ErrorLogger.LogException(_className ,"ArcApproximationDouble",
133                    new RendererException("Failed inside ArcApproximationDouble", exc));
134        }
135    }
136    private static void DrawOpenRectangleDouble(POINT2[] points, POINT2[] pointsCorner, POINT2[] resultpts) {
137        try {
138            // draw open-ended rectangle
139            POINT2 point_mid = new POINT2();
140            int j = 0;
141            //  POINT1 pts[4];
142            point_mid.x = (points[0].x + points[1].x) / 2;
143            point_mid.y = (points[0].y + points[1].y) / 2;
144            pointsCorner[0].x = points[0].x - point_mid.x + points[2].x;
145            pointsCorner[0].y = points[0].y - point_mid.y + points[2].y;
146            pointsCorner[1].x = points[1].x - point_mid.x + points[2].x;
147            pointsCorner[1].y = points[1].y - point_mid.y + points[2].y;
148            resultpts[0] = new POINT2(points[1]);
149            resultpts[1] = new POINT2(pointsCorner[1]);
150            resultpts[2] = new POINT2(pointsCorner[0]);
151            resultpts[3] = new POINT2(points[0]);
152            for (j = 0; j < 4; j++) {
153                resultpts[j].style = 0;
154            }
155            resultpts[3].style = 5;
156            
157        } catch (Exception exc) {
158            ErrorLogger.LogException(_className ,"DrawOpenRectangleDouble",
159                    new RendererException("Failed inside DrawOpenRectangleDouble", exc));
160        }
161        return;
162    }
163    private static int DetermineDirectionDouble(POINT2[] points) {
164        int result=0;
165        try {
166            double dP0P1M = 0;
167            double iP0P1B = 0;
168            if (points[0].x == points[1].x) {
169                if (points[2].x < points[0].x) {
170                    return 1;
171                } else {
172                    return 0;
173                }
174            } else {
175                // dP0P1M = slope of line between Point0 and Point1
176                dP0P1M = (double) (points[0].y - points[1].y) / (double) (points[0].x - points[1].x);
177                // iP0P1B = b component of y=mx+b equation of line
178                iP0P1B = (points[0].y - dP0P1M * points[0].x);
179                if (((points[2].y - iP0P1B) / dP0P1M) > points[2].x) {
180                    return 1;
181                } else {
182                    return 0;
183                }
184            }
185        } catch (Exception exc) {
186            ErrorLogger.LogException(_className ,"DetermineDirectionDouble",
187                    new RendererException("Failed inside DetermineDirectionDouble", exc));
188        }
189        return result;
190    }
191    private static void CalcEndpieceDeltasDouble(POINT2[] points, ref
192        <double[]> piDeltaX, ref <double[]> piDeltaY,
193        double dAngleDelta
194               )
195    {
196        try {
197            // find midpoint between point0 and point1
198            POINT2 pntMid = new POINT2();
199            double iDiagEOL_length = 0;
200            double dAngle1 = 0;
201
202            pntMid.x = (points[0].x + points[1].x) / 2;
203            pntMid.y = (points[0].y + points[1].y) / 2;
204            // iDiagEOL_length = length of the diagonal on end of line from line out to endpoint
205            iDiagEOL_length =  ((Math.sqrt // height of graphic
206                    (
207                    (points[1].x - points[0].x) * (points[1].x - points[0].x) +
208                    (points[1].y - points[0].y) * (points[1].y - points[0].y)) +
209                    Math.sqrt // length of graphic
210                    (
211                    (points[2].x - pntMid.x) * (points[2].x - pntMid.x) +
212                    (points[2].y - pntMid.y) * (points[2].y - pntMid.y))) / 20);
213
214            if ((double) iDiagEOL_length > maxLength/5) {
215                iDiagEOL_length = maxLength/5;
216            }
217            if ((double) iDiagEOL_length < minLength) {   
218                iDiagEOL_length = minLength; 
219            }
220
221            // dAngle1 = angle used to calculate the end-piece deltas
222            dAngle1 = Math.atan2(points[2].y - pntMid.y, points[2].x - pntMid.x) + dAngleDelta;
223            //  dAngle1 = atan2(points[2].y - pntMid.y, points[2].x - pntMid.x) + dAngleDelta;
224            piDeltaX.value=new double[1];
225            piDeltaY.value=new double[1];
226            piDeltaX.value[0] =  (iDiagEOL_length * Math.cos(dAngle1));
227            piDeltaY.value[0] = (iDiagEOL_length * Math.sin(dAngle1));
228            return;
229        } catch (Exception exc) {
230            ErrorLogger.LogException(_className ,"CalcEndpieceDeltasDouble",
231                    new RendererException("Failed inside CalcEndpieceDeltasDouble", exc));
232        }
233    }
234    /**
235     * Calculates the points for DELAY, WITHDRAW, WDRAWUP, RETIRE
236     *
237     * @param points OUT - the client points, also used for the returned points.
238     */
239    protected static int GetDelayGraphicEtcDouble(POINT2[] points) {
240        int counter=0;
241        try {
242            POINT2[] pts = new POINT2[2];
243            POINT2[] savepoints = new POINT2[3];
244            double iLength = 0;
245            double iRadius = 0;
246            double iDiagEOL_length = 0;
247            double dAngle1 = 0;
248            double iDeltaX1 = 0;
249            double iDeltaY1 = 0;
250            double iDeltaX2 = 0;
251            double iDeltaY2 = 0;
252            POINT2 ptArcCenter = new POINT2();
253            POINT2[] arcpoints = new POINT2[17];
254            POINT2[] deltapoints = new POINT2[4];
255            int j = 0;
256
257            for (j = 0; j < 3; j++) {
258                savepoints[j] = new POINT2(points[j]);
259            }
260
261            lineutility.InitializePOINT2Array(pts);
262            lineutility.InitializePOINT2Array(arcpoints);
263            lineutility.InitializePOINT2Array(deltapoints);
264
265            points[counter] = new POINT2(savepoints[0]);
266            points[counter].style = 14;
267            counter++;
268            points[counter] = new POINT2(savepoints[1]);
269            points[counter].style = 5;
270            counter++;
271
272            iLength =  Math.sqrt((savepoints[1].x - savepoints[0].x) * (savepoints[1].x - savepoints[0].x) +
273                    (savepoints[1].y - savepoints[0].y) * (savepoints[1].y - savepoints[0].y));
274            iRadius =  Math.sqrt((savepoints[2].x - savepoints[1].x) * (savepoints[2].x - savepoints[1].x) +
275                    (savepoints[2].y - savepoints[1].y) * (savepoints[2].y - savepoints[1].y)) / 2;
276            iDiagEOL_length = (iLength + iRadius * 2) / 20;           
277
278            if ((double) iDiagEOL_length > maxLength) {
279                iDiagEOL_length = maxLength;
280            }
281            if ((double) iDiagEOL_length < minLength) {   //was minLength
282                iDiagEOL_length = minLength;
283            }
284                        
285            dAngle1 = Math.atan2(points[1].y - points[0].y, points[1].x - points[0].x);
286
287            iDeltaX1 = (iDiagEOL_length * Math.cos(dAngle1 - CONST_PI / 4));
288            iDeltaY1 = (iDiagEOL_length * Math.sin(dAngle1 - CONST_PI / 4));
289            iDeltaX2 = (iDiagEOL_length * Math.cos(dAngle1 + CONST_PI / 4));
290            iDeltaY2 = (iDiagEOL_length * Math.sin(dAngle1 + CONST_PI / 4));
291            DrawEndpieceDeltasDouble(savepoints[0],
292                    iDeltaX1, iDeltaY1, iDeltaX2, iDeltaY2, deltapoints);
293
294
295            for (j = 0; j < 4; j++) {
296                points[counter] = new POINT2(deltapoints[j]);
297                counter++;
298            }
299            // draw the semicircle
300            ptArcCenter.x = (savepoints[1].x + savepoints[2].x) / 2;
301            ptArcCenter.y = (savepoints[1].y + savepoints[2].y) / 2;
302
303
304            boolean reverseArc = ReverseDelayArc(savepoints);
305            if (reverseArc == false) {
306                ArcApproximationDouble( (ptArcCenter.x - iRadius), (ptArcCenter.y - iRadius),
307                        (ptArcCenter.x + iRadius), (ptArcCenter.y + iRadius),
308                        savepoints[1].x, savepoints[1].y, savepoints[2].x, savepoints[2].y, arcpoints);
309            } else {
310                ArcApproximationDouble((ptArcCenter.x - iRadius), (ptArcCenter.y - iRadius),
311                        (ptArcCenter.x + iRadius), (ptArcCenter.y + iRadius),
312                        savepoints[2].x, savepoints[2].y, savepoints[1].x, savepoints[1].y, arcpoints);
313            }
314
315            for (j = 0; j < 17; j++) {
316                points[counter] = new POINT2(arcpoints[j]);
317                points[counter].style = 0;
318                counter++;
319            }
320
321        } catch (Exception exc) {
322            ErrorLogger.LogException(_className ,"GetDelayGraphicEtcDouble",
323                    new RendererException("Failed inside GetDelayGraphicEtcDouble", exc));
324        }
325        return counter;
326    }
327    /**
328     * Calculates the points for SCREEN, COVER, GUARD, SARA.
329     *
330     * @param points OUT - the client points, also used for the returned points.
331     * @param linetype the line type.
332     */
333    protected static int GetDISMCoverDouble(POINT2[] points,
334                                            int linetype) {
335            int counter = 0;
336        try {
337            // switch points[1] and points[2] if they are backwards
338            double dAngle0, dAngle1, dDeltaX0, dDeltaY0, dDeltaX1, dDeltaY1;
339            double iLengthPt0Pt1 = 0;
340            double iLengthPt0Pt2 = 0;
341            double iDelta = 0;
342            int j=0;
343            int t=1;
344            double iFontSize = 0;
345            double iLetterOffset = 0;
346            POINT2[] savepoints = new POINT2[3];
347            POINT2[] pts = new POINT2[2];
348            POINT2[] ptsJaggyLine = new POINT2[4];
349            int sign=1;
350            
351            //added section for jaggy line orientation M. Deutch 6-24-11
352            POINT2 pt0=new POINT2(points[0]);
353            POINT2 pt1=new POINT2(points[1]);
354            POINT2 pt2=new POINT2(points[2]);
355            POINT2 pt3=new POINT2();
356            POINT2 pt4=new POINT2();                        
357            
358            lineutility.LineRelativeToLine(pt1, pt2, pt0, pt3, pt4);
359            //now we have the pt3-pt4 line which pt0 is on
360            //get the corresponding point back on the original line
361            lineutility.LineRelativeToLine(pt3, pt0, pt1, pt2, pt4);
362            int quadrant=lineutility.GetQuadrantDouble(pt0, pt4);
363
364            pt1=new POINT2(points[1]);
365            pt2=new POINT2(points[2]);
366            if(pt1.x<pt2.x && quadrant==1)
367                sign=-1;
368            else if(pt1.x > pt2.x && quadrant == 2)
369                sign=-1;
370            else if(pt1.x > pt2.x && quadrant == 3)
371                sign=-1;
372            else if(pt1.x < pt2.x && quadrant == 4)
373                sign=-1;
374            
375            if(linetype==TacticalLines.SARA)
376                t=0;
377            
378
379            //save the points in the correct order
380            for (j = 0; j < 3; j++) {
381                savepoints[j] = new POINT2(points[j]);
382                savepoints[j].style = 0;
383            }
384
385            lineutility.InitializePOINT2Array(pts);
386            lineutility.InitializePOINT2Array(ptsJaggyLine);
387
388            iLengthPt0Pt1 = Math.sqrt((savepoints[1].x - savepoints[0].x) * (savepoints[1].x - savepoints[0].x) +
389                    (savepoints[1].y - savepoints[0].y) * (savepoints[1].y - savepoints[0].y));
390            iLengthPt0Pt2 = Math.sqrt((savepoints[2].x - savepoints[0].x) * (savepoints[2].x - savepoints[0].x) +
391                    (savepoints[2].y - savepoints[0].y) * (savepoints[2].y - savepoints[0].y));
392
393            if (iLengthPt0Pt1 > iLengthPt0Pt2) {
394                iLengthPt0Pt1 = iLengthPt0Pt2;
395            }
396            iFontSize = GetTGFontSize(iLengthPt0Pt1);
397            if (iFontSize > 0) {
398                iDelta = iLengthPt0Pt1 / 15;//was 15
399
400                if (iDelta > maxLength) {
401                    iDelta = maxLength;
402                }
403                if (iDelta < minLength) {
404                    iDelta = minLength;
405                }
406
407                                dAngle0 = Math.atan2(savepoints[0].y - savepoints[1].y, savepoints[0].x - savepoints[1].x);
408                                dAngle1 = Math.atan2(savepoints[0].y - savepoints[2].y, savepoints[0].x - savepoints[2].x);
409                // left side: draw letter in from the jaggy line
410                                savepoints[0].x -= 30 * Math.cos(dAngle0);  //was 20
411                                savepoints[0].y -= 30 * Math.sin(dAngle0);
412
413                iLetterOffset = 0;
414                ptsJaggyLine[0].x = savepoints[0].x - iLetterOffset * 2;//was -
415                ptsJaggyLine[0].y = savepoints[0].y;
416                ptsJaggyLine[0].x -= iLetterOffset;
417                
418                pts[0].x = (ptsJaggyLine[0].x + savepoints[1].x) / 2;
419                pts[0].y = (ptsJaggyLine[0].y + savepoints[1].y) / 2;
420                dDeltaX0 = Math.cos(dAngle0 + sign*CONST_PI / 4) * iDelta;   //was +
421                dDeltaY0 = Math.sin(dAngle0 + sign*CONST_PI / 4) * iDelta;   //was +
422                ptsJaggyLine[1].x = pts[0].x - dDeltaX0;    //was -
423                ptsJaggyLine[1].y = pts[0].y - dDeltaY0;    //was -
424                ptsJaggyLine[2].x = pts[0].x + dDeltaX0;    //was +
425                ptsJaggyLine[2].y = pts[0].y + dDeltaY0;    //was +
426                ptsJaggyLine[3] = new POINT2(savepoints[1]);
427                for (j = 0; j < 4; j++) {
428                    points[counter] = new POINT2(ptsJaggyLine[j]);
429                    counter++;
430                }
431                points[counter - 1].style = 5;
432                // draw arrow at end of line
433                dDeltaX1 = Math.cos(dAngle0 - sign*CONST_PI / 4) * iDelta;   //was -
434                dDeltaY1 = Math.sin(dAngle0 - sign*CONST_PI / 4) * iDelta;   //was -
435                ptsJaggyLine[0].x = savepoints[1].x + dDeltaX0; //was +
436                ptsJaggyLine[0].y = savepoints[1].y + dDeltaY0; //was +
437                ptsJaggyLine[1] = new POINT2(savepoints[1]);
438                ptsJaggyLine[2].x = savepoints[1].x + dDeltaX1; //was +
439                ptsJaggyLine[2].y = savepoints[1].y + dDeltaY1; //was +
440                for (j = 0; j < 3; j++) {
441                    points[counter] = new POINT2(ptsJaggyLine[j]);
442                    points[counter].style = 0;
443                    if(linetype==TacticalLines.SARA)
444                    {
445                        points[counter].style = 9;
446                    }
447
448                    counter++;
449                }
450
451                points[counter - 1].style = 5;
452                if(linetype==TacticalLines.SARA)
453                {
454                    points[counter-1].style = 9;
455                    points[counter]=new POINT2(points[counter-3]);
456                    points[counter].style=10;
457                    counter++;
458                }
459
460                // right side: draw letter and jaggy line
461                savepoints[0].x += 30 * (Math.cos(dAngle0) - Math.cos(dAngle1));  //was 20
462                savepoints[0].y += 30 * (Math.sin(dAngle0) - Math.sin(dAngle1));
463
464                ptsJaggyLine[0].x = savepoints[0].x + iLetterOffset * 2;
465                ptsJaggyLine[0].y = savepoints[0].y;
466                ptsJaggyLine[0].x += iLetterOffset;
467                
468                pts[0].x = (ptsJaggyLine[0].x + savepoints[2].x) / 2;
469                pts[0].y = (ptsJaggyLine[0].y + savepoints[2].y) / 2;
470                dDeltaX0 = Math.cos(dAngle1 - sign*CONST_PI / 4) * iDelta;   //was -
471                dDeltaY0 = Math.sin(dAngle1 - sign*CONST_PI / 4) * iDelta;   //was -
472                ptsJaggyLine[1].x = pts[0].x - dDeltaX0;    //was -
473                ptsJaggyLine[1].y = pts[0].y - dDeltaY0;    //was -
474                ptsJaggyLine[2].x = pts[0].x + dDeltaX0;    //was +
475                ptsJaggyLine[2].y = pts[0].y + dDeltaY0;    //was +
476                ptsJaggyLine[3] = new POINT2(savepoints[2]);
477                for (j = 0; j < 4; j++) {
478                    points[counter] = new POINT2(ptsJaggyLine[j]);
479                    counter++;
480                }
481                points[counter - 1].style = 5;
482                // draw arrow at end of line
483                dDeltaX1 = Math.cos(dAngle1 + sign*CONST_PI / 4) * iDelta;   //was +
484                dDeltaY1 = Math.sin(dAngle1 + sign*CONST_PI / 4) * iDelta;   //was +
485                ptsJaggyLine[0].x = savepoints[2].x + dDeltaX0;
486                ptsJaggyLine[0].y = savepoints[2].y + dDeltaY0;
487                ptsJaggyLine[1] = savepoints[2];
488                ptsJaggyLine[2].x = savepoints[2].x + dDeltaX1;
489                ptsJaggyLine[2].y = savepoints[2].y + dDeltaY1;
490                //              DrawLine(destination, mask, color, ptsJaggyLine, 3, iLineThickness);
491                for (j = 0; j < 3; j++) {
492                    points[counter] = new POINT2(ptsJaggyLine[j]);
493                    points[counter].style = 0;
494                    if(linetype==TacticalLines.SARA)
495                        points[counter].style = 9;
496
497                    counter++;
498                }
499                points[counter - 1].style = 5;
500                if(linetype==TacticalLines.SARA)
501                {
502                    points[counter-1].style = 9;
503                    points[counter]=new POINT2(points[counter-3]);
504                    points[counter].style=10;
505                    counter++;
506                }
507            }
508            else {
509                points[0] = new POINT2(savepoints[0]);
510                points[0].style = 0;
511                points[1] = new POINT2(savepoints[1]);
512                points[1].style = 5;
513                points[2] = new POINT2(savepoints[0]);
514                points[2].style = 0;
515                points[3] = new POINT2(savepoints[2]);
516                return 4;
517            }
518
519        } catch (Exception exc) {
520            ErrorLogger.LogException(_className ,"GetDISMcoverDouble",
521                    new RendererException("Failed inside GetDISMCoverDouble", exc));
522        }
523        return counter;
524    }
525    /**
526     * rev C uses 4 
527     * @param points
528     * @param linetype
529     * @return 
530     */
531    protected static int GetDISMCoverDoubleRevC(POINT2[] points,
532                                            int linetype,
533                                            int vblSaveCounter) 
534    {
535            int counter = 0;
536        try 
537        {                        
538            // switch points[1] and points[2] if they are backwards
539            double dAngle0=0, dDeltaX0=0, dDeltaY0=0, dDeltaX1=0, dDeltaY1=0;
540            double iLengthPt0Pt1 = 0;
541            double iLengthPt0Pt2 = 0;
542            double iDelta = 0;
543            int j=0;
544            int t=1;
545            double iFontSize = 0;
546            double iLetterOffset = 0;
547            POINT2[] savepoints = new POINT2[3];
548            POINT2[] pts = new POINT2[2];
549            POINT2[] ptsJaggyLine = new POINT2[4];
550            //float scale = 1;
551            boolean goLeftThenRight=false;
552            int sign=1;
553            
554            //rev C with 4 points
555            POINT2[]origPoints=null;
556            if(vblSaveCounter==4)
557            {
558                origPoints=new POINT2[4];
559                for(j=0;j<vblSaveCounter;j++)
560                    origPoints[j]=new POINT2(points[j]);
561                
562                //reorder points
563                points[1]=origPoints[0];
564                points[2]=origPoints[3];
565                points[0].x=(origPoints[1].x+origPoints[2].x)/2;
566                points[0].y=(origPoints[1].y+origPoints[2].y)/2;
567            }
568                        
569            //added section for jaggy line orientation M. Deutch 6-24-11
570            POINT2 pt0=new POINT2(points[0]);
571            POINT2 pt1=new POINT2(points[1]);
572            POINT2 pt2=new POINT2(points[2]);
573            POINT2 pt3=new POINT2();
574            POINT2 pt4=new POINT2();                        
575            
576            lineutility.LineRelativeToLine(pt1, pt2, pt0, pt3, pt4);
577            //now we have the pt3-pt4 line which pt0 is on
578            //get the corresponding point back on the original line
579            lineutility.LineRelativeToLine(pt3, pt0, pt1, pt2, pt4);
580            int quadrant=lineutility.GetQuadrantDouble(pt0, pt4);
581
582            pt1=new POINT2(points[1]);
583            pt2=new POINT2(points[2]);
584            if(pt1.x<pt2.x && quadrant==1)
585                sign=-1;
586            else if(pt1.x > pt2.x && quadrant == 2)
587                sign=-1;
588            else if(pt1.x > pt2.x && quadrant == 3)
589                sign=-1;
590            else if(pt1.x < pt2.x && quadrant == 4)
591                sign=-1;
592            if(linetype==TacticalLines.SARA)
593                t=0;
594            
595            if(points[1].x<=points[2].x)
596                goLeftThenRight=true;
597
598            //save the points in the correct order
599            for (j = 0; j < 3; j++) {
600                savepoints[j] = new POINT2(points[j]);
601                savepoints[j].style = 0;
602            }
603
604            lineutility.InitializePOINT2Array(pts);
605            lineutility.InitializePOINT2Array(ptsJaggyLine);
606
607            iLengthPt0Pt1 = Math.sqrt((savepoints[1].x - savepoints[0].x) * (savepoints[1].x - savepoints[0].x) +
608                    (savepoints[1].y - savepoints[0].y) * (savepoints[1].y - savepoints[0].y));
609            iLengthPt0Pt2 = Math.sqrt((savepoints[2].x - savepoints[0].x) * (savepoints[2].x - savepoints[0].x) +
610                    (savepoints[2].y - savepoints[0].y) * (savepoints[2].y - savepoints[0].y));
611
612            if (iLengthPt0Pt1 > iLengthPt0Pt2) {
613                iLengthPt0Pt1 = iLengthPt0Pt2;
614            }
615            iFontSize = GetTGFontSize(iLengthPt0Pt1);
616            if (iFontSize > 0) 
617            {
618                iDelta = iLengthPt0Pt1 / 15;//was 15
619
620                if (iDelta > maxLength) {
621                    iDelta = maxLength;
622                }
623                if (iDelta < minLength) {
624                    iDelta = minLength;
625                }
626                
627                // left side: draw letter in from the jaggy line
628                if(vblSaveCounter<4)//rev b
629                {
630                    if(goLeftThenRight)
631                        savepoints[0].x-=30*t;  //was 20
632                    else
633                        savepoints[0].x+=30*t;  //was 20
634                    
635                    iLetterOffset = 0;
636                    ptsJaggyLine[0].x = savepoints[0].x - iLetterOffset * 2;//was -
637                    ptsJaggyLine[0].y = savepoints[0].y;                
638                    ptsJaggyLine[0].x -= iLetterOffset;                
639                    dAngle0 = Math.atan2(ptsJaggyLine[0].y - savepoints[1].y, ptsJaggyLine[0].x - savepoints[1].x);
640                    pts[0].x = (ptsJaggyLine[0].x + savepoints[1].x) / 2;
641                    pts[0].y = (ptsJaggyLine[0].y + savepoints[1].y) / 2;
642                    dDeltaX0 = Math.cos(dAngle0 + sign*CONST_PI / 4) * iDelta;   //was +
643                    dDeltaY0 = Math.sin(dAngle0 + sign*CONST_PI / 4) * iDelta;   //was +
644                    ptsJaggyLine[1].x = pts[0].x - dDeltaX0;    //was -
645                    ptsJaggyLine[1].y = pts[0].y - dDeltaY0;    //was -
646                    ptsJaggyLine[2].x = pts[0].x + dDeltaX0;    //was +
647                    ptsJaggyLine[2].y = pts[0].y + dDeltaY0;    //was +
648                    ptsJaggyLine[3] = new POINT2(savepoints[1]);
649                    for (j = 0; j < 4; j++) 
650                    {
651                        points[counter] = new POINT2(ptsJaggyLine[j]);
652                        counter++;
653                    }
654                    points[counter - 1].style = 5;
655                }//end rev b
656                else    //rev c
657                {
658                    ptsJaggyLine[0]=new POINT2(origPoints[1]);
659                    dAngle0 = Math.atan2(ptsJaggyLine[0].y - origPoints[0].y, ptsJaggyLine[0].x - origPoints[0].x);
660                    pts[0].x = (ptsJaggyLine[0].x + origPoints[0].x) / 2;
661                    pts[0].y = (ptsJaggyLine[0].y + origPoints[0].y) / 2;
662                    dDeltaX0 = Math.cos(dAngle0 + sign*CONST_PI / 4) * iDelta;   //was +
663                    dDeltaY0 = Math.sin(dAngle0 + sign*CONST_PI / 4) * iDelta;   //was +
664                    ptsJaggyLine[1].x = pts[0].x - dDeltaX0;    //was -
665                    ptsJaggyLine[1].y = pts[0].y - dDeltaY0;    //was -
666                    ptsJaggyLine[2].x = pts[0].x + dDeltaX0;    //was +
667                    ptsJaggyLine[2].y = pts[0].y + dDeltaY0;    //was +
668                    //ptsJaggyLine[3] = new POINT2(savepoints[1]);
669                    ptsJaggyLine[3] = new POINT2(origPoints[0]);
670                    for (j = 0; j < 4; j++) 
671                    {
672                        points[counter] = new POINT2(ptsJaggyLine[j]);
673                        counter++;
674                    }
675                    points[counter - 1].style = 5;                    
676                }//end rev c
677                
678                // draw arrow at end of line
679                dDeltaX1 = Math.cos(dAngle0 - sign*CONST_PI / 4) * iDelta;   //was -
680                dDeltaY1 = Math.sin(dAngle0 - sign*CONST_PI / 4) * iDelta;   //was -
681                if(vblSaveCounter<4)
682                {
683                    ptsJaggyLine[0].x = savepoints[1].x + dDeltaX0; //was +
684                    ptsJaggyLine[0].y = savepoints[1].y + dDeltaY0; //was +
685                }
686                else
687                {
688                    ptsJaggyLine[0].x = origPoints[0].x + dDeltaX0; //was +
689                    ptsJaggyLine[0].y = origPoints[0].y + dDeltaY0; //was +                    
690                }
691                if(vblSaveCounter<4)
692                    ptsJaggyLine[1] = new POINT2(savepoints[1]);
693                else
694                    ptsJaggyLine[1] = new POINT2(origPoints[0]);
695                    
696                if(vblSaveCounter<4)
697                {
698                    ptsJaggyLine[2].x = savepoints[1].x + dDeltaX1; //was +
699                    ptsJaggyLine[2].y = savepoints[1].y + dDeltaY1; //was +
700                }
701                else
702                {
703                    ptsJaggyLine[2].x = origPoints[0].x + dDeltaX1; //was +
704                    ptsJaggyLine[2].y = origPoints[0].y + dDeltaY1; //was +                    
705                }
706                for (j = 0; j < 3; j++) {
707                    points[counter] = new POINT2(ptsJaggyLine[j]);
708                    points[counter].style = 0;
709                    if(linetype==TacticalLines.SARA)
710                    {
711                        points[counter].style = 9;
712                    }
713
714                    counter++;
715                }
716
717                points[counter - 1].style = 5;
718                if(linetype==TacticalLines.SARA)
719                {
720                    points[counter-1].style = 9;
721                    points[counter]=new POINT2(points[counter-3]);
722                    points[counter].style=10;
723                    counter++;
724                }
725
726                // right side: draw letter and jaggy line
727                if(vblSaveCounter<4)    //rev b
728                {
729                    if(goLeftThenRight)
730                        savepoints[0].x+=60*t;  //was 40
731                    else
732                        savepoints[0].x-=60*t;  //wass 40
733
734                    ptsJaggyLine[0].x = savepoints[0].x + iLetterOffset * 2;
735                    ptsJaggyLine[0].y = savepoints[0].y;
736                    ptsJaggyLine[0].x += iLetterOffset;                
737                    dAngle0 = Math.atan2(ptsJaggyLine[0].y - savepoints[2].y, ptsJaggyLine[0].x - savepoints[2].x);
738                    pts[0].x = (ptsJaggyLine[0].x + savepoints[2].x) / 2;
739                    pts[0].y = (ptsJaggyLine[0].y + savepoints[2].y) / 2;
740                    dDeltaX0 = Math.cos(dAngle0 - sign*CONST_PI / 4) * iDelta;   //was -
741                    dDeltaY0 = Math.sin(dAngle0 - sign*CONST_PI / 4) * iDelta;   //was -
742                    ptsJaggyLine[1].x = pts[0].x - dDeltaX0;    //was -
743                    ptsJaggyLine[1].y = pts[0].y - dDeltaY0;    //was -
744                    ptsJaggyLine[2].x = pts[0].x + dDeltaX0;    //was +
745                    ptsJaggyLine[2].y = pts[0].y + dDeltaY0;    //was +
746                    ptsJaggyLine[3] = new POINT2(savepoints[2]);
747                    for (j = 0; j < 4; j++) {
748                        points[counter] = new POINT2(ptsJaggyLine[j]);
749                        counter++;
750                    }
751                    points[counter - 1].style = 5;
752                    // draw arrow at end of line
753                    dDeltaX1 = Math.cos(dAngle0 + sign*CONST_PI / 4) * iDelta;   //was +
754                    dDeltaY1 = Math.sin(dAngle0 + sign*CONST_PI / 4) * iDelta;   //was +
755                    ptsJaggyLine[0].x = savepoints[2].x + dDeltaX0;
756                    ptsJaggyLine[0].y = savepoints[2].y + dDeltaY0;
757                    ptsJaggyLine[1] = savepoints[2];
758                    ptsJaggyLine[2].x = savepoints[2].x + dDeltaX1;
759                    ptsJaggyLine[2].y = savepoints[2].y + dDeltaY1;
760                }//end rev b
761                else    //rev c
762                {
763                    ptsJaggyLine[0]=new POINT2(origPoints[2]);
764                    dAngle0 = Math.atan2(ptsJaggyLine[0].y - origPoints[3].y, ptsJaggyLine[0].x - origPoints[3].x);
765                    pts[0].x = (ptsJaggyLine[0].x + origPoints[3].x) / 2;
766                    pts[0].y = (ptsJaggyLine[0].y + origPoints[3].y) / 2;
767                    dDeltaX0 = Math.cos(dAngle0 - sign*CONST_PI / 4) * iDelta;   //was -
768                    dDeltaY0 = Math.sin(dAngle0 - sign*CONST_PI / 4) * iDelta;   //was -
769                    ptsJaggyLine[1].x = pts[0].x - dDeltaX0;    //was -
770                    ptsJaggyLine[1].y = pts[0].y - dDeltaY0;    //was -
771                    ptsJaggyLine[2].x = pts[0].x + dDeltaX0;    //was +
772                    ptsJaggyLine[2].y = pts[0].y + dDeltaY0;    //was +
773                    //ptsJaggyLine[3] = new POINT2(savepoints[2]);
774                    ptsJaggyLine[3] = new POINT2(origPoints[3]);
775                    for (j = 0; j < 4; j++) {
776                        points[counter] = new POINT2(ptsJaggyLine[j]);
777                        counter++;
778                    }
779                    points[counter - 1].style = 5;
780                    // draw arrow at end of line
781                    dDeltaX1 = Math.cos(dAngle0 + sign*CONST_PI / 4) * iDelta;   //was +
782                    dDeltaY1 = Math.sin(dAngle0 + sign*CONST_PI / 4) * iDelta;   //was +
783                    ptsJaggyLine[0].x = origPoints[3].x + dDeltaX0;
784                    ptsJaggyLine[0].y = origPoints[3].y + dDeltaY0;
785                    ptsJaggyLine[1] = new POINT2(origPoints[3]);
786                    ptsJaggyLine[2].x = origPoints[3].x + dDeltaX1;
787                    ptsJaggyLine[2].y = origPoints[3].y + dDeltaY1;                    
788                }//end rev c
789                
790                for (j = 0; j < 3; j++) 
791                {
792                    points[counter] = new POINT2(ptsJaggyLine[j]);
793                    points[counter].style = 0;
794                    if(linetype==TacticalLines.SARA)
795                        points[counter].style = 9;
796
797                    counter++;
798                }
799                points[counter - 1].style = 5;
800                if(linetype==TacticalLines.SARA)
801                {
802                    points[counter-1].style = 9;
803                    points[counter]=new POINT2(points[counter-3]);
804                    points[counter].style=10;
805                    counter++;
806                }
807            }
808            else 
809            {
810                points[0] = new POINT2(savepoints[0]);
811                points[0].style = 0;
812                points[1] = new POINT2(savepoints[1]);
813                points[1].style = 5;
814                points[2] = new POINT2(savepoints[0]);
815                points[2].style = 0;
816                points[3] = new POINT2(savepoints[2]);
817                return 4;
818            }
819        } 
820        catch (Exception exc) 
821        {
822            ErrorLogger.LogException(_className ,"GetDISMcoverDoubleRevC",
823                    new RendererException("Failed inside GetDISMCoverDoubleRevc", exc));
824        }
825        return counter;
826    }
827    /**
828     * Calculates the points for BYPASS
829     *
830     * @param points OUT - the client points, also used for the returned points.
831     * @param linetype the line type.
832     */
833    protected static int GetDISMBypassDouble(POINT2[] points,
834                                            int linetype) {
835        int counter = 0;
836        try {
837            int j = 0;
838            POINT2[] pointsCorner = new POINT2[2];
839            POINT2[] rectpts = new POINT2[4];
840            POINT2[] savepoints = new POINT2[3];
841            POINT2[] deltapoints1 = new POINT2[4];
842            POINT2[] deltapoints2 = new POINT2[4];
843            ref<double[]> iDeltaX = new ref(), iDeltaY = new ref();
844            int bPointsRight = 0;
845
846            for (j = 0; j < 3; j++) {
847                savepoints[j] = new POINT2(points[j]);
848            }
849
850            lineutility.InitializePOINT2Array(pointsCorner);
851            lineutility.InitializePOINT2Array(rectpts);
852            lineutility.InitializePOINT2Array(deltapoints1);
853            lineutility.InitializePOINT2Array(deltapoints2);
854
855            DrawOpenRectangleDouble(savepoints, pointsCorner, rectpts);
856            for (j = 0; j < 4; j++) {
857                points[counter] = rectpts[j];
858                counter++;
859            }
860
861            bPointsRight = DetermineDirectionDouble(savepoints);
862
863            CalcEndpieceDeltasDouble(savepoints, iDeltaX, iDeltaY, CONST_PI / 4);
864
865            if ((savepoints[0].y - savepoints[1].y) < 0) {// Point0 is higher than Point1
866                if (bPointsRight != 0) {// figure opens to the right
867                    DrawEndpieceDeltasDouble(savepoints[0],
868                            iDeltaX.value[0], iDeltaY.value[0], iDeltaY.value[0], -iDeltaX.value[0], deltapoints1);
869                    DrawEndpieceDeltasDouble(savepoints[1],
870                            iDeltaX.value[0], iDeltaY.value[0], iDeltaY.value[0], -iDeltaX.value[0], deltapoints2);
871                } else {// figure opens to the left
872                    DrawEndpieceDeltasDouble(savepoints[0],
873                            iDeltaY.value[0], -iDeltaX.value[0], iDeltaX.value[0], iDeltaY.value[0], deltapoints1);
874                    DrawEndpieceDeltasDouble(savepoints[1],
875                            iDeltaY.value[0], -iDeltaX.value[0], iDeltaX.value[0], iDeltaY.value[0], deltapoints2);
876                }
877            } else {// Point0 is lower than Point1
878                if (bPointsRight != 0) {// figure opens to the right
879                    DrawEndpieceDeltasDouble(savepoints[0],
880                            iDeltaY.value[0], -iDeltaX.value[0], iDeltaX.value[0], iDeltaY.value[0], deltapoints1);
881                    DrawEndpieceDeltasDouble(savepoints[1],
882                            iDeltaY.value[0], -iDeltaX.value[0], iDeltaX.value[0], iDeltaY.value[0], deltapoints2);
883                } else {// figure opens to the left
884                    DrawEndpieceDeltasDouble(savepoints[0],
885                            iDeltaX.value[0], iDeltaY.value[0], iDeltaY.value[0], -iDeltaX.value[0], deltapoints1);
886                    DrawEndpieceDeltasDouble(savepoints[1],
887                            iDeltaX.value[0], iDeltaY.value[0], iDeltaY.value[0], -iDeltaX.value[0], deltapoints2);
888                }
889            }
890
891            for (j = 0; j < 4; j++) {
892                points[counter] = new POINT2(deltapoints1[j]);
893                counter++;
894            }
895            for (j = 0; j < 4; j++) {
896                points[counter] = new POINT2(deltapoints2[j]);
897                counter++;
898            }
899        } catch (Exception exc) {
900            ErrorLogger.LogException(_className ,"GetDISMBypassDouble",
901                    new RendererException("Failed inside GetDISMBypassDouble", exc));
902        }
903        return counter;
904    }
905    /**
906     * Calculates the points for BREACH.
907     *
908     * @param points OUT - the client points, also used for the returned points.
909     * @param linetype the line type.
910     */
911    protected static int GetDISMBreachDouble(POINT2[] points, int linetype) {
912        int counter = 0;
913        try {
914            POINT2[] pointsCorner = new POINT2[2];
915            POINT2[] rectpts = new POINT2[4];
916            POINT2[] deltapoints1 = new POINT2[4];
917            POINT2[] deltapoints2 = new POINT2[4];
918            ref<double[]> iDeltaX = new ref(), iDeltaY = new ref();
919            int bPointsRight = 0, j = 0;
920            POINT2[] savepoints = new POINT2[3];
921
922            for (j = 0; j < 3; j++) {
923                savepoints[j] = new POINT2(points[j]);
924            }
925
926            lineutility.InitializePOINT2Array(pointsCorner);
927            lineutility.InitializePOINT2Array(rectpts);
928            lineutility.InitializePOINT2Array(deltapoints1);
929            lineutility.InitializePOINT2Array(deltapoints2);
930
931            DrawOpenRectangleDouble(savepoints, pointsCorner, rectpts);
932            for (j = 0; j < 4; j++) {
933                points[counter] = new POINT2(rectpts[j]);
934                counter++;
935            }
936
937            bPointsRight = DetermineDirectionDouble(savepoints);
938
939            CalcEndpieceDeltasDouble(savepoints, iDeltaX, iDeltaY, CONST_PI / 4);
940
941            if ((savepoints[0].y - savepoints[1].y) < 0) {// Point0 is higher than Point1
942                if (bPointsRight != 0) {// figure opens to the right
943                    DrawEndpieceDeltasDouble(savepoints[0],
944                            iDeltaX.value[0], iDeltaY.value[0], -iDeltaX.value[0], -iDeltaY.value[0], deltapoints1);
945                    DrawEndpieceDeltasDouble(savepoints[1],
946                            iDeltaY.value[0], -iDeltaX.value[0], -iDeltaY.value[0], iDeltaX.value[0], deltapoints2);
947                } else {// figure opens to the left
948                    DrawEndpieceDeltasDouble(savepoints[0],
949                            iDeltaY.value[0], -iDeltaX.value[0], -iDeltaY.value[0], iDeltaX.value[0], deltapoints1);
950                    DrawEndpieceDeltasDouble(savepoints[1],
951                            iDeltaX.value[0], iDeltaY.value[0], -iDeltaX.value[0], -iDeltaY.value[0], deltapoints2);
952                }
953            } else {// Point0 is lower than Point1
954                if (bPointsRight != 0) {// figure opens to the right
955                    DrawEndpieceDeltasDouble(savepoints[0],
956                            iDeltaY.value[0], -iDeltaX.value[0], -iDeltaY.value[0], iDeltaX.value[0], deltapoints1);
957                    DrawEndpieceDeltasDouble(savepoints[1],
958                            iDeltaX.value[0], iDeltaY.value[0], -iDeltaX.value[0], -iDeltaY.value[0], deltapoints2);
959                } else {// figure opens to the left
960                    DrawEndpieceDeltasDouble(savepoints[0],
961                            iDeltaX.value[0], iDeltaY.value[0], -iDeltaX.value[0], -iDeltaY.value[0], deltapoints1);
962                    DrawEndpieceDeltasDouble(savepoints[1],
963                            iDeltaY.value[0], -iDeltaX.value[0], -iDeltaY.value[0], iDeltaX.value[0], deltapoints2);
964                }
965            }
966            for (j = 0; j < 4; j++) {
967                points[counter] = new POINT2(deltapoints1[j]);
968                counter++;
969            }
970            for (j = 0; j < 4; j++) {
971                points[counter] = new POINT2(deltapoints2[j]);
972                counter++;
973            }
974        } catch (Exception exc) {
975            ErrorLogger.LogException(_className ,"GetDISMBreachDouble",
976                    new RendererException("Failed inside GetDISMBreachDouble", exc));
977        }
978        return counter;
979    }
980    /**
981     * Calculates the points for CANALIZE
982     *
983     * @param points - OUT - the client points, also used for the returned points.
984     * @param linetype the line type.
985     */
986    protected static int GetDISMCanalizeDouble(POINT2[] points, int linetype) {
987        int counter = 0;
988        try {
989            POINT2[] pointsCorner = new POINT2[2];
990            POINT2[] rectpts = new POINT2[4];
991            POINT2[] deltapoints1 = new POINT2[4];
992            POINT2[] deltapoints2 = new POINT2[4];
993            int j = 0;
994            ref<double[]> iDeltaX = new ref(), iDeltaY = new ref();
995            int bPointsRight = 0;
996            POINT2[] savepoints = new POINT2[3];
997
998            for (j = 0; j < 3; j++) {
999                savepoints[j] = new POINT2(points[j]);
1000            }
1001
1002            lineutility.InitializePOINT2Array(pointsCorner);
1003            lineutility.InitializePOINT2Array(rectpts);
1004            lineutility.InitializePOINT2Array(deltapoints1);
1005            lineutility.InitializePOINT2Array(deltapoints2);
1006
1007            DrawOpenRectangleDouble(savepoints, pointsCorner, rectpts);
1008
1009            for (j = 0; j < 4; j++) {
1010                points[counter] = new POINT2(rectpts[j]);
1011                counter++;
1012            }
1013
1014            bPointsRight = DetermineDirectionDouble(savepoints);
1015
1016            CalcEndpieceDeltasDouble(savepoints, iDeltaX, iDeltaY, CONST_PI / 4);
1017
1018            if ((savepoints[0].y - savepoints[1].y) < 0) {// Point0 is higher than Point1
1019                if (bPointsRight != 0) {// figure opens to the right
1020                    DrawEndpieceDeltasDouble(savepoints[1],
1021                            iDeltaX.value[0], iDeltaY.value[0], -iDeltaX.value[0], -iDeltaY.value[0], deltapoints1);
1022                    DrawEndpieceDeltasDouble(savepoints[0],
1023                            iDeltaY.value[0], -iDeltaX.value[0], -iDeltaY.value[0], iDeltaX.value[0], deltapoints2);
1024                } else {// figure opens to the left
1025                    DrawEndpieceDeltasDouble(savepoints[1],
1026                            iDeltaY.value[0], -iDeltaX.value[0], -iDeltaY.value[0], iDeltaX.value[0], deltapoints1);
1027                    DrawEndpieceDeltasDouble(savepoints[0],
1028                            iDeltaX.value[0], iDeltaY.value[0], -iDeltaX.value[0], -iDeltaY.value[0], deltapoints2);
1029                }
1030            } else {// Point0 is lower than Point1
1031                if (bPointsRight != 0) {// figure opens to the right
1032                    DrawEndpieceDeltasDouble(savepoints[1],
1033                            iDeltaY.value[0], -iDeltaX.value[0], -iDeltaY.value[0], iDeltaX.value[0], deltapoints1);
1034                    DrawEndpieceDeltasDouble(savepoints[0],
1035                            iDeltaX.value[0], iDeltaY.value[0], -iDeltaX.value[0], -iDeltaY.value[0], deltapoints2);
1036                } else {// figure opens to the left
1037                    DrawEndpieceDeltasDouble(savepoints[1],
1038                            iDeltaX.value[0], iDeltaY.value[0], -iDeltaX.value[0], -iDeltaY.value[0], deltapoints1);
1039                    DrawEndpieceDeltasDouble(savepoints[0],
1040                            iDeltaY.value[0], -iDeltaX.value[0], -iDeltaY.value[0], iDeltaX.value[0], deltapoints2);
1041                }
1042            }
1043
1044            for (j = 0; j < 4; j++) {
1045                points[counter] = new POINT2(deltapoints1[j]);
1046                counter++;
1047            }
1048            for (j = 0; j < 4; j++) {
1049                points[counter] = new POINT2(deltapoints2[j]);
1050                counter++;
1051            }
1052        } catch (Exception exc) {
1053            ErrorLogger.LogException(_className ,"GetDISMCanalizeDouble",
1054                    new RendererException("Failed inside GetDISMCanalizeDouble", exc));
1055        }
1056        return counter;
1057    }
1058    /**
1059     * Calculates the points for DECEIVE.
1060     *
1061     * @param points - OUT - the client points, also used for the returned points.
1062     */
1063    protected static void GetDISMDeceiveDouble(POINT2[] points) {
1064        try {
1065            POINT2[] savepoints = new POINT2[3];// POINT2[3];
1066            int j = 0;
1067
1068            for (j = 0; j < 3; j++) {
1069                savepoints[j] = new POINT2(points[j]);
1070            }
1071
1072            points[0] = new POINT2(savepoints[0]);
1073            points[0].style = 1;
1074            points[1] = new POINT2(savepoints[1]);
1075            points[1].style = 5;
1076            points[2] = new POINT2(savepoints[2]);
1077            points[2].style = 1;
1078            points[3] = new POINT2(savepoints[0]);
1079            points[3].style = 5;
1080
1081        } catch (Exception exc) {
1082            ErrorLogger.LogException(_className ,"GetDISMDeceiveDouble",
1083                    new RendererException("Failed inside GetDISMDeceiveDouble", exc));
1084        }
1085    }
1086    /**
1087     * Calculates the points for DISRUPT
1088     *
1089     * @param points OUT - the client points, also used for the returned points.
1090     * @param linetype the line type.
1091     */
1092    protected static int GetDISMDisruptDouble(POINT2[] points, int linetype) {
1093        int counter = 0;
1094        try {
1095            POINT2[] pts = new POINT2[2];
1096            POINT2[] ptsArrow = new POINT2[3];
1097            POINT2 ptCenter = new POINT2();
1098            int j = 0;
1099            POINT2[] savepoints = new POINT2[3];
1100            double dAngle1 = 0;
1101            POINT2[] deltapoints1 = new POINT2[4];
1102            POINT2[] deltapoints2 = new POINT2[4];
1103            POINT2[] deltapoints3 = new POINT2[4];
1104            double iDiagEOL_length = 0;
1105            double iDeltaX1 = 0;
1106            double iDeltaY1 = 0;
1107            double iDeltaX2 = 0;
1108            double iDeltaY2 = 0;
1109
1110            for (j = 0; j < 3; j++) {
1111                savepoints[j] = new POINT2(points[j]);
1112            }
1113
1114            lineutility.InitializePOINT2Array(pts);
1115            lineutility.InitializePOINT2Array(ptsArrow);
1116            lineutility.InitializePOINT2Array(deltapoints1);
1117            lineutility.InitializePOINT2Array(deltapoints2);
1118            lineutility.InitializePOINT2Array(deltapoints3);
1119
1120            //  DrawLine(destination, mask, color, points, 2, 2);
1121            points[counter] = new POINT2(savepoints[0]);
1122            points[counter].style = 0;
1123            counter++;
1124            points[counter] = new POINT2(savepoints[1]);
1125            points[counter].style = 5;
1126            counter++;
1127            //  pts[0] = points[1];
1128            //  pts[1] = points[2];
1129            //  DrawLine(destination, mask, color, pts, 2, 2);
1130            points[counter] = new POINT2(savepoints[1]);
1131            points[counter].style = 0;
1132            counter++;
1133            points[counter] = new POINT2(savepoints[2]);
1134            points[counter].style = 5;
1135            counter++;
1136
1137            ptCenter.x = (savepoints[0].x + savepoints[1].x) / 2;
1138            ptCenter.y = (savepoints[0].y + savepoints[1].y) / 2;
1139            ptsArrow[0] = new POINT2(savepoints[2]);
1140            ptsArrow[1].x = ptCenter.x + (savepoints[2].x - savepoints[1].x) * 4 / 5;
1141            ptsArrow[1].y = ptCenter.y + (savepoints[2].y - savepoints[1].y) * 4 / 5;
1142            ptsArrow[2].x = savepoints[0].x + (savepoints[2].x - savepoints[1].x) * 3 / 5;
1143            ptsArrow[2].y = savepoints[0].y + (savepoints[2].y - savepoints[1].y) * 3 / 5;
1144
1145            pts[0].x = ptCenter.x - (savepoints[2].x - savepoints[1].x) / 5;
1146            pts[0].y = ptCenter.y - (savepoints[2].y - savepoints[1].y) / 5;
1147            pts[1] = new POINT2(ptsArrow[1]);
1148            //  DrawLine(destination, mask, color, pts, 2, 2);
1149            points[counter] = new POINT2(pts[0]);
1150            points[counter].style = 0;
1151            counter++;
1152            points[counter] = new POINT2(pts[1]);
1153            points[counter].style = 5;
1154            counter++;
1155
1156            pts[0] = new POINT2(savepoints[0]);
1157            pts[1] = new POINT2(ptsArrow[2]);
1158            //  DrawLine(destination, mask, color, pts, 2, 2);
1159            points[counter] = new POINT2(pts[0]);
1160            points[counter].style = 0;
1161            counter++;
1162            points[counter] = new POINT2(pts[1]);
1163            points[counter].style = 5;
1164            counter++;
1165
1166            // the following code is very similar to CalcEndpieceDeltas
1167            iDiagEOL_length =  ((Math.sqrt // height of graphic
1168                    (
1169                    (savepoints[1].x - savepoints[0].x) * (savepoints[1].x - savepoints[0].x) +
1170                    (savepoints[1].y - savepoints[0].y) * (savepoints[1].y - savepoints[0].y)) +
1171                    Math.sqrt // length of graphic
1172                    (
1173                    (savepoints[2].x - savepoints[1].x) * (savepoints[2].x - savepoints[1].x) +
1174                    (savepoints[2].y - savepoints[1].y) * (savepoints[2].y - savepoints[1].y))) / 15);
1175
1176            //M. Deutch 8-18-04
1177            if (iDiagEOL_length >  maxLength) {
1178                iDiagEOL_length =  maxLength;
1179            }
1180            if (iDiagEOL_length <  minLength) {//was minLength
1181                iDiagEOL_length =  minLength;   //was minLength
1182            }
1183
1184            // dAngle1 = angle used to calculate the end-piece deltas
1185            dAngle1 = Math.atan2(savepoints[1].y - savepoints[2].y, savepoints[1].x - savepoints[2].x);
1186            //  dAngle1 = atan2(savepoints[1].y - savepoints[2].y, savepoints[1].x - savepoints[2].x);
1187            iDeltaX1 =  (iDiagEOL_length * Math.cos(dAngle1 - CONST_PI / 6));
1188            iDeltaY1 =  (iDiagEOL_length * Math.sin(dAngle1 - CONST_PI / 6));
1189            iDeltaX2 =  (iDiagEOL_length * Math.cos(dAngle1 + CONST_PI / 6));
1190            iDeltaY2 =  (iDiagEOL_length * Math.sin(dAngle1 + CONST_PI / 6));
1191
1192            DrawEndpieceDeltasDouble(ptsArrow[0],
1193                    iDeltaX1, iDeltaY1, iDeltaX2, iDeltaY2, deltapoints1);
1194            DrawEndpieceDeltasDouble(ptsArrow[1],
1195                    iDeltaX1, iDeltaY1, iDeltaX2, iDeltaY2, deltapoints2);
1196            DrawEndpieceDeltasDouble(ptsArrow[2],
1197                    iDeltaX1, iDeltaY1, iDeltaX2, iDeltaY2, deltapoints3);
1198            for (j = 0; j < 4; j++) {
1199                points[counter] = new POINT2(deltapoints1[j]);
1200                counter++;
1201            }
1202            for (j = 0; j < 4; j++) {
1203                points[counter] = new POINT2(deltapoints2[j]);
1204                counter++;
1205            }
1206            for (j = 0; j < 4; j++) {
1207                points[counter] = new POINT2(deltapoints3[j]);
1208                counter++;
1209            }
1210        } catch (Exception exc) {
1211            ErrorLogger.LogException(_className ,"GetDISMDisruptDouble",
1212                    new RendererException("Failed inside GetDISMDisruptDouble", exc));
1213        }
1214        return counter;
1215    }
1216    /**
1217     * Calculates the points for CONTAIN
1218     *
1219     * @param points OUT - the client points, also used for the returned points.
1220     * @param linetype the line type.
1221     */
1222    protected static int GetDISMContainDouble(POINT2[] points, int linetype) {
1223        int counter = 0;
1224        try {
1225            POINT2[] pts = new POINT2[3];
1226            POINT2 ptCenter = new POINT2();
1227            POINT2 ptPerp = new POINT2(); // point used to draw perpendicular line
1228            double iPerpLength = 0;
1229            int j = 0;
1230            double dAngle1 = 0, d = 0;
1231            double dCosAngle1 = 0;
1232            double dSinAngle1 = 0;
1233            double iRadius = 0;
1234            double iDiagEOL_length = 0;
1235            double dAngle2 = 0;
1236            double dDeltaX1, dDeltaY1, dDeltaX2, dDeltaY2;
1237            POINT2[] savepoints = new POINT2[3];
1238            POINT2[] arcpoints = new POINT2[17];
1239
1240            for (j = 0; j < 3; j++) {
1241                savepoints[j] = new POINT2(points[j]);
1242            }
1243
1244            lineutility.InitializePOINT2Array(pts);
1245            lineutility.InitializePOINT2Array(arcpoints);
1246
1247            ptCenter.x = (savepoints[0].x + savepoints[1].x) / 2;
1248            ptCenter.y = (savepoints[0].y + savepoints[1].y) / 2;
1249
1250            //added section M. Deutch   8-10-06
1251            //reverse points 0 and 1 if necessary to ensure arc
1252            //has correct orientation
1253            ref<double[]> m = new ref();
1254            POINT2 ptRelative = lineutility.PointRelativeToLine(savepoints[0], savepoints[1], savepoints[2]);
1255
1256            lineutility.CalcTrueSlopeDouble2(savepoints[0], savepoints[1], m);
1257            if (m.value[0] != 0) {
1258                if (savepoints[0].y > savepoints[1].y) {
1259                    if (ptRelative.x > ptCenter.x) {
1260                        lineutility.Reverse2Points(savepoints[0], savepoints[1]);
1261                    }
1262                }
1263                if (savepoints[0].y < savepoints[1].y) {
1264                    if (ptRelative.x < ptCenter.x) {
1265                        lineutility.Reverse2Points(savepoints[0], savepoints[1]);
1266                    }
1267                }
1268            } else {
1269                if (savepoints[0].x < savepoints[1].x) {
1270                    if (ptRelative.y > ptCenter.y) {
1271                        lineutility.Reverse2Points(savepoints[0], savepoints[1]);
1272                    }
1273                }
1274                if (savepoints[0].x > savepoints[1].x) {
1275                    if (ptRelative.y < ptCenter.y) {
1276                        lineutility.Reverse2Points(savepoints[0], savepoints[1]);
1277                    }
1278                }
1279            }
1280            //end section
1281
1282            iPerpLength =  Math.sqrt((ptCenter.x - savepoints[2].x) * (ptCenter.x - savepoints[2].x) + (ptCenter.y - savepoints[2].y) * (ptCenter.y - savepoints[2].y));
1283            if (iPerpLength < 1) {
1284                iPerpLength = 1;
1285            }
1286
1287            dAngle1 = Math.atan2(savepoints[0].y - savepoints[1].y, savepoints[0].x - savepoints[1].x);
1288            dCosAngle1 = Math.cos(dAngle1 + CONST_PI / 2);
1289            dSinAngle1 = Math.sin(dAngle1 + CONST_PI / 2);
1290            
1291            ptPerp.x = ptCenter.x + dCosAngle1 * iPerpLength;
1292            ptPerp.y = ptCenter.y + dSinAngle1 * iPerpLength;
1293
1294            pts[0] = new POINT2(ptCenter);
1295
1296            pts[1] = new POINT2(savepoints[2]);
1297
1298            points[counter] = new POINT2(pts[0]);
1299            points[counter].style = 14;
1300            counter++;
1301            points[counter] = new POINT2(pts[1]);
1302            points[counter].style = 5;
1303            counter++;
1304
1305            // draw arrowhead
1306            iRadius =  Math.sqrt((ptCenter.x - savepoints[0].x) * (ptCenter.x - savepoints[0].x) + (ptCenter.y - savepoints[0].y) * (ptCenter.y - savepoints[0].y));
1307            iDiagEOL_length = (iPerpLength + iRadius) / 20;
1308
1309            if (iDiagEOL_length >  maxLength) {
1310                iDiagEOL_length =  maxLength;
1311            }
1312            if (iDiagEOL_length <  minLength) { 
1313                iDiagEOL_length =  minLength;   
1314            }
1315
1316            dAngle2 = Math.atan2(ptPerp.y - ptCenter.y, ptPerp.x - ptCenter.x);
1317            dDeltaX1 = Math.cos(dAngle2 + CONST_PI / 4);
1318            dDeltaY1 = Math.sin(dAngle2 + CONST_PI / 4);
1319            dDeltaX2 = Math.cos(dAngle2 - CONST_PI / 4);
1320            dDeltaY2 = Math.sin(dAngle2 - CONST_PI / 4);
1321            pts[0].x = ptCenter.x + dDeltaX1 * iDiagEOL_length;
1322            pts[0].y = ptCenter.y + dDeltaY1 * iDiagEOL_length;
1323            pts[1] = new POINT2(ptCenter);
1324            pts[2].x = ptCenter.x + dDeltaX2 * iDiagEOL_length;
1325            pts[2].y = ptCenter.y + dDeltaY2 * iDiagEOL_length;
1326            //end section
1327            for (j = 0; j < 3; j++) {
1328                points[counter] = new POINT2(pts[j]);
1329                points[counter].style = 0;
1330                counter++;
1331            }
1332            points[counter - 1].style = 5;
1333
1334            // draw arc
1335            ArcApproximationDouble(ptCenter.x - iRadius, ptCenter.y - iRadius,
1336                    ptCenter.x + iRadius, ptCenter.y + iRadius,
1337                    savepoints[0].x, savepoints[0].y, savepoints[1].x, savepoints[1].y, arcpoints);
1338
1339            for (j = 0; j < 17; j++) {
1340                points[counter] = new POINT2(arcpoints[j]);
1341                points[counter].style = 0;
1342                counter++;
1343            }
1344            points[counter - 1].style = 5;
1345
1346            // draw spokes inside arc
1347            pts[0] = new POINT2(savepoints[0]);
1348            pts[1].x = (pts[0].x + ptCenter.x) / 2;
1349            pts[1].y = (pts[0].y + ptCenter.y) / 2;
1350            d = lineutility.CalcDistanceDouble(pts[0], pts[1]);
1351            if (d > maxLength) //shorten the spoke
1352            {
1353                pts[1] = lineutility.ExtendLineDouble(pts[1], pts[0], -maxLength);
1354            }
1355
1356            points[counter] = new POINT2(pts[0]);
1357            points[counter].style = 0;
1358            counter++;
1359            points[counter] = new POINT2(pts[1]);
1360            points[counter].style = 5;
1361            counter++;
1362
1363            pts[0] = new POINT2(savepoints[1]);
1364            pts[1].x = (pts[0].x + ptCenter.x) / 2;
1365            pts[1].y = (pts[0].y + ptCenter.y) / 2;
1366            d = lineutility.CalcDistanceDouble(pts[0], pts[1]);
1367            if (d > maxLength) //shorten the spoke
1368            {
1369                pts[1] = lineutility.ExtendLineDouble(pts[1], pts[0], -maxLength);
1370            }
1371            //  DrawLine(destination, mask, color, pts, 2, 2);
1372
1373            points[counter] = new POINT2(pts[0]);
1374            points[counter].style = 0;
1375            counter++;
1376            points[counter] = new POINT2(pts[1]);
1377            points[counter].style = 5;
1378            counter++;
1379
1380            pts[0].x = ptCenter.x - (ptPerp.x - ptCenter.x) * iRadius / iPerpLength;
1381            pts[0].y = ptCenter.y - (ptPerp.y - ptCenter.y) * iRadius / iPerpLength;
1382            pts[1].x = (ptCenter.x + pts[0].x) / 2;
1383            pts[1].y = (ptCenter.y + pts[0].y) / 2;
1384            d = lineutility.CalcDistanceDouble(pts[0], pts[1]);
1385            if (d > maxLength) //shorten the spoke
1386            {
1387                pts[1] = lineutility.ExtendLineDouble(pts[1], pts[0], -maxLength);
1388            }
1389
1390            points[counter] = new POINT2(pts[0]);
1391            points[counter].style = 0;
1392            counter++;
1393            points[counter] = new POINT2(pts[1]);
1394            points[counter].style = 5;
1395            counter++;
1396
1397            pts[0].x = ptCenter.x - dDeltaX1 * iRadius;
1398            pts[0].y = ptCenter.y - dDeltaY1 * iRadius;
1399            pts[1].x = (ptCenter.x + pts[0].x) / 2;
1400            pts[1].y = (ptCenter.y + pts[0].y) / 2;
1401            d = lineutility.CalcDistanceDouble(pts[0], pts[1]);
1402            if (d > maxLength) //shorten the spoke
1403            {
1404                pts[1] = lineutility.ExtendLineDouble(pts[1], pts[0], -maxLength);
1405            }
1406
1407            points[counter] = new POINT2(pts[0]);
1408            points[counter].style = 0;
1409            counter++;
1410            points[counter] = new POINT2(pts[1]);
1411            points[counter].style = 5;
1412            counter++;
1413
1414            pts[0].x = ptCenter.x - dDeltaX2 * iRadius;
1415            pts[0].y = ptCenter.y - dDeltaY2 * iRadius;
1416            pts[1].x = (ptCenter.x + pts[0].x) / 2;
1417            pts[1].y = (ptCenter.y + pts[0].y) / 2;
1418            d = lineutility.CalcDistanceDouble(pts[0], pts[1]);
1419            if (d > maxLength) //shorten the spoke
1420            {
1421                pts[1] = lineutility.ExtendLineDouble(pts[1], pts[0], -maxLength);
1422            }
1423
1424            points[counter] = new POINT2(pts[0]);
1425            points[counter].style = 0;
1426            counter++;
1427            points[counter] = new POINT2(pts[1]);
1428            points[counter].style = 5;
1429            counter++;
1430
1431            dDeltaX1 = Math.cos(dAngle2 + CONST_PI / 8);
1432            dDeltaY1 = Math.sin(dAngle2 + CONST_PI / 8);
1433            dDeltaX2 = Math.cos(dAngle2 - CONST_PI / 8);
1434            dDeltaY2 = Math.sin(dAngle2 - CONST_PI / 8);
1435            pts[0].x = ptCenter.x - dDeltaX1 * iRadius;
1436            pts[0].y = ptCenter.y - dDeltaY1 * iRadius;
1437            pts[1].x = (ptCenter.x + pts[0].x) / 2;
1438            pts[1].y = (ptCenter.y + pts[0].y) / 2;
1439            d = lineutility.CalcDistanceDouble(pts[0], pts[1]);
1440            if (d > maxLength) //shorten the spoke
1441            {
1442                pts[1] = lineutility.ExtendLineDouble(pts[1], pts[0], -maxLength);
1443            }
1444
1445            points[counter] = new POINT2(pts[0]);
1446            points[counter].style = 0;
1447            counter++;
1448            points[counter] = new POINT2(pts[1]);
1449            points[counter].style = 5;
1450            counter++;
1451
1452            pts[0].x = ptCenter.x - dDeltaX2 * iRadius;
1453            pts[0].y = ptCenter.y - dDeltaY2 * iRadius;
1454            pts[1].x = (ptCenter.x + pts[0].x) / 2;
1455            pts[1].y = (ptCenter.y + pts[0].y) / 2;
1456            d = lineutility.CalcDistanceDouble(pts[0], pts[1]);
1457            if (d > maxLength) //shorten the spoke
1458            {
1459                pts[1] = lineutility.ExtendLineDouble(pts[1], pts[0], -maxLength);
1460            }
1461
1462            points[counter] = new POINT2(pts[0]);
1463            points[counter].style = 0;
1464            counter++;
1465            points[counter] = new POINT2(pts[1]);
1466            points[counter].style = 5;
1467            counter++;
1468
1469            dDeltaX1 = Math.cos(dAngle2 + 3 * CONST_PI / 8);
1470            dDeltaY1 = Math.sin(dAngle2 + 3 * CONST_PI / 8);
1471            dDeltaX2 = Math.cos(dAngle2 - 3 * CONST_PI / 8);
1472            dDeltaY2 = Math.sin(dAngle2 - 3 * CONST_PI / 8);
1473            pts[0].x = ptCenter.x - dDeltaX1 * iRadius;
1474            pts[0].y = ptCenter.y - dDeltaY1 * iRadius;
1475            pts[1].x = (ptCenter.x + pts[0].x) / 2;
1476            pts[1].y = (ptCenter.y + pts[0].y) / 2;
1477            d = lineutility.CalcDistanceDouble(pts[0], pts[1]);
1478            if (d > maxLength) //shorten the spoke
1479            {
1480                pts[1] = lineutility.ExtendLineDouble(pts[1], pts[0], -maxLength);
1481            }
1482
1483            points[counter] = new POINT2(pts[0]);
1484            points[counter].style = 0;
1485            counter++;
1486            points[counter] = new POINT2(pts[1]);
1487            points[counter].style = 5;
1488            counter++;
1489
1490            pts[0].x = ptCenter.x - dDeltaX2 * iRadius;
1491            pts[0].y = ptCenter.y - dDeltaY2 * iRadius;
1492            pts[1].x = (ptCenter.x + pts[0].x) / 2;
1493            pts[1].y = (ptCenter.y + pts[0].y) / 2;
1494            d = lineutility.CalcDistanceDouble(pts[0], pts[1]);
1495            if (d > maxLength) //shorten the spoke
1496            {
1497                pts[1] = lineutility.ExtendLineDouble(pts[1], pts[0], -maxLength);
1498            }
1499
1500            points[counter] = new POINT2(pts[0]);
1501            points[counter].style = 0;
1502            counter++;
1503            points[counter] = new POINT2(pts[1]);
1504            points[counter].style = 5;
1505            counter++;
1506
1507        } catch (Exception exc) {
1508            ErrorLogger.LogException(_className ,"GetDISMContainDouble",
1509                    new RendererException("Failed inside GetDISMContainDouble", exc));
1510        }
1511        return counter;
1512    }
1513    /**
1514     * Calculates the points for FIX, MNFLDFIX
1515     *
1516     * @param points OUT - the client points, also used for the returned points.
1517     * @param linetype the line type.
1518     */
1519    protected static int GetDISMFixDouble(POINT2[] points, int linetype,Rectangle2D clipBounds) {
1520        int counter = 0;
1521        try {
1522            POINT2[] pts = new POINT2[3];
1523            POINT2[] savepoints = new POINT2[2];
1524            double dAngle1 = 0;
1525            double dLength = 0;
1526            double dJaggyHalfAmp = 0;
1527            double dJaggyHalfPeriod = 0;
1528            double dDeltaXOut = 0;
1529            double dDeltaYOut = 0;
1530            double dDeltaXAlong = 0;
1531            double dDeltaYAlong = 0;
1532            int iNumJaggies = 0;
1533            int i = 0, j = 0;
1534
1535            for (j = 0; j < 2; j++) {
1536                savepoints[j] = new POINT2(points[j]);
1537            }
1538
1539            Boolean drawJaggies=true;
1540            if(clipBounds != null)
1541            {
1542                POINT2 ul=new POINT2(clipBounds.getMinX(),clipBounds.getMinY());
1543                POINT2 lr=new POINT2(clipBounds.getMaxX(),clipBounds.getMaxY());
1544                savepoints=lineutility.BoundOneSegment(savepoints[0], savepoints[1], ul, lr);
1545            }
1546            if(savepoints==null)
1547            {
1548                savepoints=new POINT2[2];
1549                for (j = 0; j < 2; j++) {
1550                    savepoints[j] = new POINT2(points[j]);
1551                }
1552                drawJaggies=false;
1553            }
1554
1555            lineutility.InitializePOINT2Array(pts);
1556            //reverse the points
1557
1558            dAngle1 = Math.atan2(savepoints[0].y - savepoints[1].y, savepoints[0].x - savepoints[1].x);
1559            dLength = Math.sqrt((savepoints[1].x - savepoints[0].x) * (savepoints[1].x - savepoints[0].x) +
1560                    (savepoints[1].y - savepoints[0].y) * (savepoints[1].y - savepoints[0].y));
1561            //arraysupport tries to set jaggylength before the points get bounded
1562            dJaggyHalfAmp = dLength / 15; // half the amplitude of the "jaggy function"
1563
1564            if (dJaggyHalfAmp > maxLength) {
1565                dJaggyHalfAmp = maxLength;
1566            }
1567            if (dJaggyHalfAmp < minLength) {  
1568                dJaggyHalfAmp = minLength;    
1569            }
1570
1571            dJaggyHalfPeriod = dJaggyHalfAmp / 1.5; // half the period of the "jaggy function"
1572            dDeltaXOut = Math.cos(dAngle1 + CONST_PI / 2) * dJaggyHalfAmp; // X-delta out from the center line
1573            dDeltaYOut = Math.sin(dAngle1 + CONST_PI / 2) * dJaggyHalfAmp; // Y-delta out from the center line
1574            dDeltaXAlong = Math.cos(dAngle1) * dJaggyHalfPeriod; // X-delta along the center line
1575            dDeltaYAlong = Math.sin(dAngle1) * dJaggyHalfPeriod; // Y-delta along the center line
1576            iNumJaggies = (int) (dLength / dJaggyHalfPeriod) - 3;
1577            i = 2;
1578            pts[0] = new POINT2(savepoints[1]);
1579            pts[1].x = savepoints[1].x + dDeltaXAlong * 1.5;
1580            pts[1].y = savepoints[1].y + dDeltaYAlong * 1.5;
1581            //DrawLine(destination, mask, color, pts, 2, 2);
1582            points[counter] = new POINT2(pts[0]);
1583            points[counter].style = 0;
1584            counter++;
1585            points[counter] = new POINT2(pts[1]);
1586            points[counter].style = 5;
1587            counter++;
1588
1589            pts[0].x = savepoints[1].x + dDeltaXOut + dDeltaXAlong * i;
1590            pts[0].y = savepoints[1].y + dDeltaYOut + dDeltaYAlong * i;
1591            i++;
1592            points[counter] = new POINT2(pts[0]);
1593            points[counter].style = 0;
1594            counter++;
1595            points[counter] = new POINT2(pts[1]);
1596            points[counter].style = 5;
1597            counter++;
1598
1599            if(drawJaggies) {
1600                while (i <= iNumJaggies) {
1601                    pts[1].x = savepoints[1].x - dDeltaXOut + dDeltaXAlong * i;
1602                    pts[1].y = savepoints[1].y - dDeltaYOut + dDeltaYAlong * i;
1603                    i++;
1604                    pts[2].x = savepoints[1].x + dDeltaXOut + dDeltaXAlong * i;
1605                    pts[2].y = savepoints[1].y + dDeltaYOut + dDeltaYAlong * i;
1606                    i++;
1607                    for (j = 0; j < 3; j++) {
1608                        points[counter] = new POINT2(pts[j]);
1609                        points[counter].style = 0;
1610                        counter++;
1611                    }
1612                    points[counter - 1].style = 5;
1613                    pts[0] = new POINT2(pts[2]);
1614                }
1615            }
1616
1617            pts[1] = new POINT2(pts[0]);
1618            pts[0].x = savepoints[1].x + dDeltaXAlong * i;
1619            pts[0].y = savepoints[1].y + dDeltaYAlong * i;
1620            points[counter] = new POINT2(pts[0]);
1621            points[counter].style = 0;
1622            counter++;
1623            points[counter] = new POINT2(pts[1]);
1624            points[counter].style = 5;
1625            counter++;
1626
1627            pts[1] = new POINT2(savepoints[0]);
1628            //DrawLine(destination, mask, color, pts, 2, 2);
1629            points[counter] = new POINT2(pts[0]);
1630            points[counter].style = 0;
1631            counter++;
1632            points[counter] = new POINT2(pts[1]);
1633            points[counter].style = 5;
1634            counter++;
1635
1636            // draw arrowhead
1637            pts[0].x = savepoints[0].x + dDeltaXOut / 1.5 - dDeltaXAlong;
1638            pts[0].y = savepoints[0].y + dDeltaYOut / 1.5 - dDeltaYAlong;
1639            pts[2].x = savepoints[0].x - dDeltaXOut / 1.5 - dDeltaXAlong;
1640            pts[2].y = savepoints[0].y - dDeltaYOut / 1.5 - dDeltaYAlong;
1641            for (j = 0; j < 3; j++) {
1642                points[counter] = new POINT2(pts[j]);
1643                if (linetype == (long) TacticalLines.MNFLDFIX) {
1644                    points[counter].style = 9;
1645                } else {
1646                    points[counter].style = 0;
1647                }
1648                counter++;
1649            }
1650            if (linetype == (long) TacticalLines.MNFLDFIX) {
1651                points[counter - 1].style = 10;
1652            } else {
1653                points[counter - 1].style = 5;
1654            }
1655
1656        } catch (Exception exc) {
1657            ErrorLogger.LogException(_className ,"GetDISMFixDouble",
1658                    new RendererException("Failed inside GetDISMFixDouble", exc));
1659        }
1660        return counter;
1661    }
1662    /**
1663     * Calculates the points for CLEAR.
1664     *
1665     * @param points OUT - the client points, also used for the returned points.
1666     * @param linetype the line type.
1667     */
1668    protected static int GetDISMClearDouble(POINT2[] points, int linetype) {
1669        int counter = 0;
1670        try {
1671            POINT2[] savepoints = new POINT2[3];
1672            int j = 0;
1673            POINT2[] pts = new POINT2[2];
1674            POINT2[] ptsArrow = new POINT2[3];
1675            double ctrX =  ((points[0].x + points[1].x) / 2);
1676            double ctrY =  ((points[0].y + points[1].y) / 2);
1677            ref<double[]> iDeltaX1 = new ref(), iDeltaY1 = new ref(), iDeltaX2 = new ref(), iDeltaY2 = new ref();
1678            POINT2[] deltapoints1 = new POINT2[4];
1679            POINT2[] deltapoints2 = new POINT2[4];
1680            POINT2[] deltapoints3 = new POINT2[4];
1681
1682            for (j = 0; j < 3; j++) {
1683                savepoints[j] = new POINT2(points[j]);
1684            }
1685
1686            lineutility.InitializePOINT2Array(pts);
1687            lineutility.InitializePOINT2Array(ptsArrow);
1688            lineutility.InitializePOINT2Array(deltapoints1);
1689            lineutility.InitializePOINT2Array(deltapoints2);
1690            lineutility.InitializePOINT2Array(deltapoints3);
1691
1692            //DrawLine(destination, mask, color, points, 2, 2);
1693            points[counter] = new POINT2(savepoints[0]);
1694            points[counter].style = 0;
1695            counter++;
1696            points[counter] = new POINT2(savepoints[1]);
1697            points[counter].style = 5;
1698            counter++;
1699
1700            pts[0].x = ctrX;
1701            pts[0].y = ctrY;
1702            pts[1] = new POINT2(savepoints[2]);
1703            ptsArrow[0] = new POINT2(pts[0]);
1704            //DrawLine(destination, mask, color, pts, 2, 2);
1705            points[counter] = new POINT2(pts[0]);
1706            points[counter].style = 0;
1707            counter++;
1708            points[counter] = new POINT2(pts[1]);
1709            points[counter].style = 5;
1710            counter++;
1711
1712            pts[0].x = (savepoints[0].x + ctrX) / 2;
1713            pts[0].y = (savepoints[0].y + ctrY) / 2;
1714            pts[1].x = savepoints[2].x + savepoints[0].x - pts[0].x;
1715            pts[1].y = savepoints[2].y + savepoints[0].y - pts[0].y;
1716            ptsArrow[1] = new POINT2(pts[0]);
1717            //DrawLine(destination, mask, color, pts, 2, 2);
1718            points[counter] = new POINT2(pts[0]);
1719            points[counter].style = 0;
1720            counter++;
1721            points[counter] = new POINT2(pts[1]);
1722            points[counter].style = 5;
1723            counter++;
1724
1725            pts[0].x = (savepoints[1].x + ctrX) / 2;
1726            pts[0].y = (savepoints[1].y + ctrY) / 2;
1727            pts[1].x = savepoints[2].x + savepoints[1].x - pts[0].x;
1728            pts[1].y = savepoints[2].y + savepoints[1].y - pts[0].y;
1729            ptsArrow[2] = new POINT2(pts[0]);
1730            points[counter] = new POINT2(pts[0]);
1731            points[counter].style = 0;
1732            counter++;
1733            points[counter] = new POINT2(pts[1]);
1734            points[counter].style = 5;
1735            counter++;
1736
1737            CalcEndpieceDeltasDouble(savepoints, iDeltaX1, iDeltaY1, CONST_PI / 6);
1738            CalcEndpieceDeltasDouble(savepoints, iDeltaX2, iDeltaY2, -CONST_PI / 6);
1739            DrawEndpieceDeltasDouble(ptsArrow[0],
1740                    iDeltaX1.value[0], iDeltaY1.value[0], iDeltaX2.value[0], iDeltaY2.value[0], deltapoints1);
1741            DrawEndpieceDeltasDouble(ptsArrow[1],
1742                    iDeltaX1.value[0], iDeltaY1.value[0], iDeltaX2.value[0], iDeltaY2.value[0], deltapoints2);
1743            DrawEndpieceDeltasDouble(ptsArrow[2],
1744                    iDeltaX1.value[0], iDeltaY1.value[0], iDeltaX2.value[0], iDeltaY2.value[0], deltapoints3);
1745            for (j = 0; j < 4; j++) {
1746                points[counter] = new POINT2(deltapoints1[j]);
1747                counter++;
1748            }
1749            for (j = 0; j < 4; j++) {
1750                points[counter] = new POINT2(deltapoints2[j]);
1751                counter++;
1752            }
1753            for (j = 0; j < 4; j++) {
1754                points[counter] = new POINT2(deltapoints3[j]);
1755                counter++;
1756            }
1757        } catch (Exception exc) {
1758            ErrorLogger.LogException(_className ,"GetDISMClearDouble",
1759                    new RendererException("Failed inside GetDISMClearDouble", exc));
1760        }
1761        return counter;
1762    }
1763    private static boolean IsSeizeArcReversed(POINT2[] pPoints){
1764        try {
1765            double dAngle1 = Math.atan2(pPoints[0].y - pPoints[1].y, pPoints[0].x - pPoints[1].x);
1766            double dDeltaX1 = Math.cos(dAngle1 + CONST_PI / 4);
1767            double dDeltaY1 = Math.sin(dAngle1 + CONST_PI / 4);
1768            double dDeltaX2 = Math.cos(dAngle1 - CONST_PI / 4);
1769            double dDeltaY2 = Math.sin(dAngle1 - CONST_PI / 4);
1770
1771            double dChordLength = Math.sqrt((pPoints[1].x - pPoints[0].x) * (pPoints[1].x - pPoints[0].x) +
1772                    (pPoints[1].y - pPoints[0].y) * (pPoints[1].y - pPoints[0].y));
1773            double dArcRadius = dChordLength / 1.414213562373; // sqrt(2) == 1.414213562373
1774            POINT2 ptArcCenter = new POINT2();
1775
1776            //get the default center
1777            ptArcCenter.x = pPoints[0].x - dDeltaX1 * dArcRadius;
1778            ptArcCenter.y = pPoints[0].y - dDeltaY1 * dArcRadius;
1779            double d = lineutility.CalcDistanceDouble(ptArcCenter, pPoints[2]);
1780
1781            //get the alternate center if the arc is reversed
1782            POINT2 ptArcCenterReversed = new POINT2();
1783            ptArcCenterReversed.x = pPoints[0].x - dDeltaX2 * dArcRadius;
1784            ptArcCenterReversed.y = pPoints[0].y - dDeltaY2 * dArcRadius;
1785            double dReversed = lineutility.CalcDistanceDouble(ptArcCenterReversed, pPoints[2]);
1786
1787            if (dReversed > d) {
1788                return true;
1789            } else {
1790                return false;
1791            }
1792        } catch (Exception exc) {
1793            ErrorLogger.LogException(_className ,"IsSeizeArcReversed",
1794                    new RendererException("Failed inside IsSeizeArcReversed", exc));
1795        }
1796        return false;
1797    }
1798    /**
1799     * Calculates the points for SEIZE
1800     *
1801     * @param points OUT - the client points, also used for the returned points.
1802     * @param linetype the line type.
1803     */
1804    protected static int GetDISMSeizeDouble(POINT2[] points,
1805            int linetype,
1806            double radius) 
1807    {
1808        int counter = 0;
1809        try {
1810            POINT2 ptArcCenter = new POINT2();
1811            POINT2 ptArcStart = new POINT2();
1812            POINT2[] savepoints = new POINT2[3];
1813            float scale = (float) 0.9;
1814            double iCircleRadius =  (25 * scale);
1815            POINT2[] arcpoints = new POINT2[17];
1816            POINT2[] pts = new POINT2[3];
1817            double dAngle1 = 0;
1818            double dDeltaX1 = 0;
1819            double dDeltaY1 = 0;
1820            double dDeltaX2 = 0;
1821            double dDeltaY2 = 0;
1822            double dChordLength = 0;
1823            double dArcRadius = 0;
1824            int j = 0;
1825            double dDeltaX3 = 0;
1826            double dDeltaY3 = 0;
1827            double iDiagEOL_length = 0;
1828            double factor = 1;
1829
1830            if(radius>0)
1831                iCircleRadius=radius;
1832            
1833            
1834            for (j = 0; j < 3; j++) {
1835                savepoints[j] = new POINT2(points[j]);
1836            }
1837            
1838            //if radius is 0 then it is rev B
1839            String client=CELineArray.getClient();
1840            if(!client.startsWith("cpof") && radius==0)
1841            {
1842                dArcRadius=lineutility.CalcDistanceDouble(savepoints[0], savepoints[1]);
1843                if(iCircleRadius>dArcRadius/2)
1844                    iCircleRadius=dArcRadius/2;
1845            }
1846
1847            lineutility.InitializePOINT2Array(pts);
1848            lineutility.InitializePOINT2Array(arcpoints);
1849            // draw circle
1850            ArcApproximationDouble(savepoints[0].x - iCircleRadius, savepoints[0].y - iCircleRadius,
1851                    savepoints[0].x + iCircleRadius, savepoints[0].y + iCircleRadius,
1852                    savepoints[0].x, savepoints[0].y, savepoints[0].x, savepoints[0].y, arcpoints);
1853            for (j = 0; j < 17; j++) {
1854                points[counter] = new POINT2(arcpoints[j]);
1855                points[counter].style = 0;
1856                counter++;
1857            }
1858            points[counter - 1].style = 5;
1859
1860            // draw arc
1861            dAngle1 = Math.atan2(savepoints[0].y - savepoints[1].y, savepoints[0].x - savepoints[1].x);
1862            dDeltaX1 = Math.cos(dAngle1 + CONST_PI / 4);
1863            dDeltaY1 = Math.sin(dAngle1 + CONST_PI / 4);
1864            dDeltaX2 = Math.cos(dAngle1 - CONST_PI / 4);
1865            dDeltaY2 = Math.sin(dAngle1 - CONST_PI / 4);
1866
1867            boolean isArcReversed = IsSeizeArcReversed(savepoints);
1868
1869            if (isArcReversed == false) {
1870                ptArcStart.x = savepoints[0].x - dDeltaX2 * iCircleRadius;
1871                ptArcStart.y = savepoints[0].y - dDeltaY2 * iCircleRadius;
1872                dChordLength = Math.sqrt((savepoints[1].x - savepoints[0].x) * (savepoints[1].x - savepoints[0].x) +
1873                        (savepoints[1].y - savepoints[0].y) * (savepoints[1].y - savepoints[0].y));
1874                dArcRadius = dChordLength / 1.414213562373; // sqrt(2) == 1.414213562373
1875                ptArcCenter.x = savepoints[0].x - dDeltaX1 * dArcRadius;
1876                ptArcCenter.y = savepoints[0].y - dDeltaY1 * dArcRadius;
1877
1878                ArcApproximationDouble((ptArcCenter.x - dArcRadius), (ptArcCenter.y - dArcRadius),
1879                        (ptArcCenter.x + dArcRadius), (ptArcCenter.y + dArcRadius),
1880                        savepoints[1].x, savepoints[1].y, ptArcStart.x, ptArcStart.y, arcpoints);
1881            } else //arc is reversed
1882            {
1883                ptArcStart.x = savepoints[0].x - dDeltaX1 * iCircleRadius;
1884                ptArcStart.y = savepoints[0].y - dDeltaY1 * iCircleRadius;
1885                dChordLength = Math.sqrt((savepoints[1].x - savepoints[0].x) * (savepoints[1].x - savepoints[0].x) +
1886                        (savepoints[1].y - savepoints[0].y) * (savepoints[1].y - savepoints[0].y));
1887                dArcRadius = dChordLength / 1.414213562373; // sqrt(2) == 1.414213562373
1888                ptArcCenter.x = savepoints[0].x - dDeltaX2 * dArcRadius;
1889                ptArcCenter.y = savepoints[0].y - dDeltaY2 * dArcRadius;
1890                ArcApproximationDouble((ptArcCenter.x - dArcRadius), (ptArcCenter.y - dArcRadius),
1891                        (ptArcCenter.x + dArcRadius), (ptArcCenter.y + dArcRadius),
1892                        ptArcStart.x, ptArcStart.y, savepoints[1].x, savepoints[1].y, arcpoints);
1893            }
1894
1895            for (j = 0; j < 17; j++) {
1896                points[counter] = new POINT2(arcpoints[j]);
1897                points[counter].style = 0;
1898                counter++;
1899            }
1900            points[counter - 1].style = 5;
1901
1902            // draw arrow
1903            if (dChordLength / 8 > maxLength) {
1904                factor = dChordLength / (8 * maxLength);
1905            }
1906            if (factor == 0) {
1907                factor = 1;
1908            }
1909
1910
1911            if (isArcReversed == false) {
1912                pts[0].x = savepoints[1].x - (savepoints[1].x - savepoints[0].x) / (8 * factor);
1913                pts[0].y = savepoints[1].y - (savepoints[1].y - savepoints[0].y) / (8 * factor);
1914                pts[1] = new POINT2(savepoints[1]);
1915                dDeltaX3 = Math.cos(dAngle1 + CONST_PI / 2);
1916                dDeltaY3 = Math.sin(dAngle1 + CONST_PI / 2);
1917                iDiagEOL_length =  (dChordLength / 8);
1918                pts[2].x = savepoints[1].x + dDeltaX3 * iDiagEOL_length / factor;
1919                pts[2].y = savepoints[1].y + dDeltaY3 * iDiagEOL_length / factor;
1920            } //DrawLine(destination, mask, color, pts, 3, 2);
1921            //diagnostic arc reversed
1922            else {
1923                pts[0].x = savepoints[1].x - (savepoints[1].x - savepoints[0].x) / (8 * factor);
1924                pts[0].y = savepoints[1].y - (savepoints[1].y - savepoints[0].y) / (8 * factor);
1925                pts[1] = new POINT2(savepoints[1]);
1926                dDeltaX3 = Math.cos(dAngle1 - CONST_PI / 2);
1927                dDeltaY3 = Math.sin(dAngle1 - CONST_PI / 2);
1928                iDiagEOL_length =  (dChordLength / 8);
1929                pts[2].x = savepoints[1].x + dDeltaX3 * iDiagEOL_length / factor;
1930                pts[2].y = savepoints[1].y + dDeltaY3 * iDiagEOL_length / factor;
1931            }
1932            //end diagnostic
1933
1934
1935            //diagnostic
1936            //end diagnostic
1937
1938            for (j = 0; j < 3; j++) {
1939                points[counter] = new POINT2(pts[j]);
1940                points[counter].style = 0;
1941                counter++;
1942            }
1943            points[counter - 1].style = 5;
1944        } catch (Exception exc) {
1945            ErrorLogger.LogException(_className ,"GetDISMSeizeDouble",
1946                    new RendererException("Failed inside GetDISMSeizeDouble", exc));
1947        }
1948        return counter;
1949    }
1950    /**
1951     * Used twice for RIP to determine if the points are clockwise.
1952     * @param x1
1953     * @param y1
1954     * @param x2
1955     * @param y2
1956     * @param px
1957     * @param py
1958     * @return RIGHT_SIDE if 3 points are clockwise
1959     */
1960    private static int side(double x1, double y1, double x2, double y2, double px, double py) {
1961        double dx1, dx2, dy1, dy2;
1962        try {
1963            double o;
1964
1965            dx1 = x2 - x1;
1966            dy1 = y2 - y1;
1967            dx2 = px - x1;
1968            dy2 = py - y1;
1969            o = (dx1 * dy2) - (dy1 * dx2);
1970            if (o > 0.0) {
1971                return (LEFT_SIDE);
1972            }
1973            if (o < 0.0) {
1974                return (RIGHT_SIDE);
1975            }
1976        } catch (Exception exc) {
1977            ErrorLogger.LogException(_className, "side",
1978                    new RendererException("Failed inside side", exc));
1979        }
1980        return (COLINEAR);
1981    }
1982
1983    /**
1984     * Calculates the points for RIP
1985     *
1986     * @param points OUT - the client points, also used for the returned points.
1987     * @param linetype the line type
1988     */
1989    protected static int GetDISMRIPDouble(POINT2[] points, int linetype) {
1990        int counter = 0;
1991        try {
1992            // draw the straight lines
1993            POINT2[] pts = new POINT2[2];
1994            POINT2[] savepoints = new POINT2[4];
1995            int j = 0;
1996            double iLengthPt0Pt1 = 0;
1997            double iDiagEOL_length = 0;
1998            double dAngle1 = 0;
1999            double iDeltaX1 = 0;
2000            double iDeltaY1 = 0;
2001            double iDeltaX2 = 0;
2002            double iDeltaY2 = 0;
2003            double iLengthPt2Pt3 = 0;
2004            double iRadius = 0;
2005            POINT2[] deltapoints = new POINT2[4];
2006            POINT2[] arcpoints = new POINT2[17];
2007            POINT2 ptArcCenter = new POINT2();
2008
2009            boolean clockwise=false;
2010            int side01=side(points[0].x,points[0].y,points[1].x,points[1].y,points[2].x,points[2].y);
2011            int side12=side(points[1].x,points[1].y,points[2].x,points[2].y,points[3].x,points[3].y);
2012            if(side01==RIGHT_SIDE && side12==RIGHT_SIDE)
2013                clockwise=true;
2014            else if(side01==RIGHT_SIDE && side12==COLINEAR)
2015                clockwise=true;
2016            else if(side01==COLINEAR && side12==RIGHT_SIDE)
2017                clockwise=true;
2018
2019            for (j = 0; j < 4; j++) {
2020                savepoints[j] = new POINT2(points[j]);
2021            }
2022
2023            lineutility.InitializePOINT2Array(pts);
2024            lineutility.InitializePOINT2Array(deltapoints);
2025            lineutility.InitializePOINT2Array(arcpoints);
2026
2027            points[counter] = new POINT2(savepoints[0]);
2028            points[counter].style = 0;
2029            counter++;
2030            points[counter] = new POINT2(savepoints[1]);
2031            points[counter].style = 5;
2032            counter++;
2033
2034            pts[0] = new POINT2(savepoints[2]);
2035            pts[1] = new POINT2(savepoints[3]);
2036            points[counter] = new POINT2(pts[0]);
2037            points[counter].style = 0;
2038            counter++;
2039            points[counter] = new POINT2(pts[1]);
2040            points[counter].style = 5;
2041            counter++;
2042
2043            // draw the arrowhead on line between savepoints 0 and 1
2044            pts[0] = new POINT2(savepoints[0]);
2045            pts[1] = new POINT2(savepoints[1]);
2046            iLengthPt0Pt1 =  Math.sqrt((pts[1].x - pts[0].x) * (pts[1].x - pts[0].x) +
2047                    (pts[1].y - pts[0].y) * (pts[1].y - pts[0].y));
2048            iDiagEOL_length = iLengthPt0Pt1 / 8;
2049
2050            //M. Deutch 8-19-04
2051            if (iDiagEOL_length >  maxLength) {
2052                iDiagEOL_length =  maxLength;
2053            }
2054            if (iDiagEOL_length <  minLength) {
2055                iDiagEOL_length =  minLength;
2056            }
2057
2058            dAngle1 = Math.atan2(pts[1].y - pts[0].y, pts[1].x - pts[0].x);
2059            iDeltaX1 =  (iDiagEOL_length * Math.cos(dAngle1 - CONST_PI / 4));
2060            iDeltaY1 =  (iDiagEOL_length * Math.sin(dAngle1 - CONST_PI / 4));
2061            iDeltaX2 =  (iDiagEOL_length * Math.cos(dAngle1 + CONST_PI / 4));
2062            iDeltaY2 =  (iDiagEOL_length * Math.sin(dAngle1 + CONST_PI / 4));
2063            DrawEndpieceDeltasDouble(pts[0],
2064                    iDeltaX1, iDeltaY1, iDeltaX2, iDeltaY2, deltapoints);
2065            for (j = 0; j < 4; j++) {
2066                points[counter] = new POINT2(deltapoints[j]);
2067                points[counter].style = 0;
2068                counter++;
2069            }
2070            points[counter - 3].style = 5;
2071            points[counter - 1].style = 5;
2072            // draw the arrowhead on line between savepoints 2 and 3
2073            pts[0] = new POINT2(savepoints[2]);
2074            pts[1] = new POINT2(savepoints[3]);
2075            iLengthPt2Pt3 =  Math.sqrt((pts[1].x - pts[0].x) * (pts[1].x - pts[0].x) +
2076                    (pts[1].y - pts[0].y) * (pts[1].y - pts[0].y));
2077            iDiagEOL_length = iLengthPt2Pt3 / 8;
2078
2079            //M. Deutch 8-19-04
2080            if (iDiagEOL_length >  maxLength) {
2081                iDiagEOL_length =  maxLength;
2082            }
2083            if (iDiagEOL_length <  minLength) {
2084                iDiagEOL_length =  minLength;
2085            }
2086
2087            dAngle1 = Math.atan2(pts[1].y - pts[0].y, pts[1].x - pts[0].x);
2088            iDeltaX1 =  (iDiagEOL_length * Math.cos(dAngle1 - CONST_PI / 4));
2089            iDeltaY1 =  (iDiagEOL_length * Math.sin(dAngle1 - CONST_PI / 4));
2090            iDeltaX2 =  (iDiagEOL_length * Math.cos(dAngle1 + CONST_PI / 4));
2091            iDeltaY2 =  (iDiagEOL_length * Math.sin(dAngle1 + CONST_PI / 4));
2092            DrawEndpieceDeltasDouble(pts[0],
2093                    iDeltaX1, iDeltaY1, iDeltaX2, iDeltaY2, deltapoints);
2094            for (j = 0; j < 4; j++) {
2095                points[counter] = new POINT2(deltapoints[j]);
2096                points[counter].style = 0;
2097                counter++;
2098            }
2099            points[counter - 3].style = 5;
2100            points[counter - 1].style = 5;
2101
2102            // draw the semicircle
2103            iRadius =  (Math.sqrt((savepoints[2].x - savepoints[1].x) * (savepoints[2].x - savepoints[1].x) +
2104                    (savepoints[2].y - savepoints[1].y) * (savepoints[2].y - savepoints[1].y)) / 2);
2105            ptArcCenter.x = (savepoints[1].x + savepoints[2].x) / 2;
2106            ptArcCenter.y = (savepoints[1].y + savepoints[2].y) / 2;
2107
2108            if(clockwise==false)
2109            {
2110                ArcApproximationDouble((ptArcCenter.x - iRadius), (ptArcCenter.y - iRadius),
2111                    (ptArcCenter.x + iRadius), (ptArcCenter.y + iRadius),
2112                    savepoints[2].x, savepoints[2].y, savepoints[1].x, savepoints[1].y, arcpoints);
2113            }
2114            else
2115            {
2116                ArcApproximationDouble((ptArcCenter.x - iRadius), (ptArcCenter.y - iRadius),
2117                    (ptArcCenter.x + iRadius), (ptArcCenter.y + iRadius),
2118                    savepoints[1].x, savepoints[1].y, savepoints[2].x, savepoints[2].y, arcpoints);
2119            }
2120            for (j = 0; j < 17; j++) {
2121                points[counter] = new POINT2(arcpoints[j]);
2122                points[counter].style = 0;
2123                counter++;
2124            }
2125            points[counter - 1].style = 5;
2126        } catch (Exception exc) {
2127            ErrorLogger.LogException(_className ,"GetDISMRIPDouble",
2128                    new RendererException("Failed inside GetDISMRIPDouble", exc));
2129        }
2130        return counter;
2131    }
2132    /**
2133     * Calculates the points for BYDIF
2134     *
2135     * @param points OUT - the client points, also used for the returned points.
2136     * @param linetype the line type.
2137     */
2138    protected static int GetDISMByDifDouble(POINT2[] points,
2139            int linetype,
2140            Rectangle2D clipBounds) {
2141        int counter = 0;
2142        try {
2143            POINT2[] pointsCorner = new POINT2[2];
2144            POINT2[] rectpts = new POINT2[4];
2145            POINT2[] savepoints = new POINT2[3], savepoints2 = new POINT2[2];
2146            POINT2[] deltapoints1 = new POINT2[4];
2147            POINT2[] deltapoints2 = new POINT2[4];
2148            POINT2[] pts = new POINT2[3];
2149            //POINT2 pt0 = new POINT2();
2150            //POINT2 pt1 = new POINT2();
2151            ref<double[]> iDeltaX = new ref(), iDeltaY = new ref();
2152            int bPointsRight = 0;
2153            double dAngle1 = 0;
2154            double dLength = 0;
2155            double dJaggyHalfAmp = 0;
2156            double dJaggyHalfPeriod = 0;
2157            double dDeltaXOut = 0;
2158            double dDeltaYOut = 0;
2159            double dDeltaXAlong = 0;
2160            double dDeltaYAlong = 0;
2161            int iNumJaggies = 0;
2162            int i = 0, j = 0;
2163            //int pointcounter = 0;
2164            //int[] segments = null;
2165            //end declarations
2166            //lineutility.WriteFile("made it this far");
2167            //ok to here
2168
2169            for (j = 0; j < 3; j++) {
2170                savepoints[j] = new POINT2(points[j]);
2171            }
2172
2173            lineutility.InitializePOINT2Array(pointsCorner);
2174            lineutility.InitializePOINT2Array(rectpts);
2175            lineutility.InitializePOINT2Array(pts);
2176            lineutility.InitializePOINT2Array(deltapoints1);
2177            lineutility.InitializePOINT2Array(deltapoints2);
2178
2179            DrawOpenRectangleDouble(savepoints, pointsCorner, rectpts);
2180            //save the back side for use by the jagged line
2181            savepoints2[0] = new POINT2(rectpts[1]);
2182            savepoints2[1] = new POINT2(rectpts[2]);
2183
2184            //diagnostic these hard coded because JavalineArray does not know the bounds
2185            if(clipBounds != null)
2186            {
2187                POINT2 ul=new POINT2(clipBounds.getMinX(),clipBounds.getMinY());
2188                POINT2 lr=new POINT2(clipBounds.getMaxX(),clipBounds.getMaxY());
2189                savepoints2=lineutility.BoundOneSegment(savepoints2[0], savepoints2[1], ul, lr);
2190            }
2191            Boolean drawJaggies=true;
2192            if(savepoints2==null)
2193            {
2194                savepoints2 = new POINT2[2];
2195                savepoints2[0] = new POINT2(rectpts[1]);
2196                savepoints2[1] = new POINT2(rectpts[2]);
2197                drawJaggies=false;
2198            }
2199            for (j = 0; j < 4; j++) {
2200                points[counter] = new POINT2(rectpts[j]);
2201                points[counter].style = 0;
2202                counter++;
2203            }
2204            points[1].style = 5;
2205            points[counter - 1].style = 5;
2206
2207            dAngle1 = Math.atan2(savepoints2[0].y - savepoints2[1].y, savepoints2[0].x - savepoints2[1].x);
2208            dLength = Math.sqrt((savepoints2[1].x - savepoints2[0].x) * (savepoints2[1].x - savepoints2[0].x) +
2209                    (savepoints2[1].y - savepoints2[0].y) * (savepoints2[1].y - savepoints2[0].y));
2210            dJaggyHalfAmp = dLength / 15; // half the amplitude of the "jaggy function"
2211
2212            if (dJaggyHalfAmp > maxLength) {
2213                dJaggyHalfAmp = maxLength;
2214            }
2215            if (dJaggyHalfAmp < minLength) {
2216                dJaggyHalfAmp = minLength;
2217            }
2218
2219            dJaggyHalfPeriod = dJaggyHalfAmp / 1.5; // half the period of the "jaggy function"
2220            dDeltaXOut = Math.cos(dAngle1 + CONST_PI / 2) * dJaggyHalfAmp; // X-delta out from the center line
2221            dDeltaYOut = Math.sin(dAngle1 + CONST_PI / 2) * dJaggyHalfAmp; // Y-delta out from the center line
2222            dDeltaXAlong = Math.cos(dAngle1) * dJaggyHalfPeriod; // X-delta along the center line
2223            dDeltaYAlong = Math.sin(dAngle1) * dJaggyHalfPeriod; // Y-delta along the center line
2224
2225            iNumJaggies = (int) (dLength / dJaggyHalfPeriod) - 3;
2226            i = 2;
2227            pts[0] = new POINT2(savepoints2[1]);
2228            pts[1].x = savepoints2[1].x + dDeltaXAlong * 1.5;
2229            pts[1].y = savepoints2[1].y + dDeltaYAlong * 1.5;
2230            points[counter] = new POINT2(pts[0]);
2231            points[counter].style = 0;
2232            counter++;
2233            points[counter] = new POINT2(pts[1]);
2234            points[counter].style = 5;
2235            counter++;
2236
2237            pts[0].x = savepoints2[1].x + dDeltaXOut + dDeltaXAlong * i;
2238            pts[0].y = savepoints2[1].y + dDeltaYOut + dDeltaYAlong * i;
2239            i++;
2240            points[counter] = new POINT2(pts[0]);
2241            points[counter].style = 0;
2242            counter++;
2243            points[counter] = new POINT2(pts[1]);
2244            points[counter].style = 5;
2245            counter++;
2246            
2247            if(drawJaggies)//diagnostic
2248            {
2249                while (i <= iNumJaggies) {
2250                    pts[1].x = savepoints2[1].x - dDeltaXOut + dDeltaXAlong * i;
2251                    pts[1].y = savepoints2[1].y - dDeltaYOut + dDeltaYAlong * i;
2252                    i++;
2253                    pts[2].x = savepoints2[1].x + dDeltaXOut + dDeltaXAlong * i;
2254                    pts[2].y = savepoints2[1].y + dDeltaYOut + dDeltaYAlong * i;
2255                    i++;
2256                    for (j = 0; j < 3; j++) {
2257                        points[counter] = new POINT2(pts[j]);
2258                        points[counter].style = 0;
2259                        counter++;
2260                    }
2261                    points[counter - 1].style = 5;
2262                    pts[0] = new POINT2(pts[2]);
2263                }
2264            }
2265
2266
2267            pts[1] = new POINT2(pts[0]);
2268            pts[0].x = savepoints2[1].x + dDeltaXAlong * i;
2269            pts[0].y = savepoints2[1].y + dDeltaYAlong * i;
2270            //DrawLine(destination, mask, color, pts, 2, 2);
2271            points[counter] = new POINT2(pts[0]);
2272            points[counter].style = 0;
2273            counter++;
2274            points[counter] = new POINT2(pts[1]);
2275            points[counter].style = 5;
2276            counter++;
2277
2278            pts[1] = new POINT2(savepoints2[0]);
2279            //DrawLine(destination, mask, color, pts, 2, 2);
2280            points[counter] = new POINT2(pts[0]);
2281            points[counter].style = 0;
2282            counter++;
2283            points[counter] = new POINT2(pts[1]);
2284            points[counter].style = 5;
2285            counter++;
2286
2287            bPointsRight = DetermineDirectionDouble(savepoints);
2288
2289            CalcEndpieceDeltasDouble(savepoints, iDeltaX, iDeltaY, CONST_PI / 4);
2290
2291            if ((savepoints[0].y - savepoints[1].y) < 0) {// Point0 is higher than Point1
2292                if (bPointsRight != 0) {// figure opens to the right
2293                    DrawEndpieceDeltasDouble(savepoints[0],
2294                            iDeltaX.value[0], iDeltaY.value[0], iDeltaY.value[0], -iDeltaX.value[0], deltapoints1);
2295                    DrawEndpieceDeltasDouble(savepoints[1],
2296                            iDeltaX.value[0], iDeltaY.value[0], iDeltaY.value[0], -iDeltaX.value[0], deltapoints2);
2297                } else {// figure opens to the left
2298                    DrawEndpieceDeltasDouble(savepoints[0],
2299                            iDeltaY.value[0], -iDeltaX.value[0], iDeltaX.value[0], iDeltaY.value[0], deltapoints1);
2300                    DrawEndpieceDeltasDouble(savepoints[1],
2301                            iDeltaY.value[0], -iDeltaX.value[0], iDeltaX.value[0], iDeltaY.value[0], deltapoints2);
2302                }
2303            } else {// Point0 is lower than Point1
2304                if (bPointsRight != 0) {// figure opens to the right
2305                    DrawEndpieceDeltasDouble(savepoints[0],
2306                            iDeltaY.value[0], -iDeltaX.value[0], iDeltaX.value[0], iDeltaY.value[0], deltapoints1);
2307                    DrawEndpieceDeltasDouble(savepoints[1],
2308                            iDeltaY.value[0], -iDeltaX.value[0], iDeltaX.value[0], iDeltaY.value[0], deltapoints2);
2309                } else {// figure opens to the left
2310                    DrawEndpieceDeltasDouble(savepoints[0],
2311                            iDeltaX.value[0], iDeltaY.value[0], iDeltaY.value[0], -iDeltaX.value[0], deltapoints1);
2312                    DrawEndpieceDeltasDouble(savepoints[1],
2313                            iDeltaX.value[0], iDeltaY.value[0], iDeltaY.value[0], -iDeltaX.value[0], deltapoints2);
2314                }
2315            }
2316            points[counter] = new POINT2(deltapoints1[1]);
2317            points[counter].style = 9;
2318            counter++;
2319            points[counter] = new POINT2(deltapoints1[0]);
2320            points[counter].style = 9;
2321            counter++;
2322            points[counter] = new POINT2(deltapoints1[3]);
2323            points[counter].style = 9;
2324            counter++;
2325            points[counter] = new POINT2(deltapoints1[3]);
2326            points[counter].style = 10;
2327            counter++;
2328
2329            points[counter] = new POINT2(deltapoints2[1]);
2330            points[counter].style = 9;
2331            counter++;
2332            points[counter] = new POINT2(deltapoints2[0]);
2333            points[counter].style = 9;
2334            counter++;
2335            points[counter] = new POINT2(deltapoints2[3]);
2336            points[counter].style = 9;
2337            counter++;
2338            points[counter] = new POINT2(deltapoints2[3]);
2339            points[counter].style = 10;
2340            counter++;
2341
2342        } catch (Exception exc) {
2343            //lineutility.WriteFile(exc.getMessage());
2344            ErrorLogger.LogException(_className ,"GetDISMByDifDouble",
2345                    new RendererException("Failed inside GetDISMByDifDouble", exc));
2346        }
2347        return counter;
2348    }
2349    /**
2350     * Calculates the points for PENETRATE
2351     *
2352     * @param points OUT - the client points, also used for the returned points.
2353     * @param linetype the line type.
2354     */
2355    protected static void GetDISMPenetrateDouble(POINT2[] points, int linetype) {
2356        try {
2357            POINT2[] arrowpts = new POINT2[3];
2358            POINT2 midpt = new POINT2();
2359            POINT2[] savepoints = new POINT2[3];
2360            int j = 0;
2361            double d = 0;
2362
2363            for (j = 0; j < 3; j++) {
2364                savepoints[j] = new POINT2(points[j]);
2365            }
2366            lineutility.InitializePOINT2Array(arrowpts);
2367
2368            points[0].x = savepoints[0].x;
2369            points[0].y = savepoints[0].y;
2370            points[0].style = 0;
2371            points[1].x = savepoints[1].x;
2372            points[1].y = savepoints[1].y;
2373            points[1].style = 5;
2374
2375            midpt = lineutility.MidPointDouble(savepoints[0], savepoints[1], 0);
2376
2377            points[2] = new POINT2(savepoints[2]);
2378
2379            points[3] = new POINT2(midpt);
2380            points[3].style = 5;
2381            d = lineutility.MBRDistance(savepoints, 3);
2382
2383            if (d / 5 > maxLength) {
2384                d = 5 * maxLength;
2385            }
2386            if (d / 5 < minLength) {  
2387                d = 5 * minLength;    
2388            }
2389            String client=CELineArray.getClient();
2390            if(client.matches("cpof3d") || client.matches("cpof2d"))
2391            {
2392                if(d<400)
2393                    d=400;                
2394            }
2395            else
2396            {
2397                if(d<150)
2398                    d=150;                
2399            }
2400            if(d>600)
2401                d=600;
2402
2403            lineutility.GetArrowHead4Double(points[2], points[3], (int)d / 20,(int)d / 20, arrowpts, 0);
2404            for (j = 0; j < 3; j++) {
2405                points[4 + j] = new POINT2(arrowpts[j]);
2406            }
2407
2408        } catch (Exception exc) {
2409            ErrorLogger.LogException(_className ,"GetDISMPenetrateDouble",
2410                    new RendererException("Failed inside GetDISMPenetrateDouble", exc));
2411        }
2412    }
2413    /**
2414     * Calculates the points for BYIMP
2415     *
2416     * @param points OUT - the client points, also used for the returned points.
2417     * @param linetype the line type.
2418     */
2419    protected static int GetDISMByImpDouble(POINT2[] points,
2420            int linetype) {
2421        int counter = 0;
2422        try {
2423            int j = 0;
2424            POINT2[] pointsCorner = new POINT2[2];
2425            POINT2[] rectpts = new POINT2[4];
2426            POINT2[] savepoints = new POINT2[3];
2427            POINT2[] deltapoints1 = new POINT2[4];
2428            POINT2[] deltapoints2 = new POINT2[4];
2429            POINT2 midpt = new POINT2();
2430            POINT2[] pts = new POINT2[6];
2431            POINT2 ptRelative = new POINT2();
2432            ref<double[]> iDeltaX = new ref(), iDeltaY = new ref();
2433            int bPointsRight = 0;
2434            double dMBR = lineutility.MBRDistance(points, 3);
2435            //end declarations
2436
2437            if (dMBR > 40 * maxLength) {
2438                dMBR = 40 * maxLength;
2439            }
2440            if (dMBR < 5 * minLength) {
2441                dMBR = 5 * minLength;
2442            }
2443            if(dMBR>250)
2444                dMBR=250;
2445
2446            for (j = 0; j < 3; j++) {
2447                savepoints[j] = new POINT2(points[j]);
2448            }
2449
2450            lineutility.InitializePOINT2Array(rectpts);
2451            lineutility.InitializePOINT2Array(deltapoints1);
2452            lineutility.InitializePOINT2Array(deltapoints2);
2453            lineutility.InitializePOINT2Array(pts);
2454            lineutility.InitializePOINT2Array(pointsCorner);
2455
2456            DrawOpenRectangleDouble(savepoints, pointsCorner, rectpts);
2457
2458            points[counter] = new POINT2(rectpts[0]);
2459            points[counter].style = 0;
2460            counter++;
2461            points[counter] = new POINT2(rectpts[1]);
2462            points[counter].style = 0;
2463            counter++;
2464            midpt = lineutility.MidPointDouble(rectpts[1], rectpts[2], 0);
2465            pts[0] = lineutility.ExtendLine2Double(rectpts[1], midpt, -5, 5);
2466            pts[1] = lineutility.ExtendLine2Double(rectpts[1], midpt, 5, 5);
2467            points[counter] = new POINT2(pts[0]);
2468            points[counter].style = 5;
2469            counter++;
2470
2471            ptRelative = lineutility.PointRelativeToLine(rectpts[0], rectpts[1], pts[0]);
2472            pts[2] = lineutility.ExtendLineDouble(ptRelative, pts[0], -dMBR / 40);
2473
2474            pts[3] = lineutility.ExtendLineDouble(ptRelative, pts[0], dMBR / 40);
2475
2476            points[counter] = new POINT2(pts[2]);
2477            points[counter].style = 0;
2478            counter++;
2479            points[counter] = new POINT2(pts[3]);
2480            points[counter].style = 5;
2481            counter++;
2482            ptRelative = lineutility.PointRelativeToLine(rectpts[2], rectpts[3], pts[1]);
2483            pts[4] = lineutility.ExtendLineDouble(ptRelative, pts[1], -dMBR / 40);
2484
2485            pts[5] = lineutility.ExtendLineDouble(ptRelative, pts[1], dMBR / 40);
2486            points[counter] = new POINT2(pts[4]);
2487            points[counter].style = 0;
2488            counter++;
2489            points[counter] = new POINT2(pts[5]);
2490            points[counter].style = 5;
2491            counter++;
2492            points[counter] = new POINT2(pts[1]);
2493            points[counter].style = 0;
2494            counter++;
2495            points[counter] = new POINT2(rectpts[2]);
2496            points[counter].style = 0;
2497            counter++;
2498            points[counter] = new POINT2(rectpts[3]);
2499            points[counter].style = 5;
2500            counter++;
2501
2502            bPointsRight = DetermineDirectionDouble(savepoints);
2503
2504            CalcEndpieceDeltasDouble(savepoints, iDeltaX, iDeltaY, CONST_PI / 4);
2505
2506            if ((savepoints[0].y - savepoints[1].y) < 0) {// Point0 is higher than Point1
2507                if (bPointsRight != 0) {// figure opens to the right
2508                    DrawEndpieceDeltasDouble(savepoints[0],
2509                            iDeltaX.value[0], iDeltaY.value[0], iDeltaY.value[0], -iDeltaX.value[0], deltapoints1);
2510                    DrawEndpieceDeltasDouble(savepoints[1],
2511                            iDeltaX.value[0], iDeltaY.value[0], iDeltaY.value[0], -iDeltaX.value[0], deltapoints2);
2512                } else {// figure opens to the left
2513                    DrawEndpieceDeltasDouble(savepoints[0],
2514                            iDeltaY.value[0], -iDeltaX.value[0], iDeltaX.value[0], iDeltaY.value[0], deltapoints1);
2515                    DrawEndpieceDeltasDouble(savepoints[1],
2516                            iDeltaY.value[0], -iDeltaX.value[0], iDeltaX.value[0], iDeltaY.value[0], deltapoints2);
2517                }
2518            } else {// Point0 is lower than Point1
2519                if (bPointsRight != 0) {// figure opens to the right
2520                    DrawEndpieceDeltasDouble(savepoints[0],
2521                            iDeltaY.value[0], -iDeltaX.value[0], iDeltaX.value[0], iDeltaY.value[0], deltapoints1);
2522                    DrawEndpieceDeltasDouble(savepoints[1],
2523                            iDeltaY.value[0], -iDeltaX.value[0], iDeltaX.value[0], iDeltaY.value[0], deltapoints2);
2524                } else {// figure opens to the left
2525                    DrawEndpieceDeltasDouble(savepoints[0],
2526                            iDeltaX.value[0], iDeltaY.value[0], iDeltaY.value[0], -iDeltaX.value[0], deltapoints1);
2527                    DrawEndpieceDeltasDouble(savepoints[1],
2528                            iDeltaX.value[0], iDeltaY.value[0], iDeltaY.value[0], -iDeltaX.value[0], deltapoints2);
2529                }
2530            }
2531
2532            points[counter] = new POINT2(deltapoints1[1]);
2533            points[counter].style = 9;
2534            counter++;
2535            points[counter] = new POINT2(deltapoints1[0]);
2536            points[counter].style = 9;
2537            counter++;
2538            points[counter] = new POINT2(deltapoints1[3]);
2539            points[counter].style = 9;
2540            counter++;
2541            points[counter] = new POINT2(deltapoints1[3]);
2542            points[counter].style = 10;
2543            counter++;
2544
2545            points[counter] = new POINT2(deltapoints2[1]);
2546            points[counter].style = 9;
2547            counter++;
2548            points[counter] = new POINT2(deltapoints2[0]);
2549            points[counter].style = 9;
2550            counter++;
2551            points[counter] = new POINT2(deltapoints2[3]);
2552            points[counter].style = 9;
2553            counter++;
2554            points[counter] = new POINT2(deltapoints2[3]);
2555            points[counter].style = 10;
2556            counter++;
2557
2558        } catch (Exception exc) {
2559            ErrorLogger.LogException(_className ,"GetDISMByImpDouble",
2560                    new RendererException("Failed inside GetDISMByImpDouble", exc));
2561        }
2562        return counter;
2563    }
2564    /**
2565     * Calculates the points for SPTBYFIRE
2566     *
2567     * @param points OUT - the client points, also used for the returned points.
2568     * @param linetype the line type.
2569     */
2570    protected static int GetDISMSupportByFireDouble(POINT2[] points,
2571            int linetype) {
2572        int counter = 0;
2573        try {
2574            POINT2[] pts = new POINT2[3];
2575            POINT2[] savepoints = new POINT2[4];
2576            int j = 0;
2577            double iDiagEOL_length = 0;
2578            double dAngle1 = 0;
2579            double iDeltaX1 = 0;
2580            double iDeltaY1 = 0;
2581            double iDeltaX2 = 0;
2582            double iDeltaY2 = 0;
2583
2584            for (j = 0; j < 4; j++) {
2585                savepoints[j] = new POINT2(points[j]);
2586            }
2587            ReorderSptByFirePoints(savepoints);
2588
2589            lineutility.InitializePOINT2Array(pts);
2590            // draw line connecting points 1 & 2
2591            points[counter] = new POINT2(savepoints[0]);
2592            points[counter].style = 0;
2593            counter++;
2594            points[counter] = new POINT2(savepoints[1]);
2595            points[counter].style = 5;
2596            counter++;
2597
2598            // draw line connecting savepoints 1 & 3
2599            pts[0] = new POINT2(savepoints[0]);
2600            pts[1] = new POINT2(savepoints[2]);
2601            points[counter] = new POINT2(pts[0]);
2602            points[counter].style = 0;
2603            counter++;
2604            points[counter] = new POINT2(pts[1]);
2605            points[counter].style = 5;
2606            counter++;
2607
2608            // draw arrow at end of line
2609            iDiagEOL_length =  (Math.sqrt(
2610                    (savepoints[0].x - savepoints[1].x) * (savepoints[0].x - savepoints[1].x) +
2611                    (savepoints[0].y - savepoints[1].y) * (savepoints[0].y - savepoints[1].y)) / 10);
2612
2613            if (iDiagEOL_length >  maxLength) {
2614                iDiagEOL_length =  maxLength;
2615            }
2616            if (iDiagEOL_length <  minLength) {
2617                iDiagEOL_length =  minLength;
2618            }
2619
2620            dAngle1 = Math.atan2(savepoints[0].y - savepoints[2].y, savepoints[0].x - savepoints[2].x);
2621            iDeltaX1 =  (Math.cos(dAngle1 + CONST_PI / 6) * iDiagEOL_length);
2622            iDeltaY1 =  (Math.sin(dAngle1 + CONST_PI / 6) * iDiagEOL_length);
2623            iDeltaX2 =  (Math.cos(dAngle1 - CONST_PI / 6) * iDiagEOL_length);
2624            iDeltaY2 =  (Math.sin(dAngle1 - CONST_PI / 6) * iDiagEOL_length);
2625            pts[0].x = savepoints[2].x + iDeltaX1;
2626            pts[0].y = savepoints[2].y + iDeltaY1;
2627            pts[1] = new POINT2(savepoints[2]);
2628            pts[2].x = savepoints[2].x + iDeltaX2;
2629            pts[2].y = savepoints[2].y + iDeltaY2;
2630            //DrawLine(destination, mask, color, pts, 3, 2);
2631            for (j = 0; j < 3; j++) {
2632                points[counter] = new POINT2(pts[j]);
2633                points[counter].style = 0;
2634                counter++;
2635            }
2636            points[counter - 1].style = 5;
2637
2638            // draw line connecting savepoints 2 & 4
2639            pts[0] = new POINT2(savepoints[1]);
2640            pts[1] = new POINT2(savepoints[3]);
2641            points[counter] = new POINT2(pts[0]);
2642            points[counter].style = 0;
2643            counter++;
2644            points[counter] = new POINT2(pts[1]);
2645            points[counter].style = 5;
2646            counter++;
2647
2648            // draw arrow at end of line
2649            dAngle1 = Math.atan2(savepoints[1].y - savepoints[3].y, savepoints[1].x - savepoints[3].x);
2650            iDeltaX1 =  (Math.cos(dAngle1 + CONST_PI / 6) * iDiagEOL_length);
2651            iDeltaY1 =  (Math.sin(dAngle1 + CONST_PI / 6) * iDiagEOL_length);
2652            iDeltaX2 =  (Math.cos(dAngle1 - CONST_PI / 6) * iDiagEOL_length);
2653            iDeltaY2 =  (Math.sin(dAngle1 - CONST_PI / 6) * iDiagEOL_length);
2654            pts[0].x = savepoints[3].x + iDeltaX1;
2655            pts[0].y = savepoints[3].y + iDeltaY1;
2656            pts[1] = new POINT2(savepoints[3]);
2657            pts[2].x = savepoints[3].x + iDeltaX2;
2658            pts[2].y = savepoints[3].y + iDeltaY2;
2659            //DrawLine(destination, mask, color, pts, 3, 2);
2660            for (j = 0; j < 3; j++) {
2661                points[counter] = new POINT2(pts[j]);
2662                points[counter].style = 0;
2663                counter++;
2664            }
2665            points[counter - 1].style = 5;
2666
2667            // draw lines on the back of the graphic
2668            dAngle1 = Math.atan2(savepoints[1].y - savepoints[0].y, savepoints[1].x - savepoints[0].x);
2669            iDiagEOL_length *= 2;
2670            iDeltaX1 =  (Math.cos(dAngle1 - CONST_PI / 4) * iDiagEOL_length);
2671            iDeltaY1 =  (Math.sin(dAngle1 - CONST_PI / 4) * iDiagEOL_length);
2672            iDeltaX2 =  (Math.cos(dAngle1 + CONST_PI / 4) * iDiagEOL_length);
2673            iDeltaY2 =  (Math.sin(dAngle1 + CONST_PI / 4) * iDiagEOL_length);
2674            pts[0].x = savepoints[0].x - iDeltaX1;
2675            pts[0].y = savepoints[0].y - iDeltaY1;
2676            pts[1] = new POINT2(savepoints[0]);
2677            points[counter] = new POINT2(pts[0]);
2678            points[counter].style = 0;
2679            counter++;
2680            points[counter] = new POINT2(pts[1]);
2681            points[counter].style = 5;
2682            counter++;
2683
2684            pts[0].x = savepoints[1].x + iDeltaX2;
2685            pts[0].y = savepoints[1].y + iDeltaY2;
2686            pts[1] = new POINT2(savepoints[1]);
2687            points[counter] = new POINT2(pts[0]);
2688            points[counter].style = 0;
2689            counter++;
2690            points[counter] = new POINT2(pts[1]);
2691            points[counter].style = 5;
2692            counter++;
2693        }
2694        catch (Exception exc) {
2695            ErrorLogger.LogException(_className ,"GetDISMSupportbyFireDouble",
2696                    new RendererException("Failed inside GetDISMSupportByFireDouble", exc));
2697        }
2698        return counter;
2699    }
2700
2701    private static void ReorderAtkByFirePoints(POINT2[] points) {
2702        try {
2703            //assume the points were ordered correctly. then pt0 is above the line from pt1 to pt2
2704            POINT2[] savepoints = new POINT2[3];
2705            POINT2 ptAboveLine = new POINT2(), ptBelowLine = new POINT2(), ptLeftOfLine = new POINT2(), ptRightOfLine = new POINT2();
2706            double distToLine = 0, distanceToPointAboveLine = 0, distanceToPointBelowLine = 0;
2707            double distanceToPointLeftOfLine = 0, distanceToPointRightOfLine = 0;
2708            for (int j = 0; j < 3; j++) {
2709                savepoints[j] = new POINT2(points[j]);
2710            }
2711
2712            if (Math.abs(savepoints[1].x - savepoints[2].x) > 2) {
2713                distToLine = lineutility.CalcDistanceToLineDouble(savepoints[1], savepoints[2], savepoints[0]);
2714                ptAboveLine = lineutility.ExtendDirectedLine(savepoints[1], savepoints[2], savepoints[2], 2, distToLine);
2715                ptBelowLine = lineutility.ExtendDirectedLine(savepoints[1], savepoints[2], savepoints[2], 3, distToLine);
2716                distanceToPointAboveLine = lineutility.CalcDistanceDouble(savepoints[0], ptAboveLine);
2717                distanceToPointBelowLine = lineutility.CalcDistanceDouble(savepoints[0], ptBelowLine);
2718                if (distanceToPointAboveLine < distanceToPointBelowLine) {
2719                    //then pt2 - pt3 should be left to right
2720                    if (savepoints[2].x < savepoints[1].x) {
2721                        lineutility.Reverse2Points(savepoints[1], savepoints[2]);
2722                    }
2723
2724
2725                } else {
2726                    if (savepoints[2].x > savepoints[1].x) {
2727                        lineutility.Reverse2Points(savepoints[1], savepoints[2]);
2728                    }
2729
2730                }
2731            } else //the last 2 points form a vertical line
2732            {
2733                distToLine = lineutility.CalcDistanceToLineDouble(savepoints[1], savepoints[2], savepoints[0]);
2734                ptLeftOfLine = lineutility.ExtendDirectedLine(savepoints[1], savepoints[2], savepoints[2], 0, distToLine);
2735                ptRightOfLine = lineutility.ExtendDirectedLine(savepoints[1], savepoints[2], savepoints[2], 1, distToLine);
2736                distanceToPointLeftOfLine = lineutility.CalcDistanceDouble(savepoints[0], ptLeftOfLine);
2737                distanceToPointRightOfLine = lineutility.CalcDistanceDouble(savepoints[0], ptRightOfLine);
2738                if (distanceToPointRightOfLine < distanceToPointLeftOfLine) {
2739                    if (savepoints[2].y < savepoints[1].y) {
2740                        lineutility.Reverse2Points(savepoints[1], savepoints[2]);
2741                    }
2742                } else {
2743                    if (savepoints[2].y > savepoints[1].y) {
2744                        lineutility.Reverse2Points(savepoints[1], savepoints[2]);
2745                    }
2746                }
2747            }
2748            points[1].x = savepoints[1].x;
2749            points[1].y = savepoints[1].y;
2750            points[2].x = savepoints[2].x;
2751            points[2].y = savepoints[2].y;
2752        } catch (Exception exc) {
2753            ErrorLogger.LogException(_className, "ReorderAtkByFirePoints",
2754                    new RendererException("Failed inside GetDISMSupportByFireDouble", exc));
2755        }
2756    }
2757    private static void ReorderSptByFirePoints(POINT2[] points) {
2758        try {
2759            //assume the points were ordered correctly. then pt0 is above the line from pt1 to pt2
2760            POINT2 ptAboveLine = new POINT2(), ptBelowLine = new POINT2(), ptLeftOfLine = new POINT2(), ptRightOfLine = new POINT2();
2761            double distToLine = 0, distanceToPointAboveLine = 0, distanceToPointBelowLine = 0;
2762            double distanceToPointLeftOfLine = 0, distanceToPointRightOfLine = 0;
2763
2764            POINT2 midpt = lineutility.MidPointDouble(points[0], points[1], 0);
2765            if (Math.abs(points[2].x - points[3].x) > 2) {
2766                distToLine = lineutility.CalcDistanceToLineDouble(points[1], points[2], midpt);
2767                ptAboveLine = lineutility.ExtendDirectedLine(points[1], points[2], points[2], 2, distToLine);
2768                ptBelowLine = lineutility.ExtendDirectedLine(points[1], points[2], points[2], 3, distToLine);
2769                distanceToPointAboveLine = lineutility.CalcDistanceDouble(points[0], ptAboveLine);
2770                distanceToPointBelowLine = lineutility.CalcDistanceDouble(points[0], ptBelowLine);
2771                if (distanceToPointAboveLine < distanceToPointBelowLine) {
2772                    //then pt2 - pt3 should be left to right
2773                    if (points[2].x < points[1].x) {
2774                        lineutility.Reverse2Points(points[0], points[1]);
2775                        lineutility.Reverse2Points(points[2], points[3]);
2776                    }
2777                } else {
2778                    if (points[2].x > points[1].x) {
2779                        lineutility.Reverse2Points(points[0], points[1]);
2780                        lineutility.Reverse2Points(points[2], points[3]);
2781                    }
2782                }
2783            } else //the last 2 points form a vertical line
2784            {
2785                distToLine = lineutility.CalcDistanceToLineDouble(points[1], points[2], midpt);
2786                ptLeftOfLine = lineutility.ExtendDirectedLine(points[1], points[2], points[2], 0, distToLine);
2787                ptRightOfLine = lineutility.ExtendDirectedLine(points[1], points[2], points[2], 1, distToLine);
2788                distanceToPointLeftOfLine = lineutility.CalcDistanceDouble(points[0], ptLeftOfLine);
2789                distanceToPointRightOfLine = lineutility.CalcDistanceDouble(points[0], ptRightOfLine);
2790                if (distanceToPointLeftOfLine < distanceToPointRightOfLine) {
2791                    //then pt2 - pt3 should be left to right
2792                    if (points[2].y > points[1].y) {
2793                        lineutility.Reverse2Points(points[0], points[1]);
2794                        lineutility.Reverse2Points(points[2], points[3]);
2795                    }
2796                } else {
2797                    if (points[2].y < points[1].y) {
2798                        lineutility.Reverse2Points(points[0], points[1]);
2799                        lineutility.Reverse2Points(points[2], points[3]);
2800                    }
2801                }
2802
2803            }
2804        } catch (Exception exc) {
2805            ErrorLogger.LogException(_className, "ReorderSptByFire",
2806                    new RendererException("Failed inside ReorderSptByFirePoints", exc));
2807        }
2808    }
2809    /**
2810     * Calculates the points for ATKBYFIRE
2811     *
2812     * @param points OUT - the client points, also used for the returned points.
2813     * @param linetype the line type.
2814     */
2815    protected static int GetDISMATKBYFIREDouble(POINT2[] points, int linetype) {
2816        int counter = 0;
2817        try {
2818            POINT2[] pts = new POINT2[3];
2819            POINT2 ptMid = new POINT2();
2820            POINT2[] savepoints = new POINT2[3];
2821            int j = 0;
2822            double iDiagEOL_length = 0;
2823            double dAngle1 = 0;
2824            double iDeltaX1 = 0;
2825            double iDeltaY1 = 0;
2826            double iDeltaX2 = 0;
2827            double iDeltaY2 = 0;
2828
2829            for (j = 0; j < 3; j++) {
2830                savepoints[j] = new POINT2(points[j]);
2831            }
2832
2833            ReorderAtkByFirePoints(savepoints);
2834
2835            lineutility.InitializePOINT2Array(pts);
2836            // draw line across back
2837            pts[0] = new POINT2(savepoints[1]);
2838            pts[1] = new POINT2(savepoints[2]);
2839            //DrawLine(destination, mask, color, pts, 2, 2);
2840            points[counter] = new POINT2(pts[0]);
2841            points[counter].style = 0;
2842            counter++;
2843            points[counter] = new POINT2(pts[1]);
2844            points[counter].style = 5;
2845            counter++;
2846
2847            // draw perpendicular line
2848            ptMid.x = (savepoints[1].x + savepoints[2].x) / 2;
2849            ptMid.y = (savepoints[1].y + savepoints[2].y) / 2;
2850            pts[0] = new POINT2(ptMid);
2851            pts[1] = new POINT2(savepoints[0]);
2852            //DrawLine(destination, mask, color, pts, 2, 2);
2853            points[counter] = new POINT2(pts[0]);
2854            points[counter].style = 0;
2855            counter++;
2856            points[counter] = new POINT2(pts[1]);
2857            points[counter].style = 5;
2858            counter++;
2859
2860            // draw arrowhead
2861            iDiagEOL_length =  ((Math.sqrt // height of graphic
2862                    (
2863                    (savepoints[1].x - savepoints[2].x) * (savepoints[1].x - savepoints[2].x) +
2864                    (savepoints[1].y - savepoints[2].y) * (savepoints[1].y - savepoints[2].y)) +
2865                    Math.sqrt // length of graphic
2866                    (
2867                    (savepoints[0].x - ptMid.x) * (savepoints[0].x - ptMid.x) +
2868                    (savepoints[0].y - ptMid.y) * (savepoints[0].y - ptMid.y))) / 20);
2869            //if(iDiagEOL_length<10)
2870            //  iDiagEOL_length=10;
2871            if ((double) iDiagEOL_length > maxLength/5) {
2872                iDiagEOL_length =  maxLength/5;
2873            }
2874            if ((double) iDiagEOL_length < minLength) {
2875                iDiagEOL_length =  minLength;
2876            }
2877
2878            dAngle1 = Math.atan2(ptMid.y - savepoints[0].y, ptMid.x - savepoints[0].x);
2879            iDeltaX1 =  (Math.cos(dAngle1 + CONST_PI / 6) * iDiagEOL_length);
2880            iDeltaY1 =  (Math.sin(dAngle1 + CONST_PI / 6) * iDiagEOL_length);
2881            iDeltaX2 =  (Math.cos(dAngle1 - CONST_PI / 6) * iDiagEOL_length);
2882            iDeltaY2 =  (Math.sin(dAngle1 - CONST_PI / 6) * iDiagEOL_length);
2883            pts[0].x = savepoints[0].x + iDeltaX1;
2884            pts[0].y = savepoints[0].y + iDeltaY1;
2885            pts[1] = new POINT2(savepoints[0]);
2886            pts[2].x = savepoints[0].x + iDeltaX2;
2887            pts[2].y = savepoints[0].y + iDeltaY2;
2888            //DrawLine(destination, mask, color, pts, 3, 2);
2889            for (j = 0; j < 3; j++) {
2890                points[counter] = new POINT2(pts[j]);
2891                points[counter].style = 0;
2892                counter++;
2893            }
2894            points[counter - 1].style = 5;
2895
2896            // draw lines on the back of the graphic
2897            dAngle1 = Math.atan2(savepoints[1].y - savepoints[2].y, savepoints[1].x - savepoints[2].x);
2898            iDeltaX1 =  (Math.cos(dAngle1 - CONST_PI / 4) * iDiagEOL_length * 2);
2899            iDeltaY1 =  (Math.sin(dAngle1 - CONST_PI / 4) * iDiagEOL_length * 2);
2900            iDeltaX2 =  (Math.cos(dAngle1 + CONST_PI / 4) * iDiagEOL_length * 2);
2901            iDeltaY2 =  (Math.sin(dAngle1 + CONST_PI / 4) * iDiagEOL_length * 2);
2902
2903            pts[0].x = savepoints[1].x + iDeltaX1;
2904            pts[0].y = savepoints[1].y + iDeltaY1;
2905            pts[1] = new POINT2(savepoints[1]);
2906            //DrawLine(destination, mask, color, pts, 2, 2);
2907            points[counter] = new POINT2(pts[0]);
2908            points[counter].style = 0;
2909            counter++;
2910            points[counter] = new POINT2(pts[1]);
2911            points[counter].style = 5;
2912            counter++;
2913
2914            pts[0].x = savepoints[2].x - iDeltaX2;
2915            pts[0].y = savepoints[2].y - iDeltaY2;
2916            pts[1] = new POINT2(savepoints[2]);
2917            //DrawLine(destination, mask, color, pts, 2, 2);
2918            points[counter] = new POINT2(pts[0]);
2919            points[counter].style = 0;
2920            counter++;
2921            points[counter] = new POINT2(pts[1]);
2922            points[counter].style = 5;
2923            counter++;
2924        } catch (Exception exc) {
2925            ErrorLogger.LogException(_className ,"GetDISMAtkByFireDouble",
2926                    new RendererException("Failed inside GetDISMAtkByFireDouble", exc));
2927        }
2928        return counter;
2929    }
2930    /**
2931     * Calculates the points for GAP
2932     *
2933     * @param points OUT - the client points, also used for the returned points.
2934     * @param linetype the line type.
2935     */
2936    protected static int GetDISMGapDouble(POINT2[] points, int linetype) {
2937        try {
2938            POINT2[] savepoints = new POINT2[4];
2939            POINT2[] pts = new POINT2[2];
2940            int j = 0;
2941            double dMBR = lineutility.MBRDistance(points, 4);
2942            //end declarations
2943
2944            for (j = 0; j < 4; j++) {
2945                savepoints[j] = new POINT2(points[j]);
2946            }
2947
2948            lineutility.InitializePOINT2Array(pts);
2949            //M. Deutch 8-19-04
2950            if (dMBR / 10 > maxLength) {
2951                dMBR = 10 * maxLength;
2952            }
2953            if (dMBR / 10 < minLength) {
2954                dMBR = 10 * minLength;
2955            }
2956
2957            points[0] = new POINT2(savepoints[0]);
2958            points[0].style = 0;
2959            points[1] = new POINT2(savepoints[1]);
2960            points[1].style = 5;
2961            points[2] = new POINT2(savepoints[2]);
2962            points[2].style = 0;
2963            points[3] = new POINT2(savepoints[3]);
2964            points[3].style = 5;
2965
2966            double dist = dMBR / 10;
2967            if(dist>20)
2968                dist=20;
2969            double dist2 = dist;
2970            switch (linetype) //change 1
2971            {
2972                case TacticalLines.BRIDGE:
2973                    dist = 1.5 * dist;
2974                    dist2 = dist / 2;
2975                    break;
2976                default:
2977                    dist2 = dist;
2978                    break;
2979            }
2980
2981            //get the extension point
2982            pts[0] = lineutility.ExtendLineDouble(savepoints[1], savepoints[0], dist);
2983            pts[1] = lineutility.ExtendLineDouble(savepoints[2], savepoints[0], dist2);
2984            points[4] = new POINT2(points[0]);
2985            points[4].style = 0;
2986            points[5] = lineutility.MidPointDouble(pts[0], pts[1], 5);
2987            //get the extension point
2988            pts[0] = lineutility.ExtendLineDouble(savepoints[0], savepoints[1], dist);
2989            pts[1] = lineutility.ExtendLineDouble(savepoints[3], savepoints[1], dist2);
2990            points[6] = new POINT2(points[1]);
2991            points[6].style = 0;
2992            points[7] = lineutility.MidPointDouble(pts[0], pts[1], 5);
2993            //get the extension point
2994            pts[0] = lineutility.ExtendLineDouble(savepoints[0], savepoints[2], dist2);
2995            pts[1] = lineutility.ExtendLineDouble(savepoints[3], savepoints[2], dist);
2996            points[8] = new POINT2(points[2]);
2997            points[8].style = 0;
2998            points[9] = lineutility.MidPointDouble(pts[0], pts[1], 5);
2999            //get the extension point
3000            pts[0] = lineutility.ExtendLineDouble(savepoints[1], savepoints[3], dist2);
3001            pts[1] = lineutility.ExtendLineDouble(savepoints[2], savepoints[3], dist);
3002            points[10] = new POINT2(points[3]);
3003            points[10].style = 0;
3004            points[11] = lineutility.MidPointDouble(pts[0], pts[1], 5);
3005
3006        } catch (Exception exc) {
3007            ErrorLogger.LogException(_className ,"GetDISMGapDouble",
3008                    new RendererException("Failed inside GetDISMGapDouble", exc));
3009        }
3010        return 12;
3011    }
3012    /**
3013     * Calculates the points for MNFLDDIS
3014     *
3015     * @param points - OUT - the client points, also used for the returned points.
3016     * @param linetype the line type.
3017     */
3018    protected static int GetDISMMinefieldDisruptDouble(POINT2[] points, int linetype) {
3019        int counter=0;
3020        try {
3021            POINT2[] pts = new POINT2[2];
3022            POINT2[] ptsArrow = new POINT2[3];
3023            POINT2 ptCenter = new POINT2();
3024            int j = 0;
3025            POINT2[] savepoints = new POINT2[3];
3026            double dAngle1 = 0, d = 0, dist = 0;
3027            POINT2[] deltapoints1 = new POINT2[4];
3028            POINT2[] deltapoints2 = new POINT2[4];
3029            POINT2[] deltapoints3 = new POINT2[4];
3030            double iDiagEOL_length = 0;
3031            double iDeltaX1 = 0;
3032            double iDeltaY1 = 0;
3033            double iDeltaX2 = 0;
3034            double iDeltaY2 = 0;
3035            POINT2 ptTail = new POINT2();
3036            //end declarations
3037
3038            for (j = 0; j < 3; j++) {
3039                savepoints[j] = new POINT2(points[j]);
3040            }
3041
3042            lineutility.InitializePOINT2Array(ptsArrow);
3043            lineutility.InitializePOINT2Array(deltapoints1);
3044            lineutility.InitializePOINT2Array(deltapoints2);
3045            lineutility.InitializePOINT2Array(deltapoints3);
3046            lineutility.InitializePOINT2Array(pts);
3047            
3048            points[counter] = new POINT2(savepoints[0]);
3049            points[counter].style = 0;
3050            counter++;
3051            points[counter] = new POINT2(savepoints[1]);
3052            points[counter].style = 5;
3053            counter++;
3054
3055            ptCenter.x = (savepoints[0].x + savepoints[1].x) / 2;
3056            ptCenter.y = (savepoints[0].y + savepoints[1].y) / 2;
3057
3058            ptsArrow[0] = new POINT2(savepoints[2]);
3059            ptsArrow[1].x = ptCenter.x + (savepoints[2].x - savepoints[0].x) * 4 / 5;
3060            ptsArrow[1].y = ptCenter.y + (savepoints[2].y - savepoints[0].y) * 4 / 5;
3061            ptsArrow[2].x = savepoints[1].x + (savepoints[2].x - savepoints[0].x) * 3 / 5;
3062            ptsArrow[2].y = savepoints[1].y + (savepoints[2].y - savepoints[0].y) * 3 / 5;
3063
3064            points[counter] = new POINT2(savepoints[1]);
3065            points[counter].style = 0;
3066            counter++;
3067            points[counter] = new POINT2(ptsArrow[2]);
3068            points[counter].style = 5;
3069            counter++;
3070
3071            pts[1] = new POINT2(ptsArrow[1]);
3072
3073            //draw middle line
3074            points[counter] = new POINT2(ptCenter);
3075            points[counter].style = 0;
3076            counter++;
3077            points[counter] = new POINT2(pts[1]);
3078            points[counter].style = 5;
3079            counter++;
3080
3081            //draw tail
3082            dist = lineutility.CalcDistanceDouble(savepoints[2], savepoints[0]);
3083            d = dist;
3084            if (d > 5 * maxLength) {
3085                d = 5 * maxLength;
3086            }
3087            if (d < 5 * minLength) {
3088                d = 5 * minLength;
3089            }
3090            ptTail.x = (savepoints[0].x + ptCenter.x) / 2;
3091            ptTail.y = (savepoints[0].y + ptCenter.y) / 2;
3092            pts[0].x = ptTail.x - (savepoints[2].x - savepoints[0].x) / 5;
3093            pts[0].y = ptTail.y - (savepoints[2].y - savepoints[0].y) / 5;
3094            pts[0] = lineutility.ExtendLineDouble(pts[0], ptTail, -d / 5);
3095            points[counter] = new POINT2(ptTail);
3096            points[counter].style = 0;
3097            counter++;
3098            points[counter] = new POINT2(pts[0]);
3099            points[counter].style = 5;
3100            counter++;
3101
3102            pts[0] = new POINT2(savepoints[0]);
3103            pts[1] = new POINT2(ptsArrow[0]);
3104
3105            points[counter] = new POINT2(pts[0]);
3106            points[counter].style = 0;
3107            counter++;
3108            points[counter] = new POINT2(pts[1]);
3109            points[counter].style = 5;
3110            counter++;
3111
3112            // the following code is very similar to CalcEndpieceDeltas
3113            iDiagEOL_length =  ((Math.sqrt // height of graphic
3114                    (
3115                    (savepoints[1].x - savepoints[0].x) * (savepoints[1].x - savepoints[0].x) +
3116                    (savepoints[1].y - savepoints[0].y) * (savepoints[1].y - savepoints[0].y)) +
3117                    Math.sqrt // length of graphic
3118                    (
3119                    (savepoints[2].x - savepoints[1].x) * (savepoints[2].x - savepoints[1].x) +
3120                    (savepoints[2].y - savepoints[1].y) * (savepoints[2].y - savepoints[1].y))) / 15);
3121            // dAngle1 = angle used to calculate the end-piece deltas
3122
3123            if (iDiagEOL_length >  maxLength) {
3124                iDiagEOL_length =  maxLength;
3125            }
3126            if (iDiagEOL_length <  minLength) {
3127                iDiagEOL_length =  minLength;
3128            }
3129
3130            dAngle1 = Math.atan2(savepoints[0].y - savepoints[2].y, savepoints[0].x - savepoints[2].x);
3131            iDeltaX1 =  (iDiagEOL_length * Math.cos(dAngle1 - CONST_PI / 6));
3132            iDeltaY1 =  (iDiagEOL_length * Math.sin(dAngle1 - CONST_PI / 6));
3133            iDeltaX2 =  (iDiagEOL_length * Math.cos(dAngle1 + CONST_PI / 6));
3134            iDeltaY2 =  (iDiagEOL_length * Math.sin(dAngle1 + CONST_PI / 6));
3135
3136            DrawEndpieceDeltasDouble(ptsArrow[0],
3137                    iDeltaX1, iDeltaY1, iDeltaX2, iDeltaY2, deltapoints1);
3138            DrawEndpieceDeltasDouble(ptsArrow[1],
3139                    iDeltaX1, iDeltaY1, iDeltaX2, iDeltaY2, deltapoints2);
3140            DrawEndpieceDeltasDouble(ptsArrow[2],
3141                    iDeltaX1, iDeltaY1, iDeltaX2, iDeltaY2, deltapoints3);
3142            points[counter] = new POINT2(deltapoints1[1]);
3143            points[counter].style = 9;
3144            counter++;
3145            points[counter] = new POINT2(deltapoints1[0]);
3146            points[counter].style = 9;
3147            counter++;
3148            points[counter] = new POINT2(deltapoints1[3]);
3149            points[counter].style = 9;
3150            counter++;
3151            points[counter] = new POINT2(deltapoints1[3]);
3152            points[counter].style = 10;
3153            counter++;
3154
3155            points[counter] = new POINT2(deltapoints2[1]);
3156            points[counter].style = 9;
3157            counter++;
3158            points[counter] = new POINT2(deltapoints2[0]);
3159            points[counter].style = 9;
3160            counter++;
3161            points[counter] = new POINT2(deltapoints2[3]);
3162            points[counter].style = 9;
3163            counter++;
3164            points[counter] = new POINT2(deltapoints2[3]);
3165            points[counter].style = 10;
3166            counter++;
3167
3168            points[counter] = new POINT2(deltapoints3[1]);
3169            points[counter].style = 9;
3170            counter++;
3171            points[counter] = new POINT2(deltapoints3[0]);
3172            points[counter].style = 9;
3173            counter++;
3174            points[counter] = new POINT2(deltapoints3[3]);
3175            points[counter].style = 9;
3176            counter++;
3177            points[counter] = new POINT2(deltapoints3[3]);
3178            points[counter].style = 10;
3179            counter++;
3180
3181        } catch (Exception exc) {
3182            ErrorLogger.LogException(_className ,"GetDISMMinefieldDisruptDouble",
3183                    new RendererException("Failed inside GetDISMMinefieldDisruptDouble", exc));
3184        }
3185        return counter;
3186    }
3187    /**
3188     * Calculates the points for LINTGT
3189     *
3190     * @param points - OUT - the client points, also used for the returned points.
3191     * @param linetype the line type.
3192     * @param vblCounter the number of points required to display the symbol
3193     */
3194    protected static int GetDISMLinearTargetDouble(POINT2[] points, int linetype, int vblCounter) {
3195        int counter = 0;
3196        try {
3197            int j = 0;
3198            double dMBR = lineutility.MBRDistance(points, vblCounter-4);
3199            //end declarations
3200
3201            if (dMBR / 20 > maxLength) {
3202                dMBR = 20 * maxLength;
3203            }
3204            if (dMBR / 20 < minLength) {
3205                dMBR = 20 * minLength;
3206            }
3207            if (dMBR < 150) {
3208                dMBR = 150;
3209            }
3210            if(dMBR>250)
3211                dMBR=250;
3212            
3213            for (j = 0; j < vblCounter - 4; j++) {
3214                points[counter].style = 0;
3215                counter++;
3216            }
3217            //for(j=vblCounter-4;j<vblCounter;j++)
3218              //  points[j]=new POINT2();
3219
3220            points[counter - 1].style = 5;
3221
3222            points[counter] = lineutility.ExtendTrueLinePerpDouble(points[0], points[1], points[0], dMBR / 20, 0);
3223            counter++;
3224            points[counter] = lineutility.ExtendTrueLinePerpDouble(points[0], points[1], points[0], -dMBR / 20, 5);
3225            counter++;
3226            points[counter] = lineutility.ExtendTrueLinePerpDouble(points[vblCounter - 5], points[vblCounter - 6], points[vblCounter - 5], dMBR / 20, 0);
3227            counter++;
3228            points[counter] = lineutility.ExtendTrueLinePerpDouble(points[vblCounter - 5], points[vblCounter - 6], points[vblCounter - 5], -dMBR / 20, 5);
3229            counter++;
3230            if (linetype == (long) TacticalLines.FPF) {
3231                points[0].style = 6;
3232            }
3233        } catch (Exception exc) {
3234            ErrorLogger.LogException(_className ,"GetDISMLinearTargetDouble",
3235                    new RendererException("Failed inside GetDISMLinearTargetDouble", exc));
3236        }
3237        return counter;
3238    }
3239    /**
3240     * Calculates the points for BLOCK, MNFLDBLK
3241     *
3242     * @param points - OUT - the client points, also used for the returned points.
3243     * @param linetype the line type.
3244     */
3245    protected static void GetDISMBlockDouble2(POINT2[] points,
3246            int linetype) {
3247        try {
3248            POINT2 ptRelative = new POINT2(points[2]);
3249            
3250            POINT2 midpt = lineutility.MidPointDouble(points[0], points[1], 0);
3251            int j = 0;
3252            points[0].style = 0;
3253            points[1].style = 5;
3254            points[2] = new POINT2(midpt);
3255            points[3] = new POINT2(ptRelative);
3256            if (linetype == (long) TacticalLines.BLOCK) {
3257                points[2].style = 14;
3258            }
3259            if (linetype == (long) TacticalLines.FPF) {
3260                points[2].style = 6;
3261            }
3262        } catch (Exception exc) {
3263            ErrorLogger.LogException(_className ,"GetDISMBlockDouble2",
3264                    new RendererException("Failed inside GetDISMBlockDouble2", exc));
3265        }
3266    }
3267    /**
3268     * Calculates the points for PAA_RECTANGULAR.
3269     *
3270     * @param points - OUT - the client points, also used for the returned points.
3271     * @param linetype the line type.
3272     */
3273    protected static void GetDISMPAADouble(POINT2[] points, int linetype) {
3274        try {
3275            POINT2 pt0 = new POINT2(points[0]);
3276            POINT2 pt1 = new POINT2(points[1]);
3277            POINT2 pt2 = new POINT2();
3278            POINT2 pt3 = new POINT2();
3279            POINT2 midpt = new POINT2();
3280            double d = lineutility.CalcDistanceDouble(pt0, pt1);
3281
3282            midpt = lineutility.MidPointDouble(pt0, pt1, 0);
3283            pt2 = lineutility.ExtendTrueLinePerpDouble(pt0, pt1, midpt, d / 2, 0);
3284            pt3 = lineutility.ExtendTrueLinePerpDouble(pt0, pt1, midpt, -d / 2, 0);
3285            d = lineutility.CalcDistanceDouble(pt0, pt2);
3286            points[0] = new POINT2(pt0);
3287            points[0].style = 14;
3288            points[1] = new POINT2(pt2);
3289            points[1].style = 14;
3290            points[2] = new POINT2(pt1);
3291            points[2].style = 14;
3292            points[3] = new POINT2(pt3);
3293            points[3].style = 14;
3294            points[4] = new POINT2(pt0);
3295            points[4].style = 5;
3296        } catch (Exception exc) {
3297            ErrorLogger.LogException(_className ,"GetDISMPAADouble",
3298                    new RendererException("Failed inside GetDISMPAADouble", exc));
3299        }
3300    }
3301
3302    private static boolean ReverseDelayArc(POINT2[] points) {
3303        POINT2 pt1 = points[0];
3304        POINT2 pt2 = points[1];
3305        POINT2 pt3 = points[2];
3306
3307        float lineAngle = getAngleBetweenPoints(pt1.x, pt1.y, pt2.x, pt2.y);
3308        float curveAngle = getAngleBetweenPoints(pt2.x, pt2.y, pt3.x, pt3.y);
3309
3310        float upperBound = curveAngle + 180;
3311        return !isInRange(curveAngle, upperBound, lineAngle);
3312    }
3313
3314    private static boolean isInRange(float min, float max, float targetAngle) {
3315        targetAngle = normalizeAngle(targetAngle);
3316        min = normalizeAngle(min);
3317        max = normalizeAngle(max);
3318
3319        if (min < max) {
3320            return min <= targetAngle && targetAngle <= max;
3321        }
3322        return min <= targetAngle || targetAngle <= max;
3323
3324    }
3325
3326    private static float getAngleBetweenPoints(double x1, double y1, double x2, double y2) {
3327        return (float) Math.toDegrees(Math.atan2(y2 - y1, x2 - x1));
3328    }
3329
3330    /**
3331     * Returns an angle from 0 to 360
3332     *
3333     * @param angle the angle to normalize
3334     * @return an angle in range from 0 to 360
3335     */
3336    public static float normalizeAngle(float angle) {
3337        return (3600000 + angle) % 360;
3338    }
3339
3340    private static void DrawEndpieceDeltasDouble(POINT2 point,
3341            double iDelta1,
3342            double iDelta2,
3343            double iDelta3,
3344            double iDelta4,
3345            POINT2[] deltapoints)
3346                {
3347        try
3348        {
3349            deltapoints[0] = new POINT2(point);
3350            deltapoints[0].style = 0;
3351            deltapoints[1].x = point.x + iDelta1;
3352            deltapoints[1].y = point.y + iDelta2;
3353            deltapoints[1].style = 5;
3354            deltapoints[2] = new POINT2(point);
3355            deltapoints[2].style = 0;
3356            deltapoints[3].x = point.x + iDelta3;
3357            deltapoints[3].y = point.y + iDelta4;
3358            deltapoints[3].style = 5;
3359        } catch (Exception exc) {
3360            ErrorLogger.LogException(_className ,"DrawEndpieceDeltasDouble",
3361                    new RendererException("Failed inside DrawEndpieceDeltasDouble", exc));
3362        }
3363    }
3364    /**
3365     * Calculates the points for EASY
3366     *
3367     * @param points - OUT - the client points, also used for the returned points.
3368     * @param linetype the line type.
3369     */
3370    protected static int GetDISMEasyDouble(POINT2[] points,
3371            int linetype) {
3372        int counter = 0;
3373        try {
3374            int j = 0;
3375            POINT2[] pointsCorner = new POINT2[2];
3376            POINT2[] rectpts = new POINT2[4];
3377            POINT2[] savepoints = new POINT2[3];
3378            POINT2[] deltapoints1 = new POINT2[4];
3379            POINT2[] deltapoints2 = new POINT2[4];
3380            ref<double[]> iDeltaX = new ref(), iDeltaY = new ref();
3381            int bPointsRight = 0;
3382            //end declarations
3383
3384            for (j = 0; j < 3; j++) {
3385                savepoints[j] = points[j];
3386            }
3387            lineutility.InitializePOINT2Array(pointsCorner);
3388            lineutility.InitializePOINT2Array(rectpts);
3389            lineutility.InitializePOINT2Array(deltapoints1);
3390            lineutility.InitializePOINT2Array(deltapoints2);
3391
3392            DrawOpenRectangleDouble(savepoints, pointsCorner, rectpts);
3393            for (j = 0; j < 4; j++) {
3394                points[counter] = new POINT2(rectpts[j]);
3395                points[counter].style = 0;
3396                counter++;
3397            }
3398            points[counter - 1].style = 5;
3399
3400            bPointsRight = DetermineDirectionDouble(savepoints);
3401
3402            CalcEndpieceDeltasDouble(savepoints, iDeltaX, iDeltaY, CONST_PI / 4);
3403
3404            if ((savepoints[0].y - savepoints[1].y) < 0) {// Point0 is higher than Point1
3405                if (bPointsRight != 0) {// figure opens to the right
3406                    DrawEndpieceDeltasDouble(savepoints[0],
3407                            iDeltaX.value[0], iDeltaY.value[0], iDeltaY.value[0], -iDeltaX.value[0], deltapoints1);
3408                    DrawEndpieceDeltasDouble(savepoints[1],
3409                            iDeltaX.value[0], iDeltaY.value[0], iDeltaY.value[0], -iDeltaX.value[0], deltapoints2);
3410                } else {// figure opens to the left
3411                    DrawEndpieceDeltasDouble(savepoints[0],
3412                            iDeltaY.value[0], -iDeltaX.value[0], iDeltaX.value[0], iDeltaY.value[0], deltapoints1);
3413                    DrawEndpieceDeltasDouble(savepoints[1],
3414                            iDeltaY.value[0], -iDeltaX.value[0], iDeltaX.value[0], iDeltaY.value[0], deltapoints2);
3415                }
3416            } else {// Point0 is lower than Point1
3417                if (bPointsRight != 0) {// figure opens to the right
3418                    DrawEndpieceDeltasDouble(savepoints[0],
3419                            iDeltaY.value[0], -iDeltaX.value[0], iDeltaX.value[0], iDeltaY.value[0], deltapoints1);
3420                    DrawEndpieceDeltasDouble(savepoints[1],
3421                            iDeltaY.value[0], -iDeltaX.value[0], iDeltaX.value[0], iDeltaY.value[0], deltapoints2);
3422                } else {// figure opens to the left
3423                    DrawEndpieceDeltasDouble(savepoints[0],
3424                            iDeltaX.value[0], iDeltaY.value[0], iDeltaY.value[0], -iDeltaX.value[0], deltapoints1);
3425                    DrawEndpieceDeltasDouble(savepoints[1],
3426                            iDeltaX.value[0], iDeltaY.value[0], iDeltaY.value[0], -iDeltaX.value[0], deltapoints2);
3427                }
3428            }
3429
3430            points[counter] = new POINT2(deltapoints1[1]);
3431            points[counter].style = 9;
3432            counter++;
3433            points[counter] = new POINT2(deltapoints1[0]);
3434            points[counter].style = 9;
3435            counter++;
3436            points[counter] = new POINT2(deltapoints1[3]);
3437            points[counter].style = 9;
3438            counter++;
3439            points[counter] = new POINT2(deltapoints1[3]);
3440            points[counter].style = 10;
3441            counter++;
3442
3443            points[counter] = new POINT2(deltapoints2[1]);
3444            points[counter].style = 9;
3445            counter++;
3446            points[counter] = new POINT2(deltapoints2[0]);
3447            points[counter].style = 9;
3448            counter++;
3449            points[counter] = new POINT2(deltapoints2[3]);
3450            points[counter].style = 9;
3451            counter++;
3452            points[counter] = new POINT2(deltapoints2[3]);
3453            points[counter].style = 10;
3454            counter++;
3455
3456        } catch (Exception exc) {
3457            ErrorLogger.LogException(_className ,"GetDISMEasyDouble",
3458                    new RendererException("Failed inside GetDISMEasyDouble", exc));
3459        }
3460        return counter;
3461    }
3462    
3463    /**
3464     * Calculates the points for AMBUSH
3465     *
3466     * @param pLinePoints - OUT - the client points, also used for the returned points.
3467     */
3468    protected static int AmbushPointsDouble(POINT2[] pLinePoints)
3469    {
3470        int counter=0;
3471        try
3472        {
3473            POINT2[] pts=new POINT2[3];
3474            POINT2[] savepoints=new POINT2[3];
3475            // calculate midpoint
3476            POINT2 ptMid=new POINT2();
3477            double dRadius=0,d=0;
3478            double dAngle1=0;
3479            double dAngle1c=0;
3480            double dAngle2c=0;
3481            double dAngle12c=0;
3482            double dAngle0=0;
3483            POINT2[] arcpoints=new POINT2[17];
3484            double dAngleTic = 0;
3485            double dDeltaX1=0, dDeltaY1=0;
3486            double dDeltaX2 = 0;
3487            double dDeltaY2 = 0;
3488            POINT2 ptCenter=new POINT2();
3489            int j=0,i=0;
3490            double iArrowLength=0;
3491
3492            for(j=0;j<3;j++)
3493            {
3494                savepoints[j]=new POINT2(pLinePoints[j]);
3495            }
3496
3497            //initialize the pOINT2 arrays
3498            lineutility.InitializePOINT2Array(arcpoints);
3499            lineutility.InitializePOINT2Array(pts);
3500
3501            ptMid.x = (savepoints[1].x + savepoints[2].x) / 2;
3502            ptMid.y = (savepoints[1].y + savepoints[2].y) / 2;
3503
3504            // calculate arc center
3505            dRadius = Math.sqrt( (ptMid.x-savepoints[2].x) * (ptMid.x-savepoints[2].x) +
3506                (ptMid.y-savepoints[2].y) * (ptMid.y-savepoints[2].y) );
3507
3508            // add section M. Deutch 8-25-05
3509            //consider the other possiblity for a center
3510            double dRadius2 = Math.sqrt( (ptMid.x-savepoints[1].x) * (ptMid.x-savepoints[1].x) +
3511                (ptMid.y-savepoints[1].y) * (ptMid.y-savepoints[1].y) );
3512
3513            dAngle1 = Math.atan2(savepoints[1].y - savepoints[2].y, savepoints[1].x - savepoints[2].x);
3514            ptCenter.x = ptMid.x + Math.cos(dAngle1 - CONST_PI / 2) * dRadius;
3515            ptCenter.y = ptMid.y + Math.sin(dAngle1 - CONST_PI / 2) * dRadius;
3516
3517            //added section M. Deutch 8-25-05
3518            //consider the other possibility for a center if the points were reversed
3519            double dAngle2 = Math.atan2(savepoints[2].y - savepoints[1].y, savepoints[2].x - savepoints[1].x);
3520            POINT2 ptCenter2=new POINT2();
3521            ptCenter2.x = ptMid.x + Math.cos(dAngle2 - CONST_PI / 2) * dRadius;
3522            ptCenter2.y = ptMid.y + Math.sin(dAngle2 - CONST_PI / 2) * dRadius;
3523            double dist=lineutility.CalcDistanceDouble(savepoints[0],ptCenter);
3524            double dist2=lineutility.CalcDistanceDouble(savepoints[0],ptCenter2);
3525            //if the distance to the new center is closer
3526            //then reverse the arc endpoints
3527            if(dist2>dist)
3528            {
3529                //POINT2 ptTemp=new POINT2();
3530                POINT2 ptTemp=new POINT2(savepoints[1]);
3531                savepoints[1]=new POINT2(savepoints[2]);
3532                savepoints[2]=new POINT2(ptTemp);
3533                ptCenter=new POINT2(ptCenter2);
3534                dAngle1=dAngle2;
3535            }
3536            //end section
3537
3538            dRadius = Math.sqrt ( (savepoints[1].x-ptCenter.x) * (savepoints[1].x-ptCenter.x) +
3539                (savepoints[1].y-ptCenter.y) * (savepoints[1].y-ptCenter.y) );
3540
3541            // draw arc
3542            ArcApproximationDouble ((ptCenter.x - dRadius),(ptCenter.y - dRadius),
3543                (ptCenter.x + dRadius),( ptCenter.y + dRadius),
3544                savepoints[2].x, savepoints[2].y, savepoints[1].x, savepoints[1].y, arcpoints);
3545
3546            for(j=0;j<17;j++)
3547            {
3548                pLinePoints[counter]=new POINT2(arcpoints[j]);
3549                pLinePoints[counter].style=0;
3550                counter++;
3551            }
3552            pLinePoints[counter-1].style=5;
3553
3554            // draw line out from arc to point 1
3555            pts[0] = new POINT2(savepoints[0]);
3556            dAngle1c = Math.atan2(ptCenter.y - savepoints[1].y, ptCenter.x - savepoints[1].x);
3557            dAngle2c = Math.atan2(ptCenter.y - savepoints[2].y, ptCenter.x - savepoints[2].x);
3558            dAngle12c = (dAngle1c + dAngle2c) / 2;
3559            if ( (dAngle1c > 0) && (dAngle2c < 0) )
3560            {
3561                pts[1].x = ptCenter.x + Math.cos(dAngle12c) * dRadius;
3562                pts[1].y = ptCenter.y + Math.sin(dAngle12c) * dRadius;
3563            }
3564            else
3565            {
3566                pts[1].x = ptCenter.x - Math.cos(dAngle12c) * dRadius;
3567                pts[1].y = ptCenter.y - Math.sin(dAngle12c) * dRadius;
3568            }
3569            pLinePoints[counter]=new POINT2(pts[0]);
3570            pLinePoints[counter].style=0;counter++;
3571            pLinePoints[counter]=new POINT2(pts[1]);
3572            pLinePoints[counter].style=5;counter++;
3573
3574
3575            // draw arrowhead on end of line
3576            dAngle0 = Math.atan2(pts[1].y - savepoints[0].y, pts[1].x - savepoints[0].x);
3577            iArrowLength =(
3578                (
3579                Math.sqrt // height of graphic
3580                (
3581                (savepoints[1].x-savepoints[2].x) * (savepoints[1].x-savepoints[2].x) +
3582                (savepoints[1].y-savepoints[2].y) * (savepoints[1].y-savepoints[2].y)
3583                ) +
3584                Math.sqrt // length of graphic
3585                (
3586                (savepoints[0].x-ptMid.x) * (savepoints[0].x-ptMid.x) +
3587                (savepoints[0].y-ptMid.y) * (savepoints[0].y-ptMid.y)
3588                )
3589                ) / 20);
3590
3591            if((double)iArrowLength>maxLength)
3592                iArrowLength=(int)maxLength;
3593            if((double)iArrowLength<minLength)
3594                iArrowLength=(int)minLength;
3595
3596            pts[0].x = savepoints[0].x + Math.cos(dAngle0 + CONST_PI / 6) * iArrowLength;
3597            pts[0].y = savepoints[0].y + Math.sin(dAngle0 + CONST_PI / 6) * iArrowLength;
3598            pts[1] = savepoints[0];
3599            pts[2].x = savepoints[0].x + Math.cos(dAngle0 - CONST_PI / 6) * iArrowLength;
3600            pts[2].y = savepoints[0].y + Math.sin(dAngle0 - CONST_PI / 6) * iArrowLength;
3601            for(j=0;j<3;j++)
3602            {
3603                pLinePoints[counter]=new POINT2(pts[j]);
3604                pLinePoints[counter].style=0;
3605                counter++;
3606            }
3607            pLinePoints[counter-1].style=5;
3608
3609            // draw lines out from arc toward back of graphic
3610            d=dRadius/3;
3611            if(d>maxLength)
3612                    d=maxLength;
3613            if(d<minLength)
3614                    d=minLength;
3615
3616            dAngleTic = CONST_PI / 18; // angle in radians between tic-marks
3617            dDeltaX2 = Math.cos(dAngle1 + CONST_PI / 2) * d;
3618            dDeltaY2 = Math.sin(dAngle1 + CONST_PI / 2) * d;
3619            for (i=0; i<8; i++)
3620            {
3621                dAngle1c += dAngleTic;
3622                dDeltaX1 = Math.cos(dAngle1c) * dRadius;
3623                dDeltaY1 = Math.sin(dAngle1c) * dRadius;
3624                pts[0].x = ptCenter.x - dDeltaX1;
3625                pts[0].y = ptCenter.y - dDeltaY1;
3626                pLinePoints[counter]=new POINT2(pts[0]);
3627                pLinePoints[counter].style=0;
3628                counter++;
3629                pts[1].x = pts[0].x - dDeltaX2;
3630                pts[1].y = pts[0].y - dDeltaY2;
3631                pLinePoints[counter]=new POINT2(pts[1]);
3632                pLinePoints[counter].style=5;
3633                counter++;
3634            }
3635        }
3636        catch(Exception exc)
3637        {
3638            ErrorLogger.LogException(_className ,"AmbushPointsDouble",
3639                    new RendererException("Failed inside AmbushPointsDouble", exc));
3640        }
3641        return counter;
3642    }
3643}