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

📄 hqapplet.java

📁 java 写的股票技术分析;软件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            UserCommand("80");
            break;

        case 116: // 't'
            OnF5();
            break;

        case 118: // 'v'
            UserCommand("70");
            break;

        default:
            if(mainGraph != null)
                bNeedRepaint = mainGraph.KeyPressed(e);
            break;
        }
        if(bNeedRepaint)
            repaint();
    }

    void ChangeStock(boolean bUp, boolean bIgnoreStatus) {
        int iIndex = -1;
        for(int i = 0; i < m_codeList.size(); i++) {
            if(!strCurrentCode.equals(m_codeList.elementAt(i)))
                continue;
            iIndex = i;
            break;
        }

        if(iIndex == -1) {
            if(m_codeList.size() > 0)
                strCurrentCode = (String)m_codeList.elementAt(0);
        } else {
            if(bUp) {
                if(--iIndex < 0)
                    iIndex = m_codeList.size() - 1;
            } else
            if(++iIndex >= m_codeList.size())
                iIndex = 0;
            strCurrentCode = (String)m_codeList.elementAt(iIndex);
        }
        if(!bIgnoreStatus) {
            CodeTable s = (CodeTable)m_htProduct.get(strCurrentCode);
            if(s.status == 1 || s.status == 4) {
                ChangeStock(bUp, bIgnoreStatus);
                return;
            }
        }
        if(1 == iCurrentPage)
            mainGraph = new Page_MinLine(m_rcMain, this);
        else
        if(2 == iCurrentPage)
            mainGraph = new Page_KLine(m_rcMain, this);
    }

    void this_mouseLeftPressed(MouseEvent e) {
        if(mainGraph == null)
            return;
        if(mainGraph.MouseLeftClicked(e.getX(), e.getY()))
            repaint();
    }

    void this_mouseRightReleased(MouseEvent e) {
        if(mainGraph == null) {
            return;
        } else {
            mainGraph.processMenuEvent(popupMenu, e.getX(), e.getY());
            return;
        }
    }

    void this_mouseLeftDblClicked(MouseEvent e) {
        if(mainGraph == null)
            return;
        if(mainGraph.MouseLeftDblClicked(e.getX(), e.getY()))
            repaint();
    }

    void this_mouseMoved(MouseEvent e) {
        if(mainGraph == null)
            return;
        if(mainGraph.MouseMoved(e.getX(), e.getY()))
            repaint();
    }

    void this_mouseDragged(MouseEvent e) {
        if(mainGraph == null)
            return;
        if(mainGraph.MouseDragged(e.getX(), e.getY()))
            repaint();
    }

    void this_componentResized(ComponentEvent e) {
        Dimension d = getSize();
        m_rcMain = new Rectangle(d);
        m_rcBottom = new Rectangle(d);
        m_rcMain.height -= 20;
        m_rcBottom.y = m_rcMain.y + m_rcMain.height;
        m_rcBottom.height = 20;
        if(mainGraph != null)
            mainGraph.m_rc = m_rcMain;
        if(bottomGraph != null)
            bottomGraph.rc = m_rcBottom;
    }

    void QueryStock(String sCode) {
        strCurrentCode = sCode;
        if(2 == iCurrentPage)
            mainGraph = new Page_KLine(m_rcMain, this);
        else
            mainGraph = new Page_MinLine(m_rcMain, this);
    }

    void UserCommand(String sCmd) {
        if(sCmd.equals("about") && !bAboutDlgShow) {
            Frame f = getParentFrame(this);
            Rectangle rc = getBounds();
            Point p = getLocationOnScreen();
            int x = (p.x + rc.width / 2) - 110;
            int y = (p.y + rc.height / 2) - 60;
            AboutDialog dlg = new AboutDialog(f, this);
            dlg.setBounds(x, y, 220, 120);
            bAboutDlgShow = true;
            dlg.show();
            bAboutDlgShow = false;
            return;
        }
        if(sCmd.startsWith("INDEX_")) {
            strCurrentCode = sCmd.substring(6);
            mainGraph = new Page_KLine(m_rcMain, this);
            return;
        }
        if(sCmd.startsWith("SERIES_")) {
            strCurrentCode = sCmd.substring(7);
            mainGraph = new Page_KLine(m_rcMain, this);
            return;
        }
        if(sCmd.equals("page_history")) {
            UserCommand("70");
            return;
        }
        int iCmd = Integer.parseInt(sCmd);
        if(bDebug != 0)
            System.out.println("sCmd = ==" + iCmd);
        switch(iCmd) {
        case 1: // '\001'
            mainGraph = new Page_Bill(m_rcMain, this);
            break;

        case 5: // '\005'
            OnF5();
            break;

        case 60: // '<'
            mainGraph = new Page_MultiQuote(m_rcMain, this, (byte)1);
            break;

        case 80: // 'P'
            mainGraph = new Page_MarketStatus(m_rcMain, this, (byte)1);
            break;

        case 70: // 'F'
            mainGraph = new Page_History(m_rcMain, this);
            break;
        }
    }

    void ShowMutilQuote(byte stockType) {
        mainGraph = new Page_MultiQuote(m_rcMain, this, stockType);
        repaint();
    }

    void OnF5() {
        if(strCurrentCode.length() == 0)
            return;
        if(1 == iCurrentPage) {
            mainGraph = new Page_KLine(m_rcMain, this);
            iCurrentPage = 2;
        } else {
            mainGraph = new Page_MinLine(m_rcMain, this);
            iCurrentPage = 1;
        }
    }

    void showPageMinLine(String stockCode) {
        strCurrentCode = stockCode;
        mainGraph = new Page_MinLine(m_rcMain, this);
        iCurrentPage = 1;
        repaint();
    }

    void showPageKLine(String stockCode) {
        strCurrentCode = stockCode;
        mainGraph = new Page_KLine(m_rcMain, this);
        iCurrentPage = 2;
        repaint();
    }

    void showPageMinLine() {
        mainGraph = new Page_MinLine(m_rcMain, this);
        iCurrentPage = 1;
        repaint();
    }

    void showPageKLine() {
        mainGraph = new Page_KLine(m_rcMain, this);
        iCurrentPage = 2;
        repaint();
    }

    void repaintBottom() {
        if(bottomGraph != null)
            bottomGraph.Paint();
    }

    void Repaint(Rectangle rc) {
        repaint(rc.x, rc.y, rc.width + 1, rc.height + 1);
    }

    public void focusLost(FocusEvent focusevent) {
    }

    public void focusGained(FocusEvent event) {
        repaint();
    }

    public void update(Graphics g) {
        paint(g);
    }

    public void paint(Graphics g) {
        if(m_rcMain == null)
            return;
        m_bEndPaint = false;
        try {
            m_img = createImage(m_rcMain.width, m_rcMain.height);
        }
        catch(Exception exception) { }
        if(mainGraph != null) {
            Graphics myG = m_img.getGraphics();
            if(myG != null) {
                myG.clearRect(0, 0, m_rcMain.width, m_rcMain.height);
                mainGraph.Paint(myG);
            }
        }
        EndPaint();
        if(bottomGraph != null)
            bottomGraph.Paint();
    }

    public void EndPaint() {
        if(!m_bEndPaint) {
            getGraphics().setPaintMode();
            getGraphics().drawImage(m_img, m_rcMain.x, m_rcMain.y, this);
        }
        m_bEndPaint = true;
    }

    public void destroy() {
        mainGraph.stopFlag = true;
        mainGraph = null;
        bRunning = false;
        httpThread.AskForData(null);
        sendThread.AskForData(null);
        try {
            if(socket != null)
                socket.close();
        }
        catch(IOException e) {
            System.out.println("eroo111");
            e.printStackTrace();
        }
        socket = null;
        httpThread = null;
        receiveThread = null;
        if(bDebug != 0)
            System.out.println("destroy HQApplet ");
    }

    int GetPrecision(String sCode) {
        int iType = getProductType(sCode);
        switch(iType) {
        case 2: // '\002'
        case 3: // '\003'
            return m_iPrecisionIndex;
        }
        return m_iPrecision;
    }

    int getProductType(String code) {
        CodeTable codeTable = (CodeTable)m_htProduct.get(code);
        if(codeTable == null)
            return -1;
        else
            return codeTable.status;
    }

    boolean isIndex(String code) {
        int iType = getProductType(code);
        return iType == 2 || iType == 3;
    }

    String getShowString(String key) {
        String strShow = "";
        try {
            String s = m_resourceBundle.getString(key);
            strShow = new String(s.getBytes("8859_1"), "GB2312");
        }
        catch(Exception exception) { }
        return strShow;
    }

}

⌨️ 快捷键说明

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