示例#1
0
        //======================================
        protected void drawPriceLines(xGraphics g)
        {
            if (getShare() == null)
            {
                return;
            }

            for (int i = 0; i < 5; i++)
            {
                if (mPricesY[i] < -2000)    //  bug
                {
                    break;
                }
                g.setColor(C.GREY_LINE_COLOR);
                g.drawLine(0, mPricesY[i], internalW(), mPricesY[i]);

                String sz = (mPrices[i]).ToString("0.0");
                g.setColor(C.COLOR_GRAY_LIGHT);
                g.drawString(mFont, sz, getW() - 8, mPricesY[i], xGraphics.RIGHT | xGraphics.VCENTER);
            }

            int y = getH() - 4;

            g.setColor(C.GREY_LINE_COLOR);
            g.drawLine(0, y, getW(), y);
        }
        public override void render(xGraphics g)
        {
            if (isHiding())
            {
                return;
            }
            if (getShare(3) == null)
            {
                return;
            }
            Share share = getShare();
            int   mX    = 0;
            int   mY    = 0;

            if (detectShareCursorChanged())
            {
                calcVolumeByPrice();
            }

            int    i = 0;
            vBlock v;
            double maxTotalVol = 0;

            //  get max total volume
            for (i = 0; i < mBlocks.size(); i++)
            {
                v = (vBlock)mBlocks.elementAt(i);
                if (v.positiveVolume + v.negativeVolume > maxTotalVol)
                {
                    maxTotalVol = v.positiveVolume + v.negativeVolume;
                }
            }
            if (maxTotalVol == 0)
            {
                return;
            }
            int   w  = getW() / 2;
            float rx = (float)(w / maxTotalVol);

            for (i = 0; i < mBlocks.size(); i++)
            {
                v = (vBlock)mBlocks.elementAt(i);

                int bottomY = priceToY(v.beginPrice);
                int topY    = priceToY(v.endPrice);
                //  green block
                g.setColor(0x4000ff00);
                int bw1 = (int)(v.positiveVolume * rx);
                g.fillRect(0, topY + 1, bw1, bottomY - topY - 2);
                g.setColor(0xa000ff00);
                //g.drawRect(0, topY + 1, bw1, bottomY - topY - 2);

                //  red block
                g.setColor(0x40ff0000);
                int bw2 = (int)(v.negativeVolume * rx);
                g.fillRect(bw1, topY + 1, bw2, bottomY - topY - 2);
                g.setColor(0xa0ff0000);
                //g.drawRect(bw1, topY + 1, bw2, bottomY - topY - 2);
            }
        }
示例#3
0
 public void renderDrawer(xGraphics g)
 {
     if (hasDrawer())
     {
         mDrawer.render(g);
     }
 }
示例#4
0
        void renderSnapshot2(xGraphics g)
        {
            stPriceboardState item = getPriceboard();

            if (item != null)
            {
                stCell cell = getCellAt(7);

                //  snapshot
                if (rcSnapshot == null)
                {
                    rcSnapshot = new Rectangle();
                }
                rcSnapshot.X      = cell.x;
                rcSnapshot.Y      = 0;
                rcSnapshot.Width  = cell.w;
                rcSnapshot.Height = getH();

                sharethumb.DrawAChartDelegator.renderToView(item.code, g, rcSnapshot);

                //  date
                stGainloss gainloss = (stGainloss)getUserData();
                String     s        = Utils.dateIntToStringDDMM(gainloss.date);

                g.setColor(C.COLOR_WHITE);
                g.drawStringInRect(cell.f, s, cell.x, getH() - 17, cell.w, 17, xGraphics.LEFT);
            }
        }
示例#5
0
        void drawChart(xGraphics g, int y, int h)
        {
            pricesToXYs(mPrices, mCandleCnt, mChartXYs, mTimes, y, h);

            g.setColor(0xffffffff);
            g.drawLines(mChartXYs, mCandleCnt);
        }
