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

📄 hqapplet.java

📁 一份java写的期货交易程序
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   HQApplet.java

package gnnt.MEBS.HQApplet;

import gnnt.MEBS.hq.ProductDataVO;
import gnnt.MEBS.hq.TradeTimeVO;
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.io.IOException;
import java.io.PrintStream;
import java.net.Socket;
import java.net.URL;
import java.util.*;

// Referenced classes of package gnnt.MEBS.HQApplet:
//            ProductData, HttpThread, SendThread, ReceiveThread, 
//            RHColor, Page_Bottom, InputDialog, Page_KLine, 
//            Draw_KLine, Page_Main, Common, Page_MarketStatus, 
//            Page_MultiQuote, CodeTable, Page_MinLine, AboutDialog, 
//            Page_Bill, Page_History

public class HQApplet extends Applet
    implements FocusListener
{

    private static final long serialVersionUID = 0x5ba23793a3c0f861L;
    private boolean isStandalone;
    static final int PAGE_MULTIQUOTE = 0;
    static final int PAGE_MINLINE = 1;
    static final int PAGE_KLINE = 2;
    static final int PAGE_F10 = 3;
    static final int PAGE_BILL = 4;
    static final int PAGE_MARKETSTATUS = 5;
    static final int PAGE_HISTORY = 6;
    int iCurrentPage;
    public String strCurrentCode;
    String indexMainCode;
    int m_iKLineCycle;
    String m_strIndicator;
    int m_iCodeDate;
    int m_iCodeTime;
    int m_iDate;
    int m_iTime;
    TradeTimeVO m_timeRange[];
    int m_iMinLineInterval;
    Vector m_codeList;
    Hashtable m_htProduct;
    Vector vProductData;
    ProductDataVO m_quoteList[];
    private Rectangle m_rcMain;
    private Rectangle m_rcBottom;
    Page_Main mainGraph;
    Page_Bottom bottomGraph;
    public static RHColor rhColor = null;
    String strSocketIP;
    int iSocketPort;
    String strURLPath;
    Socket socket;
    SendThread sendThread;
    ReceiveThread receiveThread;
    HttpThread httpThread;
    boolean bRunning;
    PopupMenu popupMenu;
    static int bDebug = 0;
    int iShowBuySellPrice;
    String m_strMarketName;
    int m_bShowIndexAtBottom;
    int m_bShowIndexKLine;
    int m_iPrecision;
    int m_iPrecisionIndex;
    ResourceBundle m_resourceBundle;
    String strLanguageName;
    boolean bInputDlgShow;
    boolean bAboutDlgShow;
    private boolean m_bEndPaint;
    private Image m_img;

    public String getParameter(String key, String def)
    {
        return isStandalone ? System.getProperty(key, def) : getParameter(key) == null ? def : getParameter(key);
    }

    public static void main(String args[])
    {
        final HQApplet applet = new HQApplet();
        applet.isStandalone = true;
        Frame frame = new Frame() {

            private static final long serialVersionUID = 0x5ee6fe2cdea8105dL;

            protected void processWindowEvent(WindowEvent e)
            {
                super.processWindowEvent(e);
                if(e.getID() == 201)
                {
                    applet.destroy();
                    System.exit(0);
                }
            }

            public synchronized void setTitle(String title)
            {
                super.setTitle(title);
                enableEvents(64L);
            }

        };
        frame.setTitle("Applet Frame");
        frame.add(applet, "Center");
        frame.setSize(800, 600);
        Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
        frame.setLocation((d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2);
        frame.setVisible(true);
        applet.init();
        applet.start();
    }

    ProductData GetProductData(String code)
    {
        for(int i = 0; i < vProductData.size(); i++)
            if(((ProductData)vProductData.elementAt(i)).sCode.equals(code))
                return (ProductData)vProductData.elementAt(i);

        return null;
    }

    public HQApplet()
    {
        isStandalone = false;
        iCurrentPage = -1;
        strCurrentCode = "";
        indexMainCode = "";
        m_iKLineCycle = 1;
        m_strIndicator = "ORDER";
        m_iDate = 0;
        m_iTime = 0;
        m_timeRange = null;
        m_iMinLineInterval = 60;
        m_codeList = new Vector();
        m_htProduct = new Hashtable();
        vProductData = new Vector();
        m_quoteList = new ProductDataVO[0];
        m_rcMain = null;
        m_rcBottom = null;
        mainGraph = null;
        bottomGraph = null;
        socket = null;
        bRunning = true;
        popupMenu = new PopupMenu();
        m_strMarketName = "";
        m_bShowIndexAtBottom = 1;
        m_bShowIndexKLine = 0;
        m_iPrecision = 0;
        m_iPrecisionIndex = 2;
        strLanguageName = "zh";
        bInputDlgShow = false;
        bAboutDlgShow = false;
        System.out.println("new HQApplet ");
    }

    public void init()
    {
        bRunning = true;
        try
        {
            jbInit();
        }
        catch(Exception e)
        {
            if(bDebug != 0)
                e.printStackTrace();
        }
        if(bDebug != 0)
            System.out.println("init HQApplet ");
    }

    private void jbInit()
        throws Exception
    {
        if(isStandalone)
        {
            strSocketIP = "172.16.2.214";
            iSocketPort = 8002;
            strURLPath = "http://" + strSocketIP + ":80/hqApplet/";
            iShowBuySellPrice = 3;
        } else
        {
            URL url = getDocumentBase();
            strSocketIP = url.getHost();
            iSocketPort = Integer.parseInt(getParameter("Port", "888"));
            strURLPath = url.toString();
            strURLPath = strURLPath.substring(0, strURLPath.lastIndexOf(47) + 1);
            bDebug = Integer.parseInt(getParameter("Debug", "0"));
            iShowBuySellPrice = Integer.parseInt(getParameter("ShowBuySell", "3"));
            if(iShowBuySellPrice > 5 || iShowBuySellPrice <= 0)
                iShowBuySellPrice = 3;
            m_strMarketName = getParameter("MarketName", "");
            m_bShowIndexAtBottom = Integer.parseInt(getParameter("ShowIndexAtBottom", "1"));
            strLanguageName = getParameter("Language", "zh");
            m_iPrecision = Integer.parseInt(getParameter("Precision", "0"));
            m_iPrecisionIndex = Integer.parseInt(getParameter("IndexPrecision", "2"));
            m_bShowIndexKLine = Integer.parseInt(getParameter("ShowIndexKLine", "0"));
        }
        try
        {
            m_resourceBundle = ResourceBundle.getBundle("rc/string", new Locale(strLanguageName, ""));
        }
        catch(Exception e)
        {
            System.out.println("Language resource loaded failed !");
            e.printStackTrace();
        }
        m_rcMain = null;
        (new HttpThread(0, this)).start();
        sendThread = new SendThread(this);
        sendThread.start();
        receiveThread = new ReceiveThread(this);
        receiveThread.start();
        httpThread = new HttpThread(1, this);
        httpThread.start();
        String strColorStyle = getParameter("ColorStyle", "0");
        rhColor = new RHColor(Integer.parseInt(strColorStyle));
        setBackground(rhColor.clBackGround);
        addComponentListener(new ComponentAdapter() {

            public void componentResized(ComponentEvent e)
            {
                this_componentResized(e);
            }

        });
        addKeyListener(new KeyAdapter() {

            public void keyPressed(KeyEvent e)
            {
                int iKey = e.getKeyCode();
                if(iKey != 33 && iKey != 34)
                    this_keyPressed(e);
            }

            public void keyReleased(KeyEvent e)
            {
                int iKey = e.getKeyCode();
                if(iKey == 33 || iKey == 34)
                    this_keyPressed(e);
            }

        });
        addMouseListener(new MouseAdapter() {

            public void mousePressed(MouseEvent e)
            {
                if(e.getModifiers() != 4 && e.getClickCount() == 1)
                    this_mouseLeftPressed(e);
            }

            public void mouseReleased(MouseEvent e)
            {
                if(e.getModifiers() == 4)
                    this_mouseRightReleased(e);
            }

            public void mouseClicked(MouseEvent e)
            {
                if(e.getModifiers() != 4 && e.getClickCount() > 1)
                    this_mouseLeftDblClicked(e);
            }

        });
        addMouseMotionListener(new MouseMotionAdapter() {

            public void mouseMoved(MouseEvent e)
            {
                this_mouseMoved(e);
            }

            public void mouseDragged(MouseEvent e)
            {
                if(e.getModifiers() != 4)
                    this_mouseDragged(e);
            }

        });
        addFocusListener(this);
        this_componentResized(null);
        bottomGraph = new Page_Bottom(getGraphics(), m_rcBottom, this);
        requestFocus();
        add(popupMenu);
        popupMenu.addActionListener(mainGraph);
        strCurrentCode = getParameter("CurrentCode", "");
        if(strCurrentCode.length() == 0)
        {
            UserCommand("60");
        } else
        {
            String strPage = getParameter("CurrentPage", "MinLinePage");
            if(strPage.equalsIgnoreCase("MinLine"))
                showPageMinLine();
            else
            if(strPage.equalsIgnoreCase("KLine"))
            {
                showPageMinLine();
                try
                {
                    Thread.sleep(1000L);
                }
                catch(InterruptedException interruptedexception) { }
                showPageKLine();
            } else
            {
                UserCommand("60");
            }
        }
    }

    public String getAppletInfo()
    {
        return "Applet Information 金网安泰";
    }

    public String[][] getParameterInfo()
    {
        return null;
    }

    public Frame getParentFrame(Component c)
    {
        Frame mainFrame = null;
        Container dad;
        for(dad = c.getParent(); !(dad instanceof Frame) && dad != null; dad = dad.getParent());
        if(dad instanceof Frame)
            mainFrame = (Frame)dad;
        return mainFrame;
    }

    void this_keyPressed(KeyEvent e)
    {
        if(bInputDlgShow)
            return;
        char ch = e.getKeyChar();
        if(Character.isLetterOrDigit(ch))
        {
            Frame f = getParentFrame(this);
            Rectangle rc = getBounds();
            Point p = getLocationOnScreen();
            int x = (p.x + rc.width) - 125;
            int y = (p.y + rc.height) - 160;
            InputDialog dlg = new InputDialog(f, ch, this);
            dlg.setBounds(x, y, 125, 160);
            bInputDlgShow = true;
            dlg.show();
            bInputDlgShow = false;
            String str = dlg.strCmd;
            if(str == null || str.length() == 0)
                return;
            switch(str.charAt(0))
            {
            case 65: // 'A'
                UserCommand(str.substring(1));
                break;

            case 84: // 'T'
                m_strIndicator = str.substring(1);
                ((Page_KLine)mainGraph).draw_KLine.CreateIndicator();
                repaint();
                break;

            case 67: // 'C'
                rhColor = new RHColor(str.charAt(1) - 48);
                setBackground(rhColor.clBackGround);
                break;

            case 80: // 'P'
                QueryStock(str.substring(1));
                break;
            }
            repaint();
            return;
        }
        boolean bNeedRepaint = true;
        int iKey = e.getKeyCode();
        switch(iKey)
        {
        case 27: // '\033'
            if(mainGraph != null)
            {
                bNeedRepaint = mainGraph.KeyPressed(e);

⌨️ 快捷键说明

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