void renderVolume(xGraphics g) { int h = (int)(rcView.Height / 2.5f); // get biggest volume long biggest = 0; long lowest = -1; int vol; int i, j; for (i = beginIdx; i <= endIdx; i++) { vol = volumes[i]; if (lowest == -1) { lowest = vol; } if (biggest < vol) { biggest = vol; } if (lowest > vol) { lowest = vol; } } if (biggest == 0) { return; } int rightPadding = (int)1;// xUtils.pointToPixels(1); float w = rcView.Width - rightPadding; double ry = (float)h / (biggest - lowest); double rw = w / mChartLineLength; float mVolumeBarW = ((w / mChartLineLength) * 2.0f / 3); float volumeBarWHalf = mVolumeBarW / 2; for (i = 0; i < mChartLineLength; i++) { j = (i + beginIdx); mChartLineXY[i * 2] = (short)(rcView.X + (i * rw - volumeBarWHalf)); // x mChartLineXY[i * 2 + 1] = (short)(rcView.Y + (h - (volumes[j] - lowest) * ry)); // h } // render g.setColor(0xff00ff00); float tmp = rcView.Height; int y0 = rcView.Height - h; for (i = 0; i < mChartLineLength; i++) { if (beginIdx + i > 0) { if (closes[beginIdx + i] > closes[beginIdx + i - 1]) { g.setColor(0xff00c000); } else if (closes[beginIdx + i] < closes[beginIdx + i - 1]) { g.setColor(0xffa00000); } else { g.setColor(0xffa08000); } } g.fillRectF(mChartLineXY[2 * i], y0 + mChartLineXY[2 * i + 1], mVolumeBarW, h - mChartLineXY[2 * i + 1]); } }
public override void render(xGraphics g) { int mH = getH(); int mW = getW(); if (isHiding()) { return; } Share share = getShare(3); if (share == null) { return; } if (detectShareCursorChanged()) { share.calcOBV(); mChartLineXY = allocMem(mChartLineXY, mChartLineLength * 2); float min = 0xffffff; float max = -0xffffff; for (int i = share.mBeginIdx; i <= share.mEndIdx; i++) { if (share.pOBV[i] > max) { max = share.pOBV[i]; } if (share.pOBV[i] < min) { min = share.pOBV[i]; } } pricesToYs(share.pOBV, share.mBeginIdx, mChartLineXY, mChartLineLength, min, max); if (mContext.mOptOBV_EMA > 0) { mChartEMA = allocMem(mChartEMA, mChartLineLength * 2); if (mContext.mOptOBV_EMA_ON[0]) { Share.EMA(share.pOBV, share.getCandleCount(), (int)mContext.mOptOBV_EMA, share.pTMP); } else { Share.SMA(share.pOBV, 0, share.getCandleCount(), (int)mContext.mOptOBV_EMA, share.pTMP); } pricesToYs(share.pTMP, share.mBeginIdx, mChartEMA, mChartLineLength, min, max); } } if (mChartLineLength == 0) { return; } //======================== if (mShouldDrawGrid) { drawGrid(g); } //=============================================== // OBV g.setColor(0xff00f000); g.drawLines(mChartLineXY, mChartLineLength, 1.5f); if (mContext.mOptOBV_EMA > 0) { g.setColor(C.COLOR_MAGENTA); g.drawLines(mChartEMA, mChartLineLength, 1.0f); } renderCursor(g); renderDrawer(g); }
override public void render(xGraphics g) { g.setColor(C.COLOR_BLACK); g.clear(); if (isProcessing) { g.setColor(C.COLOR_ORANGE); g.drawStringInRect(mContext.getFontSmallB(), "Đang xử lý", 0, 0, getW(), getH(), xGraphics.HCENTER | xGraphics.VCENTER); return; } if (onBack != null) { g.setColor(C.COLOR_ORANGE); g.drawString(mContext.getFontSmall(), "<<<BACK", 10, 4); } if (onHistoryClick != null) { g.setColor(C.COLOR_ORANGE); g.drawString(mContext.getFontSmall(), ">>>Đồ Thị", getW() - 10, 4, xGraphics.RIGHT); } // title // [Hom nay] [1 Tuan] [1 Thang] [3 thang] [1 nam] // Tang | Giam | // VN30: +15%; GTDG: 30.1ti ->Chart // if (mChanges.size() == 0) { calcChanged(mPeriod); } if (mChanges.size() == 0) { return; } float x, y; int buttonW = 76; int buttonH = 26; int gap = 4; x = (getW() - 6 * (buttonW + gap)) / 2; // button y = 2; mButtonPositions.removeAllElements(); mPeriods.removeAllElements(); string[] buttons = { "1 Ngày", "1 Tuần", "1 Tháng", "3 Tháng", "6 Tháng", "1 Năm" }; int[] periods = { 1, 5, 22, 67, 130, 260 }; for (int i = 0; i < buttons.Length; i++) { string s = buttons[i]; g.setColor(C.COLOR_GRAY_LIGHT); g.drawRect((int)x, 2, buttonW, buttonH); g.setColor(mPeriod == periods[i]?C.COLOR_ORANGE:C.COLOR_WHITE); g.drawStringInRect(mContext.getFontSmallB(), s, (int)x, (int)y, buttonW, buttonH, xGraphics.HCENTER | xGraphics.VCENTER); Rectangle rc = new Rectangle((int)x, 2, buttonW, buttonH); mButtonPositions.addElement(rc); mPeriods.addElement(periods[i]); x += buttonW + gap; } g.setColor(C.COLOR_GRAY_DARK); g.drawHorizontalLine(0, buttonH + 4, getW()); int numberOfColumns = 4; int maxItemPerColumns = mChanges.size() / numberOfColumns; if ((mChanges.size() % numberOfColumns) != 0) { maxItemPerColumns++; } ItemH = (getH() - 40) / maxItemPerColumns; int columnH = ItemH; float maxPercent = 0; for (int i = 0; i < mChanges.size(); i++) { ShareChanges gc = (ShareChanges)mChanges.elementAt(i); if (Math.Abs(gc.changedPercent) > maxPercent) { maxPercent = (float)Math.Abs(gc.changedPercent); } } //-------------------- int buttonY = 30; columnH = ItemH; float cellW = getW() / numberOfColumns; float cellH = ItemH; maxPercent *= 1.15f; // Left side int j = 0; y = buttonY + 4; int itemPerColumn = maxItemPerColumns; x = 2; drawItems(0, maxItemPerColumns, x, y, cellW, columnH, maxPercent, numberOfColumns, g); x += getW() / numberOfColumns; drawItems(maxItemPerColumns, maxItemPerColumns, x, y, cellW, columnH, maxPercent, numberOfColumns, g); x += getW() / numberOfColumns; drawItems(2 * maxItemPerColumns, maxItemPerColumns, x, y, cellW, columnH, maxPercent, numberOfColumns, g); x += getW() / numberOfColumns; drawItems(3 * maxItemPerColumns, maxItemPerColumns, x, y, cellW, columnH, maxPercent, numberOfColumns, g); }
//====================================== 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); } } }
public override void render(xGraphics g) { if (isHiding()) { return; } if (getShare(3) == null) { return; } Share share = getShare(); if (share == null) { return; } if (detectShareCursorChanged()) { share.calcBollinger(); mBBUpperXY = allocMem(mBBUpperXY, mChartLineLength * 2 + 10); mBBLowerXY = allocMem(mBBLowerXY, mChartLineLength * 2 + 10); mCenterXY = allocMem(mCenterXY, mChartLineLength * 2 + 10); mBBLine = allocMem(mBBLine, mChartLineLength * 4 + 10); pricesToYs(share.pBBUpper, share.mBeginIdx, mBBUpperXY, mChartLineLength, share.getLowestPrice(), share.getHighestPrice()); pricesToYs(share.pBBLower, share.mBeginIdx, mBBLowerXY, mChartLineLength, share.getLowestPrice(), share.getHighestPrice()); int j = 0; j = 0; for (int i = 0; i < mChartLineLength; i++) { mBBLine[j++] = mBBUpperXY[2 * i]; mBBLine[j++] = mBBUpperXY[2 * i + 1]; mCenterXY[2 * i] = mBBLowerXY[2 * i]; mCenterXY[2 * i + 1] = (short)((mBBUpperXY[2 * i + 1] + mBBLowerXY[2 * i + 1]) / 2); } mBBLine[j++] = mBBUpperXY[2 * (mChartLineLength - 1)]; // x mBBLine[j++] = mBBLowerXY[2 * (mChartLineLength - 1) + 1]; // y for (int i = mChartLineLength - 1; i >= 0; i--) { mBBLine[j++] = mBBLowerXY[2 * i]; mBBLine[j++] = mBBLowerXY[2 * i + 1]; } mPointCnt = j / 2; } if (mChartLineLength == 0) { return; } int mX = 0; int mY = 0; int mW = getW(); int mH = getH(); g.setColor(mBBColorBG); g.fillShapes(mBBLine, mPointCnt); g.setColor(0xa00080ff); g.drawLinesDot(mCenterXY, mChartLineLength); g.setColor(0xff752922); g.drawLines(mBBUpperXY, mChartLineLength); g.drawLines(mBBLowerXY, mChartLineLength); //================================= int cur = share.getCursor(); if (mShouldDrawValue && cur >= 0 && cur < share.getCandleCount()) { g.setColor(0xffffa0a0); String s1 = formatPrice(share.pBBUpper[cur]); String s2 = formatPrice(share.pBBLower[cur]); StringBuilder sb = Utils.sb; sb.Length = 0; sb.AppendFormat("BB({0},{1}) U:{2} L:{3}", (int)mContext.mOptBBPeriod, (int)mContext.mOptBBD, s1, s2); s1 = sb.ToString(); g.drawString(mFont, s1, 150, 12, 0); } }
override public void render(xGraphics g) { if (isHiding()) { return; } Share share = getShare(3); if (share == null) { return; } int mX = 0; int mY = 0; // update line ordinates if (detectShareCursorChanged() && mChartLineLength > 0) // share's cursor has been changed { calcZigzag(); //======================= int items = (mChartLineLength + 10) * 2; if (items < 2 * mZigzag.size() + 100) { items = mZigzag.size() * 2 + 100; } mZigzagPointCnt = 0; mChartLineXY = allocMem(mChartLineXY, items); mChartLineLength = 0; if (mZigzag != null && mZigzag.size() > 0) { // seek to the nearest point int i; float low = share.getLowestPrice(); float rY = (float)getDrawingH() / mPriceDistance; float rX = (float)getDrawingW() / mChartLineLength; int begin = -1; for (i = 0; i < mZigzag.size(); i++) { int idx = mZigzag.elementAt(i); if (idx >= share.mBeginIdx) { begin = i - 1; break; } } if (begin < 0) { begin = 0; } mChartLineLength = 0; for (i = begin; i < mZigzag.size(); i++) { int idx = mZigzag.elementAt(i); mChartLineXY[2 * mZigzagPointCnt] = (short)candleToX(idx); float close = share.getClose(mZigzag.elementAt(i)); mChartLineXY[2 * mZigzagPointCnt + 1] = (short)priceToY(close); mZigzagPointCnt++; if (mChartLineXY[2 * (mZigzagPointCnt - 1)] > mX + getW()) { break; } } } } //==========draw now if (mZigzagPointCnt > 0) { g.setColor(C.COLOR_RED_ORANGE); g.drawLines(mChartLineXY, mZigzagPointCnt, 2.0f); } }
public void drawFiboProjection(xGraphics g, stTrendLine t) { uint color = t.color;// Constants.COLOR_FIBO_DOT_LINE2; // blue g.setColor(color); float[] percent = { 0f, 23.6f, 38.2f, 50.0f, 61.8f, 100f, 161.8f }; String[] txt = { "0", "23.6", "38.2", "50.0", "61.8", "100", "161.8" }; int minX = t.x[0] < t.x[1] ? t.x[0] : t.x[1]; minX = minX < t.x[2] ? minX : t.x[2]; int maxX = t.x[0] > t.x[1] ? t.x[0] : t.x[1] + 30; maxX = mX + getW() - 35; int maxY = mY + getH() - 20; int deltaY = t.y[1] - t.y[0]; if (deltaY < 0) { deltaY = -deltaY; } int up = 1; int y0 = t.y[2]; if (t.x[0] < t.x[1] && t.y[0] < t.y[1]) { up = 1; } if (t.x[0] < t.x[1] && t.y[0] > t.y[1]) { up = -1; } if (t.x[0] > t.x[1] && t.y[0] > t.y[1]) { up = 1; } if (t.x[0] > t.x[1] && t.y[0] < t.y[1]) { up = -1; } String s; for (int i = 0; i < 7; i++) { int y = (int)(y0 + up * (percent[i] * deltaY) / 100); if (y > maxY || y < 0) { continue; } g.setColor(color); if (i == 5) { g.drawLine(minX - 30, y, maxX + 30, y); } else { g.drawLineDotHorizontal(minX - 30, y, maxX + 30, y); } //===================== if (i == 0 || i == 3 || i == 5) { s = Utils.formatDecimalNumber((int)mChart.yToPrice(y), 10, 1); g.setColor(C.COLOR_WHITE); g.drawString(mFont, s, maxX, y, xGraphics.VCENTER | xGraphics.TOP); g.drawString(mFont, txt[i], minX - 30, y, xGraphics.VCENTER | xGraphics.TOP); } } }
override public void render(xGraphics g) { g.setColor(C.COLOR_BLACK); g.fillRect(0, 0, getW(), getH()); g.setColor(C.COLOR_GRAY_LIGHT); g.drawRect(0, 0, getW(), getH()); Share share = mShare; if (share == null) { return; } if (share.mCClose == null && share.getID() > 0) { share.loadShareFromCommonData(true); mContext.setCurrentShare(share.getID()); } else { //return; } if (share.mCClose == null || share.getID() == 0) { return; } Font f = mContext.getFontText(); int x, y; x = 0; y = 0; stPriceboardState ps = mContext.mPriceboard.getPriceboard(share.getID()); if (ps == null) { return; } StringBuilder sb = Utils.getSB(); f = mContext.getBigFont(); // current price float price = ps.getCurrentPrice(); uint color = mContext.valToColorF(price, ps.getCe(), ps.getRef(), ps.getFloor()); if (price == 0) { price = ps.getRef(); } // current price sb.AppendFormat("{0:F2}", price); //l.setFont(f); x = 10; g.setColor(color); g.drawString(f, sb.ToString(), x, y); y += f.Height; // change float change = price - ps.getRef(); float changePercent = 0; if (ps.getRef() > 0) { changePercent = (change * 100) / ps.getRef(); } sb.Length = 0; sb.AppendFormat("{0:F1} ({1:F2}%)", (float)(change), changePercent); f = mContext.getFontText(); g.setColor(color); g.drawString(f, sb.ToString(), x, y); // --------------------vol x = 4; y += f.Height + 10; int vol = ps.getTotalVolume(); int vol10 = share.getAveVolumeInDays(10); int barMax = getW() - 20; float bar0 = 0; float bar10 = 0; if (vol < vol10) { bar0 = ((float)vol / vol10) * barMax; bar10 = barMax; } else if (vol != 0) { bar0 = barMax; bar10 = ((float)vol10 / vol) * barMax; } if (bar0 < 1) { bar0 = 1; } if (bar10 < 1) { bar10 = 1; } string tmp = Utils.formatNumber(vol); sb.Length = 0; sb.AppendFormat("Vol: {0}", tmp); g.setColor(C.COLOR_WHITE); g.drawString(f, sb.ToString(), x, y); y += (int)f.Height; g.setColor(C.COLOR_ORANGE); g.fillRect(x, y, (int)bar0, 10); y += 20; // --------------------vol10 tmp = Utils.formatNumber(vol10); sb.Length = 0; sb.AppendFormat("TB 10phiên: {0}", tmp); g.setColor(C.COLOR_WHITE); g.drawString(f, sb.ToString(), x, y); y += f.Height; g.setColor(C.COLOR_ORANGE); g.fillRect(x, y, (int)bar10, 10); }
public override void render(xGraphics g) { if (isHiding()) { return; } if (getShare(3) == null) { return; } Share share = getShare(); if (detectShareCursorChanged()) { share.calcPSAR(0, 0); int newSize = mChartLineLength * 2; mChartLineXY = allocMem(mChartLineXY, newSize); pricesToYs(share.pPSAR, share.mBeginIdx, mChartLineXY, mChartLineLength, false); } if (mChartLineLength == 0) { return; } int mX = 0; int mY = 0; g.setColor(0xffff0000); uint color; for (int i = 0; i < mChartLineLength; i++) { if (share.pSAR_SignalUp[share.mBeginIdx + i]) // is up { color = 0xff00ff00; } else { color = 0xffff0000; } g.setColor(color); g.drawPoint(mChartLineXY[2 * i], mChartLineXY[2 * i + 1], 2); } // info int cur = share.getCursor(); if (mShouldDrawValue && cur >= 0 && cur < share.getCandleCount()) { if (share.pSAR_SignalUp[cur]) { g.setColor(0xff00a000); } else { g.setColor(0xffa00000); } String s = formatPrice(share.pPSAR[cur]); StringBuilder sb = Utils.sb; sb.Length = 0; sb.AppendFormat("PSAR({0:F2},{1:F2}) {2}", mContext.mOptPSAR_alpha_max, mContext.mOptPSAR_alpha, s); s = sb.ToString(); g.drawString(mFont, s, 375, 12, 0); } }
public override void render(xGraphics g) { if (isHiding()) { return; } if (getShare(3) == null) { return; } if (detectShareCursorChanged()) { recalcMACD(); } if (mChartLineLength == 0) { return; } if (mShouldDrawGrid) { drawGrid(g); } //mOY = getH() / 2; g.setColor(C.COLOR_FADE_YELLOW); g.drawLine(0, mOY, getW() - 34, mOY); g.setColor(C.COLOR_FADE_YELLOW0); g.drawString(mFont, "0", getW() - 8, mOY, xGraphics.VCENTER | xGraphics.RIGHT); int hisW = (int)(((float)getDrawingW() / mChartLineLength) * 2.0f / 3); for (int i = 0; i < mChartLineLength; i++) { if (mHistogramH[i] > 0) { g.setColor(0xffff0000); } else { g.setColor(0xff00ff00); } g.fillRect(mHistogramXY[2 * i], mHistogramXY[2 * i + 1], hisW, mHistogramH[i]); } g.setColor(C.COLOR_BLUE_LIGHT); g.drawLines(mLineMACD, mChartLineLength, 2.0f); g.setColor(0xffff0000); g.drawLines(mLineSignal9, mChartLineLength, 1.0f); StringBuilder sb = Utils.sb; //========================= sb.Length = 0; float v = (mOY - mLastY) / ry; sb.AppendFormat("{0:F2}", v); mMouseTitle = sb.ToString(); renderCursor(g); // bottom border g.setColor(0xffa0a0a0); g.drawHorizontalLine(0, 0, getW()); renderDrawer(g); }
public override void render(xGraphics g) { if (isHiding()) { return; } if (getShare(3) == null) { return; } Share share = getShare(); if (share == null) { return; } if (detectShareCursorChanged()) { share.calcEnvelop(); float[] percent = { 110, 105, 102.5f, 100, 97.5f, 95.0f, 90 }; float[] p = share.pTMP; float min = share.getLowestPrice(); float max = share.getHighestPrice(); for (int i = 0; i < 7; i++) { mLines[i] = allocMem(mLines[i], mChartLineLength * 2 + 10); for (int j = 0; j < mChartLineLength; j++) { p[j] = (percent[i] * share.pSMA_Envelop[share.mBeginIdx + j]) / 100; } pricesToYs(p, 0, mLines[i], mChartLineLength, min, max); } } if (mChartLineLength == 0) { return; } int mX = 0; int mY = 0; int mW = getW(); int mH = getH(); uint[] color = { 0xffff00ff, 0xff00a000, 0xffa00000, 0xffff8000, 0xffa00000, 0xff00a000, 0xffff00ff }; bool[] draws = { false, false, false, true, false, false, false }; if (mContext.mOptEnvelopLine0[0]) // 2.5% { draws[2] = draws[4] = true; } if (mContext.mOptEnvelopLine1[0]) // 5% { draws[1] = draws[5] = true; } if (mContext.mOptEnvelopLine2[0]) // 10% { draws[0] = draws[6] = true; } for (int i = 0; i < 7; i++) { if (draws[i]) { g.setColor(color[i]); g.drawLinesDot(mLines[i], mChartLineLength); } } }
public override void render(xGraphics g) { g.setColor(C.COLOR_BLACK); g.clear(); g.setColor(0xffffffff); g.drawLine(0, 0, 0, getH()); stPriceboardStateIndex pi = mContext.mPriceboard.getPriceboardIndexOfMarket(mMarketID); if (pi == null || pi.current_point == 0) { return; } //=========================================== // VNIndex 375.3 (-1.86, -0.49%) KL: 37,716,548 GT: 560.9 ty up:84 no:53 down:169 //=========================================== int lineH = 20; int x0 = 4; int x = x0; int y = 0; uint color; g.setColor(C.COLOR_WHITE); Font fTitle = mContext.getFontTextItalic(); // date x = x0; g.setColor(C.COLOR_WHITE); g.drawString(fTitle, pi.mDate, x, y); y += lineH; //============================== // VNINDEX g.drawString(mFont, pi.code, x, y); //======point if (pi.changed_point > 0) { color = C.COLOR_GREEN; } else if (pi.changed_point < 0) { color = C.COLOR_RED; } else { color = C.COLOR_YELLOW; } g.setColor(color); String s; s = String.Format("{0:F2}", pi.current_point); // point x += g.getStringWidth(mFont, pi.code) + 10; g.drawString(mFont, s, x, y); // change g.setColor(C.COLOR_WHITE); y += lineH + 10; g.drawString(fTitle, "Thay đổi: ", x0, y); x = x0 + g.getStringWidth(fTitle, "Thay đổi: ") + 6; g.setColor(color); // change String s1 = String.Format("{0:F2}", pi.changed_point); float changedPercent = (pi.changed_point * 100) / pi.current_point; String s2 = String.Format("{0:F2}", changedPercent); StringBuilder sb = Utils.sb; sb.Length = 0; sb.AppendFormat("({0}, {1} %)", s1, s2); s = sb.ToString(); g.drawString(mFont, s, x, y); x = x0; y += lineH + 10; // KL g.setColor(C.COLOR_WHITE); double t = pi.total_volume; t /= 1000000; //s = s = Utils.formatNumber((float)t, 2); //Utils.formatNumber(0, 1); sb.Length = 0; sb.AppendFormat("KLGD: {0} tr", s); g.drawString(mFont, sb.ToString(), x, y); x = x0; y += lineH; // GT s = Utils.formatDecimalNumber(pi.totalGTGD, 1000, 1); sb.Length = 0; sb.AppendFormat("GTGD: {0} tỷ", s); g.drawString(mFont, sb.ToString(), x, y); x = x0; y += lineH; // cung-cau g.setColor(C.COLOR_WHITE); double[] tt = { 0, 0 }; calcBuySellRemains(pi.marketID, tt); // mua t = tt[0] / 1000000; s = Utils.formatNumber((float)t, 1); // ban t = tt[1] / 1000000; s1 = Utils.formatNumber((float)t, 1); sb.Length = 0; sb.AppendFormat("Dư mua/bán (tr): {0} / {1}", s, s1); g.drawString(mFont, sb.ToString(), x, y); x = x0; y += lineH + 10; g.setColor(C.COLOR_WHITE); g.drawString(fTitle, "Số mã tăng/giảm:", x, y); y += lineH; // up/none/down int frmW = mArrows.Width / 3; int frmH = mArrows.Height; g.drawImage(mArrows, x, y, frmW, frmH, 0, 0); x += frmW + 2; g.setColor(C.COLOR_GREEN); g.drawString(mFont, "" + pi.inc_cnt, x, y); x += 40; // none g.drawImage(mArrows, x, y, frmW, frmH, 2 * frmW, 0); x += frmW + 2; g.setColor(C.COLOR_YELLOW); g.drawString(mFont, "" + pi.floor_cnt, x, y); x += 40; // down g.drawImage(mArrows, x, y, frmW, frmH, frmW, 0); x += frmW + 2; g.setColor(C.COLOR_RED); g.drawString(mFont, "" + pi.dec_cnt, x, y); //===========cao: x = x0; g.setColor(C.COLOR_YELLOW); TradeHistory trade = mContext.getTradeHistory(pi.id); // referent s = String.Format("{0:F2}", pi.reference); y += lineH + 10; s = "Tham chiếu: " + s; //fTitle = mContext.getFon g.drawString(mFont, s, x, y); // cao s = String.Format("{0:F2}", trade.mHighest); y += lineH; s = "Cao nhất: " + s; g.drawString(mFont, s, x, y); // thap s = String.Format("{0:F2}", trade.mLowest); y += lineH; s = "Thấp nhất: " + s; g.drawString(mFont, s, x, y); }
public override void render(xGraphics g) { g.setColor(0xff002000); g.fillRect(0, 0, getW(), getH()); if (_isProcessing) { g.setColor(C.COLOR_ORANGE); g.drawStringInRect(mContext.getFontSmallB(), "Đang xử lý", 0, 0, getW(), getH(), xGraphics.HCENTER | xGraphics.VCENTER); return; } g.setColor(C.COLOR_ORANGE); String sz = String.Format("MãCP (giá, thay đổi %): Tăng/Giảm index: {0:F2}/{1:F2}", totalIndexInc, totalIndexDec); g.drawString(mContext.getFontSmall(), sz, 8, 1, xGraphics.TOP); if (totalIndexInc == 0 && totalIndexDec == 0) { return; } double total = totalIndexInc + Math.Abs(totalIndexDec); float incPercent = (float)(totalIndexInc / total); float decPercent = (float)(Math.Abs(totalIndexDec) / total); if (incPercent < 0.25) { incPercent = 0.25f; decPercent = 1.0f - incPercent; } if (decPercent < 0.25) { decPercent = 0.25f; incPercent = 1.0f - decPercent; } float incW = (getW() - 4) * 0.5f; //incPercent; float decW = (getW() - 4) * 0.5f; //decPercent; int maxItems = 22; int incCnt = vChangeInc.size() > maxItems?maxItems:vChangeInc.size(); float itemH = (getH() - 20) / maxItems; int decCnt = vChangeDec.size() > maxItems?maxItems:vChangeDec.size(); int x0 = 1; int x1 = (int)(getW() - decW); float incBiggest = 0; float decBiggest = 0; ChangeIndexItem first = (ChangeIndexItem)vChangeInc.firstElement(); if (vChangeInc.size() > 0) { incBiggest = 1.1f * first.modifiedValue; } first = (ChangeIndexItem)vChangeDec.firstElement(); if (vChangeDec.size() > 0) { decBiggest = 1.1f * first.modifiedValue; } float maxBiggest = Math.Max(incBiggest, decBiggest); int titleH = 20; // increase for (int i = 0; i < incCnt; i++) { ChangeIndexItem item = (ChangeIndexItem)vChangeInc.elementAt(i); g.setColor(C.COLOR_GREEN_DARK); float y = titleH + i * itemH; float itemW = item.modifiedValue * incW / maxBiggest; g.fillRectF(x0, y, itemW, itemH - 1); g.setColor(C.COLOR_WHITE); stPriceboardState ps = mContext.mPriceboard.getPriceboard(item.shareID); sz = String.Format("{0}({1:F1}, {2:F1}%): {3:F3}", ps.code, item.price, item.modifiedPercent, item.modifiedValue); g.drawStringF(mContext.getFontSmall(), sz, x0 + 8, y + itemH / 2, xGraphics.VCENTER); item.x = x0; item.y = y; item.w = incW; item.h = itemH; } // decrease for (int i = 0; i < decCnt; i++) { ChangeIndexItem item = (ChangeIndexItem)vChangeDec.elementAt(i); g.setColor(C.COLOR_RED); float y = titleH + i * itemH; float itemW = item.modifiedValue * decW / maxBiggest; g.fillRectF(x1, y, itemW, itemH - 1); g.setColor(C.COLOR_WHITE); stPriceboardState ps = mContext.mPriceboard.getPriceboard(item.shareID); sz = String.Format("{0}({1:F1}, {2:F1%}): {3:F3}", ps.code, item.price, item.modifiedPercent, item.modifiedValue); g.drawStringF(mContext.getFontSmall(), sz, x1 + 8, y + itemH / 2, xGraphics.VCENTER); item.x = x1; item.y = y; item.w = decW; item.h = itemH; } if (currentSelected != null && currentSelected.selected) { g.setColor(C.COLOR_ORANGE); g.drawRectF(currentSelected.x, currentSelected.y, currentSelected.w, currentSelected.h); } }
protected void drawDateSeparator(xGraphics g) { if (!mShouldDrawDateSeparator) { return; } if (getShare() == null) { return; } Share share = getShare(); if (share.isRealtime()) { return; } int y = getH() - 4; //----------draw vertical separators int range = share.getCursorScope(); int[] scopes = { Share.SCOPE_1WEEKS, Share.SCOPE_1MONTH, Share.SCOPE_3MONTHS, Share.SCOPE_6MONTHS, Share.SCOPE_1YEAR, Share.SCOPE_2YEAR, Share.SCOPE_ALL, -1 }; int scope = 1; int i = 1; while (scopes[i] != -1) { if (scopes[i] >= range) { scope = scopes[i]; break; } i++; } if (range > Share.SCOPE_2YEAR) { scope = Share.SCOPE_ALL; } //----------------------------------------- int lastSeperator = -1; int flag = 0; int jump = 0; StringBuilder sb = new StringBuilder(100); String sz; for (i = share.mBeginIdx; i < share.mEndIdx; i++) { if (scope == Share.SCOPE_1WEEKS) { } else if (scope == Share.SCOPE_1MONTH) { i = seekToFirstDayOfWeek(share, i); jump = 2; } else if (scope == Share.SCOPE_3MONTHS) { i = seekToFirstDayOfWeek(share, i); jump = 2; } else if (scope == Share.SCOPE_6MONTHS) { i = seekToFirstDayOfMonth(share, i); jump = 10; } else if (scope == Share.SCOPE_1YEAR) { i = seekToFirstDayOfMonth(share, i); jump = 10; } else if (scope == Share.SCOPE_2YEAR) { i = seekToFirstDayOfMonth(share, i); jump = 16; flag++; if (flag == 3) { flag = 0; } } else if (scope == Share.SCOPE_ALL) { i = seekToFirstDayOfQ(share, i); jump = 100; // about 6 months //flag++; //if (flag == 3) ///flag = 0; } if (i == -1 || i >= share.mEndIdx) { break; } if (flag != 0) { continue; } lastSeperator = share.getDate(i); int m = ((lastSeperator >> 8) & 0xff) - 1; int d = (lastSeperator & 0xff); int year = (lastSeperator >> 16) & 0xffff; year = year % 100; sb.Length = 0; if (scope == Share.SCOPE_ALL) { sb.AppendFormat("{0:D2}/{1:D2}", (m + 1), year); } else { sb.AppendFormat("{0:D2}/{1:D2}", d, m + 1); } sz = sb.ToString(); int x = candleToX(i); //g.setColor(C.GREY_LINE_COLOR); g.setColor(0x70454545); g.drawLine(x, y - 30, x, y); //g.drawLine(x, 0, x, y); g.setColor(C.COLOR_GRAY_LIGHT); Font fs = mContext.getFontSmaller(); g.drawString(fs, sz, x, y - fs.Height, xGraphics.LEFT); //-------------------- i += jump; } }
override public void render(xGraphics g) { g.setColor(C.COLOR_BLACK); g.clear(); // title xVector v = getMoneyVolumeArray(); if (v == null || v.size() == 0) { return; } int biggest = 0; int i = 0; for (i = 0; i < v.size(); i++) { MoneyVol mv = (MoneyVol)v.elementAt(i); if (mv.volume > biggest) { biggest = mv.volume; } } float rx; StringBuilder sb = Utils.sb; uint color; int itemH = (getH() - 18) / v.size() - 4; int y = 4; int x = 60; stPriceboardState ps = mContext.mPriceboard.getPriceboard(mShareID); if (ps == null) { return; } Font f = mContext.getFontSmall(); int x1 = g.getStringWidth(f, "444.44") + 2; int w0 = getW() - x1; string s; g.setColor(C.COLOR_GRAY_DARK); g.fillRect(0, 0, x1, 14); g.setColor(C.COLOR_WHITE); g.drawString(f, "Giá", 2, 0); g.setColor(C.COLOR_GRAY_DARK); g.fillRect(x1 + 2, 0, getW() - x1 - 5, 14); g.setColor(C.COLOR_WHITE); g.drawString(f, "Khối lượng", x1 + 4, 0); y = 18; for (i = 0; i < v.size(); i++) { MoneyVol mv = (MoneyVol)v.elementAt(i); sb.Length = 0; sb.AppendFormat("{0:F2}", (float)mv.price); // gia g.setColor(C.COLOR_GRAY_DARK); g.fillRect(0, y, x1, itemH); g.setColor(0xffffffff); g.drawString(f, sb.ToString(), 2, y); if (x1 == 0) { x1 = g.getStringWidth(f, sb.ToString()); } // column color = mContext.valToColorF(mv.price, ps.getCe(), ps.getRef(), ps.getFloor()); g.setColor(color); float w = ((float)mv.volume / biggest) * (w0 - 10); g.fillRect(2 + x1, y, (int)w, itemH); // volume s = Utils.formatNumber(mv.volume); sb.Length = 0; sb.AppendFormat("kl={0:}", s); s = sb.ToString(); int w2 = g.getStringWidth(f, s) + 2; g.setColor(C.COLOR_GRAY_DARK); g.fillRect(4 + x1, y, w2, 14); g.setColor(C.COLOR_ORANGE); g.drawString(f, s, 5 + x1, y); y += itemH + 3; } }
public override void render(xGraphics g) { if (isFocus()) g.setColor(0xff306AC5); else g.setColor(C.COLOR_BLACK); g.clear(); g.setColor(C.COLOR_GRAY_LIGHT); g.drawLine(0, 0, getW(), 0); g.setColor(C.COLOR_GRAY_LIGHT); g.drawLine(0, getH()-2, getW(), getH()-2); stPriceboardStateIndex pi = mContext.mPriceboard.getPriceboardIndexOfMarket(mMarketID); if (pi == null || pi.current_point == 0) return; //=========================================== // VNIndex 375.3 (-1.86, -0.49%) KL: 37,716,548 GT: 560.9 ty up:84 no:53 down:169 //=========================================== int x = 0; int y = 0; uint color; /* g.setColor(C.COLOR_WHITE); g.drawString(mFont, pi.code, x, y); */ int iconIdx = mMarketID == 1 ? 0 : 1; g.drawImage(mIcons.Images[iconIdx], 0, 1); x = mIcons.ImageSize.Width + 1; if (pi.changed_point > 0) color = C.COLOR_GREEN; else if (pi.changed_point < 0) color = C.COLOR_RED; else color = C.COLOR_YELLOW; g.setColor(color); String s; s = String.Format("{0:F2}", pi.current_point); // point g.drawString(mFont, s, x, y); x = 77; // change String s1 = String.Format("{0:F2}", pi.changed_point); float changedPercent = (pi.changed_point * 100) / pi.current_point; String s2 = String.Format("{0:F2}", changedPercent); StringBuilder sb = Utils.sb; sb.Length = 0; if (pi.changed_point >= 0) sb.AppendFormat("(+{0}, {1})", s1, s2); else sb.AppendFormat("(-{0}, {1})", s1, s2); s = sb.ToString(); g.drawString(mFont, s, x, y); x = 160; // KL g.setColor(C.COLOR_WHITE); s = Utils.formatNumber((int)pi.total_volume); sb.Length = 0; sb.AppendFormat("KL:{0:F1} tr", (double)(pi.total_volume/1000000)); g.drawString(mFont, sb.ToString(), x, y); x = 245; // GT sb.Length = 0; sb.AppendFormat("GT:{0:F1} tỷ", (double)pi.totalGTGD/1000); g.drawString(mFont, sb.ToString(), x, y); /* x = 520; // up/none/down int frmW = mArrows.Width/3; int frmH = mArrows.Height; g.drawImage(mArrows, x, y, frmW, frmH, 0, 0); x += frmW + 2; g.setColor(C.COLOR_GREEN); g.drawString(mFont, "" + pi.inc_cnt, x, y); x += 40; // none g.drawImage(mArrows, x, y, frmW, frmH, 2*frmW, 0); x += frmW + 2; g.setColor(C.COLOR_YELLOW); g.drawString(mFont, "" + pi.floor_cnt, x, y); x += 40; // down g.drawImage(mArrows, x, y, frmW, frmH, frmW, 0); x += frmW + 2; g.setColor(C.COLOR_RED); g.drawString(mFont, "" + pi.dec_cnt, x, y); */ }