示例#6
0
 public void drawFibonacci(xGraphics g)
 {
     if (mDrawer != null)
     {
         mDrawer.render(g);
     }
 }
示例#7
0
        override public void render(xGraphics g)
        {
            g.setColor(C.COLOR_BLACK);
            g.clear();
            //  title
            String title = "";

            if (mChartType == BUBBLE_TRADE_MONEY)
            {
                title = "Đồ thị minh họa luồng tiền (Mã / Giá trị GD / Thay đổi giá)";
            }
            else if (mChartType == BUBBLE_VOLUME_WEIGHT)
            {
                title = "Đồ thị minh họa mức độ ảnh hưởng (Mã / Trọng số / Thay đổi giá)";
            }
            else if (mChartType == BUBBLE_INDEX_WEIGHT_RATIO_INC)
            {
                title = "Tốp mã làm tăng thị trường (Mã / Thay đổi index / Thay đổi giá)";
            }
            else if (mChartType == BUBBLE_INDEX_WEIGHT_RATIO_DEC)
            {
                title = "Tốp mã làm giảm thị trường (Mã / Thay đổi index / Thay đổi giá)";
            }
            Font f = mContext.getFontText();

            g.setColor(C.COLOR_WHITE);
            g.drawString(f, title, 10, 2, xGraphics.TOP | xGraphics.LEFT);

            for (int i = 0; i < mUsedBlocks.size(); i++)
            {
                stBubbleBlock b = (stBubbleBlock)mUsedBlocks.elementAt(i);
                drawBlock(g, b);
            }
        }
示例#8
0
        void drawVolume(xGraphics g, int y, int h)
        {
            y += h;
            //================================================
            int max_volume = 1;
            int vol;

            for (int i = 0; i < mCandleCnt; i++)
            {
                vol = mVolumes[i];
                if (vol > max_volume)
                {
                    max_volume = vol;
                }
            }

            float ratioY = (float)(h) / max_volume;
            int   w      = 1;

            g.setColor(0xff00ff00);
            int x = 0;

            //  volume
            for (int i = 0; i < mCandleCnt; i++)
            {
                vol = mVolumes[i];
                h   = (int)(vol * ratioY);
                g.fillRect(mChartXYs[2 * i], y - h, w, h);
            }
            //Font fLabel = mContext.getFontText();
            //g.setColor(C.COLOR_GRAY_LIGHT);
            //g.drawString(fLabel, mVolumeLabel, x + getW() - 3, 0, xGraphics.RIGHT | xGraphics.TOP);
        }
示例#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() - 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);
            //==================
        }
示例#10
0
        public override void render(xGraphics g)
        {
            int mH = getH();
            int mW = getW();

            if (isHiding())
            {
                return;
            }
            Share share = getShare(3);

            if (share == null || baseShare() == null)
            {
                return;
            }

            if (mChartType == CHART_CRS_RATIO)
            {
                drawComparativeCRSRatio(g);
            }
            else if (mChartType == CHART_CRS_PERCENT)
            {
                drawComparativeCRSPercent(g);
            }
        }
示例#11
0
        void drawBlock(xGraphics g, stStatisticsBlock block)
        {
            int viewW = getW() - 4;

            uint alp = 0xa0ffffff;

            g.setColor(block.color & alp);
            g.fillRect((int)block.x, (int)block.y, (int)block.w, (int)block.h - 1);
            if (block.x + block.w < getW() - 4)
            {
                g.setColor(0xff202020);
                int x1 = (int)(block.x + block.w);
                g.fillRect(x1, (int)block.y, (int)(getW() - 4 - x1), (int)block.h - 1);
            }

            Font f = mContext.getFontSmallest();

            g.setColor(C.COLOR_WHITE);

            int itemH = (int)f.GetHeight();

            String s = String.Format("{0}; {1}; {2}", block.code, block.changed, block.inf);

            g.drawStringInRect(f, s, (int)block.x + 4, (int)block.y + 3, getW() / 2, (int)block.h, xGraphics.VCENTER);
            //g.drawStringInRect(f, block.inf, x, y + h / 2 - 8, w, itemH, xGraphics.HCENTER | xGraphics.TOP);
            //g.drawStringInRect(f, block.changed, x, y + h / 2 + 4, w, itemH, xGraphics.HCENTER | xGraphics.TOP);
        }
