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

📄 page_multiquote.java

📁 一份java写的期货交易程序
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
                        paintNumber(g, data.totalAmount, "", m_strItems[j], 0, close, x, y);
                    else
                    if(m_strItems[j].equals("TotalMoney"))
                        paintNumber(g, data.totalMoney, "", m_strItems[j], iPrecision, close, x, y);
                    else
                    if(m_strItems[j].equals("ReverseCount"))
                        paintNumber(g, data.reserveCount, "", m_strItems[j], 0, close, x, y);
                    else
                    if(m_strItems[j].equals("CurAmount"))
                        paintNumber(g, data.curAmount, "", m_strItems[j], 0, close, x, y);
                    else
                    if(m_strItems[j].equals("AmountRate"))
                        paintNumber(g, data.amountRate, "", m_strItems[j], 2, close, x, y);
                    else
                    if(m_strItems[j].equals("ConsignRate"))
                        paintNumber(g, data.consignRate, "", m_strItems[j], 2, close, x, y);
                    else
                    if(m_strItems[j].equals("Unit") && m_applet.m_strMarketName.equalsIgnoreCase("Anhui"))
                    {
                        String strText;
                        if(data.code.startsWith("G"))
                            strText = "单";
                        else
                        if(data.code.startsWith("X"))
                            strText = "批";
                        else
                            strText = "";
                        g.setColor(HQApplet.rhColor.clProductName);
                        strLen = fm.stringWidth(strText);
                        g.drawString(strText, x - strLen, y);
                    }
                    if(x > m_rc.x + m_rc.width)
                        break;
                }

                x = m_rc.x;
                y += fontHeight + gap;
            }
        }

    }

    private void paintPromptMessage(Graphics g)
    {
        String prompt = "请用注册账户登录后在页面中设定自选股";
        Font font = new Font("宋体", 0, 16);
        FontMetrics fm = g.getFontMetrics(font);
        int promptWidth = fm.stringWidth(prompt);
        int lines = promptWidth / (m_rc.width - 8);
        g.setFont(font);
        g.setColor(HQApplet.rhColor.clProductName);
        if(promptWidth % (m_rc.width - 8) > 0)
            lines++;
        int y = (m_rc.height - fm.getHeight() * lines - 20) / 2 + 20 + fm.getAscent();
        int x = 4;
        int beginIndex = 0;
        int lineChars = (m_rc.width - 8) / 16;
        while(beginIndex < prompt.length()) 
        {
            int endIndex = beginIndex + lineChars;
            String strLine = "";
            if(endIndex > prompt.length())
            {
                strLine = prompt.substring(beginIndex);
                beginIndex = prompt.length();
            } else
            {
                strLine = prompt.substring(beginIndex, endIndex);
                beginIndex = endIndex;
            }
            x = (m_rc.width - 8 - fm.stringWidth(strLine)) / 2 + 4;
            g.drawString(strLine, x, y);
            y += fm.getHeight();
        }
    }

    void paintNumber(Graphics g, double num, String strSuffix, String itemName, int iPrecision, float close, 
            int x, int y)
    {
        StringBuffer buffer = new StringBuffer();
        if(itemName.equals("TotalAmount") || itemName.equals("CurAmount") || itemName.equals("BuyAmount") || itemName.equals("SellAmount") || itemName.equals("AmountRate"))
            g.setColor(HQApplet.rhColor.clVolume);
        else
        if(itemName.equals("ReverseCount"))
            g.setColor(HQApplet.rhColor.clReserve);
        else
        if(itemName.equals("TotalMoney"))
            g.setColor(HQApplet.rhColor.clNumber);
        else
        if(itemName.equals("ConsignRate"))
            g.setColor(HQApplet.rhColor.clNumber);
        else
        if(itemName.equals("YesterBalance"))
            g.setColor(HQApplet.rhColor.clEqual);
        else
        if(itemName.equals("UpValue"))
        {
            if(num > 0.0D)
            {
                buffer.append("+");
                g.setColor(HQApplet.rhColor.clIncrease);
            } else
            if(num == 0.0D)
                g.setColor(HQApplet.rhColor.clEqual);
            else
                g.setColor(HQApplet.rhColor.clDecrease);
        } else
        if(num > (double)close)
            g.setColor(HQApplet.rhColor.clIncrease);
        else
        if(num == (double)close || num == 0.0D)
            g.setColor(HQApplet.rhColor.clEqual);
        else
            g.setColor(HQApplet.rhColor.clDecrease);
        if(itemName.equals("UpRate"))
        {
            if(num == -100D || num == 0.0D)
            {
                buffer.append("—");
            } else
            {
                buffer.append(Common.FloatToString(num, iPrecision));
                buffer.append("%");
            }
        } else
        if(num == 0.0D)
            buffer.append("—");
        else
            buffer.append(Common.FloatToString(num, iPrecision));
        buffer.append(strSuffix);
        int strLen = fm.stringWidth(buffer.toString());
        g.drawString(buffer.toString(), x - strLen, y);
    }

    void paintHighlightBar()
    {
        if(m_applet.m_quoteList.length > 0 && iHighlightIndex > m_applet.m_quoteList.length)
        {
            iHighlightIndex = m_applet.m_quoteList.length - 1;
            if(iHighlightIndex < 0)
                iHighlightIndex = 0;
        }
        Graphics g = m_applet.getGraphics();
        int gap = 2;
        int oldY = m_rc.y + (iHighlightIndex + 1) * (fontHeight + gap);
        g.setColor(HQApplet.rhColor.clBackGround);
        g.setXORMode(HQApplet.rhColor.clHighlight);
        g.fillRect(m_rc.x, oldY, m_rc.width, fontHeight);
        g.setPaintMode();
    }

    void repaintHighlightBar(int iNewPos)
    {
        Graphics m_graphics = m_applet.getGraphics();
        int gap = 2;
        int oldY = m_rc.y + (iHighlightIndex + 1) * (fontHeight + gap);
        int newY = m_rc.y + (iNewPos + 1) * (fontHeight + gap);
        m_graphics.setColor(HQApplet.rhColor.clBackGround);
        m_graphics.setXORMode(HQApplet.rhColor.clHighlight);
        m_graphics.fillRect(m_rc.x, oldY, m_rc.width, fontHeight);
        m_graphics.fillRect(m_rc.x, newY, m_rc.width, fontHeight);
        iHighlightIndex = iNewPos;
        m_graphics.setPaintMode();
    }

    boolean KeyPressed(KeyEvent e)
    {
        int iKeyCode = e.getKeyCode();
        boolean bNeedRepaint = false;
        switch(iKeyCode)
        {
        case 38: // '&'
            bNeedRepaint = Key_UP_Pressed();
            break;

        case 40: // '('
            bNeedRepaint = Key_DOWN_Pressed();
            break;

        case 37: // '%'
            bNeedRepaint = Key_LEFT_Pressed();
            break;

        case 39: // '\''
            bNeedRepaint = Key_RIGHT_Pressed();
            break;

        case 34: // '"'
            bNeedRepaint = Key_PAGEDOWN_Pressed();
            break;

        case 33: // '!'
            bNeedRepaint = Key_PAGEUP_Pressed();
            break;

        case 10: // '\n'
            bNeedRepaint = Key_ENTER_Pressed();
            break;
        }
        return bNeedRepaint;
    }

    boolean MouseLeftClicked(int x, int y)
    {
        if(y > fontHeight)
        {
            selectProduct(x, y);
        } else
        {
            int iLeft = m_rc.x;
            for(int i = 0; i < m_strItems.length; i++)
            {
                if(i > m_iStaticIndex && i < iDynamicIndex)
                    continue;
                MultiQuoteItemInfo info = (MultiQuoteItemInfo)m_htItemInfo.get(m_strItems[i]);
                if(info == null)
                    continue;
                if(x > iLeft && x < iLeft + info.width)
                {
                    changeSortField(m_strItems[i]);
                    break;
                }
                iLeft += info.width;
                if(iLeft > m_rc.x + m_rc.width)
                    break;
            }

        }
        return false;
    }

    private void selectProduct(int x, int y)
    {
        if(m_applet.m_quoteList.length > 0)
        {
            int gap = 2;
            int xx = m_rc.x;
            int yy = m_rc.y + fontHeight + gap;
            int count = m_applet.m_quoteList.length - iStart;
            if(count > iStockRows)
                count = iStockRows;
            for(int i = 0; i < count; i++)
            {
                if(x > xx && x < xx + m_rc.width && y > yy && y < yy + fontHeight + gap)
                {
                    if(i != iHighlightIndex)
                        repaintHighlightBar(i);
                    break;
                }
                yy += fontHeight + gap;
            }

        }
    }

    boolean MouseLeftDblClicked(int x, int y)
    {
        if(m_applet.m_quoteList.length > 0)
        {
            int gap = 2;
            int xx = m_rc.x;
            int yy = m_rc.y + fontHeight;
            int count = m_applet.m_quoteList.length - iStart;
            if(count > iStockRows)
                count = iStockRows;
            for(int i = 0; i < count; i++)
            {
                if(x > xx && x < xx + m_rc.width && y > yy && y < yy + fontHeight)
                {
                    String sCode = m_applet.m_quoteList[iStart + i].code;
                    m_applet.QueryStock(sCode);
                    return true;
                }
                yy += fontHeight + gap;
            }

        }
        return false;
    }

    boolean MouseMoved(int x, int y)
    {
        if(y <= 0 || y >= fontHeight)
        {
            m_applet.setCursor(new Cursor(0));
            return false;
        }
        int iLeft = m_rc.x;
        for(int i = 0; i < m_strItems.length; i++)
        {
            if(i > m_iStaticIndex && i < iDynamicIndex)
                continue;
            MultiQuoteItemInfo info = (MultiQuoteItemInfo)m_htItemInfo.get(m_strItems[i]);
            if(info == null)
                continue;
            if(x > iLeft && x < iLeft + info.width && info.sortID != -1)
            {
                m_applet.setCursor(new Cursor(12));
                return false;
            }

⌨️ 快捷键说明

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