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); }
//====================================== public void render(xGraphics g) { if (!mShow) { return; } Share share = getShare(3); if (share == null) { return; } int b = share.mBeginIdx; int e = share.mEndIdx; int selSquareSide = 0; uint selSquareColor = 0xff00ff00; for (int i = 0; i < mTrends.size(); i++) { stTrendLine t = (stTrendLine)mTrends.elementAt(i); g.setColor(C.COLOR_ORANGE); // grey if (t.type != DRAW_TREND) { g.setColor(C.COLOR_FIBO_DOT_LINE2); } if (t.type == DRAW_TREND) { g.setColor(t.color); } //if (mSelectedTrend == t) //{ //g.setColor(C.COLOR_RED); //} if (t != mSelectedTrend && (t.type == DRAW_RECTANGLE || t.type == DRAW_TRIANGLE || t.type == DRAW_ANDREWS_PITCHFORK || t.type == DRAW_ABC || t.type == DRAW_OVAL)) { } else { g.setColor(t.color); g.drawLineDot(t.x[0], t.y[0], t.x[1], t.y[1], t.thickness); } if (t.type == DRAW_FIBO_PROJECTION) { g.drawLine(t.x[1], t.y[1], t.x[2], t.y[2]); } int pointRadiu = 2; if (mSelectedTrend == t) { pointRadiu = 4; selSquareSide = 60; } // draw the point if (t.x[0] >= mX) { g.setColor(0xff00ff00); g.fillRect(t.x[0] - pointRadiu, t.y[0] - pointRadiu, 2 * pointRadiu, 2 * pointRadiu); } if (t.x[1] < mX + getW()) { g.setColor(0xffff5522); g.fillRect(t.x[1] - pointRadiu, t.y[1] - pointRadiu, 2 * pointRadiu, 2 * pointRadiu); } if (t.type == DRAW_FIBO_PROJECTION || t.type == DRAW_TRIANGLE || t.type == DRAW_ANDREWS_PITCHFORK) { if (t.x[2] < mX + getW()) { g.setColor(0xffffff00); g.fillRect(t.x[2] - pointRadiu, t.y[2] - pointRadiu, 2 * pointRadiu, 2 * pointRadiu); } } // draw the dragging point if (mSelectedTrend == t) { g.setColor(C.COLOR_MAGENTA); int r = 4; int cx = (t.x[0] + t.x[1]) / 2; int cy = (t.y[0] + t.y[1]) / 2; g.drawRect(cx - 2, cy - 2, 4, 4); g.drawRect(cx - 5, cy - 5, 10, 10); } // draw fibo lines if (t.type == DRAW_TREND) { drawTrend(g, t); } if (t.type == DRAW_TREND_ARROW) { drawTrendArrow(g, t); } else if (t.type == DRAW_FIBO_RETRACEMENT) { drawFiboRetracementLines(g, t); } else if (t.type == DRAW_FIBO_PROJECTION) { drawFiboProjection(g, t); } else if (t.type == DRAW_FIBO_TIME) { drawFiboTime(g, t); } else if (t.type == DRAW_FIBO_FAN) { drawFiboFan(g, t); } else if (t.type == DRAW_FIBO_ARC) { drawFiboArc(g, t); } else if (t.type == DRAW_RECTANGLE) { drawRectangle(g, t); } else if (t.type == DRAW_TRIANGLE) { drawTriangle(g, t); } else if (t.type == DRAW_OVAL) { drawOval(g, t); } else if (t.type == DRAW_ABC) { drawAbc(g, t); } else if (t.type == DRAW_ANDREWS_PITCHFORK) { drawAndrewsPitchFork(g, t); } if (mSelectedTrend != null) { drawControls(g); } } //==================draw finger square if (mSelectedTrend != null && mSelVertex != -1) { int x = mSelectedTrend.x[0]; int y = mSelectedTrend.y[0]; if (mSelVertex == 1) { x = mSelectedTrend.x[1]; y = mSelectedTrend.y[1]; } else if (mSelVertex == 2) { x = mSelectedTrend.x[2]; y = mSelectedTrend.y[2]; } selSquareSide = 20; g.setColor(C.COLOR_YELLOW); //g.drawRect(x - selSquareSide / 2, y - selSquareSide / 2, selSquareSide, selSquareSide); //x += selSquareSide / 4; //y += selSquareSide / 4; //g.drawRect(x, y, selSquareSide / 2, selSquareSide / 2); if (mSelectedTrend.type != DRAW_FIBO_TIME && mFont != null) { //sprintf(sz, "%d", mSelVertex+1); //g.setColor(C.COLOR_WHITE); //g.drawString(mFont, "" + (mSelVertex + 1), x + 3, y - (int)mFont.GetHeight(), 0); } } }