Example #1
0
        void drawTriangle(xGraphics g, stTrendLine t)
        {
            uint color = t.color;

            g.setColor(color);

            g.drawTriangleDot(t.x[0], t.y[0], t.x[1], t.y[1], t.x[2], t.y[2]);
        }
Example #2
0
        void drawAndrewsPitchFork(xGraphics g, stTrendLine t)
        {
            //
            //     -----1
            // 0---
            //     -----2
            g.setColor(t.color);
            g.drawTriangleDot(t.x[0], t.y[0], t.x[1], t.y[1], t.x[2], t.y[2]);

            float cX = (t.x[1] + t.x[2]) / 2;
            float cY = (t.y[1] + t.y[2]) / 2;

            if (cX == t.x[0])
            {
                cX = t.x[0] + 1;
            }

            //  PT for center line: y = ax + b
            float a = (float)(cY - t.y[0]) / (cX - t.x[0]);
            float b = t.y[0] - a * t.x[0];
            //  find the PT 0 - top line // center line
            float b1 = t.y[1] - a * t.x[1];
            //  find the bottom line
            float b2 = t.y[2] - a * t.x[2];

            int l  = (int)(getW() - cX);   //  do dai du kien
            int xx = (int)(cX + l);

            int[] yy = { 0, 0, 0 };

            //  center point: y0 = a*x0 + b
            yy[0] = (int)(a * xx + b);
            yy[1] = (int)(a * xx + b1);
            yy[2] = (int)(a * xx + b2);

            //  now draw 3 // lines
            g.drawLineDot(t.x[1], t.y[1], xx, yy[1], 1);
            g.drawLineDot(t.x[0], t.y[0], xx, yy[0], 1);
            g.drawLineDot(t.x[2], t.y[2], xx, yy[2], 1);
        }