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); } }
protected void addCellValue1(int idx, int v, int dev, uint color) { String s; if (v != 0) { if (dev > 0) { s = String.Format("{0:F}", (float)v / dev); } else { s = String.Format("{0}", v); } } else { s = "-"; } stCell c = getCellAt(idx); if (c != null) { c.text2 = s; c.textColor2 = color; } }
protected void setCellBackgroundColor(int idx, uint color) { stCell c = getCellAt(idx); if (c != null) { c.bgColor = color; } }
protected void addCellValue1(int idx, String s) { stCell c = getCellAt(idx); if (c != null) { c.text2 = s; c.textColor2 = c.textColor; } }
protected void setCellValue(int idx, String text, uint textColor) { stCell c = getCellAt(idx); if (c != null) { c.text = text; c.textColor = textColor; } }
protected void addCellValue1(int idx, String s, uint color) { if (s == null) { s = "-"; } stCell c = getCellAt(idx); if (c != null) { c.text2 = s; c.textColor2 = color; } }
protected void init(int w, int h, float[] columnPercents, Font[] f, uint[] bgcolors) { // mFont = f; setSize(w, h); int columnCnt = 0; int i = 0; while (columnPercents[i] != -1) { columnCnt++; i++; } for (i = 0; i < columnCnt; i++) { stCell c = new stCell(); mCells.addElement(c); } //-------------------------------- i = 0; short x = 0; short columnW = 0; while (columnPercents[i] != -1) { columnW = (short)(w * columnPercents[i] / 100); stCell c = getCellAt(i); c.text = ""; c.bgColor = bgcolors[i]; c.x = x; c.w = columnW; c.f = f[i]; x += columnW; i++; } }
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); } }
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); }
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; } } }
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); } } }