예제 #1
0
        void drawMACDButton(xGraphics g)
        {
            Font f = mContext.getFontSmall();
            int  w = 60;
            int  h = f.Height;
            int  x = 2;
            int  y = 2;

            if (mShouldDrawMACD)
            {
                g.setColor(0xc00080ff);
            }
            else
            {
                g.setColor(0xc0ff8000);
            }
            g.fillRect(x, y, w, h);

            g.setColor(C.COLOR_GRAY);
            g.drawRect(x, y, w, h);

            x += w / 2;// (w - g.getStringWidth(f, "MACD")) / 2;
            y += h / 2;

            g.setColor(C.COLOR_WHITE);
            g.drawString(f, "MACD", x, y, xGraphics.HCENTER | xGraphics.VCENTER);
        }
예제 #2
0
        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() - 1, getH() - 1);

            Share share = mShare;

            if (share == null)
            {
                return;
            }

            int x, y;

            x = 0;
            y = 0;
            int h = getH();

            //===========================================
            drawCandle(g, x, y, getW(), h);
            //==================
        }
예제 #3
0
        void drawRectangle(xGraphics g, stTrendLine t)
        {
            uint color = t.color;

            g.setColor(color);

            int w = t.x[1] - t.x[0];
            int h = t.y[1] - t.y[0];

            g.drawRect(t.x[0], t.y[0], w, h);
        }
        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;
                }
            }
        }
예제 #5
0
        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);
        }
예제 #6
0
        void drawMACD(xGraphics g, int y, int h)
        {
            calcMACD();

            if (mCandleCnt < 5)
            {
                return;
            }

            //  translate to XYs
            //======================
            float lo = 1000;
            float hi = -1000;

            int i;

            float[] his = pMACDHistogram;
            for (i = 0; i < mCandleCnt; i++)
            {
                his[i] = pMACD[i] - pMACDSignal9[i];
            }
            //===========================

            float[] macd   = pMACD;
            float[] signal = pMACDSignal9;
            his = pMACDHistogram;

            int cnt = mCandleCnt;

            //	get the highest
            int   w  = getW();
            float rx = (float)w / cnt;

            //	lo/hi
            for (i = 0; i < cnt; i++)
            {
                if (macd[i] > hi)
                {
                    hi = macd[i];
                }
                if (macd[i] < lo)
                {
                    lo = macd[i];
                }
            }
            for (i = 0; i < cnt; i++)
            {
                if (signal[i] > hi)
                {
                    hi = signal[i];
                }
                if (signal[i] < lo)
                {
                    lo = signal[i];
                }
            }

            if (hi < 0)
            {
                hi = 0;
            }
            if (lo < 0)
            {
                lo = -lo;
            }

            float double_hi = Utils.ABS_FLOAT(hi) > Utils.ABS_FLOAT(lo) ? hi : lo;// hi + lo;

            double_hi = 2 * Utils.ABS_FLOAT(double_hi);

            int   minHistoH   = 9;
            int   signalDrawH = h - 2 * minHistoH;
            int   OY          = y + h / 2;
            float ry          = 0;

            if (double_hi != 0)
            {
                OY = y + h / 2;
                ry = (float)signalDrawH / double_hi;
            }

            //	make sure all macd is now > 0 && < 100
            for (i = 0; i < cnt; i++)
            {
                mLineMACD[2 * i + 1]    = (short)(OY - macd[i] * ry);
                mLineSignal9[2 * i + 1] = (short)(OY - signal[i] * ry);
            }

            //	cnt == CHART_W
            int max_time = getMaxTimeOfChart();
            int timeb    = Utils.EXTRACT_HOUR(mTimes[0]) * 3600
                           + Utils.EXTRACT_MINUTE(mTimes[0]) * 60
                           + Utils.EXTRACT_SECOND(mTimes[0]);

            rx = (float)getW() / max_time;
            for (i = 0; i < cnt; i++)
            {
                int time = timeToSeconds(mTimes[i]);
                time -= timeb;

                mLineMACD[2 * i]    = (short)(time * rx);
                mLineSignal9[2 * i] = mLineMACD[2 * i];
            }

            //	histogram
            hi = 0;
            for (i = 0; i < cnt; i++)
            {
                if (Utils.ABS_FLOAT(his[i]) > hi)
                {
                    hi = Utils.ABS_FLOAT(his[i]);
                }
            }
            //	int deltaY = 0;//deltaLoHi*mDrawingH/double_hi;
            double_hi = 2 * hi;
            //	double_hi	==	100 pixels
            int   halfH = h / 2;
            float hry   = 0;

            if (hi != 0)
            {
                hry = (float)halfH / hi;//double_hi;
            }
            i = 0;
            int drawW = 0;

            for (i = 0; i < cnt; i++)
            {
                if (double_hi != 0)
                {
                    mHistogramH[i] = (short)(-his[i] * ry);
                }
                else
                {
                    mHistogramH[i] = 0;
                }

                if (mHistogramH[i] == 0)
                {
                    if (his[i] > 0)
                    {
                        mHistogramH[i] = -1;
                    }
                    else
                    {
                        mHistogramH[i] = 1;
                    }
                }
                int time = timeToSeconds(mTimes[i]);
                time -= timeb;

                mHistogramXY[2 * i] = (short)(time * rx);
                drawW = mHistogramXY[2 * i];
                mHistogramXY[2 * i + 1] = (short)OY;
            }

            // ===========================================================
            //  ===== now draw =====
            // ===========================================================
            g.setColor(C.COLOR_FADE_YELLOW);
            g.drawLine(0, OY, getW() - 20, OY);
            g.setColor(C.COLOR_FADE_YELLOW0);
            g.drawString(mContext.getFontSmall(), "0", getW() - 20, OY, xGraphics.VCENTER);

            int hisW  = (int)(((float)drawW / mCandleCnt) * 2.0f / 3);
            int hisW2 = hisW / 2;

            if (hisW <= 0)
            {
                hisW = 1;
            }
            //g.setColor(0x6000ff00);
            for (i = 0; i < mCandleCnt; i++)
            {
                //g.fillRect(mHistogramXY[2 * i], mHistogramXY[2 * i + 1], hisW, mHistogramH[i]);
                if (mHistogramH[i] < 0)
                {
                    g.setColor(0xff70ee00);
                }
                else
                {
                    g.setColor(0xffc03000);
                }

                //g.drawRect(mHistogramXY[2 * i] - hisW2, mHistogramXY[2 * i + 1], hisW, mHistogramH[i]);
                g.drawRect(mHistogramXY[2 * i], mHistogramXY[2 * i + 1], 1, mHistogramH[i]);
                //g.drawVerticalLine(mHistogramXY[2 * i], mHistogramXY[2 * i + 1] + hisW / 2, mHistogramH[i]);
            }

            g.setColor(C.COLOR_BLUE_LIGHT);
            g.drawLines(mLineMACD, mCandleCnt, 2.0f);

            g.setColor(0xffff0000);
            g.drawLines(mLineSignal9, mCandleCnt, 1.0f);
        }
예제 #7
0
        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);
        }
예제 #8
0
        //======================================
        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);
                }
            }
        }
예제 #9
0
        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);
        }