示例#12
0
        void drawFiboArc(xGraphics g, stTrendLine t)
        {
            uint color = t.color;// Constants.COLOR_FIBO_DOT_LINE2;	//	blue

            g.setColor(color);

            float[]  percent = { 23.6f, 38.2f, 50.0f, 61.8f, 100f, 161.8f };
            String[] txt     = { "23.6", "38.2", "50", "61.8", "100", "161.8" };
            int      y       = 0;

            double R = (t.x[0] - t.x[1]) * (t.x[0] - t.x[1]) + (t.y[0] - t.y[1]) * (t.y[0] - t.y[1]);

            R = Math.Sqrt(R);

            int r;

            g.setColor(color);

            for (int i = 0; i < percent.Length; i++)
            {
                r = (int)(R * percent[i]) / 100;

                if (i == 4)
                {
                    g.drawArc(t.x[0], t.y[0], r, 0f, 360);
                }
                else
                {
                    g.drawArcDot(t.x[0], t.y[0], r, 0f, 360);
                }

                g.drawString(mFont, txt[i], t.x[0] - r, t.y[0]);
            }
        }
示例#13
0
        void drawFiboFan(xGraphics g, stTrendLine t)
        {
            uint color = t.color;       //	blue

            g.setColor(color);

            float[]  percent = { 23.6f, 38.2f, 50.0f, 61.8f };//, 100f};
            String[] txt     = { "23.6", "38.2", "50", "61.8", "100", "161.8" };
            int      y       = 0;
            int      deltaY  = t.y[0] - t.y[1];
            int      dx      = t.x[1] - t.x[0];
            int      dy      = t.y[1] - t.y[0];

            for (int i = 0; i < percent.Length; i++)
            {
                y = t.y[0] - (int)(deltaY * percent[i] / 100);
                int x2  = t.x[1] + 2 * dx;
                int dx2 = x2 - t.x[0];
                dy = y - t.y[0];    //  => y = dy + t.y[0]

                //  dx/dx2 = dy/dy2
                int dy2 = 0;
                if (dx != 0)
                {
                    dy2 = dx2 * dy / dx;
                    y   = t.y[0] + dy2;
                }

                g.drawLineDotHorizontal(t.x[0], t.y[0], x2, y);
                g.drawString(mFont, txt[i], x2 - 30, y);
            }
        }
示例#14
0
        void drawControls(xGraphics g)
        {
            int x  = 0;
            int y  = 24;
            int fw = bw;
            int fh = bh;
            int sx = 0;

            x = getW() - 40 - fw;

            //  delete
            g.setColor(C.COLOR_GRAY_LIGHT);
            Image img = mContext.getImage(C.IMG_DRAWER_BUTTONS);

            if (mButtonSel == 0)
            {
                sx = fw;
            }

            g.drawImage(img, x, y, fw, fh, sx, 0);

            //  colors: RED/ORANGE/GREEN/PINK/WHITE
            x  -= colors.Length * bw;
            sx += 2 * bw;
            for (int i = 0; i < colors.Length; i++)
            {
                g.setColor(colors[i]);
                g.fillRect(x, y, bw, bh);
                g.drawImage(img, x, y, fw, fh, sx, 0);

                x += bw;
            }
        }
