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

📄 page_multiquote.java

📁 java 写的股票技术分析;软件
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
// NMI's Java Code Viewer 6.0a
// www.trinnion.com/javacodeviewer

// Registered to Evaluation Copy                                      
// Generated PGFZKD AyTB 14 2007 15:44:19 

//source File Name:   Page_MultiQuote.java

package gnnt.MEBS.HQApplet;

import gnnt.MEBS.hq.ProductDataVO;
import gnnt.util.service.HQVO.CMDSortVO;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.io.PrintStream;
import java.util.Hashtable;

// Referenced classes of package gnnt.MEBS.HQApplet:
//            Page_Main, MenuListener, HQApplet, SendThread, 
//            MultiQuoteItemInfo, Common, RHColor, Packet_MultiQuote, 
//            Arrays, CodeTable

class Page_MultiQuote extends Page_Main {

    static byte flag = 0;
    ProductDataVO backQuoteData[];
    private int iDynamicIndex;
    String strSortItem;
    int iHighlightIndex;
    int iStockRows;
    Font font;
    Font fontTitle;
    FontMetrics fm;
    int fontHeight;
    private static final int TITLE_GAP = 2;
    boolean bCanMove;
    byte currentStockType;
    byte sortBy;
    byte isDescend;
    int iStart;
    private int iEnd;
    boolean bShowUserStock;
    String iUserStockCode[];
    String backIUserStockCode[];
    Packet_MultiQuote packetInfo;
    ProductDataVO quoteData[];
    private Hashtable m_htItemInfo;
    private String m_strItems[];
    private int m_iStaticIndex;
    Menu menuStockRank;
    MenuItem menuMarket;
    MenuItem menuPageMinLine;
    MenuItem menuPageKLine;
    boolean m_bShowSortTag;

    void AskForDataOnTimer() {
        setSortStockRequestPacket();
    }

    private void setSortStockRequestPacket() {
        CMDSortVO packet = new CMDSortVO();
        packet.isDescend = isDescend;
        packet.sortBy = sortBy;
        if(iStart == iEnd)
            iEnd = iStart + 1;
        packet.start = iStart;
        packet.end = iEnd;
        HQApplet _tmp = super.m_applet;
        if(HQApplet.bDebug != 0)
            System.out.println("\u53D6\u62A5\u4EF7\u6392\u540DStart = " + iStart + "  End = " + iEnd);
        super.m_applet.sendThread.AskForData(packet);
    }

    private void setUserStockRequestPacket() {
    }

    public Page_MultiQuote(Rectangle _rc, HQApplet applet, byte currentStockType) {
        super(_rc, applet);
        strSortItem = "Code";
        iHighlightIndex = 1;
        font = new Font("\u5B8B\u4F53", 0, 16);
        fontTitle = new Font("\u5B8B\u4F53", 1, 16);
        bCanMove = true;
        sortBy = 0;
        isDescend = 0;
        iStart = 1;
        iEnd = 30;
        m_bShowSortTag = false;
        super.m_applet.iCurrentPage = 0;
        this.currentStockType = currentStockType;
        initStockFieldInfo();
        calculateRowsOfPage();
        iStart = 1;
        iEnd = iStockRows;
        flag = 0;
        setUserStockCode();
        if(this.currentStockType == 0) {
            initUserStockArray();
            bShowUserStock = true;
        }
        AskForDataOnTimer();
        makeMenus();
        setMenuEnable(this.currentStockType, false);
    }

    void initStockFieldInfo() {
        m_htItemInfo = new Hashtable();
        m_htItemInfo.put("No", new MultiQuoteItemInfo("", 20, -1));
        m_htItemInfo.put("Name", new MultiQuoteItemInfo(super.m_applet.getShowString("Name"), 80, -1));
        m_htItemInfo.put("Code", new MultiQuoteItemInfo(super.m_applet.getShowString("Code"), 64, 0));
        m_htItemInfo.put("CurPrice", new MultiQuoteItemInfo(super.m_applet.getShowString("Newly"), 60, 1));
        m_htItemInfo.put("CurAmount", new MultiQuoteItemInfo(super.m_applet.getShowString("CurVol"), 60, -1));
        m_htItemInfo.put("SellPrice", new MultiQuoteItemInfo(super.m_applet.getShowString("SellPrice"), 60, -1));
        m_htItemInfo.put("SellAmount", new MultiQuoteItemInfo(super.m_applet.getShowString("SellVol"), 48, -1));
        m_htItemInfo.put("BuyPrice", new MultiQuoteItemInfo(super.m_applet.getShowString("BuyPrice"), 60, -1));
        m_htItemInfo.put("BuyAmount", new MultiQuoteItemInfo(super.m_applet.getShowString("BuyVol"), 48, -1));
        m_htItemInfo.put("TotalAmount", new MultiQuoteItemInfo(super.m_applet.getShowString("Volume"), 75, 9));
        m_htItemInfo.put("UpValue", new MultiQuoteItemInfo(super.m_applet.getShowString("ChangeValue"), 65, 2));
        m_htItemInfo.put("UpRate", new MultiQuoteItemInfo(super.m_applet.getShowString("ChangeRate"), 65, 3));
        m_htItemInfo.put("ReverseCount", new MultiQuoteItemInfo(super.m_applet.getShowString("Order"), 70, -1));
        m_htItemInfo.put("Balance", new MultiQuoteItemInfo(super.m_applet.getShowString("Balance"), 60, -1));
        m_htItemInfo.put("OpenPrice", new MultiQuoteItemInfo(super.m_applet.getShowString("Open"), 55, -1));
        m_htItemInfo.put("HighPrice", new MultiQuoteItemInfo(super.m_applet.getShowString("High"), 55, -1));
        m_htItemInfo.put("LowPrice", new MultiQuoteItemInfo(super.m_applet.getShowString("Low"), 55, -1));
        m_htItemInfo.put("YesterBalance", new MultiQuoteItemInfo(super.m_applet.getShowString("PreBalance"), 60, -1));
        m_htItemInfo.put("TotalMoney", new MultiQuoteItemInfo(super.m_applet.getShowString("Money"), 80, 6));
        m_htItemInfo.put("AmountRate", new MultiQuoteItemInfo(super.m_applet.getShowString("VolRate"), 50, 5));
        m_htItemInfo.put("ConsignRate", new MultiQuoteItemInfo(super.m_applet.getShowString("ConsignRate"), 50, 7));
        m_htItemInfo.put("Unit", new MultiQuoteItemInfo(super.m_applet.getShowString("Unit"), 40, -1));
        String strItemName = super.m_applet.getParameter("MultiQuoteName", "Name:;Code:;CurPrice:;CurAmount:;SellPrice:;SellAmount:;BuyPrice:;BuyAmount:;TotalAmount:;UpValue:;UpRate:;ReverseCount:;Balance:;OpenPrice:;HighPrice:;LowPrice:;YesterBalance:;TotalMoney:;AmountRate:;ConsignRate:;Unit:;");
        String strItemNames[] = Common.split(strItemName, 59);
        for(int i = 0; i < strItemNames.length; i++) {
            String str[] = Common.split(strItemNames[i], 58);
            if(str.length == 2 && str[1].length() > 0) {
                MultiQuoteItemInfo itemInfo = (MultiQuoteItemInfo)m_htItemInfo.get(str[0]);
                if(itemInfo != null)
                    itemInfo.name = str[1];
            }
        }

        String strItems = super.m_applet.getParameter("MultiQuoteItems", "No;Name;Code;CurPrice;CurAmount;SellPrice;SellAmount;BuyPrice;BuyAmount;TotalAmount;UpValue;ReverseCount;Balance;OpenPrice;HighPrice;LowPrice;YesterBalance;");
        m_strItems = Common.split(strItems, 59);
        m_iStaticIndex = Integer.parseInt(super.m_applet.getParameter("MultiQuoteStaticIndex", "3"));
        iDynamicIndex = m_iStaticIndex + 1;
    }

    private void initGraph(Graphics g) {
        fm = g.getFontMetrics(font);
        fontHeight = fm.getHeight();
        g.setFont(font);
    }

    private void calculateRowsOfPage() {
        int gap = 2;
        Graphics g = super.m_applet.getGraphics();
        fm = g.getFontMetrics(font);
        fontHeight = fm.getHeight();
        iStockRows = super.m_rc.height / (fontHeight + gap) - 1;
        if(iStockRows < 1)
            iStockRows = 25;
        iEnd = (iStart + iStockRows) - 1;
    }

    void Paint(Graphics g) {
        bCanMove = true;
        initGraph(g);
        calculateRowsOfPage();
        paintTitleItems(g);
        paintQuoteData(g);
        super.m_applet.EndPaint();
        paintHighlightBar();
    }

    void paintTitleItems(Graphics g) {
        int x = super.m_rc.x;
        int y = super.m_rc.y + fm.getAscent();
        g.setColor(HQApplet.rhColor.clMultiQuote_TitleBack);
        g.fillRect(super.m_rc.x, super.m_rc.y, super.m_rc.width, fontHeight);
        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;
            String strName = info.name;
            if(m_bShowSortTag && strSortItem.equals(m_strItems[i])) {
                if(isDescend == 1) {
                    g.setColor(HQApplet.rhColor.clIncrease);
                    strName = strName + "\u2193";
                } else {
                    g.setColor(HQApplet.rhColor.clHighlight);
                    strName = strName + "\u2191";
                }
            } else {
                g.setColor(HQApplet.rhColor.clItem);
            }
            x += info.width;
            int strLen = fm.stringWidth(strName);
            g.drawString(strName, x - strLen, y);
            if(x > super.m_rc.x + super.m_rc.width)
                break;
        }

    }

    void paintQuoteData(Graphics g) {
        if(bShowUserStock && iUserStockCode.length == 0) {
            paintPromptMessage(g);
            return;
        }
        if(packetInfo == null || quoteData == null)
            return;
        g.setFont(font);
        if(!bShowUserStock && (packetInfo.iStart != iStart || packetInfo.isDescend != isDescend || packetInfo.sortBy != getSortByField(strSortItem) || packetInfo.currentStockType != currentStockType))
            return;
        if(bShowUserStock) {
            Arrays.sort(quoteData, strSortItem);
            if(isDescend == 0) {
                int size = quoteData.length;
                int count = size / 2;
                for(int i = 0; i < count; i++) {
                    ProductDataVO tmp = quoteData[i];
                    quoteData[i] = quoteData[size - i - 1];
                    quoteData[size - i - 1] = tmp;
                }

            }
        }
        int gap = 2;
        int x = super.m_rc.x;
        int y = super.m_rc.y + fontHeight + 2 + fm.getAscent();
        int count = iStockRows;
        if(quoteData.length < iStockRows)
            count = quoteData.length;
        for(int i = 0; i < count; i++) {
            int num = iStart + i;
            ProductDataVO data = quoteData[i];
            if(data.code == null) {
                System.out.println("Code = null");
            } else {
                CodeTable stockTable = (CodeTable)super.m_applet.m_htProduct.get(data.code);
                String stockName = "-";
                if(stockTable != null) {
                    if(stockTable.sName != null)
                        stockName = stockTable.sName;
                    else
                        System.out.println("stockTable.sName = null");
                } else {
                    System.out.println(" stockTable = null ");
                }
                int iPrecision = super.m_applet.GetPrecision(data.code);
                float close = data.yesterBalancePrice;
                int strLen = 0;
                for(int j = 0; j < m_strItems.length; j++) {
                    if(j > m_iStaticIndex && j < iDynamicIndex)
                        continue;
                    MultiQuoteItemInfo info = (MultiQuoteItemInfo)m_htItemInfo.get(m_strItems[j]);
                    if(info == null)
                        continue;
                    x += info.width;
                    if(m_strItems[j].equals("No")) {
                        String strText = String.valueOf(num);
                        g.setColor(HQApplet.rhColor.clNumber);
                        strLen = fm.stringWidth(strText);
                        g.drawString(strText, x - strLen, y);
                    } else
                    if(m_strItems[j].equals("Name")) {
                        String strText = stockName;
                        g.setColor(HQApplet.rhColor.clProductName);
                        strLen = fm.stringWidth(strText);
                        g.drawString(strText, x - strLen, y);
                    } else
                    if(m_strItems[j].equals("Code")) {
                        String strText = data.code;
                        g.setColor(HQApplet.rhColor.clProductName);
                        strLen = fm.stringWidth(strText);
                        g.drawString(strText, x - strLen, y);
                    } else
                    if(m_strItems[j].equals("CurPrice"))
                        paintNumber(g, data.curPrice, "", m_strItems[j], iPrecision, close, x, y);
                    else
                    if(m_strItems[j].equals("Balance"))
                        paintNumber(g, data.balancePrice, "", m_strItems[j], iPrecision, close, x, y);
                    else
                    if(m_strItems[j].equals("UpValue")) {
                        float up = close == 0.0F || data.curPrice == 0.0F ? 0.0F : data.curPrice - close;
                        paintNumber(g, up, "", m_strItems[j], 0, close, x, y);
                    } else
                    if(m_strItems[j].equals("UpRate")) {
                        float upRate = close <= 0.0F || data.curPrice <= 0.0F ? 0.0F : ((data.curPrice - close) / close) * 100F;
                        paintNumber(g, upRate, "", m_strItems[j], 2, 0.0F, x, y);
                    } else
                    if(m_strItems[j].equals("YesterBalance"))
                        paintNumber(g, data.yesterBalancePrice, "", m_strItems[j], iPrecision, close, x, y);
                    else
                    if(m_strItems[j].equals("OpenPrice"))
                        paintNumber(g, data.openPrice, "", m_strItems[j], iPrecision, close, x, y);
                    else
                    if(m_strItems[j].equals("BuyPrice"))
                        paintNumber(g, data.buyPrice[0], "", m_strItems[j], iPrecision, close, x, y);
                    else
                    if(m_strItems[j].equals("SellPrice"))
                        paintNumber(g, data.sellPrice[0], "", m_strItems[j], iPrecision, close, x, y);
                    else
                    if(m_strItems[j].equals("BuyAmount"))
                        paintNumber(g, data.buyAmount[0], "", m_strItems[j], 0, close, x, y);
                    else
                    if(m_strItems[j].equals("SellAmount"))
                        paintNumber(g, data.sellAmount[0], "", m_strItems[j], 0, close, x, y);
                    else
                    if(m_strItems[j].equals("HighPrice"))
                        paintNumber(g, data.highPrice, "", m_strItems[j], iPrecision, close, x, y);
                    else
                    if(m_strItems[j].equals("LowPrice"))
                        paintNumber(g, data.lowPrice, "", m_strItems[j], iPrecision, close, x, y);
                    else
                    if(m_strItems[j].equals("TotalAmount"))
                        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") && super.m_applet.m_strMarketName.equalsIgnoreCase("Anhui")) {
                        String strText;
                        if(data.code.startsWith("G"))
                            strText = "\u5355";
                        else
                        if(data.code.startsWith("X"))
                            strText = "\u6279";
                        else
                            strText = "";
                        g.setColor(HQApplet.rhColor.clProductName);
                        strLen = fm.stringWidth(strText);
                        g.drawString(strText, x - strLen, y);
                    }
                    if(x > super.m_rc.x + super.m_rc.width)
                        break;
                }

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

    }

⌨️ 快捷键说明

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