void update() { if (mTrade == null) { return; } if (mTradeIndex >= 0 && mTradeIndex < mTrade.getTransactionCount()) { int time = mTrade.getTime(mTradeIndex); float price = mTrade.getPrice(mTradeIndex); int vol = mTrade.getTradeVolume(mTradeIndex); StringBuilder sb = Utils.sb; sb.Length = 0; // time sb.AppendFormat("{0:D2}:{1:D2}:{2:D2}", ((time >> 16) & 0xff), ((time >> 8) & 0xff), (time & 0xff)); setTextForCell(P_TIME, sb.ToString(), C.COLOR_WHITE); // price stPriceboardState ps = mContext.mPriceboard.getPriceboard(mTrade.mShareID); if (ps != null) { uint color = mContext.valToColorF(price, ps.getCe(), ps.getRef(), ps.getFloor()); sb.Length = 0; sb.AppendFormat("{0:F2}", (float)price); setTextForCell(P_PRICE, sb.ToString(), color); // volume string sv = Utils.formatNumber(vol); setTextForCell(P_VOLUME, sv, color); } } }
void renderSnapshot2(xGraphics g) { stPriceboardState item = getPriceboard(); if (item != null) { stCell cell = getCellAt(7); // snapshot if (rcSnapshot == null) { rcSnapshot = new Rectangle(); } rcSnapshot.X = cell.x; rcSnapshot.Y = 0; rcSnapshot.Width = cell.w; rcSnapshot.Height = getH(); sharethumb.DrawAChartDelegator.renderToView(item.code, g, rcSnapshot); // date stGainloss gainloss = (stGainloss)getUserData(); String s = Utils.dateIntToStringDDMM(gainloss.date); g.setColor(C.COLOR_WHITE); g.drawStringInRect(cell.f, s, cell.x, getH() - 17, cell.w, 17, xGraphics.LEFT); } }
void calcBuySellRemains(int marketID, double[] buysell) { double buy = 0; double sell = 0; int total = mContext.mShareManager.getTotalShareIDCount(); int[] mid = { 0 }; for (int i = 0; i < total; i++) { mid[0] = -1; int shareID = mContext.mShareManager.getShareIDAt(i, mid); if (shareID == 257) { shareID = 257; } if (/*mid[0] == marketID && */ shareID != 0) { stPriceboardState ps = mContext.mPriceboard.getPriceboard(shareID); if (ps.getMarketID() == marketID) { buy += ps.getRemainBuyVolume0(); buy += ps.getRemainBuyVolume1(); buy += ps.getRemainBuyVolume2(); sell += ps.getRemainSellVolume0(); sell += ps.getRemainSellVolume1(); sell += ps.getRemainSellVolume2(); } } } buysell[0] = buy; buysell[1] = sell; }
static void evalueSortValuePrice(xVector v) { for (int i = 0; i < v.size(); i++) { Share share = (Share)v.elementAt(i); /*if (share.getCode().CompareTo("NAW") == 0) * { * stPriceboardState ps = Context.getInstance().mPriceboard.getPriceboard(share.getShareID()); * share.mSortParam = ps.current_price_1; * } */ if (!share.isIndex()) { stPriceboardState ps = Context.getInstance().mPriceboard.getPriceboard(share.getShareID()); share.mSortParam = ps.current_price_1; share.mSortParam = 0; if (share.mSortParam == 0) { share.loadShareFromCommonData(false); if (share.getCandleCnt() > 0) { share.mSortParam = share.getClose(share.getCandleCnt() - 1); } } } else { share.mSortParam = 10000; } } }
public static void evalueSortValueTrade(xVector v) { for (int i = 0; i < v.size(); i++) { Share share = (Share)v.elementAt(i); if (share.isIndex()) { share.mSortParam = 0; share.mCompareText = "0"; } else { stPriceboardState ps = Context.getInstance().mPriceboard.getPriceboard(share.getShareID()); if (ps != null) { share.mSortParam = ps.current_price_1 * ps.total_volume; double t = share.mSortParam / 1000; share.mCompareText = RowNormalShare.valueMToString((int)t, true); } else { share.mSortParam = 0; share.mCompareText = "0"; } } } }
static void evalueSortValueVonhoa(xVector v) { for (int i = 0; i < v.size(); i++) { Share share = (Share)v.elementAt(i); if (share.isIndex()) { share.mSortParam = 0; share.mCompareText = "0"; } else { stCompanyInfo inf = Context.getInstance().mShareManager.getCompanyInfo(share.getShareID()); stPriceboardState ps = Context.getInstance().mPriceboard.getPriceboard(share.getShareID()); if (inf != null && ps != null) { share.mSortParam = inf.volume * ps.current_price_1; double t = share.mSortParam; share.mCompareText = RowNormalShare.valueMToString(t, true); } else { share.mSortParam = 0; share.mCompareText = "0"; } } } }
static void processListIndices(VTDictionary dict) { int code = dict.getValueInt(kErrorCode); ArrayList arr = dict.getArray(kArray); stShareGroup g = Context.getInstance().vnIndicesGroup; if (g == null) { g = new stShareGroup(); Context.getInstance().vnIndicesGroup = g; g.setType(stShareGroup.ID_GROUP_INDICES); } if (code == 0 & arr != null) { for (int i = 0; i < arr.Count; i++) { VTDictionary d = (VTDictionary)arr[i]; int id = d.getValueInt("id"); String symbol = d.getValueString(kSymbol); float price = d.getValueFloat(kPoint) / 1000.0f; float change = d.getValueFloat(kChanged) / 1000.0f; long vol = d.getValueLong(kVolume); float hi = d.getValueFloat(kHighest) / 1000.0f; float lo = d.getValueFloat(kLowest) / 1000.0f; float reference = d.getValueFloat(kRef) / 1000.0f; stPriceboardState ps = GlobalData.getPriceboardStateOfIndexWithSymbol(symbol); if (ps == null) { ps = new stPriceboardState(); GlobalData.addPriceboardStateOfIndex(ps); } ps.id = id; ps.code = symbol; ps.current_price_1 = price; ps.total_volume = Convert.ToInt32(vol); ps.max = hi; ps.min = lo; ps.change = change; ps.reference = reference; g.addCode(symbol); } } }
static void evalueSortValueVolume(xVector v) { for (int i = 0; i < v.size(); i++) { Share share = (Share)v.elementAt(i); stPriceboardState ps = Context.getInstance().mPriceboard.getPriceboard(share.getShareID()); if (!share.isIndex() && ps != null) { share.mSortParam = ps.total_volume; share.mCompareText = RowNormalShare.volumeToString(ps.total_volume); } else { share.mSortParam = 0; share.mCompareText = "0"; } } }
void drawQuotePoint(xGraphics g, int x) { stPriceboardState ps = mContext.mPriceboard.getPriceboard(mAlarm.code); // current price float price = ps.getCurrentPrice(); uint color = mContext.valToColorF(price, ps.getCe(), ps.getRef(), ps.getFloor()); if (price == 0) { price = ps.getRef(); } Font f = mContext.getBigFont(); StringBuilder sb = Utils.getSB(); // current price sb.AppendFormat("{0:F2}", (float)price); int y = 0; //l.setFont(f); 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); }
void updatePercentLabel(int price, Label l) { stPriceboardState ps = mContext.mPriceboard.getPriceboard(mAlarm.code); if (ps != null && price > 0) { float percent = (float)(price - ps.getCurrentPrice()) / ps.getCurrentPrice(); percent *= 100; StringBuilder sb = Utils.getSB(); if (percent > 0) { sb.AppendFormat("+{0:F1} %", percent); } else { sb.AppendFormat("{0:F1} %", percent); } l.Text = sb.ToString(); } }
public void renderSnapshot(int cellVolume, stPriceboardState item, xGraphics g) { if (item != null) { stCell cell = getCellAt(cellVolume); // snapshot if (rcSnapshot == null) { rcSnapshot = new Rectangle(); } rcSnapshot.X = cell.x; rcSnapshot.Y = 0; rcSnapshot.Width = cell.w; rcSnapshot.Height = getH(); sharethumb.DrawAChartDelegator.renderToView(item.code, g, rcSnapshot); // volume String s = Utils.formatVolumeUsingLetters(item.total_volume); g.setColor(C.COLOR_WHITE); g.drawStringInRect(cell.f, s, cell.x, getH() - 17, cell.w, 17, xGraphics.LEFT); } }
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; } }
private void refreshChart(int martketID) { // block data int total = 1000; int i = 0; if (getW() == 0 || getH() == 0) { return; } for (i = 0; i < mUsedBlocks.size(); i++) { stStatisticsBlock b = (stStatisticsBlock)mUsedBlocks.elementAt(i); mFreeBlocks.addElement(b); } // reset mUsedBlocks.removeAllElements(); //-------------------------------------- int shareCount = mContext.mShareManager.getTotalShareIDCount(); int[] market = { 0 }; double totalEquity = 0.0f; double totalIndexInc = 0; double totalIndexDec = 0; stPriceboardStateIndex pi = mContext.mPriceboard.getPriceboardIndexOfMarket(martketID); // calc totalEquity for (i = 0; i < shareCount; i++) { int shareID = mContext.mShareManager.getShareIDAt(i, market); stCompanyInfo inf = mContext.mShareManager.getCompanyInfo(shareID); if (inf != null && inf.floor == martketID) { stPriceboardState priceboard = mContext.mPriceboard.getPriceboard(inf.shareID); if (priceboard != null) { double ff = priceboard.getCurrentPrice(); // avoiding of overstack if (mChartType == BUBBLE_TRADE_MONEY) { totalEquity += ff * priceboard.getTotalVolume(); } else if (mChartType == BUBBLE_VOLUME_WEIGHT || mChartType == BUBBLE_INDEX_WEIGHT_RATIO_INC || mChartType == BUBBLE_INDEX_WEIGHT_RATIO_DEC) { totalEquity += ((double)inf.volume * ff); } } } } // extra for (i = 0; i < shareCount; i++) { int shareID = mContext.mShareManager.getShareIDAt(i, market); stCompanyInfo inf = mContext.mShareManager.getCompanyInfo(shareID); if (inf != null && inf.floor == martketID) { stPriceboardState priceboard = mContext.mPriceboard.getPriceboard(inf.shareID); if (priceboard != null) { double ff = priceboard.getCurrentPrice(); // avoiding of overstack if (mChartType == BUBBLE_TRADE_MONEY) { } else if (mChartType == BUBBLE_VOLUME_WEIGHT || mChartType == BUBBLE_INDEX_WEIGHT_RATIO_INC || mChartType == BUBBLE_INDEX_WEIGHT_RATIO_DEC) { if (mChartType == BUBBLE_INDEX_WEIGHT_RATIO_INC && priceboard.change > 0) { double indexPointOfShare = pi.current_point * ((inf.volume * ff) / totalEquity); double indexChanged = priceboard.change * indexPointOfShare / priceboard.current_price_1; totalIndexInc += 1.2f * indexChanged; } else if (mChartType == BUBBLE_INDEX_WEIGHT_RATIO_DEC && priceboard.change < 0) { double indexPointOfShare = pi.current_point * ((inf.volume * ff) / totalEquity); double indexChanged = priceboard.change * indexPointOfShare / priceboard.current_price_1; totalIndexDec += -1.2f * indexChanged; } } } } } if (totalEquity == 0.0) { return; } double tmp = 0; StringBuilder sb = new StringBuilder(); // now calc blocks for (i = 0; i < shareCount; i++) { int shareID = mContext.mShareManager.getShareIDAt(i, market); stCompanyInfo inf = mContext.mShareManager.getCompanyInfo(shareID); if (inf != null && inf.floor == martketID) { stPriceboardState priceboard = mContext.mPriceboard.getPriceboard(inf.shareID);//martketID, share.mShareID); if (priceboard != null) { String code = mContext.mShareManager.getShareCode(inf.shareID); //if (code != null && (code.CompareTo("MSN") == 0 || code.CompareTo("AAM") == 0)) //{ //Utils.trace("aaa"); //} double modifierValue = 0.0f; double ff = priceboard.getCurrentPrice(); // avoiding of overstack //String log = String.Format("{0}, {1}, {2}, {3}", code, priceboard.current_price_1, inf.volume, totalEquity); //Utils.trace(log); float threshold = 0.003f; if (mChartType == BUBBLE_TRADE_MONEY) { modifierValue = ff * priceboard.getTotalVolume(); } else if (mChartType == BUBBLE_VOLUME_WEIGHT) { modifierValue = ((double)inf.volume * ff); } else if (mChartType == BUBBLE_INDEX_WEIGHT_RATIO_INC) { double indexPointOfShare = pi.current_point * ((inf.volume * ff) / totalEquity); double indexChanged = priceboard.change * indexPointOfShare / priceboard.current_price_1; modifierValue = indexChanged; threshold = 0.000001f; } else if (mChartType == BUBBLE_INDEX_WEIGHT_RATIO_DEC) { double indexPointOfShare = pi.current_point * ((inf.volume * ff) / totalEquity); double indexChanged = priceboard.change * indexPointOfShare / priceboard.current_price_1; modifierValue = -indexChanged; threshold = 0.000001f; } float percent = (float)(modifierValue / totalEquity); // <= 1 if (mChartType == BUBBLE_INDEX_WEIGHT_RATIO_INC || mChartType == BUBBLE_INDEX_WEIGHT_RATIO_DEC) { percent = (float)(modifierValue / (double)pi.current_point); } //String log = String.Format("{0}, {1}, {2}, {3}, {4}, {5}", code, priceboard.current_price_1, inf.volume //, totalEquity, modifierValue, pi.current_point); //Utils.trace(log); if (percent >= threshold && mFreeBlocks.size() > 0) { // big enough to care float value = percent; if (mChartType == BUBBLE_INDEX_WEIGHT_RATIO_INC) { percent *= 100;// (float)(equity / totalIndexInc); } else if (mChartType == BUBBLE_INDEX_WEIGHT_RATIO_DEC) { percent *= 100;// (float)(equity / totalIndexDec); } stStatisticsBlock block = (stStatisticsBlock)mFreeBlocks.pop(); block.code = mContext.mShareManager.getShareCode(inf.shareID);; // w & h //block.w = (short)Math.Sqrt(cells); //block.h = block.w; //if (block.h * block.w < cells) block.w++; //if (block.h >= 50) //{ //int k = 0; //} // color uint color = C.COLOR_YELLOW; float price = priceboard.getCurrentPrice(); float reference = priceboard.getRef(); if (price == reference) { color = C.COLOR_YELLOW; } else if (price == priceboard.getCe()) { color = C.COLOR_MAGENTA; } else if (price == priceboard.getFloor()) { color = C.COLOR_CYAN; } else if (price < reference) { int r = (int)((reference - price) * 100 / reference); // percent if (r < 8) { r = (0xff - 150) + r * 30; } else { r = 0xff; } if (r > 0xff) { r = 0xff; } //--------------- r = 0xff; color = (uint)((0xff << 24) | (r << 16)); } else if (price > reference) { int g = (int)((price - reference) * 100 / reference); // percent if (g < 8) { g = (0xff - 150) + g * 30; } else { g = 0xff; } if (g > 0xff) { g = 0xff; } //---------------- g = 0xff; color = (uint)((0xff << 24) | (g << 8)); } block.color = color; // point block.point = (short)(percent * 1000);//(priceboard.current_price_1 - priceboard.ref)*1000/priceboard.ref; // x & y //setBlockPosition(block); // extra inf sb.Length = 0; if (mChartType == BUBBLE_TRADE_MONEY) { sb.AppendFormat("{0:F1}tỉ", (modifierValue / 1000000)); // money unit = 100 vnd } else if (mChartType == BUBBLE_VOLUME_WEIGHT) { sb.AppendFormat("{0:F1}%", (percent * 100)); } else if (mChartType == BUBBLE_INDEX_WEIGHT_RATIO_INC) { double r = (inf.volume * price) / totalEquity; // totalE = pi.point // vonhoa = ? // index-point of code: (r*pi.point); // price <> (r*pi.point) // changed <> ? double indexChanged = (priceboard.change * r * pi.current_point) / priceboard.current_price_1; tmp += indexChanged; sb.AppendFormat("{0:F4}", (indexChanged)); } else if (mChartType == BUBBLE_INDEX_WEIGHT_RATIO_DEC) { double r = (inf.volume * price) / totalEquity; double indexChanged = (priceboard.change * r * pi.current_point) / priceboard.current_price_1; sb.AppendFormat("{0:F4}", (indexChanged)); } block.inf = sb.ToString(); if (priceboard.getCode() == "GAS") { int k = 0; } // changed sb.Length = 0; if (reference != 0) { float changed = price - reference; if (changed > 0) { sb.AppendFormat("({0:F2}; +{1:F2}%)", price, (float)((changed * 100) / reference)); } else { sb.AppendFormat("({0:F2}; {1:F2}%)", price, (float)((changed * 100) / reference)); } } block.changed = sb.ToString(); //String log = String.Format("{0}, {1}, {2}, {3}, {4}, {5}, {6}", code, priceboard.current_price_1, inf.volume //, totalEquity, modifierValue, pi.current_point, mUsedBlocks.size()); //Utils.trace(log); mUsedBlocks.addElement(block); } } } }// end of for sortBlocks(); }
// code | ref | KL1 | G1 |= GiaKhop | KLKhop | TongKL =| KL1 | G1 |=== TB | Cao | Thap override protected void updateQuote() { if (getID() < 0) { return; } Context ctx = Context.getInstance(); if (getID() == 0) { // code setCellValue(0, "Mã/TC", C.COLOR_GRAY); setCellValue(2, "Giá", C.COLOR_GRAY); setCellValue(3, "+/-", C.COLOR_GRAY); setCellValue(4, "GiáMua/KL", C.COLOR_GRAY); setCellValue(5, "Vốn (tr)", C.COLOR_WHITE); setCellValue(6, "Lãi % / vnd", C.COLOR_GRAY); setCellValue(7, "Ngày mua", C.COLOR_WHITE); } if (getID() == 0) { return; } stGainloss gainloss = (stGainloss)getUserData(); if (gainloss == null) { return; } String code = gainloss.code; stPriceboardState item = ctx.mPriceboard.getPriceboard(code); if (item == null) { return; } String s; // code uint color; setCellValue(0, item.getCode(), C.COLOR_WHITE); addCellValue1(0, String.Format("{0:F2}", item.getRef()), C.COLOR_YELLOW); float reference = item.getRef(); float price = item.getCurrentPrice(); if (price == 0) { price = reference; } int j = 0; // price color = ctx.valToColorF(item.getCurrentPrice(), item.getCe(), item.getRef(), item.getFloor()); setCellValue(2, String.Format("{0:F2}", item.getCurrentPrice()), color); // vol //s = volumeToString(item.getCurrentVolume()); //addCellValue1(1, s); // change +/- float v = price - reference; s = String.Format("{0:F2}", (float)v); if (item.getCurrentPrice() == 0) { s = "-"; } setCellValue(3, s, color); // GiaMua s = String.Format("{0:F2}", gainloss.price); setCellValue(4, s, C.COLOR_WHITE); // KLMua s = String.Format("{0:D}", gainloss.volume); addCellValue1(4, s); // Tien von double capital = gainloss.price * gainloss.volume / 1000.0f; s = String.Format("{0:F} tr", capital); setCellValue(5, s, C.COLOR_WHITE); //======================== // %GainLoss stPriceboardState ps = item; float currentPrice = ps.getCurrentPrice(); if (currentPrice == 0) { currentPrice = ps.getRef(); } price = gainloss.price; float percent = 0; if (price > 0) { percent = (float)(100 * (currentPrice - price)) / price; } if (percent > 0) { s = String.Format("+{0:F2} %", percent); } else { s = String.Format("{0:F2} %", percent); } if (percent > 0) { color = C.COLOR_GREEN; } else if (percent == 0) { color = C.COLOR_YELLOW; } else { color = C.COLOR_RED; } setCellValue(6, s, color); // gainloss money double oValue = price * gainloss.volume; double cValue = currentPrice * gainloss.volume; double benefit = (cValue - oValue) / 1000; if (benefit > 0) { s = String.Format("+{0:F2} tr", benefit); } else { s = String.Format("{0:F2} tr", benefit); } addCellValue1(6, s); // date //s = Utils.dateIntToString4(gainloss.date); //setCellValue(7, s, C.COLOR_WHITE); }
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); } }
void createFullDesc() { Font f; xLabel l; int x = 2; int y = 8; int w = getW(); String s; stCompanyInfo inf = mContext.mShareManager.getCompanyInfo(mShareID); if (inf == null) { return; } mShowCompanyName = true; if (mShowCompanyName) { f = mContext.getFontTextB(); l = xLabel.createMultiLineLabel(inf.company_name, f, getW()); addControl(l); l.setTextColor(mFontColor); y = l.getBottom() + 10; } StringBuilder sb = Utils.sb; sb.Length = 0; f = mContext.getFontSmall();// Text(); //if (mFont != null) // f = mFont; // EPS sb.AppendFormat("EPS: {0:F1} K", (float)(inf.EPS) / 1000); l = xLabel.createSingleLabel(sb.ToString(), f, w); l.setPosition(x, y); l.setTextColor(mFontColor); addControl(l); y = l.getBottom(); // P/E sb.Length = 0; sb.AppendFormat("P/E: {0:F1}", (float)inf.PE / 100); l = xLabel.createSingleLabel(sb.ToString(), f, w); l.setPosition(x, y); l.setTextColor(mFontColor); addControl(l); y = l.getBottom(); // Beta sb.Length = 0; sb.AppendFormat("Beta: {0:F2}", (float)inf.Beta / 100); l = xLabel.createSingleLabel(sb.ToString(), f, w); l.setPosition(x, y); l.setTextColor(mFontColor); addControl(l); y = l.getBottom(); // book value sb.Length = 0; sb.AppendFormat("Giá sổ sách: {0:F1} K", (float)(inf.book_value / 10)); l = xLabel.createSingleLabel(sb.ToString(), f, w); l.setPosition(x, y); l.setTextColor(mFontColor); addControl(l); y = l.getBottom(); // KLTB 10 phien sb.Length = 0; Share share = mContext.mShareManager.getShare(mShareID); if (share == null) { return; } int cnt = share.getCandleCount(); int nums = cnt > 10 ? 10 : cnt; int total = 0; for (int i = 0; i < nums; i++) { int volume = share.getVolume(cnt - i - 1); total += volume; } if (nums == 0) { nums = 1; } total = total / nums; s = Utils.formatNumber((int)total); sb.Length = 0; sb.AppendFormat("Vol TB 10 phiên={0}", s); l = xLabel.createSingleLabel(sb.ToString(), f, w); l.setPosition(x, y); l.setTextColor(mFontColor); addControl(l); y = l.getBottom(); // KLCP luu hanh sb.Length = 0; sb.AppendFormat("KL lưu hành: {0:F2} tr; ", (inf.volume / 1000.0f)); l = xLabel.createSingleLabel(sb.ToString(), f, w); l.setPosition(x, y); l.setTextColor(mFontColor); addControl(l); y = l.getBottom(); // Von hoa tt stPriceboardState ps = mContext.mPriceboard.getPriceboard(mShareID); float price = 0; double vonhoa = 0; if (ps != null) { price = ps.getCurrentPrice(); if (price == 0) { price = ps.getRef(); } vonhoa = price; vonhoa = vonhoa * inf.volume; vonhoa = vonhoa / 1000; } else { } sb.Length = 0; sb.AppendFormat("Vốn hóa: {0:F2} tỉ", vonhoa); l = xLabel.createSingleLabel(sb.ToString(), f, w); l.setPosition(x, y); l.setTextColor(mFontColor); addControl(l); y = l.getBottom(); // ROA sb.Length = 0; sb.AppendFormat("ROA: {0:F1} %", (float)inf.ROA); l = xLabel.createSingleLabel(sb.ToString(), f, w); l.setPosition(x, y); l.setTextColor(mFontColor); addControl(l); y = l.getBottom(); // ROE sb.Length = 0; sb.AppendFormat("ROE: {0:F1} %", (float)inf.ROE); l = xLabel.createSingleLabel(sb.ToString(), f, w); l.setPosition(x, y); l.setTextColor(mFontColor); addControl(l); setSize(getW(), l.getBottom()); }
protected void renderCandle(xGraphics g, stCell c) { int x, y; x = c.x; y = 0; uint color; object o = getUserData(); String code; if (o is String) { code = (String)o; } else { stGainloss gainloss = (stGainloss)o; code = gainloss.code; } if (code == null) { return; } stPriceboardState ps = Context.getInstance().mPriceboard.getPriceboard(code); if (ps == null) { return; } Context ctx = Context.getInstance(); float price = ps.getCurrentPrice(); float open = ctx.mPriceboard.getOpen(ps.getID()); if (open == 0) { open = price; } float hi = ps.getMax(); float lo = ps.getMin(); // check hi/lo valid if ((hi == 0 || lo == 0)) { TradeHistory trade = Context.getInstance().getTradeHistory(ps.getID()); float[] hl = new float[2]; if (trade != null && trade.getHiLo(hl)) { if (hi == 0) { hi = hl[0]; } if (lo == 0) { lo = hl[1]; } } } if (hi == lo) { hi = price; } if (hi == 0) { hi = open > price ? open : price; } if (lo == 0) { lo = open < price ? open : price; } if (lo == 0) { lo = hi; } //--------------------------------------------- float priceLen = (float)(hi - lo); int y0 = 0; float min = ps.getRef() - (ps.getRef() / 13); // +-7% (7*13==100) float max = ps.getRef() + (ps.getRef() / 13); if (ps.getMarketID() == 1) { min = ps.getRef() - (ps.getRef() / 19); // +-5% max = ps.getRef() + (ps.getRef() / 19); } if (min > lo && lo > 0) { min = (float)lo; } if (max < hi) { max = (float)hi; } float totalPrice = (max - min); //(10%); if (totalPrice < priceLen) { totalPrice = priceLen; } if (totalPrice == 0) { return; } float ry = (float)(getH() - 2 * y0) / totalPrice; int totalH = (int)(ry * totalPrice); int bodyW = c.w / 2; //================frame============================= // line _ref g.setColor(0x70ffff00); y = (int)(y0 + totalH - (ps.getRef() - min) * ry); g.drawLineDotHorizontal(c.x + 1, y, c.w - 2); //=================================================== if (price == 0) { return; // khong co giao dich } color = price < open ? C.COLOR_RED : C.COLOR_GREEN; if (price == open) { color = C.COLOR_WHITE; } // draw shadow g.setColor(C.COLOR_WHITE); x = c.x + c.w / 2; if (lo > 0 && hi > 0) { int minY = (int)(y0 + totalH - (lo - min) * ry); int maxY = (int)(y0 + totalH - (hi - min) * ry); g.drawLine(x, maxY, x, minY); } int centerX = x + bodyW / 2; // candle's body int oY = (int)(y0 + totalH - (open - min) * ry); int cY = (int)(y0 + totalH - (price - min) * ry); y = oY < cY ? oY : cY; int bodyH = Utils.ABS_INT(cY - oY); if (bodyH < 2) { bodyH = 2; } g.setColor(color); g.fillRect(x - bodyW / 2, y, bodyW, bodyH); }
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); } } }
// code | _ref | KL1 | G1 |= GiaKhop | KLKhop | TongKL =| KL1 | G1 |=== TB | Cao | Thap override protected void updateQuote() { if (getID() < 0) { return; } Context ctx = Context.getInstance(); stCell c; if (getID() == 0) { // code setCellValue(0, "Mã/TC", C.COLOR_GRAY); setCellValue(2, "Giá", C.COLOR_GRAY); setCellValue(3, "+/-", C.COLOR_GRAY); setCellValue(4, "H/L", C.COLOR_GRAY); setCellValue(5, "TổngKL", C.COLOR_GRAY); } if (getID() == 0) { return; } String code = (String)getUserData(); if (code == null) { return; } stPriceboardState item = GlobalData.getPriceboardStateOfIndexWithSymbol(code); stPriceboardState ps = item; if (item == null) { return; } String s; // code uint color; setCellValue(0, code, C.COLOR_WHITE); addCellValue1(0, String.Format("{0:F2}", item.getRef()), C.COLOR_YELLOW); float _ref = item.getRef(); int j = 0; float v; // Khop float currentPrice = item.getCurrentPrice(); int currentVol = item.getCurrentVolume(); color = ctx.valToColorF(currentPrice, item.getCe(), item.getRef(), item.getFloor()); setCellValue(2, String.Format("{0:F2}", currentPrice), color); s = volumeToString(currentVol); addCellValue1(2, s); // change +/- v = currentPrice - item.getRef(); s = String.Format("{0:F2}", (float)v); if (currentPrice == 0) { s = "-"; } setCellValue(3, s, color); // cao - thap setCellValue(4, String.Format("{0:F2}", item.getMax()), ctx.valToColorF(item.getMax(), item.getCe(), item.getRef(), item.getFloor())); addCellValue1(4, String.Format("{0:F2}", item.getMin()), ctx.valToColorF(item.getMin(), item.getCe(), item.getRef(), item.getFloor())); // total volume s = volumeToString(item.getTotalVolume()); setCellValue(5, s, C.COLOR_WHITE); }
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) { Utils.trace("=====render today candle"); if (mIsSelected) { g.setColor(C.COLOR_BLUE); g.fillRect(0, 0, getW(), getH()); g.setColor(C.COLOR_BLACK); g.fillRect(3, 3, getW() - 6, getH() - 6); } else { g.setColor(C.COLOR_BLACK); g.fillRect(0, 0, getW(), getH()); } g.setColor(C.COLOR_GRAY_LIGHT); g.drawRect(0, 0, getW() - 1, getH() - 1); Share share = mShare; if (share == null) { return; } int x, y; x = 0; y = 0; int h = getH(); if (mHasTitle) { Font ft = mContext.getFontTextB(); // title background if (mIsSelected) { g.setColor(C.COLOR_BLUE); } else { g.setColor(0xff204040); } //g.setColor(0xff004070); g.fillRect(1, 1, getW() - 2, 1 * ft.Height); // code g.setColor(C.COLOR_WHITE); g.drawString(ft, mShare.mCode, 1, 1); // point stPriceboardState ps = mContext.mPriceboard.getPriceboard(share.getID()); float price = ps.getCurrentPrice(); float change = price - ps.getRef(); StringBuilder sb = Utils.getSB(); if (change >= 0) { sb.AppendFormat("{0:F2} (+{1:F2})", (float)price, (float)change); } else { sb.AppendFormat("{0:F2} ({1:F2})", (float)price, (float)change); } x += g.getStringWidth(ft, mShare.mCode) + 4; uint color = mContext.valToColorF(price, ps.getCe(), ps.getRef(), ps.getFloor()); g.setColor(color); g.drawString(ft, sb.ToString(), x, 1); //=====vol g.setColor(C.COLOR_ORANGE); x = 1; ft = mContext.getFontSmall(); y = getH() - ft.Height; sb.Length = 0; if (ps.getTotalVolume() > 100000) { sb.AppendFormat("{0}K", (ps.getTotalVolume() / 1000)); } else if (ps.getTotalVolume() > 1000) { sb.AppendFormat("{0:F1}K", (float)(ps.getTotalVolume() / 1000)); } else { sb.AppendFormat("{0}", ps.getTotalVolume()); } g.drawString(ft, sb.ToString(), x, y); //========================= x = 0; h -= (int)ft.Height; y = ft.Height; } //=========================================== drawCandle(g, x, y, getW(), h); }
void drawCandle(xGraphics g, int x, int y0, int w, int h) { Share share = mShare; int y = 0; Font f = mContext.getFontSmall(); uint color; stPriceboardState ps = mContext.mPriceboard.getPriceboard(share.getID()); if (ps == null) { return; } TradeHistory trade = mContext.getTradeHistory(share.getID()); float price = ps.getCurrentPrice(); float open = mContext.mPriceboard.getOpen(ps.getID()); if (trade != null && trade.getTransactionCount() > 0) { open = trade.getPrice(0); } else { open = mContext.mPriceboard.getOpen(mShare.mID); } if (open != 0 && mContext.mPriceboard.getOpen(mShare.mID) == 0 && !share.isIndex()) { mContext.mPriceboard.setOpen(mShare.mID, (int)open); } float hi = ps.getMax(); float lo = ps.getMin(); // check hi/lo valid if ((hi == 0 || lo == 0)) { float[] hl = new float[2]; if (trade.getHiLo(hl)) { if (hi == 0) { hi = hl[0]; } if (lo == 0) { lo = hl[1]; } } } if (hi == 0) { hi = open > price ? open : price; } if (lo == 0) { lo = open < price ? open : price; } if (lo == 0) { lo = hi; } //--------------------------------------------- float priceLen = hi - lo; float reference = ps.getRef(); float min, max; if (share.isIndex()) { stPriceboardStateIndex pi = mContext.mPriceboard.getPriceboardIndexOfMarket(mShare.getMarketID()); price = pi.current_point; min = lo - price / 40; max = hi + price / 40; } else { min = ps.getFloor() - reference / 30; max = ps.getCe() + reference / 30; } if (price == 0) { return; } //if (min > ps.getMin() && ps.getMin() > 0) min = ps.getMin(); //if (max < ps.getMax()) max = ps.getMax(); float totalPrice = (max - min); //(10%); if (totalPrice < priceLen) { totalPrice = priceLen; } if (totalPrice == 0) { return; } float ry = (float)(h) / totalPrice; int totalH = (int)(ry * totalPrice); int bodyW = w / 3; StringBuilder sb = Utils.getSB(); //================frame============================= // line ref g.setColor(0x30ffff00); y = (int)(y0 + totalH - (reference - min) * ry); g.drawLineDotHorizontal(1, y, getW() - 2, y); g.setColor(0xa0ffff00); if (mDrawRefLabel) { sb.AppendFormat("{0:F2}", reference); g.drawString(f, sb.ToString(), 1, y - f.Height / 2, 0); } // CE line if (!share.isIndex()) { g.setColor(0x30ff00ff); y = (int)(y0 + totalH - (ps.getCe() - min) * ry); g.drawLineDotHorizontal(1, y, getW() - 2, y); g.setColor(0xa0ff00ff); sb.Length = 0; sb.AppendFormat("{0:F2}", ps.getCe()); if (mDrawRefLabel) { g.drawString(f, sb.ToString(), 1, y, 0); } // FLOOR line g.setColor(0x3000FFFF); y = (int)(y0 + totalH - (ps.getFloor() - min) * ry); g.drawLineDotHorizontal(1, y, getW() - 2, y); g.setColor(0xa000FFFF); sb.Length = 0; sb.AppendFormat("{0:F2}", ps.getFloor()); if (mDrawRefLabel) { g.drawString(f, sb.ToString(), 1, y - f.Height, 0); } } //=================================================== color = price < open? C.COLOR_RED:C.COLOR_GREEN; if (price == open) { color = C.COLOR_WHITE; } if (price == 0) { return; } // draw shadow g.setColor(C.COLOR_WHITE); x = getW() / 2; if (hi > 0 && lo > 0) { int minY = (int)(y0 + totalH - (lo - min) * ry); int maxY = (int)(y0 + totalH - (hi - min) * ry); g.drawLine(x, maxY, x, minY); } int centerX = x; // candle's body int oY = (int)(y0 + totalH - (open - min) * ry); int cY = (int)(y0 + totalH - (price - min) * ry); y = oY < cY?oY:cY; int bodyH = Utils.ABS_INT(cY - oY); if (bodyH < 2) { bodyH = 2; } g.setColor(color); g.fillRect(x - bodyW / 2, y, bodyW, bodyH); if (lo > 0 && lo != open && lo != price) { y = (int)(y0 + totalH - (lo - min) * ry); g.setColor(C.COLOR_YELLOW); sb.Length = 0; sb.AppendFormat("{0:F2}", lo); g.drawString(f, sb.ToString(), centerX - 10, y + 1, 0); } if (hi > 0 && hi != open && hi != price) { y = (int)(y0 + totalH - (hi - min) * ry); g.setColor(C.COLOR_YELLOW); sb.Length = 0; sb.AppendFormat("{0:F2}", hi); g.drawString(f, sb.ToString(), centerX - 10, y - f.Height, 0); } // 2 lines g.setColor(C.COLOR_WHITE); sb.Length = 0; sb.AppendFormat("{0:F2}", open); // open if (oY < cY) { y = oY - f.Height; } else { y = oY + 1; } if (y < 0) { y = 0; } if (y + f.Height > getH()) { y = getH() - f.Height; } g.drawString(f, sb.ToString(), x + bodyW / 2, y, 0); // price sb.Length = 0; sb.AppendFormat("{0:F2}", price); if (cY < oY) { y = cY - f.Height; } else { y = cY + 1; } if (y < 0) { y = 0; } if (y + f.Height > getH()) { y = getH() - f.Height; } g.drawString(f, sb.ToString(), x + bodyW / 2, y, 0); }
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); } }
// code | ref | KL1 | G1 |= GiaKhop | KLKhop | TongKL =| KL1 | G1 |=== TB | Cao | Thap override protected void updateQuote() { if (getID() < 0) { return; } Context ctx = Context.getInstance(); if (getID() == 0) { // code setCellValue(0, "Mã/Giá", C.COLOR_GRAY); setCellValue(2, "+/-", C.COLOR_GRAY); addCellValue1(2, "%", C.COLOR_GRAY); setCellValue(3, "Khối lượng", C.COLOR_GRAY); setCellValue(4, ShareSortUtils.sortTypeToString(sortType), C.COLOR_ORANGE); } if (getID() == 0) { return; } String code = (String)this.getUserData(); if (code == null) { return; } stPriceboardState item = ctx.mPriceboard.getPriceboard(code); if (item == null) { return; } String s; // code uint color; setCellValue(0, item.getCode(), C.COLOR_WHITE); float reference = item.getRef(); float price = item.getCurrentPrice(); if (price == 0) { price = reference; } color = ctx.valToColorF(item.getCurrentPrice(), item.getCe(), item.getRef(), item.getFloor()); addCellValue1(0, String.Format("{0:F2}", item.getCurrentPrice()), color); int j = 0; // change +/- float v = price - reference; s = String.Format("{0:F2}", (float)v); if (item.getCurrentPrice() == 0) { s = "-"; } setCellValue(2, s, color); // change percent if (reference > 0) { s = String.Format("{0:F1}", (float)((v * 100) / reference)); addCellValue1(2, s, color); } // volume //s = volumeToString(item.getTotalVolume()); //setCellValue(3, s, C.COLOR_WHITE); //Share share = (Share)mFilteredShares.elementAt(row); mVolumeColumn = 3; // short column Share share = Context.getInstance().mShareManager.getShare(getCode()); if (share != null) { setCellValue(4, share.mCompareText, C.COLOR_ORANGE); stCell c = getCellAt(4); if (c != null) { c.text2 = null; c.textColor2 = C.COLOR_ORANGE; } } }
// code | _ref | KL1 | G1 |= GiaKhop | KLKhop | TongKL =| KL1 | G1 |=== TB | Cao | Thap virtual protected void updateQuote() { if (getID() < 0) { return; } Context ctx = Context.getInstance(); stCell c; if (getID() == 0) { // code setCellValue(0, "▼ Mã\nTC", C.COLOR_ORANGE); setCellValue(2, "M3/KL", C.COLOR_GRAY); setCellValue(3, "M2/KL", C.COLOR_GRAY); setCellValue(4, "M1/KL", C.COLOR_GRAY); setCellValue(5, "Khớp", C.COLOR_GRAY); setCellValue(6, "+/-", C.COLOR_GRAY); setCellValue(7, "B1/KL", C.COLOR_GRAY); setCellValue(8, "B2/KL", C.COLOR_GRAY); setCellValue(9, "B3/KL", C.COLOR_GRAY); setCellValue(10, "H/L", C.COLOR_GRAY); setCellValue(11, "TổngKL", C.COLOR_GRAY); /* * c = getCellAt(11); * if (c != null) * { * c.text2 = "DưB"; * c.textColor2 = C.COLOR_GRAY; * } */ if (sortType == ShareSortUtils.SORT_DUMUA_DUBAN) { setCellValue(12, "▼ Dư\nM/B", C.COLOR_ORANGE); } else { setCellValue(12, "▼ " + ShareSortUtils.sortTypeToString(sortType), C.COLOR_ORANGE); } } if (getID() == 0) { return; } String code = (String)getUserData(); if (code == null) { return; } stPriceboardState item = ctx.mPriceboard.getPriceboard(code); stPriceboardState ps = item; if (item == null) { return; } Share share = ctx.mShareManager.getShare(ps.id); if (share == null) { return; } String s; // code uint color; setCellValue(0, code, C.COLOR_WHITE); addCellValue1(0, String.Format("{0:F2}", item.getRef()), C.COLOR_YELLOW); float _ref = item.getRef(); int j = 0; float v; int[] rbc = { 2, 3, 4 }; // remain buy col float[] rb = { ps.getRemainBuyPrice2(), ps.getRemainBuyPrice1(), ps.getRemainBuyPrice0() }; int[] rbv = { ps.getRemainBuyVolume2(), ps.getRemainBuyVolume1(), ps.getRemainBuyVolume0() }; int[] rsc = { 7, 8, 9 }; float[] rs = { ps.getRemainSellPrice0(), ps.getRemainSellPrice1(), ps.getRemainSellPrice2() }; int[] rsv = { ps.getRemainSellVolume0(), ps.getRemainSellVolume1(), ps.getRemainSellVolume2() }; // mua1, mua2, mua3 for (j = 0; j < 3; j++) { // price color = ctx.valToColorF(rb[j], item.getCe(), item.getRef(), item.getFloor()); setCellValue(rbc[j], String.Format("{0:F2}", rb[j]), color); // vol s = volumeToString(rbv[j]); addCellValue1(rbc[j], s); } // Khop float currentPrice = item.getCurrentPrice(); int currentVol = item.getCurrentVolume(); color = ctx.valToColorF(currentPrice, item.getCe(), item.getRef(), item.getFloor()); setCellValue(5, String.Format("{0:F2}", currentPrice), color); s = volumeToString(currentVol); addCellValue1(5, s); // change +/- v = currentPrice - item.getRef(); s = String.Format("{0:F2}", (float)v); if (currentPrice == 0) { s = "-"; } setCellValue(6, s, color); // sell1, sell2, sell3 for (j = 0; j < 3; j++) { // price color = ctx.valToColorF(rs[j], item.getCe(), item.getRef(), item.getFloor()); setCellValue(rsc[j], String.Format("{0:F2}", rs[j]), color); // vol s = volumeToString(rsv[j]); addCellValue1(rsc[j], s); } // cao - thap setCellValue(10, String.Format("{0:F2}", item.getMax()), ctx.valToColorF(item.getMax(), item.getCe(), item.getRef(), item.getFloor())); addCellValue1(10, String.Format("{0:F2}", item.getMin()), ctx.valToColorF(item.getMin(), item.getCe(), item.getRef(), item.getFloor())); // total volume // s = volumeToString(item.getTotalVolume()); // setCellValue(11, s, C.COLOR_WHITE); mVolumeColumn = 11; // cung - cau if (sortType == ShareSortUtils.SORT_DUMUA_DUBAN) { int buy = item.getRemainBuyVolume0() + item.getRemainBuyVolume1() + item.getRemainBuyVolume2(); int sell = item.getRemainSellVolume0() + item.getRemainSellVolume1() + item.getRemainSellVolume2(); String sbuy = volumeToString(buy); String ssell = volumeToString(sell); setCellValue(12, sbuy, C.COLOR_ORANGE); c = getCellAt(12); if (c != null) { c.text2 = ssell; c.textColor2 = C.COLOR_ORANGE; } } else { setCellValue(12, share.mCompareText, C.COLOR_ORANGE); c = getCellAt(12); if (c != null) { c.text2 = null; c.textColor2 = C.COLOR_ORANGE; } } }
void drawCandle(xGraphics g, int x, int y0, int w, int h) { Share share = mShare; int y = 0; Font f = mContext.getFontSmall(); uint color; stPriceboardState ps = mContext.mPriceboard.getPriceboard(share.getID()); if (ps == null) { return; } TradeHistory trade = mContext.getTradeHistory(share.getID()); float price = ps.getCurrentPrice(); float open = price;//ps.getRef(); // should be open - testing if (trade != null && trade.getTransactionCount() > 0) { open = trade.getPrice(0); } else { open = mContext.mPriceboard.getOpen(mShare.mID); } if (open != 0 && mContext.mPriceboard.getOpen(mShare.mID) == 0 && !share.isIndex()) { mContext.mPriceboard.setOpen(mShare.mID, (int)open); } float hi = ps.getMax(); float lo = ps.getMin(); float priceLen = hi - lo; float reference = ps.getRef(); float min = ps.getFloor() - (float)reference / 30; float max = ps.getCe() + (float)reference / 30; if (share.isIndex()) { price = trade.mClose / 10.0f; open = trade.mOpen / 10.0f; reference = trade.mPriceRef / 10.0f; hi = trade.mHighest / 10.0f; lo = trade.mLowest / 10.0f; min = reference - reference / 40; max = reference + reference / 40; if (min > lo) { min = lo; } if (max < hi) { max = hi; } priceLen = (int)(hi - lo); } if (price == 0) { return; } //if (min > ps.getMin() && ps.getMin() > 0) min = ps.getMin(); //if (max < ps.getMax()) max = ps.getMax(); float totalPrice = (max - min); //(10%); if (totalPrice < priceLen) { totalPrice = priceLen; } if (totalPrice == 0) { return; } float ry = (float)(h) / totalPrice; int totalH = (int)(ry * totalPrice); int bodyW = w / 3; StringBuilder sb = Utils.getSB(); //================frame============================= // line ref g.setColor(0x30ffff00); y = (int)(y0 + totalH - (reference - min) * ry); g.drawLineDotHorizontal(1, y, getW() - 2, y); g.setColor(0xa0ffff00); /* * if (mDrawRefLabel) * { * sb.AppendFormat("{0:F1}", (float)reference / 10); * g.drawString(f, sb.ToString(), 1, y - f.Height / 2, 0); * } */ // CE line if (!share.isIndex()) { g.setColor(0x30ff00ff); y = (int)(y0 + totalH - (ps.getCe() - min) * ry); g.drawLineDotHorizontal(1, y, getW() - 2, y); g.setColor(0xa0ff00ff); sb.Length = 0; sb.AppendFormat("{0:F1}", (float)(ps.getCe() / 10)); if (mDrawRefLabel) { g.drawString(f, sb.ToString(), 1, y, 0); } // FLOOR line g.setColor(0x3000FFFF); y = (int)(y0 + totalH - (ps.getFloor() - min) * ry); g.drawLineDotHorizontal(1, y, getW() - 2, y); g.setColor(0xa000FFFF); sb.Length = 0; sb.AppendFormat("{0:F1}", (float)(ps.getFloor() / 10)); if (mDrawRefLabel) { g.drawString(f, sb.ToString(), 1, y - f.Height, 0); } } //=================================================== color = price < open? C.COLOR_RED:C.COLOR_GREEN; if (price == open) { color = C.COLOR_WHITE; } if (price == 0) { return; } // draw shadow g.setColor(C.COLOR_WHITE); x = getW() / 2; if (share.isIndex() && hi > 0 && lo > 0) { int minY = (int)(y0 + totalH - (lo - min) * ry); int maxY = (int)(y0 + totalH - (hi - min) * ry); g.drawLine(x, maxY, x, minY); } int centerX = x + bodyW / 2; // candle's body int oY = (int)(y0 + totalH - (open - min) * ry); int cY = (int)(y0 + totalH - (price - min) * ry); y = oY < cY?oY:cY; int bodyH = Utils.ABS_INT(cY - oY); if (bodyH < 2) { bodyH = 2; } g.setColor(color); g.fillRect(x - bodyW / 2, y, bodyW, bodyH); /* * if (lo > 0 && lo != open && lo != price) * { * y = (int)(y0 + totalH - (lo - min)*ry); * g.setColor(C.COLOR_WHITE); * sb.Length = 0; * sb.AppendFormat("{0:F1}", (float)lo/10); * g.drawString(f, sb.ToString(), centerX - 44, y + 1, 0); * } * if (hi > 0 && hi != open && hi != price) * { * y = (int)(y0 + totalH - (hi - min)*ry); * g.setColor(C.COLOR_WHITE); * sb.Length = 0; * sb.AppendFormat("{0:F1}", (float)hi/10); * g.drawString(f, sb.ToString(), centerX - 44, y - f.Height, 0); * } * // 2 lines * g.setColor(C.COLOR_WHITE); * sb.Length = 0; * sb.AppendFormat("{0:F1}", (float)open/10); * * // open * if (oY < cY) * y = oY - f.Height; * else * y = oY + 1; * if (y < 0) y = 0; * if (y + f.Height > getH()) * y = getH() - f.Height; * g.drawString(f, sb.ToString(), x + bodyW / 2, y, 0); * // price * sb.Length = 0; * sb.AppendFormat("{0:F1}", (float)price/10); * if (cY < oY) * y = cY - f.Height; * else * y = cY + 1; * if (y < 0) y = 0; * if (y + f.Height > getH()) * y = getH() - f.Height; * g.drawString(f, sb.ToString(), x + bodyW / 2, y, 0); */ }
void showQuickInfo(int x, int y) { if (!_showQuickInfo) { return; } try { if (mToolTip == null) { mToolTip = new ToolTip(); } //mToolTip.SetToolTip(getControl(), "Abc asdad asd asd sada"); Object o = getUserData(); String code = null; if (o.GetType() == typeof(stGainloss)) { code = ((stGainloss)o).code; } else if (o.GetType() == typeof(String)) { code = (String)o; } if (code == null) { return; } stPriceboardState item = Context.getInstance().mPriceboard.getPriceboard(code); if (item == null) { return; } stCompanyInfo inf = Context.getInstance().mShareManager.getCompanyInfo(item.id); if (inf != null) { StringBuilder sb = Utils.sb2; sb.Length = 0; sb.Append(inf.company_name); sb.Append("\n"); sb.AppendFormat("EPS={0:F1} K; P/E={1:F1}", ((float)inf.EPS / 1000), ((float)inf.PE / 100)); sb.AppendFormat("; KLCP={0:F2} tr\n", (inf.volume / 1000.0f)); float price = 0; double vonhoa = 0; price = item.getCurrentPrice(); if (price == 0) { price = item.getRef(); } vonhoa = price; vonhoa = vonhoa * inf.volume; vonhoa = vonhoa / 1000; sb.AppendFormat("Vốn hóa tt={0:F2} tỉ", vonhoa); mToolTip.Show(sb.ToString(), getControl(), x, y, 3000); } } catch (Exception e) { } }
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 void update() { if (mShare.isIndex()) { if (mShare.mMarketID == 1) { setImageIndex(0); } else if (mShare.mMarketID == 2) { setImageIndex(1); } // truncate the code StringBuilder sb = Utils.sb; sb.Length = 0; for (int i = 0; i < mShare.mCode.Length; i++) { if (mShare.mCode[i] == '^') { continue; } sb.Append(mShare.mCode[i]); //if (sb.Length > 5) //break; } setTextFont(P_CODE, mContext.getFontSmall()); setTextForCell(P_CODE, sb.ToString(), C.COLOR_WHITE); stPriceboardStateIndex pi = mContext.mPriceboard.getPriceboardIndexOfMarket(mShare.mMarketID); // khop uint color = C.COLOR_YELLOW; if (pi.changed_point > 0) { color = C.COLOR_GREEN; } else { color = C.COLOR_RED; } setTextForCell(P_PRICE, String.Format("{0:F2}", pi.current_point), color); Utils.sb.Length = 0; if (pi.changed_point > 0) { Utils.sb.AppendFormat("+{0:F2}", (float)(pi.changed_point / 100)); } else { Utils.sb.AppendFormat("{0:F2}", ((float)pi.changed_point / 100)); } // change setTextForCell(P_COMPARE, Utils.sb.ToString(), color); } else { stPriceboardState ps = mContext.mPriceboard.getPriceboard(mShare.mID); if (ps != null) { if (ps.getMarketID() == 1) { if (mContext.mAlarmManager.isAlarmInstalled(ps.getCode())) { setImageIndex(2); } else { setImageIndex(0); } } else if (ps.getMarketID() == 2) { if (mContext.mAlarmManager.isAlarmInstalled(ps.getCode())) { setImageIndex(3); } else { setImageIndex(1); } } // code setTextForCell(P_CODE, ps.getCode(), C.COLOR_WHITE); //setID(ps.getID()); // ref float reference = ps.getRef(); float ce = ps.getCe(); float floor = ps.getFloor(); float price = ps.getCurrentPrice(); if (price == 0) { price = ps.getRef(); } // khop uint color = mContext.valToColorF(price, ce, reference, floor); Utils.sb.Length = 0; Utils.sb.AppendFormat("{0:F2}", (float)price); setTextForCell(P_PRICE, Utils.sb.ToString(), color); // extra info if (mShare.mCompareText == null) { Utils.sb.Length = 0; Utils.sb.AppendFormat("{0:F2}", (float)ps.getChange()); mShare.mCompareText = Utils.sb.ToString(); } if (mShare.mCompareText != null) { setTextForCell(P_COMPARE, mShare.mCompareText, C.COLOR_WHITE); } } } }
public void refreshChart(int martketID) { rx = (float)(getW() - 10) / mMapW; ry = (float)(getH() - 15) / mMapH; // block data int total = 1000; int i = 0; for (i = 0; i < mUsedBlocks.size(); i++) { stBubbleBlock b = (stBubbleBlock)mUsedBlocks.elementAt(i); b.x = 0; b.y = 0; mFreeBlocks.addElement(b); } // reset mUsedBlocks.removeAllElements(); for (i = 0; i < mMapH; i++) { for (int j = 0; j < mMapW; j++) { mMap[map(i, j)] = 0; } } //-------------------------------------- //xVector v = mContext.mShareManager.getCompanyInfos(); double totalEquity = 0.0f; double totalIndexInc = 0; double totalIndexDec = 0; stPriceboardStateIndex pi = mContext.mPriceboard.getPriceboardIndexOfMarket(martketID); int shareCount = mContext.mShareManager.getTotalShareIDCount(); // calc totalEquity int[] market = { 0 }; for (i = 0; i < shareCount; i++) { int shareID = mContext.mShareManager.getShareIDAt(i, market); stCompanyInfo inf = mContext.mShareManager.getCompanyInfo(shareID); if (inf != null && inf.floor == martketID) { stPriceboardState priceboard = mContext.mPriceboard.getPriceboard(inf.shareID); if (priceboard != null) { double ff = priceboard.getCurrentPrice(); // avoiding of overstack if (mChartType == BUBBLE_TRADE_MONEY) { totalEquity += ff * priceboard.getTotalVolume(); } else if (mChartType == BUBBLE_VOLUME_WEIGHT || mChartType == BUBBLE_INDEX_WEIGHT_RATIO_INC || mChartType == BUBBLE_INDEX_WEIGHT_RATIO_DEC) { totalEquity += ((double)inf.volume * ff); } } } } // extra for (i = 0; i < shareCount; i++) { int shareID = mContext.mShareManager.getShareIDAt(i, market); stCompanyInfo inf = mContext.mShareManager.getCompanyInfo(shareID); if (inf != null && inf.floor == martketID) { stPriceboardState priceboard = mContext.mPriceboard.getPriceboard(inf.shareID); if (priceboard != null) { double ff = priceboard.getCurrentPrice(); // avoiding of overstack if (mChartType == BUBBLE_TRADE_MONEY) { } else if (mChartType == BUBBLE_VOLUME_WEIGHT || mChartType == BUBBLE_INDEX_WEIGHT_RATIO_INC || mChartType == BUBBLE_INDEX_WEIGHT_RATIO_DEC) { if (mChartType == BUBBLE_INDEX_WEIGHT_RATIO_INC && priceboard.change > 0) { double indexPointOfShare = pi.current_point * ((inf.volume * ff) / totalEquity); double indexChanged = priceboard.change * indexPointOfShare / priceboard.current_price_1; totalIndexInc += 1.2f * indexChanged; } else if (mChartType == BUBBLE_INDEX_WEIGHT_RATIO_DEC && priceboard.change < 0) { double indexPointOfShare = pi.current_point * ((inf.volume * ff) / totalEquity); double indexChanged = priceboard.change * indexPointOfShare / priceboard.current_price_1; totalIndexDec += -1.2f * indexChanged; } } } } } if (totalEquity == 0.0) { return; } double squareOfCell = 1.0 / (mMapW * mMapH); double tmp = 0; // now calc blocks for (i = 0; i < shareCount; i++) { int shareID = mContext.mShareManager.getShareIDAt(i, market); stCompanyInfo inf = mContext.mShareManager.getCompanyInfo(shareID); if (inf != null && inf.floor == martketID) { stPriceboardState priceboard = mContext.mPriceboard.getPriceboard(inf.shareID);//martketID, share.mShareID); if (priceboard != null) { String code = mContext.mShareManager.getShareCode(inf.shareID); if (code != null && (code.CompareTo("MSN") == 0 || code.CompareTo("MBB") == 0)) { Utils.trace("aaa"); } double equity = 0.0f; double ff = priceboard.getCurrentPrice(); // avoiding of overstack float threshold = 0.003f; if (mChartType == BUBBLE_TRADE_MONEY) { equity = ff * priceboard.getTotalVolume(); } else if (mChartType == BUBBLE_VOLUME_WEIGHT) { equity = ((double)inf.volume * ff); } else if (mChartType == BUBBLE_INDEX_WEIGHT_RATIO_INC) { double indexPointOfShare = pi.current_point * ((inf.volume * ff) / totalEquity); double indexChanged = priceboard.change * indexPointOfShare / priceboard.current_price_1; equity = indexChanged; threshold = 0.00001f; } else if (mChartType == BUBBLE_INDEX_WEIGHT_RATIO_DEC) { double indexPointOfShare = pi.current_point * ((inf.volume * ff) / totalEquity); double indexChanged = priceboard.change * indexPointOfShare / priceboard.current_price_1; equity = -indexChanged; threshold = 0.00001f; } float percent = (float)(equity / totalEquity); // <= 1 if (mChartType == BUBBLE_INDEX_WEIGHT_RATIO_INC || mChartType == BUBBLE_INDEX_WEIGHT_RATIO_DEC) { percent = (float)(equity / (double)pi.current_point); //percent = (float)(equity/totalEquityOfUsedBlock); } if (percent >= threshold && mFreeBlocks.size() > 0) { // big enough to care float percentR = percent; if (mChartType == BUBBLE_INDEX_WEIGHT_RATIO_INC) { percentR = (float)(equity / totalIndexInc); } else if (mChartType == BUBBLE_INDEX_WEIGHT_RATIO_DEC) { percentR = (float)(equity / totalIndexDec); } float square = percentR * (mMapH * mMapW); float cells = square; if (cells < 1) { cells = 1; } stBubbleBlock block = (stBubbleBlock)mFreeBlocks.pop(); block.code = mContext.mShareManager.getShareCode(inf.shareID);; // w & h block.w = (short)Math.Sqrt(cells); block.h = block.w; if (block.h * block.w < cells) { block.w++; } if (block.h >= 50) { int k = 0; } // color uint color = C.COLOR_YELLOW; float price = priceboard.getCurrentPrice(); float reference = priceboard.getRef(); if (price == reference) { color = C.COLOR_YELLOW; } else if (price == priceboard.getCe()) { color = C.COLOR_MAGENTA; } else if (price == priceboard.getFloor()) { color = C.COLOR_CYAN; } else if (price < reference) { int r = (int)((reference - price) * 100 / reference); // percent if (r < 8) { r = (0xff - 150) + r * 30; } else { r = 0xff; } if (r > 0xff) { r = 0xff; } //--------------- r = 0xff; color = (uint)((0xff << 24) | (r << 16)); } else if (price > reference) { int g = (int)((price - reference) * 100 / reference); // percent if (g < 8) { g = (0xff - 150) + g * 30; } else { g = 0xff; } if (g > 0xff) { g = 0xff; } //---------------- g = 0xff; color = (uint)((0xff << 24) | (g << 8)); } block.color = color; // point block.point = (short)(percent * 1000);//(priceboard.current_price_1 - priceboard.ref)*1000/priceboard.ref; // x & y //setBlockPosition(block); // extra inf StringBuilder sb = Utils.sb; sb.Length = 0; if (mChartType == BUBBLE_TRADE_MONEY) { sb.AppendFormat("{0:F1}tỉ", (equity / 1000000)); // money unit = 100 vnd } else if (mChartType == BUBBLE_VOLUME_WEIGHT) { sb.AppendFormat("{0:F1}%", (percent * 100)); } else if (mChartType == BUBBLE_INDEX_WEIGHT_RATIO_INC) { double r = (inf.volume * price) / totalEquity; // totalE = pi.point // vonhoa = ? // index-point of code: (r*pi.point); // price <> (r*pi.point) // changed <> ? double indexChanged = (priceboard.change * r * pi.current_point) / priceboard.current_price_1; tmp += indexChanged; sb.AppendFormat("{0:F4}", (indexChanged)); } else if (mChartType == BUBBLE_INDEX_WEIGHT_RATIO_DEC) { double r = (inf.volume * price) / totalEquity; double indexChanged = (priceboard.change * r * pi.current_point) / priceboard.current_price_1; sb.AppendFormat("{0:F4}", (indexChanged)); } block.inf = sb.ToString(); if (priceboard.getCode() == "ACB") { int k = 0; } // changed sb.Length = 0; if (reference != 0) { float changed = price - reference; if (changed > 0) { sb.AppendFormat("+{0:F2}%", (float)((changed * 100) / reference)); } else { sb.AppendFormat("{0:F2}%", (float)((changed * 100) / reference)); } } block.changed = sb.ToString(); mUsedBlocks.addElement(block); } } } }// end of for sortBlocks(); }