示例#15
0
        void drawTrendArrow(xGraphics g, stTrendLine t)
        {
            double h = (t.x[1] - t.x[0]) * (t.x[1] - t.x[0]) + (t.y[1] - t.y[0]) * (t.y[1] - t.y[0]);

            h = Math.Sqrt(h);

            double sina = (float)(t.y[1] - t.y[0]) / h;
            double cosa = (float)(t.x[1] - t.x[0]) / h;

            int x01 = -14;
            int y01 = -7;
            int x02 = -14;
            int y02 = +7;

            int x1 = (int)(x01 * cosa - y01 * sina) + t.x[1];
            int y1 = (int)(x01 * sina + y01 * cosa) + t.y[1];

            int x2 = (int)(x02 * cosa - y02 * sina) + t.x[1];
            int y2 = (int)(x02 * sina + y02 * cosa) + t.y[1];

            short[] xy = { (short)x1, (short)y1, (short)x2, (short)y2, (short)t.x[1], (short)t.y[1] };

            g.setColor(t.color);
            g.fillShapes(xy, 3);

            //g.drawTriangle(x1, y1, t.x[1], t.y[1], x2, y2);
        }
示例#16
0
        public override void render(xGraphics g)
        {
            int mH = getH();
            int mW = getW();

            if (isHiding())
            {
                return;
            }
            Share share = getShare();

            if (share == null)
            {
                return;
            }

            if (mChartType == CHART_AROON)
            {
                drawChartAroon(g);
            }
            if (mChartType == CHART_AROON_OSCILLATOR)
            {
                drawChartAroonOscillator(g);
            }
        }
示例#17
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);
        }
示例#18
0
        void drawTriangle(xGraphics g, stTrendLine t)
        {
            uint color = t.color;

            g.setColor(color);

            g.drawTriangleDot(t.x[0], t.y[0], t.x[1], t.y[1], t.x[2], t.y[2]);
        }
        void _renderToView(String code, xGraphics g, xBaseControl view)
        {
            mCode    = code;
            graphics = g;

            Rectangle rc = new Rectangle(view.getX(), view.getY(), view.getW(), view.getH());

            _renderToView(code, g, rc);
        }
示例#20
0
        protected void drawPriceLines(xGraphics g, float[] prices)
        {
            if (getShare() == null)
            {
                return;
            }

            Share share = getShare();
            float hi    = -100000;
            float lo    = 100000;

            for (int i = share.mBeginIdx; i <= share.mEndIdx; i++)
            {
                if (prices[i] > hi)
                {
                    hi = prices[i];
                }
                if (prices[i] < lo)
                {
                    lo = prices[i];
                }
            }
            float distance = hi - lo;

            if (distance <= 0)
            {
                return;
            }
            float rY = (float)getDrawingH() / distance;
            int   mH = getH();
            int   mY = 0;
            //		float rX = (float)getDrawingW()/mChartLineLength;
            //price
            //rY = (float)priceDistance/drawingH;
            float priceStep = distance / 5;

            for (int i = 0; i < 5; i++)
            {
                mPrices[i]  = lo + i * priceStep + priceStep / 2;
                mPricesY[i] = mY + (mH - getMarginY()) - (int)((mPrices[i] - lo) * rY);
            }
            //===================================
            for (int i = 0; i < 5; i++)
            {
                g.setColor(C.GREY_LINE_COLOR);
                g.drawLine(0, mPricesY[i], internalW(), mPricesY[i]);

                String sz = (mPrices[i]).ToString("0.0");
                g.setColor(C.COLOR_GRAY_LIGHT);
                g.drawString(mFont, sz, getW() - 8, mPricesY[i], xGraphics.RIGHT | xGraphics.VCENTER);
            }

            int y = getH() - 4;

            g.setColor(C.GREY_LINE_COLOR);
            g.drawLine(0, y, getW(), y);
        }
示例#21
0
        //=============================================
        protected void drawChartBar(xGraphics g, int[] _x, int[] _y, int barW, int[] barH, int cnt, int color)
        {
            g.setColor(color);

            for (int i = 0; i < cnt; i++)
            {
                g.fillRect(_x[i], _y[i], barW, barH[i]);
            }
        }
