void drawPriceLines(xGraphics g, int y, int h) { int x = 0; int w = getW(); g.drawHorizontalLine(x, y, w); //====================price lines================================= // pricelines if (price_distance > 0 && mTrade.mShare != null) { x = 0 + 1; float priceRef = mTrade.mShare.getRefFromPriceboard(); float step = (price_distance / 5); g.setColor(C.GREY_LINE_COLOR); String sz; Font fNum = mContext.getFontSmall(); for (int i = -5; i < 5; i++) { float price = priceRef + i * step; int yy = priceToY(price, y, h); if (yy < 15 || yy > h - 15) { continue; } if (i == 0) { g.setColor(C.YELLOW_LINE_COLOR); } else { g.setColor(C.GREY_LINE_COLOR); } g.drawHorizontalLine(x, yy, getW() - 4); g.setColor(C.COLOR_GRAY_LIGHT); g.drawString(fNum, String.Format("{0:F2}", price), x, yy, xGraphics.VCENTER | xGraphics.LEFT); } } }
void drawText(xGraphics g, int x) { Font f = mContext.getFontSmall(); Font fLabel = mContext.getFontText(); // ma co phieu g.setColor(C.COLOR_WHITE); string s = "#" + mTrade.getCode(); g.drawString(mContext.getFontTextB(), s, x, 1); x += g.getStringWidth(mContext.getFontTextB(), s) + 5; // time if (mCandleCnt > 0) { g.setColor(C.COLOR_GRAY_DARK); g.fillRect(0, getH() - 12, getW(), 12); g.setColor(C.COLOR_WHITE); g.drawString(f, mTimeStart, 0 + 1, 0 + getH(), xGraphics.BOTTOM | xGraphics.LEFT); g.drawString(f, mTimeEnd, mChartXYs[2 * (mCandleCnt - 1)], 0 + getH() - 12, xGraphics.BOTTOM | xGraphics.LEFT); g.setColor(C.COLOR_WHITE); s = "KL: " + Utils.formatNumber(mTrade.getVolume(-1)); g.drawString(f, s, (getW() - Utils.getStringW(s, f)) / 2, getH(), xGraphics.BOTTOM); } g.setColor(C.GREY_LINE_COLOR); g.drawHorizontalLine(x, 0 + getH(), getW()); //=============cursor & some info======================== if (mCandleCnt > 0) { //x = getW() / 2; g.setColor(C.COLOR_GRAY_LIGHT); g.drawString(fLabel, mCurrentTrade, x, 0 + 1, xGraphics.LEFT);// xGraphics.HCENTER | xGraphics.TOP); g.setColor(C.COLOR_FADE_YELLOW0); g.drawVerticalLine(mChartXYs[2 * mCurrentTradeSel], 12, getH() - 26); //g.drawPoint(mChartXYs[2 * mCurrentTradeSel] - 2, mChartXYs[2 * mCurrentTradeSel + 1] - 4, 4); if (mChangedValue > 0) { g.setColor(C.COLOR_GREEN); } else if (mChangedValue == 0) { g.setColor(C.COLOR_YELLOW); } else { g.setColor(C.COLOR_RED); } g.drawString(fLabel, mChanged, mChartXYs[2 * mCurrentTradeSel], 26); } //===================================================== }
override public void render(xGraphics g) { if (getID() < 0) { return; } int x = 0; int y = 2; int h = getH(); if (mCells.size() == 0) { return; } if (mIsSelected && getID() > 0) { g.setColor(C.COLOR_BUTTON_SEL); g.fillRect(0, 0, getW(), getH()); } int i; x = 0; for (i = 0; i < mCells.size(); i++) { stCell c = (stCell)mCells.elementAt(i); uint color = c.bgColor; int w = c.w; x = c.x; if (color != COLOR_NONE) { g.setColor(color); g.fillRect(x, 0, w, h); } } //---------text // printf("\n=========================================="); for (i = 0; i < mCells.size(); i++) { stCell c = (stCell)mCells.elementAt(i); if (i == mCandleColumeIdx && getID() != 0) { renderCandle(g, c); continue; } if (c.text2 == null) { g.setColor(c.textColor); if (c.text != null) { g.drawStringInRect(c.f, c.text, c.x, 0, c.w, h, xGraphics.HCENTER | xGraphics.VCENTER); } } else if (getH() < 36) { g.setColor(c.textColor); g.drawStringInRect(c.f, c.text, c.x, (int)(h / 2 - c.f.GetHeight()) + 3, c.w, h / 2, xGraphics.HCENTER | xGraphics.VCENTER); g.setColor(c.textColor2); g.drawStringInRect(c.f, c.text2, c.x, h / 2 + 1, c.w, (int)(c.f.GetHeight()), xGraphics.HCENTER | xGraphics.VCENTER); } else { g.setColor(c.textColor); g.drawStringInRect(c.f, c.text, c.x, (int)(h / 2 - c.f.GetHeight()) - 0, c.w, h / 2, xGraphics.HCENTER | xGraphics.VCENTER); g.setColor(c.textColor2); g.drawStringInRect(c.f, c.text2, c.x, h / 2 + 2, c.w, (int)(c.f.GetHeight()), xGraphics.HCENTER | xGraphics.VCENTER); } //Utils.trace("here 5:" + c.text + " x=" + c.x + " w=" + c.w + " h=" + h); } // grid g.setColor(0xff808080); for (i = 1; i < mCells.size(); i++) { stCell c = (stCell)mCells.elementAt(i); x = c.x; g.drawLine(x, y, x, y + h); } g.drawHorizontalLine(0, 0, getW()); /* * // history chart button * if (getID() > 0) * { * g.setColor(C.COLOR_ORANGE); * int tmp = 6; * y = getH() / 2; * x = getW() - tmp - 4; * g.drawLine(x, y - tmp, x + tmp, y); * g.drawLine(x, y + tmp, x + tmp, y); * } */ // render snapshot if (mVolumeColumn >= 0) { stPriceboardState item = getPriceboard(); renderSnapshot(11, item, g); } }
public override void render(xGraphics g) { int mH = getH(); int mW = getW(); if (isHiding()) { return; } Share share = getShare(); if (share == null) { return; } int idx = 0; int maxPrice = 80; if (detectShareCursorChanged()) { share.calcADX(); int newSize = mChartLineLength * 2; mChartLineXY = allocMem(mChartLineXY, newSize); mLineMDI = allocMem(mLineMDI, newSize); mLinePDI = allocMem(mLinePDI, newSize); idx = share.mBeginIdx; pricesToYs(share.pPLUS_DI, idx, mLinePDI, mChartLineLength, 0, maxPrice); pricesToYs(share.pMINUS_DI, idx, mLineMDI, mChartLineLength, 0, maxPrice); pricesToYs(share.pADX, idx, mChartLineXY, mChartLineLength, 0, maxPrice); float ry = (float)getDrawingH() / maxPrice; mY20 = (int)(getMarginY() + getDrawingH() - 20 * ry); mY40 = (int)(getMarginY() + getDrawingH() - 40 * ry); } if (mChartLineLength == 0) { return; } if (mShouldDrawGrid) { drawGrid(g); } //=============================================== g.setColor(C.COLOR_FADE_YELLOW); g.drawHorizontalLine(0, mY20, mW - 34); g.drawHorizontalLine(0, mY40, mW - 34); g.setColor(C.COLOR_FADE_YELLOW0); g.drawString(mFont, "20", 0 + mW - 2, mY20, xGraphics.RIGHT | xGraphics.VCENTER); g.drawString(mFont, "40", 0 + mW - 2, mY40, xGraphics.RIGHT | xGraphics.VCENTER); g.setColor(0xffffffff); g.drawLines(mChartLineXY, mChartLineLength, 2.0f); g.setColor(0xff00ff00); g.drawLines(mLinePDI, mChartLineLength, 1.0f); g.setColor(0xffff0000); g.drawLines(mLineMDI, mChartLineLength, 1.0f); //============================== StringBuilder sb = Utils.sb; sb.Length = 0; sb.AppendFormat("{0:F2}", (float)yToPrice(mLastY, 0, 80)); mMouseTitle = sb.ToString(); renderCursor(g); //=================== // bottom border g.setColor(0xffa0a0a0); g.drawHorizontalLine(0, 0, getW()); renderDrawer(g); }
override public void render(xGraphics g) { //========================= if (viewState == VIEWSTATE_1_NHOMNGANH && chartG != null) { chartG.render(g); return; } 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; } // 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 = 80; 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 columnH = ItemH; double maxPercent = 0; for (int i = 0; i < mChanges.size(); i++) { GroupChanges gc = (GroupChanges)mChanges.elementAt(i); if (Math.Abs(gc.changedPercent) > maxPercent) { maxPercent = Math.Abs(gc.changedPercent); } } //-------------------- int buttonY = 30; int drawH = getH() - buttonY; ItemH = getItemH(getH() - 40, mChanges.size()); float cellW = getW() / 2; float cellH = ItemH; maxPercent *= 1.15; // Left side int j = 0; y = buttonY + 4; int itemPerColumn = mChanges.size() / 2; for (int i = 0; i < itemPerColumn; i++) { GroupChanges gc = (GroupChanges)mChanges.elementAt(i); x = 2; //if (gc.changedPercent >= 0) { y = buttonY + 4 + j * cellH; cellW = (float)((Math.Abs(gc.changedPercent) / maxPercent) * getW() / 2); g.setColor(gc.changedPercent > 0?C.COLOR_GREEN_DARK:C.COLOR_RED); g.fillRectF(x, y, cellW, cellH - 2); // text g.setColor(C.COLOR_WHITE); if (gc.changedPercent >= 0) { string s = String.Format("{0} +{1:F2} %", gc.code, gc.changedPercent); g.drawString(mContext.getFontText(), s, (int)x, (int)(y + cellH / 2), xGraphics.VCENTER); } else { string s = String.Format("{0} {1:F2} %", gc.code, gc.changedPercent); g.drawString(mContext.getFontText(), s, (int)x, (int)(y + cellH / 2), xGraphics.VCENTER); } j++; gc.x = (int)x; gc.y = (int)y; gc.w = (int)getW() / 2 - 10; gc.h = (int)cellH; } } g.setColor(C.COLOR_GRAY_DARK); g.drawVerticalLine(getW() / 2, buttonY, getH()); // Right side j = 0; for (int i = itemPerColumn; i < mChanges.size(); i++) { GroupChanges gc = (GroupChanges)mChanges.elementAt(i); x = getW() / 2 + 2; //if (gc.changedPercent < 0) { y = buttonY + 4 + j * cellH; cellW = (float)((Math.Abs(gc.changedPercent) / maxPercent) * getW() / 2); g.setColor(gc.changedPercent > 0 ? C.COLOR_GREEN_DARK : C.COLOR_RED); g.fillRectF(x, y, cellW, cellH - 2); // text g.setColor(C.COLOR_WHITE); if (gc.changedPercent >= 0) { string s = String.Format("{0}: +{1:F2} %", gc.code, gc.changedPercent); g.drawString(mContext.getFontText(), s, (int)x, (int)(y + cellH / 2), xGraphics.VCENTER); } else { string s = String.Format("{0}: {1:F2} %", gc.code, gc.changedPercent); g.drawString(mContext.getFontText(), s, (int)x, (int)(y + cellH / 2), xGraphics.VCENTER); } j++; gc.x = (int)x; gc.y = (int)y; gc.w = (int)getW() / 2 - 10; gc.h = (int)cellH; } } }
public override void render(xGraphics g) { if (getID() < 0) { return; } int x = 0; int y = 2; int h = getH(); if (mCells.size() == 0) { return; } if (mIsSelected && getID() > 0) { g.setColor(C.COLOR_BUTTON_SEL); g.fillRect(0, 0, getW(), getH()); } int i; x = 0; for (i = 0; i < mCells.size(); i++) { stCell c = (stCell)mCells.elementAt(i); uint color = c.bgColor; int w = c.w; x = c.x; if (color != COLOR_NONE) { g.setColor(color); g.fillRect(x, 0, w, h); } } //---------text // printf("\n=========================================="); for (i = 0; i < mCells.size(); i++) { stCell c = (stCell)mCells.elementAt(i); if (i == mCandleColumeIdx && getID() != 0) { renderCandle(g, c); continue; } if (c.text2 == null) { g.setColor(c.textColor); if (c.text != null) { g.drawStringInRect(c.f, c.text, c.x, 0, c.w, h, xGraphics.HCENTER | xGraphics.VCENTER); } } else { g.setColor(c.textColor); g.drawStringInRect(c.f, c.text, c.x, (int)(h / 2 - c.f.GetHeight()) - 0, c.w, h / 2, xGraphics.HCENTER | xGraphics.VCENTER); g.setColor(c.textColor2); g.drawStringInRect(c.f, c.text2, c.x, h / 2 + 2, c.w, (int)(c.f.GetHeight()), xGraphics.HCENTER | xGraphics.VCENTER); } //Utils.trace("here 5:" + c.text + " x=" + c.x + " w=" + c.w + " h=" + h); } // grid g.setColor(0xff808080); for (i = 1; i < mCells.size(); i++) { stCell c = (stCell)mCells.elementAt(i); x = c.x; g.drawLine(x, y, x, y + h); } g.drawHorizontalLine(0, 0, getW()); // snapshot and volume String code = getCode(); if (code != null) { // volume stPriceboardState item = Context.getInstance().mPriceboard.getPriceboard(code); if (item != null) { renderSnapshot(3, item, g); } } }
public override void render(xGraphics g) { g.setColor(C.COLOR_BLACK); g.clear(); stPriceboardState ps = mContext.mPriceboard.getPriceboard(mAlarm.code); if (ps == null) { return; } Font f = mContext.getBigFont(); int x = 0; int y = 0; // code x = 4; y = (getH() - f.Height) / 2 - 4; g.setColor(C.COLOR_WHITE); g.drawString(f, mAlarm.code, x, y - 4); x += 120; // gia hien tai drawQuotePoint(g, x); x += 120; // upper alarm int ch = getH() / 2 - 5; f = mContext.getFontText(); y = (ch - f.Height) / 2; int x0 = drawThreahold(g, x, y, true); // upper y = ch + (ch - f.Height) / 2; int x1 = drawThreahold(g, x, y, false); // lower x = x0 > x1? x0 + 2:x1 + 2; //========================================= int alarm = mAlarm.hasAlarm(); if (alarm != 0) { String s; if (alarm == 1) { s = "Giá đã vượt lên trên " + Utils.formatNumber(mAlarm.upperPrice); g.setColor(C.COLOR_GREEN); y = (ch - mAlarmImage.Height) / 2; } else { s = "Giá đã xuống thấp hơn " + Utils.formatNumber(mAlarm.lowerPrice); g.setColor(C.COLOR_RED); y = ch + (ch - mAlarmImage.Height) / 2; } if (mShowingAlarm) { g.drawImage(mAlarmImage, x, y); } g.drawString(f, s, x + mAlarmImage.Width + 10, y + 2); } if (mAlarm.comment != null && mAlarm.comment.Length > 0) { y = getH() - f.Height - 1; g.setColor(C.COLOR_YELLOW); g.drawString(mContext.getFontTextItalic(), "(" + mAlarm.comment + ")", 8, y); } //======================= g.setColor(C.COLOR_WHITE); g.drawHorizontalLine(0, getH() - 1, getW()); }
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 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); }