Esempio n. 1
0
        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();
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        //  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);
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
        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();
        }