示例#22
0
        void drawOval(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.drawEclipse(t.x[0], t.y[0], w, h);
        }
示例#23
0
        void drawAbc(xGraphics g, stTrendLine t)
        {
            string text = (string)t.data;

            if (text != null)
            {
                g.setColor(t.color);
                g.drawString(mFont, text, t.x[0], t.y[0]);
            }
        }
示例#24
0
        public override void render(xGraphics g)
        {
            if (detectShareCursorChanged())
            {
                mHi = -1000000;
                mLo = 1000000;
                Share s = getShare();

                int period = (int)mContext.mOptCFMPeriod;

                s.calcCFM(period, mCFM);

                for (int i = s.mBeginIdx; i < s.mEndIdx; i++)
                {
                    if (mCFM[i] > mHi)
                    {
                        mHi = mCFM[i];
                    }
                    if (mCFM[i] < mLo)
                    {
                        mLo = mCFM[i];
                    }
                }
                mChartLineXY = allocMem(mChartLineXY, mChartLineLength * 2);

                pricesToYs(mCFM, s.mBeginIdx, mChartLineXY, mChartLineLength, mLo, mHi);
            }

            if (mShouldDrawGrid)
            {
                drawGrid(g);
            }

            String[] ss  = { "-0.2", "-0.1", "0.0", "0.1", "0.2" };
            float[]  tmp = { -0.2f, -0.1f, 0.0f, 0.1f, 0.2f };
            pricesToYs(tmp, 0, mPricelines, 5, mLo, mHi);

            for (int i = 0; i < 5; i++)
            {
                g.setColor(C.COLOR_FADE_YELLOW);
                g.drawLine(0, mPricelines[2 * i + 1], getW() - 34, mPricelines[2 * i + 1]);
                g.setColor(C.COLOR_FADE_YELLOW0);
                g.drawString(mFont, ss[i], getW() - 8, mPricelines[2 * i + 1], xGraphics.VCENTER | xGraphics.RIGHT);
            }

            g.setColor(C.COLOR_GREEN_DARK);
            g.drawLines(mChartLineXY, mChartLineLength, mLineThink);

            fillColorGreen(g, mChartLineXY, mChartLineLength, mPricelines[5]);
            fillColorRed(g, mChartLineXY, mChartLineLength, mPricelines[5]);

            mMouseTitle = null;//"" + (int)yToPrice(mLastY, 0, 100);

            renderCursor(g);
        }
示例#25
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);
        }
示例#26
0
 public override void render(xGraphics g)
 {
     for (int i = 0; i < mCharts.Length; i++)
     {
         xBaseControl c = (xBaseControl)mCharts[i];
         if (c != null)
         {
             c.render(g);
         }
     }
 }
        static public void renderToView(String code, xGraphics g, xBaseControl view)
        {
            DrawAChartDelegator sharedInstance = (DrawAChartDelegator)GlobalData.vars().getValue("DrawAChartDelegator");

            if (sharedInstance == null)
            {
                sharedInstance = new DrawAChartDelegator();
                GlobalData.vars().setValue("DrawAChartDelegator", sharedInstance);
            }

            sharedInstance._renderToView(code, g, view);
        }
