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

📄 page_multiquote.java

📁 一份java写的期货交易程序
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
            iLeft += info.width;
            if(iLeft > m_rc.x + m_rc.width)
                break;
        }

        m_applet.setCursor(new Cursor(0));
        return false;
    }

    boolean Key_UP_Pressed()
    {
        if(!bCanMove)
            return false;
        if(m_applet.m_quoteList.length > 0)
            if(iHighlightIndex > 0)
                repaintHighlightBar(iHighlightIndex - 1);
            else
            if(iStart > 0)
            {
                iStart -= iStockRows - 1 <= 0 ? 1 : iStockRows - 1;
                if(iStart < 0)
                    iStart = 0;
                iHighlightIndex = iStockRows - 1;
                if(iHighlightIndex >= m_applet.m_quoteList.length)
                    iHighlightIndex = m_applet.m_quoteList.length - 1;
                m_applet.repaint();
            }
        return false;
    }

    boolean Key_DOWN_Pressed()
    {
        if(!bCanMove)
            return false;
        if(m_applet.m_quoteList.length > 0 && iStart + iHighlightIndex < m_applet.m_quoteList.length - 1)
            if(iHighlightIndex < iStockRows - 1)
            {
                repaintHighlightBar(iHighlightIndex + 1);
            } else
            {
                iStart += iStockRows - 1 <= 0 ? 1 : iStockRows - 1;
                iHighlightIndex = 0;
                m_applet.repaint();
            }
        return false;
    }

    boolean Key_PAGEUP_Pressed()
    {
        if(m_applet.m_quoteList.length > 0)
            if(iStart > 0)
            {
                iStart -= iStockRows - 1 <= 0 ? 1 : iStockRows - 1;
                if(iStart < 0)
                    iStart = 0;
                iHighlightIndex = iStockRows - 1;
                if(iHighlightIndex >= m_applet.m_quoteList.length)
                    iHighlightIndex = m_applet.m_quoteList.length - 1;
                m_applet.repaint();
            } else
            {
                repaintHighlightBar(0);
            }
        return false;
    }

    boolean Key_PAGEDOWN_Pressed()
    {
        if(m_applet.m_quoteList.length > 0)
            if(iStart + iStockRows < m_applet.m_quoteList.length)
            {
                iStart += iStockRows - 1 <= 0 ? 1 : iStockRows - 1;
                iHighlightIndex = 0;
                m_applet.repaint();
            } else
            {
                repaintHighlightBar(m_applet.m_quoteList.length - 1 - iStart);
            }
        return false;
    }

    boolean Key_LEFT_Pressed()
    {
        if(iDynamicIndex == m_iStaticIndex + 1)
        {
            return false;
        } else
        {
            iDynamicIndex--;
            return true;
        }
    }

    boolean Key_RIGHT_Pressed()
    {
        boolean bNeedRepaint = false;
        if(iDynamicIndex < m_strItems.length - 1)
        {
            iDynamicIndex++;
            bNeedRepaint = true;
        }
        return bNeedRepaint;
    }

    boolean Key_ENTER_Pressed()
    {
        if(m_applet.m_quoteList.length > 0)
        {
            int iIndex = iStart + iHighlightIndex;
            if(iIndex >= 0 && iIndex <= m_applet.m_quoteList.length - 1)
            {
                String sCode = m_applet.m_quoteList[iIndex].code;
                m_applet.QueryStock(sCode);
                return true;
            }
        }
        return false;
    }

    byte getSortByField(String strSortItem)
    {
        MultiQuoteItemInfo info = (MultiQuoteItemInfo)m_htItemInfo.get(strSortItem);
        if(info == null)
            return 0;
        else
            return (byte)info.sortID;
    }

    void printQuoteData()
    {
        for(int i = 0; i < m_applet.m_quoteList.length; i++)
        {
            ProductDataVO stock = m_applet.m_quoteList[i];
            float uprate = ((stock.curPrice - stock.yesterBalancePrice) / stock.yesterBalancePrice) * 100F;
            System.err.println(i + "\t涨幅" + "\t最新" + "\t前收" + "\t开盘" + "\t最高" + "\t最低" + "\t成交量" + "\t成交金额" + "\t现手" + "\t量比" + "\t委比");
            System.out.print("\t" + uprate + "%");
            System.out.print("\t" + stock.curPrice);
            System.out.print("\t" + stock.closePrice);
            System.out.print("\t" + stock.openPrice);
            System.out.print("\t" + stock.highPrice);
            System.out.print("\t" + stock.lowPrice);
            System.out.print("\t" + stock.totalAmount);
            System.out.print("\t" + stock.totalMoney);
            System.out.print("\t" + stock.curAmount);
            System.out.print("\t" + stock.amountRate);
            System.out.print("\t" + stock.consignRate);
        }

    }

    void processMenuEvent(PopupMenu popupMenu, int x, int y)
    {
        selectProduct(x, y);
        popupMenu.removeAll();
        popupMenu.add(menuStockRank);
        popupMenu.addSeparator();
        popupMenu.add(menuPageMinLine);
        popupMenu.add(menuPageKLine);
        popupMenu.addSeparator();
        popupMenu.add(menuMarket);
        processCommonMenuEvent(popupMenu, this);
        popupMenu.show(m_applet, x, y);
    }

    void makeMenus()
    {
        menuStockRank = new Menu(m_applet.getShowString("SortBy"));
        menuMarket = new MenuItem(m_applet.getShowString("ClassedList") + "  F4");
        menuPageMinLine = new MenuItem(m_applet.getShowString("MinLine") + "  F5");
        menuPageKLine = new MenuItem(m_applet.getShowString("Analysis"));
        menuMarket.setActionCommand("cmd_80");
        menuMarket.addActionListener(this);
        for(int i = 0; i < m_strItems.length; i++)
        {
            MultiQuoteItemInfo info = (MultiQuoteItemInfo)m_htItemInfo.get(m_strItems[i]);
            if(info != null && info.sortID != -1)
            {
                MenuItem menuItem = new MenuItem(info.name);
                menuItem.setActionCommand("Sort_" + m_strItems[i]);
                menuItem.addActionListener(this);
                menuStockRank.add(menuItem);
            }
        }

        menuPageMinLine.setActionCommand("minline");
        menuPageMinLine.addActionListener(this);
        menuPageKLine.setActionCommand("kline");
        menuPageKLine.addActionListener(this);
    }

    public void actionPerformed(ActionEvent e)
    {
        String cmd = e.getActionCommand();
        if(cmd.indexOf("cmd_") >= 0)
            executeCommand();
        else
        if(cmd.indexOf("Sort_") >= 0)
        {
            changeSortField(cmd.substring(5));
            if(HQApplet.bDebug != 0)
                System.out.println("cmd ====" + cmd);
        } else
        if(cmd.indexOf("STOCK_") >= 0)
            m_applet.ShowMutilQuote(getStockType(cmd));
        else
        if(cmd.equals("minline"))
        {
            if(iHighlightIndex > 0 && iHighlightIndex <= m_applet.m_quoteList.length)
            {
                ProductDataVO stockData = m_applet.m_quoteList[iStart + iHighlightIndex];
                String scode = String.valueOf(stockData.code);
                m_applet.showPageMinLine(scode);
            }
        } else
        if(cmd.equals("kline"))
        {
            if(iHighlightIndex > 0 && iHighlightIndex <= m_applet.m_quoteList.length)
            {
                ProductDataVO stockData = m_applet.m_quoteList[iStart + iHighlightIndex];
                String scode = String.valueOf(stockData.code);
                m_applet.showPageKLine(scode);
            }
        } else
        if(cmd.equals("userstock"))
            m_applet.ShowMutilQuote((byte)0);
        else
            super.actionPerformed(e);
    }

    private void changeSortField(String strSortItem)
    {
        MultiQuoteItemInfo info = (MultiQuoteItemInfo)m_htItemInfo.get(strSortItem);
        if(info == null)
            return;
        if(info.sortID == -1)
            return;
        m_bShowSortTag = true;
        if(this.strSortItem.equals(strSortItem))
        {
            isDescend = isDescend != 1 ? 1 : 0;
            iStart = 0;
        } else
        {
            isDescend = 0;
            this.strSortItem = strSortItem;
        }
        sortItems();
        m_applet.repaint();
        AskForDataOnTimer();
    }

    public void sortItems()
    {
        Arrays.sort(m_applet.m_quoteList, strSortItem);
        if(isDescend == 0)
        {
            int size = m_applet.m_quoteList.length;
            int count = size / 2;
            for(int i = 0; i < count; i++)
            {
                ProductDataVO tmp = m_applet.m_quoteList[i];
                m_applet.m_quoteList[i] = m_applet.m_quoteList[size - i - 1];
                m_applet.m_quoteList[size - i - 1] = tmp;
            }

        }
    }

    private byte getStockType(String name)
    {
        return !name.equals("PRODUCT_COMMON") ? -1 : 0;
    }

    void setMenuEnable(byte stockType, boolean b)
    {
        switch(stockType)
        {
        case 0: // '\0'
        default:
            return;
        }
    }

    private void setUserStockCode()
    {
    }

    private void executeCommand()
    {
        switch(currentStockType)
        {
        case 1: // '\001'
            m_applet.UserCommand("80");
            break;
        }
    }

}

⌨️ 快捷键说明

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