Пример #1
0
        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);
                    }
                }
            }
        }
Пример #2
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();

            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);
        }
Пример #3
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();
        }
Пример #4
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();

            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;
                }
            }
        }
Пример #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();
        }