示例#28
0
        public void fillColorRed(xGraphics g, short[] line, int pointCount, short baseline)
        {
            mChartLineColorArea = allocMem(mChartLineColorArea, pointCount * 2 + 20);
            //========red area
            int j = 0;

            g.setColor(0x80ff0000);
            short x  = 0;
            int   x0 = line[0];

            for (int i = 1; i < pointCount; i++)
            {
                x = line[2 * i];
                int y = line[2 * i + 1];
                if (y >= baseline)
                {
                    if (j == 0)
                    {
                        mChartLineColorArea[2 * j]     = (short)(x0 + ((x - x0) / 2));
                        mChartLineColorArea[2 * j + 1] = (short)baseline;
                        j++;
                    }
                    {
                        mChartLineColorArea[2 * j]     = x;
                        mChartLineColorArea[2 * j + 1] = line[2 * i + 1];
                        j++;
                    }
                }
                else if (y < baseline)
                {
                    if (j >= 2)
                    {
                        mChartLineColorArea[2 * j]     = (short)(x0 + ((x - x0) / 2));
                        mChartLineColorArea[2 * j + 1] = (short)baseline;
                        j++;

                        g.fillShapes(mChartLineColorArea, j);
                    }
                    j = 0;
                }
                x0 = x;
            }
            if (j > 1 && pointCount > 2)
            {
                x = line[2 * (pointCount - 1)];

                mChartLineColorArea[2 * j]     = x;
                mChartLineColorArea[2 * j + 1] = (short)baseline;
                j++;

                g.fillShapes(mChartLineColorArea, j);
            }
        }
        static public void renderToView(String code, xGraphics g, System.Drawing.Rectangle rc)
        {
            DrawAChartDelegator sharedInstance = (DrawAChartDelegator)GlobalData.vars().getValue("DrawAChartDelegator");

            if (sharedInstance == null)
            {
                sharedInstance = new DrawAChartDelegator();
                GlobalData.vars().setValue("DrawAChartDelegator", sharedInstance);
            }

            sharedInstance._renderToView(code, g, rc);
        }
示例#30
0
        void drawText(xGraphics g, int x)
        {
            Font f      = mContext.getFontSmall();
            Font fLabel = mContext.getFontText();

            //  ma co phieu
            g.setColor(C.COLOR_WHITE);
            string s = "#" + mTrade.getCode();

            g.drawString(mContext.getFontTextB(), s, x, 1);
            x += g.getStringWidth(mContext.getFontTextB(), s) + 5;
            //	time
            if (mCandleCnt > 0)
            {
                g.setColor(C.COLOR_GRAY_DARK);
                g.fillRect(0, getH() - 12, getW(), 12);
                g.setColor(C.COLOR_WHITE);
                g.drawString(f, mTimeStart, 0 + 1, 0 + getH(), xGraphics.BOTTOM | xGraphics.LEFT);
                g.drawString(f, mTimeEnd, mChartXYs[2 * (mCandleCnt - 1)], 0 + getH() - 12, xGraphics.BOTTOM | xGraphics.LEFT);

                g.setColor(C.COLOR_WHITE);
                s = "KL: " + Utils.formatNumber(mTrade.getVolume(-1));
                g.drawString(f, s, (getW() - Utils.getStringW(s, f)) / 2, getH(), xGraphics.BOTTOM);
            }

            g.setColor(C.GREY_LINE_COLOR);
            g.drawHorizontalLine(x, 0 + getH(), getW());
            //=============cursor & some info========================
            if (mCandleCnt > 0)
            {
                //x = getW() / 2;
                g.setColor(C.COLOR_GRAY_LIGHT);
                g.drawString(fLabel, mCurrentTrade, x, 0 + 1, xGraphics.LEFT);// xGraphics.HCENTER | xGraphics.TOP);
                g.setColor(C.COLOR_FADE_YELLOW0);
                g.drawVerticalLine(mChartXYs[2 * mCurrentTradeSel], 12, getH() - 26);
                //g.drawPoint(mChartXYs[2 * mCurrentTradeSel] - 2, mChartXYs[2 * mCurrentTradeSel + 1] - 4, 4);

                if (mChangedValue > 0)
                {
                    g.setColor(C.COLOR_GREEN);
                }
                else if (mChangedValue == 0)
                {
                    g.setColor(C.COLOR_YELLOW);
                }
                else
                {
                    g.setColor(C.COLOR_RED);
                }
                g.drawString(fLabel, mChanged, mChartXYs[2 * mCurrentTradeSel], 26);
            }
            //=====================================================
        }