⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 draw_quote.java

📁 一份java写的期货交易程序
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        x = (rc.x + rc.width) - fm.stringWidth(str1);
        g.drawString(str1, x, y);
        for(int i = iShowBuySellNum - 1; i >= 0; i--)
        {
            y += fm.getHeight();
            if(y + iDescent > rc.y + rc.height)
                return;
            if(product != null && fSellP[i] > 0.0F)
            {
                g.setColor(GetPriceColor(fSellP[i], product.realData.yesterBalancePrice));
                str = Common.FloatToString(fSellP[i], iPrecision);
            } else
            {
                str = "—";
                g.setColor(HQApplet.rhColor.clEqual);
            }
            x = (rc.x + rc.width / 2) - fm.stringWidth(str);
            g.drawString(str, x, y);
            if(product != null && fSellV[i] > 0.0F)
                str = String.valueOf((int)fSellV[i]);
            else
                str = "—";
            g.setColor(HQApplet.rhColor.clVolume);
            x = (rc.x + rc.width) - fm.stringWidth(str);
            g.drawString(str, x, y);
        }

        for(int i = 0; i < iShowBuySellNum; i++)
        {
            y += fm.getHeight();
            if(y + iDescent > rc.y + rc.height)
                return;
            if(product != null && fBuyP[i] > 0.0F)
            {
                g.setColor(GetPriceColor(fBuyP[i], product.realData.yesterBalancePrice));
                str = Common.FloatToString(fBuyP[i], iPrecision);
            } else
            {
                str = "—";
                g.setColor(HQApplet.rhColor.clEqual);
            }
            x = (rc.x + rc.width / 2) - fm.stringWidth(str);
            g.drawString(str, x, y);
            if(product != null && fBuyV[i] > 0.0F)
                str = String.valueOf((int)fBuyV[i]);
            else
                str = "—";
            g.setColor(HQApplet.rhColor.clVolume);
            x = (rc.x + rc.width) - fm.stringWidth(str);
            g.drawString(str, x, y);
        }

        y += fm.getHeight();
        if(y + iDescent > rc.y + rc.height)
            return;
        if(product.realData != null && product.realData.curPrice > 0.0F)
        {
            str = Common.FloatToString(product.realData.curPrice, iPrecision);
            g.setColor(GetPriceColor(product.realData.curPrice, product.realData.yesterBalancePrice));
        } else
        {
            str = "—";
            g.setColor(HQApplet.rhColor.clEqual);
        }
        x = (rc.x + rc.width / 2) - fm.stringWidth(str);
        g.drawString(str, x, y);
        y += fm.getHeight();
        if(y + iDescent > rc.y + rc.height)
            return;
        if(product.realData != null && product.realData.curPrice > 0.0F && product.realData.yesterBalancePrice > 0.0F)
        {
            str = Common.FloatToString(product.realData.curPrice - product.realData.yesterBalancePrice, iPrecision);
            g.setColor(GetPriceColor(product.realData.curPrice, product.realData.yesterBalancePrice));
        } else
        {
            str = "—";
            g.setColor(HQApplet.rhColor.clEqual);
        }
        x = (rc.x + rc.width / 2) - fm.stringWidth(str);
        g.drawString(str, x, y);
        if(product.realData != null && product.realData.openPrice > 0.0F)
        {
            str = Common.FloatToString(product.realData.openPrice, iPrecision);
            g.setColor(GetPriceColor(product.realData.openPrice, product.realData.yesterBalancePrice));
        } else
        {
            str = "—";
            g.setColor(HQApplet.rhColor.clEqual);
        }
        x = (rc.x + rc.width) - fm.stringWidth(str);
        g.drawString(str, x, y);
        y += fm.getHeight();
        if(y + iDescent > rc.y + rc.height)
            return;
        if(product.realData != null && product.realData.curPrice > 0.0F && product.realData.yesterBalancePrice > 0.0F)
        {
            str = Common.FloatToString(((product.realData.curPrice - product.realData.yesterBalancePrice) / product.realData.yesterBalancePrice) * 100F, 2) + "%";
            g.setColor(GetPriceColor(product.realData.curPrice, product.realData.yesterBalancePrice));
        } else
        {
            str = "—";
            g.setColor(HQApplet.rhColor.clEqual);
        }
        x = (rc.x + rc.width / 2) - fm.stringWidth(str);
        g.drawString(str, x, y);
        if(product.realData != null && product.realData.highPrice > 0.0F)
        {
            str = Common.FloatToString(product.realData.highPrice, iPrecision);
            g.setColor(GetPriceColor(product.realData.highPrice, product.realData.yesterBalancePrice));
        } else
        {
            str = "—";
            g.setColor(HQApplet.rhColor.clEqual);
        }
        x = (rc.x + rc.width) - fm.stringWidth(str);
        g.drawString(str, x, y);
        y += fm.getHeight();
        if(y + iDescent > rc.y + rc.height)
            return;
        if(product.realData != null && product.realData.curAmount > 0)
            str = String.valueOf(product.realData.curAmount);
        else
            str = "—";
        g.setColor(HQApplet.rhColor.clVolume);
        x = (rc.x + rc.width / 2) - fm.stringWidth(str);
        g.drawString(str, x, y);
        if(product.realData != null && product.realData.lowPrice > 0.0F)
        {
            str = Common.FloatToString(product.realData.lowPrice, iPrecision);
            g.setColor(GetPriceColor(product.realData.lowPrice, product.realData.yesterBalancePrice));
        } else
        {
            str = "—";
            g.setColor(HQApplet.rhColor.clEqual);
        }
        x = (rc.x + rc.width) - fm.stringWidth(str);
        g.drawString(str, x, y);
        y += fm.getHeight();
        if(y + iDescent > rc.y + rc.height)
            return;
        if(product.realData != null && product.realData.totalAmount > 0L)
            str = String.valueOf((int)product.realData.totalAmount);
        else
            str = "—";
        g.setColor(HQApplet.rhColor.clVolume);
        x = (rc.x + rc.width / 2) - fm.stringWidth(str);
        g.drawString(str, x, y);
        if(product.realData != null && product.realData.amountRate > 0.0F)
            str = Common.FloatToString(product.realData.amountRate, 2);
        else
            str = "—";
        g.setColor(HQApplet.rhColor.clVolume);
        x = (rc.x + rc.width) - fm.stringWidth(str);
        g.drawString(str, x, y);
        y += fm.getHeight();
        if(y + iDescent > rc.y + rc.height)
            return;
        if(product.realData != null && product.realData.balancePrice > 0.0F)
        {
            str = Common.FloatToString(product.realData.balancePrice, iPrecision);
            g.setColor(GetPriceColor(product.realData.balancePrice, product.realData.yesterBalancePrice));
        } else
        {
            str = "—";
            g.setColor(HQApplet.rhColor.clEqual);
        }
        x = (rc.x + rc.width / 2) - fm.stringWidth(str);
        g.drawString(str, x, y);
        if(product.realData != null && product.realData.yesterBalancePrice > 0.0F)
            str = Common.FloatToString(product.realData.yesterBalancePrice, iPrecision);
        else
            str = "—";
        g.setColor(HQApplet.rhColor.clEqual);
        x = (rc.x + rc.width) - fm.stringWidth(str);
        g.drawString(str, x, y);
        y += fm.getHeight();
        if(y + iDescent > rc.y + rc.height)
            return;
        if(product.realData != null && product.realData.reserveCount > 0)
            str = String.valueOf(product.realData.reserveCount);
        else
            str = "—";
        g.setColor(HQApplet.rhColor.clReserve);
        x = (rc.x + rc.width / 2) - fm.stringWidth(str);
        g.drawString(str, x, y);
        if(product.realData != null)
            str = String.valueOf(product.realData.reserveChange);
        else
            str = "—";
        g.setColor(HQApplet.rhColor.clVolume);
        x = (rc.x + rc.width) - fm.stringWidth(str);
        g.drawString(str, x, y);
        y += fm.getHeight();
        if(y + iDescent > rc.y + rc.height)
            return;
        if(product != null && product.realData != null && product.realData.outAmount > 0)
            str = String.valueOf(product.realData.outAmount);
        else
            str = "—";
        g.setColor(HQApplet.rhColor.clVolume);
        x = (rc.x + rc.width / 2) - fm.stringWidth(str);
        g.drawString(str, x, y);
        if(product != null && product.realData != null && product.realData.inAmount > 0)
            str = String.valueOf(product.realData.inAmount);
        else
            str = "—";
        g.setColor(HQApplet.rhColor.clVolume);
        x = (rc.x + rc.width) - fm.stringWidth(str);
        g.drawString(str, x, y);
    }

    static Color GetPriceColor(float fPrice, float fBenchMark)
    {
        if(fPrice > fBenchMark)
            return HQApplet.rhColor.clIncrease;
        if(fPrice < fBenchMark)
            return HQApplet.rhColor.clDecrease;
        else
            return HQApplet.rhColor.clEqual;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -