page_marketstatus.java

来自「java 写的股票技术分析;软件」· Java 代码 · 共 494 行 · 第 1/2 页

JAVA
494
字号
// 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_MarketStatus.java

package gnnt.MEBS.HQApplet;

import gnnt.util.service.HQVO.CMDMarketSortVO;
import gnnt.util.service.HQVO.MarketStatusVO;
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, 
//            RHColor, Pos, CodeTable, Common, 
//            Packet_MarketStatus

public class Page_MarketStatus extends Page_Main {

    byte currentStockType;
    int iCount;
    int iHighlightRowIndex;
    int iHighlightColIndex;
    static Pos pos[][];
    Font font;
    FontMetrics fm;
    MenuItem menuQuote;
    MenuItem menuMinLine;
    MenuItem menuKLine;
    static final int RANK_RATE = 0;
    static final int RANK_AMOUNTRATE = 5;
    static final int RANK_CONSIGNRATE = 6;
    static final int RANK_TOTALMONEY = 8;
    static String STOCK_RANK_NAME[][];
    Packet_MarketStatus packetInfo;
    MarketStatusVO statusData[];

    void AskForDataOnTimer() {
        CMDMarketSortVO packet = new CMDMarketSortVO();
        iCount = getICount();
        packet.num = iCount;
        super.m_applet.sendThread.AskForData(packet);
    }

    public Page_MarketStatus(Rectangle _rc, HQApplet applet, byte currentStockType) {
        super(_rc, applet);
        iCount = 7;
        iHighlightRowIndex = 0;
        iHighlightColIndex = 0;
        font = new Font("\u5B8B\u4F53", 0, 16);
        statusData = null;
        super.m_applet.iCurrentPage = 5;
        this.currentStockType = currentStockType;
        AskForDataOnTimer();
        makeMenus();
        setMenuEnable(this.currentStockType, false);
        STOCK_RANK_NAME = new String[3][3];
        STOCK_RANK_NAME[0][0] = super.m_applet.getShowString("UpRateList");
        STOCK_RANK_NAME[1][0] = super.m_applet.getShowString("DownRateList");
        STOCK_RANK_NAME[2][0] = super.m_applet.getShowString("SwingList");
        STOCK_RANK_NAME[0][1] = super.m_applet.getShowString("5MinUpRateList");
        STOCK_RANK_NAME[1][1] = super.m_applet.getShowString("5MinDownRateList");
        STOCK_RANK_NAME[2][1] = super.m_applet.getShowString("VolRateList");
        STOCK_RANK_NAME[0][2] = super.m_applet.getShowString("ConsignRateDesc");
        STOCK_RANK_NAME[1][2] = super.m_applet.getShowString("ConsignRateAsce");
        STOCK_RANK_NAME[2][2] = super.m_applet.getShowString("MoneyList");
    }

    void Paint(Graphics g) {
        if(statusData != null) {
            HQApplet _tmp = super.m_applet;
            if(HQApplet.bDebug != 0) {
                System.out.println("this.iCount = " + iCount);
                System.out.println("statusData.length / 9 = " + statusData.length / 9);
            }
        }
        initilizer(g);
        paintGrid(g);
        paintTitle(g);
        paintStockData(g);
        super.m_applet.EndPaint();
        paintHighlight(iHighlightRowIndex, iHighlightColIndex);
    }

    void paintGrid(Graphics g) {
        this.fm = g.getFontMetrics(this.font);
        Font font = new Font("\u5B8B\u4F53", 0, 16);
        FontMetrics fm = g.getFontMetrics(font);
        g.setColor(HQApplet.rhColor.clEqual);
        g.drawRect(super.m_rc.x, super.m_rc.y, super.m_rc.width - 1, super.m_rc.height - 2);
        int fontHeight = fm.getHeight() + 2;
        g.drawLine(super.m_rc.x, super.m_rc.y + fontHeight, super.m_rc.x + super.m_rc.width, super.m_rc.y + fontHeight);
        g.drawLine(super.m_rc.x, super.m_rc.y + super.m_rc.height / 3, super.m_rc.x + super.m_rc.width, super.m_rc.y + super.m_rc.height / 3);
        g.drawLine(super.m_rc.x, super.m_rc.y + super.m_rc.height / 3 + fontHeight, super.m_rc.x + super.m_rc.width, super.m_rc.y + super.m_rc.height / 3 + fontHeight);
        g.drawLine(super.m_rc.x, super.m_rc.y + (super.m_rc.height / 3) * 2, super.m_rc.x + super.m_rc.width, super.m_rc.y + (super.m_rc.height / 3) * 2);
        g.drawLine(super.m_rc.x, super.m_rc.y + (super.m_rc.height / 3) * 2 + fontHeight, super.m_rc.x + super.m_rc.width, super.m_rc.y + (super.m_rc.height / 3) * 2 + fontHeight);
        g.drawLine(super.m_rc.x + super.m_rc.width / 3, super.m_rc.y, super.m_rc.x + super.m_rc.width / 3, (super.m_rc.y + super.m_rc.height) - 2);
        g.drawLine(super.m_rc.x + (super.m_rc.width / 3) * 2, super.m_rc.y, super.m_rc.x + (super.m_rc.width / 3) * 2, (super.m_rc.y + super.m_rc.height) - 2);
    }

    void paintTitle(Graphics g) {
        int x = super.m_rc.x;
        int y = super.m_rc.y;
        int blockWidth = super.m_rc.width / 3;
        int blockHeight = super.m_rc.height / 3;
        Font font = new Font("\u5B8B\u4F53", 0, 16);
        FontMetrics fm = g.getFontMetrics(font);
        g.setFont(font);
        for(int i = 0; i < 3; i++) {
            for(int j = 0; j < 3; j++) {
                String str = STOCK_RANK_NAME[i][j];
                int strWidth = fm.stringWidth(str);
                int hgap = 0;
                if(blockWidth > strWidth)
                    hgap = (blockWidth - strWidth) / 2;
                g.setColor(HQApplet.rhColor.clMultiQuote_TitleBack);
                g.fillRect(x + 1, y + 1, super.m_rc.width / 3 - 1, fm.getHeight() + 1);
                g.setColor(HQApplet.rhColor.clItem);
                g.drawString(str, x + hgap, y + fm.getAscent() + 2);
                x += super.m_rc.width / 3;
            }

            x = super.m_rc.x;
            y += super.m_rc.height / 3;
        }

    }

    void paintHighlight(int newRowIndex, int newColIndex) {
        if(newRowIndex >= iCount * 3)
            return;
        Graphics g = super.m_applet.getGraphics();
        Font font = new Font("\u5B8B\u4F53", 0, 16);
        FontMetrics fm = g.getFontMetrics(font);
        if(iCount <= 0)
            return;
        Pos oldPos = null;
        if(iHighlightRowIndex < iCount * 3)
            oldPos = pos[iHighlightRowIndex][iHighlightColIndex];
        Pos newPos = null;
        if(newRowIndex < iCount * 3)
            newPos = pos[newRowIndex][newColIndex];
        g.setColor(HQApplet.rhColor.clBackGround);
        g.setXORMode(HQApplet.rhColor.clHighlight);
        if(oldPos != null)
            g.fillRect(oldPos.x, oldPos.y, super.m_rc.width / 3, fm.getHeight());
        if(iHighlightRowIndex != newRowIndex || iHighlightColIndex != newColIndex) {
            if(newPos != null)
                g.fillRect(newPos.x, newPos.y, super.m_rc.width / 3, fm.getHeight());
            iHighlightRowIndex = newRowIndex;
            iHighlightColIndex = newColIndex;
        }
        g.setPaintMode();
    }

    boolean KeyPressed(KeyEvent e) {
        if(packetInfo == null || statusData == null)
            return false;
        int iKeyCode = e.getKeyCode();
        switch(iKeyCode) {
        default:
            break;

        case 38: // '&'
        {
            if(iHighlightRowIndex <= 0)
                break;
            int i;
            for(i = 1; iHighlightRowIndex - i >= 0 && getIndexOfStatusDataArray(iHighlightRowIndex - i, iHighlightColIndex) < 0; i++);
            paintHighlight(iHighlightRowIndex - i, iHighlightColIndex);
            break;
        }

        case 40: // '('
        {
            if(iHighlightRowIndex >= 3 * iCount - 1)
                break;
            int i;
            for(i = 1; iHighlightRowIndex + i <= 3 * iCount - 1 && getIndexOfStatusDataArray(iHighlightRowIndex + i, iHighlightColIndex) < 0; i++);
            paintHighlight(iHighlightRowIndex + i, iHighlightColIndex);
            break;
        }

        case 37: // '%'
        {
            if(iHighlightColIndex > 0)
                paintHighlight(iHighlightRowIndex, iHighlightColIndex - 1);
            break;
        }

        case 39: // '\''
        {
            if(iHighlightColIndex < 2)
                paintHighlight(iHighlightRowIndex, iHighlightColIndex + 1);
            break;
        }

        case 10: // '\n'
        {
            int index = getIndexOfStatusDataArray(iHighlightRowIndex, iHighlightColIndex);
            if(index >= 0)
                super.m_applet.QueryStock(statusData[index].code);
            break;
        }
        }
        return false;
    }

    void initilizer(Graphics g) {
        FontMetrics fm = g.getFontMetrics(font);
        int x = super.m_rc.x;
        int fontHeight = fm.getHeight() + 2;
        int y = super.m_rc.y + fontHeight + 2;
        int temp = (super.m_rc.height / 3 - (fontHeight + 2)) / fontHeight;
        if(iCount > temp)
            iCount = temp;
        if(iCount <= 0)
            return;
        pos = new Pos[iCount * 3][3];
        for(int i = 0; i < iCount * 3; i++) {
            for(int j = 0; j < 3; j++) {
                pos[i][j] = new Pos();
                pos[i][j].x = x;
                pos[i][j].y = y;
                x += super.m_rc.width / 3;
            }

            x = super.m_rc.x;
            if(i == iCount - 1)
                y = super.m_rc.y + super.m_rc.height / 3 + fontHeight + 2;
            else
            if(i == 2 * iCount - 1)
                y = super.m_rc.y + (super.m_rc.height / 3) * 2 + fontHeight + 2;
            else
                y += fontHeight;
        }

    }

    private int getICount() {
        Graphics g = super.m_applet.getGraphics();

⌨️ 快捷键说明

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