/*
############################################################################
#
#   DOS/V & Mac  Java 1.0 AWT
#   Use    HACCP 総合情報検索システム
#
############################################################################
#
# Edition History
#
#  #   date    comments                                                 by
# -------------------------------------------------------------------------
# 00 04-02-02  Create.                                                 M.T
#
############################################################################
#
#   Purpose     メインフレーム()
#
############################################################################
*/

import javax.swing.tree.*;
import javax.swing.event.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
import java.util.*;
import java.io.*;
import java.lang.*;
import java.awt.Toolkit;
import java.awt.Image;
/*--------------------------------------------------------------------*/
// スプラッシュ画面
/*--------------------------------------------------------------------*/
class RollImage extends java.awt.Window implements MouseListener{
    private Image bk_img;
    private int sx;
    private int sy;
    private Haccp   frame;

    /** Creates new form testdlg */
    public RollImage(java.awt.Frame parent, Image img, int w, int h) {
        super (parent);
        this.prepareImage(img, this);
        frame = (Haccp)parent;
        this.addMouseListener(this);
        bk_img = img;
        Dimension dim = getToolkit().getScreenSize();
        this.setLocation((dim.width - w )/2, (dim.height - h )/2 );
        this.setSize(w,h);
    }
    public boolean imageUpdate( Image image, int flag,
                  int x, int y, int width, int height ) {
        if( (flag & ALLBITS) == ALLBITS ) {
            this.setSize( width, height );
            this.repaint();
        }
        return true;
    }

    public void paint( java.awt.Graphics g ){
        if( bk_img != null )g.drawImage( bk_img, 0,0, this );
    }
    public void mouseReleased(java.awt.event.MouseEvent p1) {
        setVisible (false);
        dispose ();
        frame.TimerSub(null);
    }
    public void mouseClicked(java.awt.event.MouseEvent p1) {
    }
    public void mouseEntered(java.awt.event.MouseEvent p1) {
    }
    public void mousePressed(java.awt.event.MouseEvent p1) {
    }
    public void mouseExited(java.awt.event.MouseEvent p1) {
    }
}
/*--------------------------------------------------------------------*/
// 文字列変換
/*--------------------------------------------------------------------*/
class FormatBuff extends Object{
    private String p_Data;
    public FormatBuff(String a){
        p_Data = a;
    }
    public FormatBuff(String fmt, String a ){
        p_Data = convert(fmt,a);
    }
    public String toString(){
        return p_Data;
    }
    // 文字列区切り
    public int descript( String d, StringBuffer data ){
        int     i,j;

        if( d == null )return data.length();

        for( i = 0 ; i < data.length() ;i++ ){
            for( j = 0 ; j < d.length() ;j++ ){
                if( d.charAt(j) != data.charAt(i) )continue;
                data.deleteCharAt(i);
                break;
            }
            if( j < d.length() )break;
        }
        return i;
    }
    // 書式変換
    public String convert( String fmt, String a ){
        int     i;
        int     j;
        String  s;
        String  d;

        StringBuffer sb = new StringBuffer(a);
        StringBuffer nb = new StringBuffer();
        d = null;
        i = fmt.lastIndexOf("-d");
        if( i > 0 ){
            d = fmt.substring(i+2);
            fmt = fmt.substring(0,i-1);
        }
        for( i = 0 ; i < fmt.length() ;i++ ){
            switch( fmt.charAt(i) ){
            case 'A':
            case 'S':
            case 'C':
                for( j = i ; j < fmt.length() ;j++ ){
                    if( fmt.charAt(j) == 'A' )continue;
                    if( fmt.charAt(j) == 'S' )continue;
                    if( fmt.charAt(j) == 'C' )continue;
                    break;
                }
                s = chara( fmt.substring(i,j), sb, descript(d,sb) );
                if( s != null )nb.append(s);
                i = j-1;
                break;
            case '9':
            case 'Z':
            case '#':
                for( j = i ; j < fmt.length() ;j++ ){
                    if( fmt.charAt(j) == '9' )continue;
                    if( fmt.charAt(j) == 'Z' )continue;
                    if( fmt.charAt(j) == '#' )continue;
                    if( fmt.charAt(j) == ',' )continue;
                    break;
                }
                s = numeric( fmt.substring(i,j), sb, descript(d,sb) );
                if( s != null )nb.append(s);
                i = j-1;
                break;
            default:
                nb.append(fmt.charAt(i));
                break;
            }
        }
        return nb.toString();
    }
    // 文字列変換
    public String chara( String fmt, StringBuffer data, int nlen  ){
        int     i;
        int     j;
        int     n;
        char    c;


        if( fmt.length() == 0 )return "";



        // 文字の取り出し
        StringBuffer nn = new StringBuffer();
        i = 0;
        while( data.length() > 0 ){
            if( i >= nlen )break;
            c = data.charAt(0);
            if( c >= '0' && c <= '9' )break;
            nn.append(c);
            data.deleteCharAt(0);
            i++;
        }
        // 書式変換
        StringBuffer nb = new StringBuffer();
        for( i = 0 ; i < fmt.length() ;i++ ){
            n = nn.length();
            switch( fmt.charAt(i) ){
            case 'S':
                if( n == 0 )continue;
                nb.append( nn.toString() );
                nn.delete( 0, n );
                break;
            // 右詰
            case 'A':
                if( n == 0 ){
                    nb.insert(0, ' ');
                    continue;
                }
                nb.insert(0, nn.charAt(n-1));
                nn.deleteCharAt(n-1);
                break;
            // 左詰
            case 'C':
                if( n == 0 ){
                    nb.append(' ');
                    continue;
                }
                nb.append(nn.charAt(0));
                nn.delete( 0, 1 );
                break;
            default:
                nb.append(fmt.charAt(i));
                break;
            }
        }
        if( nn.length() > 0 ){
            data.insert(0,nn.toString());
        }
        return nb.toString();
    }
    // 数値変換
    public String numeric( String fmt, StringBuffer data, int nlen ){
        int     i;
        int     j;
        int     n;
        char    c;

        if( fmt.length() == 0 )return "";

        // 数値の取り出し
        StringBuffer nn = new StringBuffer();
        i = 0;
        while( data.length() > 0 ){
            if( i >= nlen )break;
            c = data.charAt(0);
            if( c == ',' && nn.length() > 0 ){
                data.deleteCharAt(0);
                i++;
                continue;
            }
            if( c < '0' )break;
            if( c > '9' )break;
            nn.append(c);
            data.deleteCharAt(0);
            i++;
        }
        // 先頭ゼロ削除
        while( nn.length() > 1 ){
            if( nn.charAt(0) != '0' )break;
            nn.deleteCharAt(0);
        }

        // 書式変換
        StringBuffer nb = new StringBuffer();
        for( i = fmt.length()-1 ; i >= 0 ;i-- ){
            n = nn.length();
            switch( fmt.charAt(i) ){
            // 左詰
            case '#':
                if( n == 0 )continue;
                nb.insert(0, nn.charAt(n-1));
                nn.deleteCharAt(n-1);
                break;
            // 右詰ゼロサプレス
            case '9':
                if( n == 0 ){
                    nb.insert(0, '0');
                    continue;
                }
                nb.insert(0, nn.charAt(n-1));
                nn.deleteCharAt(n-1);
                break;
            // 右詰スペースサプレス
            case 'Z':
                if( n == 0 ){
                    nb.insert(0, ' ');
                    continue;
                }
                nb.insert(0, nn.charAt(n-1));
                nn.deleteCharAt(n-1);
                break;
            case ',':
                if( n == 0 ){
                    if( i == 0 )continue;
                    if( fmt.charAt(i-1) == '9' ){
                        nb.insert(0, '0');
                    }
                    if( fmt.charAt(i-1) == 'Z' ){
                        nb.insert(0, ' ');
                    }
                    continue;
                }
                nb.insert(0, ',');
                break;
            default:
                nb.insert(0, fmt.charAt(i));
                break;

            }
        }
        return nb.toString();
    }
}
/*--------------------------------------------------------------------*/
// メインクラス
/*--------------------------------------------------------------------*/
public class Haccp extends javax.swing.JFrame {
    static int SCREEN_X = 1024;
    static int SCREEN_Y = 768;
    static int FONT_SIZE = 18;

    private static String   DATA_PATH = new String();
    private int nScrNo;         // 画面番号 0=メニュー画面 1=フロー図 2=個表一覧画面 4=説明文画面 8=個表画面 16=個表設定 32=文献表示 64=総括画面
    private int             nPageBk;
    private int             nSelBk;

    private int             nKey1No;    // Key1 選択番号
    private int             nKey2No;    // Key2 選択番号
    private int             nKey3No;    // Key3 選択番号
    private int             nKey1NoBk;  // Key1 選択番号
    private int             nKey2NoBk;  // Key2 選択番号
    private int             nKey3NoBk;  // Key3 選択番号

// IIS Start 複数化
    private KeyData         Keys[];     // Keyデータ
// IIS End
    private ListData        Lists;      // 個表データ
    private String          szSelFName; // 選択文献ファイル名
    private String          szSelURL;   // 選択工程URL
// IIS Start
    private String          szSumFName; // 総括ファイル名：工程フロー画面から起動時
// IIS End

    private static int      nKind;     // 種類

    private JLabel          jBack;     // 背景

// IIS Start
    private static int      nType;      // チーズの種類 1:ゴーダチーズ、2:クリームチーズ、3:カマンベールチーズ//IIS
    private final String    sType[] =  {"ゴーダチーズ", "クリームチーズ", "カマンベールチーズ"
    };
// IIS End

    // 文献選択画面
    private JTable          jTable;
    private JList           jList;
    private JScrollPane     jScrollPane;
    private JTree           jTree;
    private int nSort;

    // 文献表示画面
    private JRadioButton    jRadio[];   // ボタン
    private JTextField      jTextField; // テキスト
    private JComboBox       jCombo[];
// IIS Start
    private String          sBunkenNo;      // 文献番号
    private int             nBunkenTotal;   // 文献総数
    private int             nBunkenPage;    // 文献ページ
// IIS End

// IIS Start
    // 総括表示画面
    private SumDrawPanel    sumPanel;
    private JRadioButton    jRadioSum[];   // ボタン
// IIS End

    private DrawPanel       dpPanel;
    private ExpPanel        expPanel;
    private JScrollPane     jScrollPaneS;
    private JList           jListS;


    private DrawButton      dButton[];
    static  LayOut          Lys;
    static  RollImage       ri;
    private Vector          vc;
    private Vector          vcS;

    private JLabel          jl;
    private Vector          vt;
    private int             nMouse;
    private JTree           jTree1;
    private JTree           jTree2;
    private int             TreeNum;
    private boolean         expTree[];
    private int             selTree;
    /*----------------------------------------------------------------*/
    // コンストラクタ
    /*----------------------------------------------------------------*/

    public Haccp() {
        // 初期化
        initComponents ();
        this.setTitle("ＨＡＣＣＰ情報総合検索システム");
        // データ初期化
        vt = new Vector();
// IIS Start 複数化
        Keys = new KeyData[3];
        Keys[0] = new KeyData(DATA_PATH + "KeyDataFile1.txt");;
        Keys[1] = new KeyData(DATA_PATH + "KeyDataFile2.txt");
        Keys[2] = new KeyData(DATA_PATH + "KeyDataFile3.txt");
// IIS End
        Lys = new LayOut(DATA_PATH + "Layout.txt");
        nScrNo = -1;
        szSelFName = "";


        // ロールイメージ（スプラッシュ）表示
        String szFName = DATA_PATH + Lys.FindRec("STARTUP_BACK").szImg1;
        Image img =  this.getToolkit().getImage(szFName);
        ri = new RollImage(this, img, Lys.FindRec("STARTUP_BACK").w,  Lys.FindRec("STARTUP_BACK").h );
        ri.show();

        // タイマー起動
        javax.swing.Timer tm = new javax.swing.Timer(5000, new ActionListener(){
                public void actionPerformed( ActionEvent e ){
                    TimerSub(e);
                }
            }
        );
        tm.setInitialDelay(60000);
        tm.setRepeats(false);
        tm.start();
    }
     /*----------------------------------------------------------------*/
    // 起動タイマー
    /*----------------------------------------------------------------*/
    public void TimerSub(ActionEvent e){
        if( nScrNo != -1 )return;
        ri.setVisible (false);
        ri.dispose();
        nScrNo = 0;
        setComponentsTop();
        this.show();
    }
    /*----------------------------------------------------------------*/
    // 文献表示
    /*----------------------------------------------------------------*/
    private void setComponentsDisp() {
        int         i,j;
        LayOutRec   LyRec;

        String szFName = DATA_PATH + Lys.FindRec("BKDSP_BACK").szImg1;
        jBack = new JLabel( new ImageIcon( szFName ) );
        getContentPane().add( jBack );
        jBack.setBounds(0,0,SCREEN_X,SCREEN_Y);

        dButton = new DrawButton[20];


        java.awt.Dimension dim = this.getSize();

        //  縮小率
        ButtonGroup bgroup = new ButtonGroup();

        jRadio = new JRadioButton[3];
        jRadio[0] = new JRadioButton( "75%" );
        jRadio[0].setFont(new java.awt.Font ("ＭＳ 明朝", 0, FONT_SIZE));
        jRadio[0].setForeground(java.awt.Color.black);
        jRadio[0].setBackground(java.awt.Color.white);
        jRadio[0].setOpaque(false);
        bgroup.add( jRadio[0] );
        jRadio[1] = new JRadioButton( "100%", true );
        jRadio[1].setFont(new java.awt.Font ("ＭＳ 明朝", 0, FONT_SIZE));
        jRadio[1].setForeground(java.awt.Color.black);
        jRadio[1].setBackground(java.awt.Color.white);
        jRadio[1].setOpaque(false);
        bgroup.add( jRadio[1] );
        jRadio[2] = new JRadioButton( "125%" );
        jRadio[2].setFont(new java.awt.Font ("ＭＳ 明朝", 0, FONT_SIZE));
        jRadio[2].setForeground(java.awt.Color.black);
        jRadio[2].setBackground(java.awt.Color.white);
        jRadio[2].setOpaque(false);
        bgroup.add( jRadio[2] );


        jBack.add(jRadio[0]);
        jRadio[0].setBounds(120, dim.height-90-22, 60, 20);
        jBack.add(jRadio[1]);
        jRadio[1].setBounds(180, dim.height-90-22, 70, 20);
        jBack.add(jRadio[2]);
        jRadio[2].setBounds(250, dim.height-90-22, 70, 20);


        jRadio[0].addItemListener(new java.awt.event.ItemListener() {
                public void itemStateChanged(java.awt.event.ItemEvent evt) {
                    chkBoxsItemActionPerformed(evt);
                }
            }
        );
        jRadio[1].addItemListener(new java.awt.event.ItemListener() {
                public void itemStateChanged(java.awt.event.ItemEvent evt) {
                    chkBoxsItemActionPerformed(evt);
                }
            }
        );
        jRadio[2].addItemListener(new java.awt.event.ItemListener() {
                public void itemStateChanged(java.awt.event.ItemEvent evt) {
                    chkBoxsItemActionPerformed(evt);
                }
            }
        );



        JLabel jLabel;
        jLabel = new JLabel("表示倍率");
        jLabel.setFont(new java.awt.Font ("ＭＳ 明朝", 0, FONT_SIZE));
        jLabel.setForeground(java.awt.Color.black);
        jBack.add( jLabel );
        jLabel.setBounds(30, dim.height-90-22, 80, 20);


        // URL
        jLabel = new JLabel("URL:");
        jLabel.setFont(new java.awt.Font ("ＭＳ 明朝", 0, FONT_SIZE));
        jLabel.setForeground(java.awt.Color.black);
        jBack.add( jLabel );
        jLabel.setBounds(330, dim.height-90 - 22, 50, 20);

        jTextField= new JTextField();
        jTextField.setBackground(java.awt.Color.white);
        jTextField.setFont(new java.awt.Font ("ＭＳ 明朝", 0, FONT_SIZE));
        jTextField.setForeground(java.awt.Color.black);
        jBack.add(jTextField);
        jTextField.setBounds(380, dim.height-90 - 22 , 440, 20);

        // 文献
        dpPanel = new DrawPanel(szSelFName, DATA_PATH );
        dpPanel.setFont(new java.awt.Font ("ＭＳ 明朝", 0, FONT_SIZE-1));
        LyRec =  Lys.FindRec("BKDSP_AREABK");
        if( LyRec != null ){
            dpPanel.setBackground( new java.awt.Color( LyRec.r,LyRec.g,LyRec.b ) );
        }else{
            dpPanel.setBackground(java.awt.Color.white);
        }
        dpPanel.setForeground(java.awt.Color.black);
        jBack.add(dpPanel);
// IIS Start 位置調整
//        dpPanel.setBounds(30, 160, SCREEN_X - 70, SCREEN_Y - 280 );
        dpPanel.setBounds(21, 160-21, SCREEN_X - 70, SCREEN_Y - 280 );
// IIS End
        jTextField.setText(dpPanel.getURL());
        int nHeight = dpPanel.getHeightArea();
        int nWidth = dpPanel.getWidthArea();


        jScrollPane = new javax.swing.JScrollPane();
        jScrollPane.setBounds(20, 160-22, SCREEN_X - 50, SCREEN_Y - 280 );
        jBack.add(jScrollPane);
        jScrollPane.setViewportView(dpPanel);
        dpPanel.setPreferredSize( new Dimension( nWidth, nHeight ) );
        dpPanel.setSize(nWidth,nHeight);



        jScrollPane.getVerticalScrollBar().setUnitIncrement(FONT_SIZE);
        jScrollPane.getHorizontalScrollBar().setUnitIncrement(FONT_SIZE);
        jScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
//        jScrollPane.setWheelScrollingEnabled( true ); // for v1.4

        jScrollPane.requestDefaultFocus();
        // 図ボタン作成
        i = 0;
        for( j = 0 ; j < dpPanel.nList+1 ; j++ ){
            LyRec =  Lys.FindRec("BKDSP_PICT"+Integer.toString(j+1));
            if( LyRec != null ){
                dButton[i] = new DrawButton(DATA_PATH, LyRec);
                jBack.add( dButton[i] );
                dButton[i].setActionCommand(Integer.toString(j));
                dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                        public void mouseReleased( MouseEvent evt) {
                            dspButtonClicked(evt);
                        }
                    }
                );
                dButton[i].setBounds(SCREEN_X - 40 -(( dpPanel.nList - i + 1 )* LyRec.w ), 160 - LyRec.h -22, LyRec.w, LyRec.h);
                i++;
            }
        }
        // GOボタン作成
        LyRec =  Lys.FindRec("BKDSP_GO");
        if( LyRec != null ){
            dButton[i] = new DrawButton(DATA_PATH, LyRec);
            jBack.add( dButton[i] );
            dButton[i].setActionCommand("GO");
            dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseReleased( MouseEvent evt) {
                        dspButtonClicked(evt);
                    }
                }
            );
            i++;
        }
        // PUBMEDボタン作成
        LyRec =  Lys.FindRec("BKDSP_PUBMED");
        if( LyRec != null ){
            dButton[i] = new DrawButton(DATA_PATH, LyRec);
            jBack.add( dButton[i] );
            dButton[i].setActionCommand("PUBMED");
            dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseReleased( MouseEvent evt) {
                        dspButtonClicked(evt);
                    }
                }
            );
            if( dpPanel.getPUB() == "" )dButton[i].disable();
            i++;
        }
        // 戻るボタン作成
        LyRec =  Lys.FindRec("BKDSP_RETURN");
        if( LyRec != null ){
            dButton[i] = new DrawButton(DATA_PATH, LyRec);
            jBack.add( dButton[i] );
            dButton[i].setActionCommand("RETURN");
            dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseReleased( MouseEvent evt) {
                        dspButtonClicked(evt);
                    }
                }
            );
            i++;
        }
        // 印刷ボタン作成
        LyRec =  Lys.FindRec("BKDSP_PRINT");
        if( LyRec != null ){
            dButton[i] = new DrawButton(DATA_PATH, LyRec);
            jBack.add( dButton[i] );
            dButton[i].setActionCommand("PRINT");
            dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseReleased( MouseEvent evt) {
                        dspButtonClicked(evt);
                    }
                }
            );
            i++;
        }

        // メニューへ戻るボタン作成
        LyRec =  Lys.FindRec("BKDSP_MENU");
        if( LyRec != null ){
            dButton[i] = new DrawButton(DATA_PATH, LyRec);
            jBack.add( dButton[i] );
            dButton[i].setActionCommand("MENU");
            dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseReleased( MouseEvent evt) {
                        dspButtonClicked(evt);
                    }
                }
            );
            i++;
        }
// IIS Start 複数文献カード対応
        // 次文献・前文献ボタン作成
        LyRec =  Lys.FindRec("BKDSP_PREV");
        if( LyRec != null ){
            dButton[i] = new DrawButton(DATA_PATH, LyRec);
            jBack.add( dButton[i] );
            dButton[i].setActionCommand("PREV");
            dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseReleased( MouseEvent evt) {
                        dspButtonClicked(evt);
                    }
                }
            );
            String sImage = DATA_PATH + Lys.FindRec("BKDSP_NOTSELPREV").szImg1;
            JLabel jLabelNotSelPrev = new JLabel( new ImageIcon( sImage ) );
            jBack.add( jLabelNotSelPrev );
            jLabelNotSelPrev.setBounds(dButton[i].getBounds());

            File prevF = new File(getPrevBunkenFile());
            if (!prevF.exists()) {
                // 前文献ボタン選択不可
                dButton[i].setVisible(false);
                jLabelNotSelPrev.setVisible(true);
            }
            else {
                dButton[i].setVisible(true);
                jLabelNotSelPrev.setVisible(false);
            }
            i++;
        }
        LyRec =  Lys.FindRec("BKDSP_NEXT");
        if( LyRec != null ){
            dButton[i] = new DrawButton(DATA_PATH, LyRec);
            jBack.add( dButton[i] );
            dButton[i].setActionCommand("NEXT");
            dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseReleased( MouseEvent evt) {
                        dspButtonClicked(evt);
                    }
                }
            );
            String sImage = DATA_PATH + Lys.FindRec("BKDSP_NOTSELNEXT").szImg1;
            JLabel jLabelNotSelNext = new JLabel( new ImageIcon( sImage ) );
            jBack.add( jLabelNotSelNext );
            jLabelNotSelNext.setBounds(dButton[i].getBounds());

            File nextF = new File(getNextBunkenFile());
            if (!nextF.exists()) {
                // 次文献ボタン選択不可
                dButton[i].setVisible(false);
                jLabelNotSelNext.setVisible(true);
            }
            else {
                dButton[i].setVisible(true);
                jLabelNotSelNext.setVisible(false);
            }
            i++;
        }

        nBunkenTotal = getBunkenTotalNum();
        // ページ番号
        nBunkenPage = getBunkenFileNo();
        JLabel jLabelPage;
        jLabelPage = new JLabel(nBunkenPage+"／"+nBunkenTotal);
        jLabelPage.setFont(new java.awt.Font ("ＭＳ 明朝", 0, FONT_SIZE));
        jLabelPage.setForeground(java.awt.Color.black);
        jBack.add( jLabelPage );
        jLabelPage.setBounds(23, 116, 75, 20);
// IIS End

    }
    /*----------------------------------------------------------------*/
    // 文献：ボタン処理
    /*----------------------------------------------------------------*/
    public void dspButtonClicked( MouseEvent evt) {

        DrawButton db = (DrawButton)evt.getSource();
        if( db.isClicked() == false )return;


        if( db.szCmd.compareTo("MENU") == 0 ){
            this.getContentPane().removeAll();
            nScrNo = 0;
            setComponentsTop();
            return;
        }
        if( db.szCmd.compareTo("PRINT") == 0 ){
            PrintJob    pjob = getToolkit().getPrintJob(this,"Test", null, null );
            if( pjob == null )return;
            dpPanel.printDoc( pjob );
            pjob.end();
            return;
        }
        if( db.szCmd.compareTo("RETURN") == 0 ){
            this.getContentPane().removeAll();
            nScrNo = nScrNo & ~32;
            setComponentsList ();
            return;
        }
        if( db.szCmd.compareTo("GO") == 0 ){
            if( jTextField.getText().compareTo("")==0 )return;
            OpenHtml op = new OpenHtml(jTextField.getText() );

//            try{
//                Runtime.getRuntime().exec("explorer " +  "\"" + jTextField.getText() + "\"" );
//            }catch (IOException e){
//                System.out.println("Can't Exec" );
//            }
            return;
        }
        if( db.szCmd.compareTo("PUBMED") == 0 ){
            OpenHtml op = new OpenHtml(dpPanel.getPUB() );
//            try{
//                Runtime.getRuntime().exec("explorer " + "\""+ dpPanel.getPUB() + "\"" );
//            }catch (IOException e){
//                System.out.println("Can't Exec" );
//            }
            return;
        }
// IIS Start 複数文献カード対応
        if( db.szCmd.compareTo("NEXT") == 0 ){
            String sNextF = getNextBunkenFile();
            File nextF = new File(sNextF);
            if (nextF.exists()){
                szSelFName = sNextF;
                this.getContentPane().removeAll();
                setComponentsDisp();
            }
            else {
//                JOptionPane.showMessageDialog(this,
//                            "次文献はありません。","警告", JOptionPane.WARNING_MESSAGE);
            }
            return;
        }
        if( db.szCmd.compareTo("PREV") == 0 ){
            String sPrevF = getPrevBunkenFile();
            File prevF = new File(sPrevF);
            if (prevF.exists()){
                szSelFName = sPrevF;
                this.getContentPane().removeAll();
                setComponentsDisp();
            }
            else {
//                JOptionPane.showMessageDialog(this,
//                            "前文献はありません。","警告", JOptionPane.WARNING_MESSAGE);
            }
            return;
        }
// IIS End
        int value = dpPanel.getPos(Integer.parseInt(db.szCmd));
        jScrollPane.getVerticalScrollBar().setValue(value);
    }
    /*----------------------------------------------------------------*/
    // 文献：縮小・拡大処理
    /*----------------------------------------------------------------*/
    public void chkBoxsItemActionPerformed(java.awt.event.ItemEvent evt) {
        if( evt.getSource() == jRadio[0] )dpPanel.setScale( 75.0 );
        if( evt.getSource() == jRadio[1] )dpPanel.setScale( 100.0 );
        if( evt.getSource() == jRadio[2] )dpPanel.setScale( 125.0 );

        dpPanel.setPreferredSize( new Dimension( dpPanel.getWidthArea(), dpPanel.getHeightArea() ) );
        dpPanel.revalidate();
    }
// IIS Start 複数文献カード対応
    /**
     * 文献番号の文献カード総数を取得
     */
    private int getBunkenTotalNum() {
        File path = new File(DATA_PATH);
        if (!path.isDirectory()) return 0;
        String files[] = path.list(new BunkenCardFilenameFilter());
        return files.length;

    }
    class BunkenCardFilenameFilter implements FilenameFilter {
        public boolean accept(File dir, String name){
            File file = new File(dir, name);
            String sName = file.getName();
            if(file.isDirectory()) return false;
            if (!sName.toUpperCase().endsWith("TXT")) return false;

            if(file.isFile() && sName.startsWith(sBunkenNo+"-")) {
                return true;
            }
            return false;
        }
    }
    /**
     * 文献ファイル名から番号を取得
     */
    private int getBunkenFileNo() {
        int iPos = szSelFName.indexOf(".txt");
        if (iPos < 0) return 0;
        String sIndex = szSelFName.substring(iPos-1, iPos);
        int iIndex = -1;
        try {
            iIndex = Integer.parseInt(sIndex);
        } catch (NumberFormatException e) {
            return 0;
        }
        return iIndex;
    }
    /**
     * 次文献ファイル名取得
     */
    private String getNextBunkenFile() {
        int iPos = szSelFName.indexOf(".txt");
        if (iPos < 0) return "";
        int iIndex = getBunkenFileNo();
        if (iIndex <= 0) return "";
        String sFileName = szSelFName.substring(0, iPos-1) + (iIndex+1) + ".txt";
        return sFileName;
    }
    /**
     * 前文献ファイル名取得
     */
    private String getPrevBunkenFile() {
        int iPos = szSelFName.indexOf(".txt");
        if (iPos < 0) return "";
        int iIndex = getBunkenFileNo();
        if (iIndex <= 0) return "";
        String sFileName = szSelFName.substring(0, iPos-1) + (iIndex-1) + ".txt";
        return sFileName;
    }
// IIS End

    /*----------------------------------------------------------------*/
    // 個表表示
    /*----------------------------------------------------------------*/
    private void setComponentsList() {
        int         i,j;
        LayOutRec   LyRec;
        String      szFName;

        // 個票
        if( nScrNo != 8 ){
            szFName = DATA_PATH + Lys.FindRec("KHDSP_BACK").szImg1;
        // 文献一覧
        }else{
            szFName = DATA_PATH + Lys.FindRec("BKTBL_BACK").szImg1;
        }
        jBack = new JLabel( new ImageIcon( szFName ) );
        getContentPane().add( jBack );
        jBack.setBounds(0,0,SCREEN_X,SCREEN_Y);



        dButton = new DrawButton[9];

        this.setFont(new java.awt.Font ("ＭＳ 明朝", 0, FONT_SIZE));



        LyRec =  Lys.FindRec("KHDSP_COMBBK");
        if( nScrNo != 8 ){
            jCombo= new JComboBox[3];

            for( i = 0 ; i < 3 ; i++ ){
                jCombo[i] = new JComboBox();
                if( LyRec != null ){
                    jCombo[i].setBackground( new java.awt.Color( LyRec.r,LyRec.g,LyRec.b ) );
                }else{
                    jCombo[i].setBackground(java.awt.Color.white);
                }
                jCombo[i].setForeground(java.awt.Color.black);
                jCombo[i].setFont(new java.awt.Font ("ＭＳ 明朝", 0, FONT_SIZE));
                jBack.add(jCombo[i]);
                jCombo[i].setBounds(20+(290*i), 113, 280, 30);
            }
            szSelURL = "";
// IIS Start 複数化
//            for( j = 0 ; j < Keys.nCnt ; j++ ){
//                if( Keys.getKey( j , 1 )  != 0 )continue;
//                if( Keys.getKey( j , 2 )  != 0 )continue;
//                jCombo[0].addItem( Keys.getTitle(j) );
//                if( Keys.getKey( j , 0 )  == nKey1No ){
//                    jCombo[0].setSelectedItem(Keys.getTitle(j));
//                }
//            }
            for( j = 0 ; j < Keys[nType-1].nCnt ; j++ ){
                if( Keys[nType-1].getKey( j , 1 )  != 0 )continue;
                if( Keys[nType-1].getKey( j , 2 )  != 0 )continue;
                jCombo[0].addItem( Keys[nType-1].getTitle(j) );
                if( Keys[nType-1].getKey( j , 0 )  == nKey1No ){
                    jCombo[0].setSelectedItem(Keys[nType-1].getTitle(j));
                }
            }
// IIS End
            jCombo[0].revalidate();


// IIS Start 複数化
//            for( j = 0 ; j < Keys.nCnt ; j++ ){
//                if( Keys.getKey( j , 0 )  != nKey1No )continue;
//                if( Keys.getKey( j , 1 )  == 0 )continue;
//                if( Keys.getKey( j , 2 )  != 0 )continue;
//                jCombo[1].addItem( Keys.getTitle(j) );
//                if( Keys.getKey( j , 1 )  == nKey2No ){
//                    jCombo[1].setSelectedItem(Keys.getTitle(j));
//                }
//
//            }
            for( j = 0 ; j < Keys[nType-1].nCnt ; j++ ){
                if( Keys[nType-1].getKey( j , 0 )  != nKey1No )continue;
                if( Keys[nType-1].getKey( j , 1 )  == 0 )continue;
                if( Keys[nType-1].getKey( j , 2 )  != 0 )continue;
                jCombo[1].addItem( Keys[nType-1].getTitle(j) );
                if( Keys[nType-1].getKey( j , 1 )  == nKey2No ){
                    jCombo[1].setSelectedItem(Keys[nType-1].getTitle(j));
                }

            }
            jCombo[2].addItem( "指定なし" );
            i = 0;
//            for( j = 0 ; j < Keys.nCnt ; j++ ){
//                if( Keys.getKey( j , 0 )  != nKey1No )continue;
//                if( Keys.getKey( j , 1 )  != nKey2No )continue;
//                if( Keys.getKey( j , 2 )  == 0 )continue;
//                jCombo[2].addItem( Keys.getTitle(j) );
//                if( Keys.getKey( j , 2 )  == nKey3No ){
//                    jCombo[2].setSelectedItem(Keys.getTitle(j));
//                }
//                i++;
//            }
            for( j = 0 ; j < Keys[nType-1].nCnt ; j++ ){
                if( Keys[nType-1].getKey( j , 0 )  != nKey1No )continue;
                if( Keys[nType-1].getKey( j , 1 )  != nKey2No )continue;
                if( Keys[nType-1].getKey( j , 2 )  == 0 )continue;
                jCombo[2].addItem( Keys[nType-1].getTitle(j) );
                if( Keys[nType-1].getKey( j , 2 )  == nKey3No ){
                    jCombo[2].setSelectedItem(Keys[nType-1].getTitle(j));
                }
                i++;
            }
// IIS End
            if( i == 0 )jCombo[2].setVisible(false);
            for( i = 0 ; i < 3 ; i++ ){
                jCombo[i].addItemListener(new java.awt.event.ItemListener() {
                        public void itemStateChanged(java.awt.event.ItemEvent evt) {
                            choiseItemStateChanged(evt);
                        }
                    }
                );
            }
        }



        java.awt.Dimension dim = this.getSize();
        Lists = new ListData();


        redispList();


        i = 0;
        // 検索ボタン作成
        if( nScrNo != 8 ){
            LyRec =  Lys.FindRec("KHDSP_REFER");
            if( LyRec != null ){
                dButton[i] = new DrawButton(DATA_PATH, LyRec);
                jBack.add( dButton[i] );
                dButton[i].setActionCommand("REFER");
                dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                        public void mouseReleased( MouseEvent evt) {
                            listButtonClicked(evt);
                        }
                    }
                );
                i++;
            }
        }
        // 表示設定ボタン作成
        LyRec =  Lys.FindRec("KHDSP_EST");
        if( LyRec != null ){
            dButton[i] = new DrawButton(DATA_PATH, LyRec);
            jBack.add( dButton[i] );
            dButton[i].setActionCommand("EST");
            dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseReleased( MouseEvent evt) {
                        listButtonClicked(evt);
                    }
                }
            );
            i++;
        }
        // 文献表示ボタン作成
        LyRec =  Lys.FindRec("KHDSP_BUNDISP");
        if( LyRec != null ){
            dButton[i] = new DrawButton(DATA_PATH, LyRec);
            jBack.add( dButton[i] );
            dButton[i].setActionCommand("BUNDISP");
            dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseReleased( MouseEvent evt) {
                        listButtonClicked(evt);
                    }
                }
            );
            i++;
        }
        // デフォルト幅ボタン作成
        LyRec =  Lys.FindRec("KHDSP_DEFAULT");
        if( LyRec != null ){
            dButton[i] = new DrawButton(DATA_PATH, LyRec);
            jBack.add( dButton[i] );
            dButton[i].setActionCommand("DEFAULT");
            dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseReleased( MouseEvent evt) {
                        listButtonClicked(evt);
                    }
                }
            );
            i++;
        }
        // 戻るボタン作成
        LyRec =  Lys.FindRec("KHDSP_RETURN");
        if( LyRec != null ){
            dButton[i] = new DrawButton(DATA_PATH, LyRec);
            jBack.add( dButton[i] );
            dButton[i].setActionCommand("RETURN");
            dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseReleased( MouseEvent evt) {
                        listButtonClicked(evt);
                    }
                }
            );
            i++;
        }
        // 印刷ボタン作成
        LyRec =  Lys.FindRec("KHDSP_PRINT");
        if( LyRec != null ){
            dButton[i] = new DrawButton(DATA_PATH, LyRec);
            jBack.add( dButton[i] );
            dButton[i].setActionCommand("PRINT");
            dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseReleased( MouseEvent evt) {
                        listButtonClicked(evt);
                    }
                }
            );
            i++;
        }
        // ＣＳＶ出力ボタン作成
        LyRec =  Lys.FindRec("KHDSP_CSV");
        if( LyRec != null ){
            dButton[i] = new DrawButton(DATA_PATH, LyRec);
            jBack.add( dButton[i] );
            dButton[i].setActionCommand("CSV");
            dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseReleased( MouseEvent evt) {
                        listButtonClicked(evt);
                    }
                }
            );
            i++;
        }
        // メニューへ戻るボタン作成
        LyRec =  Lys.FindRec("KHDSP_MENU");
        if( LyRec != null ){
            dButton[i] = new DrawButton(DATA_PATH, LyRec);
            jBack.add( dButton[i] );
            dButton[i].setActionCommand("MENU");
            dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseReleased( MouseEvent evt) {
                        listButtonClicked(evt);
                    }
                }
            );
            i++;
        }
    }
    /*----------------------------------------------------------------*/
    // 個表：ボタン処理
    /*----------------------------------------------------------------*/
    public void listButtonClicked( MouseEvent evt) {
        DrawButton db = (DrawButton)evt.getSource();
        String      szTitle = "";
        String      szSub = "";

        if( db.isClicked() == false )return;

        if( db.szCmd.compareTo("DEFAULT") == 0 ){
            int n = 0;
            for( int i = 0 ; i < Lists.nCol-1; i++ ){
                for( int j = 0 ; j < Lists.nCol-1 ; j++ ){
                    if( Lists.lrRec[0].nPos[j] != i )continue;
                    String szBuff = Lists.lrRec[0].szName[j];
                    jTable.getTableHeader().getColumnModel().getColumn(n).setPreferredWidth( szBuff.length()*FONT_SIZE  );
                    n++;
                    break;
                }
            }
            int nHbak = jScrollPane.getHorizontalScrollBar().getValue();
            int nVbak = jScrollPane.getVerticalScrollBar().getValue();
            setHeaderSize();
            jBack.remove(jScrollPane);
            redispList();
            jScrollPane.getHorizontalScrollBar().setValue(nHbak);
            jScrollPane.getVerticalScrollBar().setValue(nVbak);
            return;
        }
        setHeaderSize();
        if( db.szCmd.compareTo("MENU") == 0 ){
            if( Lists.nRow == 0 )return;
            this.getContentPane().removeAll();
            nScrNo = 0;
            setComponentsTop();
            return;
        }
        if( db.szCmd.compareTo("CSV") == 0 ){
            if( Lists.nRow == 0 )return;
            JFileChooser jFileC = new JFileChooser();
            int sel = jFileC.showSaveDialog(this);
            if( sel == JFileChooser.APPROVE_OPTION ){
                File selFile = jFileC.getSelectedFile();

                int n  = selFile.getName().indexOf(".csv");
                if( n < 0 ){
                    String szCsvName  = selFile.getPath() + ".csv";
                    selFile = new File( szCsvName );

                }
                try{
                    FileOutputStream fin = new FileOutputStream(selFile);
                    String szBuff;

                    for( int i = 0 ; i < Lists.nRow ; i++ ){
                        szBuff = "";
                        for( int j = 0 ; j < Lists.nCol ; j++ ){
                            if( j == 0 ){
                                if( Lists.lrRec[i].nPos[Lists.nCol-1] != -1 ){
                                    if( i == 0 ){

                                        String szStr = Lists.lrRec[i].szName[Lists.nCol-1].trim();
                                        while( true ){
                                            if( szStr.endsWith("　") == false )break;
                                            int l = szStr.length();
                                            if( l == 0 )break;
                                            szStr = szStr.substring(0,l-1);
                                        }
                                        szBuff = szStr;
                                    }else{
                                        szBuff = Lists.lrRec[i].szName[Lists.nCol-1];
                                    }
                                }
                                continue;
                            }
                            for( int k = 0 ; k < (Lists.nCol-1) ; k++ ){
                                if( Lists.lrRec[0].nPos[k] != j-1 )continue;
                                szBuff = szBuff.concat(",");
                                if( i == 0 ){
                                    String szStr = Lists.lrRec[i].szName[k].trim();
                                    while( true ){
                                        if( szStr.endsWith("　") == false )break;
                                        int l = szStr.length();
                                        if( l == 0 )break;
                                        szStr = szStr.substring(0,l-1);
                                    }
                                    szBuff = szBuff.concat(szStr);
                                }else{
                                    szBuff = szBuff.concat(Lists.lrRec[i].szName[k]);
                                }
                                break;

                            }
                        }
                        szBuff = szBuff.concat("\r\n");
                        fin.write(szBuff.getBytes());
                    }
                    fin.close();
                }
                catch(IOException err){
                    System.out.println("WRITE ERROR!");
                }
            }else if( sel == JFileChooser.CANCEL_OPTION ){
                return;
            }
            return;
        }
        if( db.szCmd.compareTo("PRINT") == 0 ){
// IIS Start
            szTitle = sType[nType-1];
            szSub = "個票：";
            for( int j = 0 ; j < Keys[nType-1].nCnt ; j++ ){
                if( Keys[nType-1].getKey( j , 0 )  != nKey1No )continue;
                if( Keys[nType-1].getKey( j , 1 )  != 0 )continue;
                if( Keys[nType-1].getKey( j , 2 )  != 0 )continue;
                szSub = szSub.concat(Keys[nType-1].getTitle(j) );
                break;
            }
            for( int j = 0 ; j < Keys[nType-1].nCnt ; j++ ){
                if( Keys[nType-1].getKey( j , 0 )  != nKey1No )continue;
                if( Keys[nType-1].getKey( j , 1 )  != nKey2No )continue;
                if( Keys[nType-1].getKey( j , 2 )  != 0 )continue;
                szSub = szSub.concat(" - ");
                szSub = szSub.concat(Keys[nType-1].getTitle(j) );
                break;
            }
            if( nKey3No > 0 ){
                for( int j = 0 ; j < Keys[nType-1].nCnt ; j++ ){
                    if( Keys[nType-1].getKey( j , 0 )  != nKey1No )continue;
                    if( Keys[nType-1].getKey( j , 1 )  != nKey2No )continue;
                    if( Keys[nType-1].getKey( j , 2 )  != nKey3No )continue;
                    szSub = szSub.concat(" - ");
                    szSub = szSub.concat(Keys[nType-1].getTitle(j));
                    break;
                }
            }
// IIS End
            if( nScrNo == 8 )szSub = "個票一覧";
            ListData_Print ListData_Prt = new ListData_Print(new Frame(), FONT_SIZE, Lists, szTitle, szSub);
            ListData_Prt.PrtOut();
            return;
        }
        if( db.szCmd.compareTo("RETURN") == 0 ){
            this.getContentPane().removeAll();
            nScrNo = nScrNo & ~8;

            if( (nScrNo & 4 )== 4 ){
                nKey1No = nKey1NoBk;
                nKey2No = nKey2NoBk;
                nKey3No = nKey3NoBk;
                setComponentsExp ();
            }else{
                if( nScrNo ==  0 ){
                    setComponentsTop ();
                }else{
                    setComponentsDiv ();
                }
            }
            return;
        }
        if( db.szCmd.compareTo("BUNDISP") == 0 ){
            if( Lists.nRow == 0 )return;
            int no = jTable.getSelectedRow();
            if( no < 0 )return;
            if( no >=  Lists.nRow) return;
// IIS Start 複数文献対応
            szSelFName = DATA_PATH + Lists.getName(no+1,Lists.nCol-1) + "-1.txt";
            sBunkenNo = Lists.getName(no+1,Lists.nCol-1); //IIS
// IIS End
            File fi = new File(szSelFName);
            if( fi.exists() == false )return;

            nSelBk = jTable.getSelectedRow();
            nPageBk = jScrollPane.getVerticalScrollBar().getValue();


            this.getContentPane().removeAll();
            nScrNo = nScrNo | 32;
            setComponentsDisp();
        }
        if( db.szCmd.compareTo("EST") == 0 ){
            if( Lists.nRow == 0 )return;
            this.getContentPane().removeAll();
            nScrNo = nScrNo | 16;
            setComponentsMente();
        }
        if( db.szCmd.compareTo("REFER") == 0 ){
            jBack.remove(jScrollPane);
            redispList();
        }
    }
    /*----------------------------------------------------------------*/
    // 個表：選択ボタン処理
    /*----------------------------------------------------------------*/
    private void choiseItemStateChanged(java.awt.event.ItemEvent evt) {
        int     i,j;

        if( evt.getSource() == jCombo[0] ){
            nKey1No = -1;
            nKey2No = -1;
            nKey3No = -1;
            jCombo[1].removeAllItems();
// IIS Start 複数化
            for( j = 0 ; j < Keys[nType-1].nCnt ; j++ ){
                if( Keys[nType-1].getKey( j , 1 )  != 0 )continue;
                if( Keys[nType-1].getKey( j , 2 )  != 0 )continue;
                if( jCombo[0].getSelectedItem() == Keys[nType-1].getTitle(j) ){
                    nKey1No = Keys[nType-1].getKey( j , 0 );
                    break;
                }
            }
// IIS End
        }
        if( evt.getSource() != jCombo[2] ){
            if( evt.getSource() == jCombo[1] ){
                nKey2No = -1;
                nKey3No = -1;
            }
            jCombo[2].removeAllItems();
            jCombo[2].addItem( "指定なし" );
// IIS Start 複数化
            for( j = 0 ; j < Keys[nType-1].nCnt ; j++ ){
                if( Keys[nType-1].getKey( j , 0 )  != nKey1No )continue;
                if( Keys[nType-1].getKey( j , 1 )  == 0 )continue;
                if( Keys[nType-1].getKey( j , 2 )  != 0 )continue;

                if( evt.getSource() == jCombo[0] ){
                    jCombo[1].addItem( Keys[nType-1].getTitle(j) );
                    if( nKey2No == -1)nKey2No =Keys[nType-1].getKey( j , 1 );
                }else{
                    if( jCombo[1].getSelectedItem() == Keys[nType-1].getTitle(j) ){
                        nKey2No = Keys[nType-1].getKey( j , 1 );
                        break;
                    }
                }
// IIS End
            }
        }
        i = 0;
// IIS Start 複数化
        for( j = 0 ; j < Keys[nType-1].nCnt ; j++ ){
            if( Keys[nType-1].getKey( j , 0 )  != nKey1No )continue;
            if( Keys[nType-1].getKey( j , 1 )  != nKey2No )continue;
            if( Keys[nType-1].getKey( j , 2 )  == 0 )continue;
             if( evt.getSource() == jCombo[2] ){
                if( jCombo[2].getSelectedItem() == Keys[nType-1].getTitle(j) ){
                     nKey3No = Keys[nType-1].getKey( j , 2 );
                     break;
                }
             }else{
                jCombo[2].addItem( Keys[nType-1].getTitle(j) );
                i++;
             }
        }
// IIS End
        if( evt.getSource() != jCombo[2] && i == 0 ){
            jCombo[2].setVisible(false);
        }else{
            jCombo[2].setVisible(true);
        }

    }
    /*----------------------------------------------------------------*/
    // 個表：再表示ボタン処理
    /*----------------------------------------------------------------*/
    private void redispList() {
        int     i,j,n;
        String  szFName;
        String  szBuff;
        ListDsp ld;
        LayOutRec   LyRec;

        szFName = "";
        if( nScrNo != 8 ){
// IIS Start 複数化
            for( j = 0 ; j < Keys[nType-1].nCnt ; j++ ){
                if( Keys[nType-1].getKey( j , 1 )  != 0 )continue;
                if( Keys[nType-1].getKey( j , 2 )  != 0 )continue;
                if( Keys[nType-1].getKey( j , 0 )  == nKey1No ){
                    if( Keys[nType-1].getURL(j).compareTo("")!=0)szSelURL = Keys[nType-1].getURL( j );
                    szFName = Keys[nType-1].getFName(j);
                }
            }
            for( j = 0 ; j < Keys[nType-1].nCnt ; j++ ){
                if( Keys[nType-1].getKey( j , 0 )  != nKey1No )continue;
                if( Keys[nType-1].getKey( j , 1 )  == 0 )continue;
                if( Keys[nType-1].getKey( j , 2 )  != 0 )continue;
                if( Keys[nType-1].getKey( j , 1 )  == nKey2No ){
                    if( Keys[nType-1].getURL( j ).compareTo("")!=0)szSelURL = Keys[nType-1].getURL( j );
                    szFName = Keys[nType-1].getFName(j);
                }
            }
            for( j = 0 ; j < Keys[nType-1].nCnt ; j++ ){
                if( Keys[nType-1].getKey( j , 0 )  != nKey1No )continue;
                if( Keys[nType-1].getKey( j , 1 )  != nKey2No )continue;
                if( Keys[nType-1].getKey( j , 2 )  == 0 )continue;
                if( Keys[nType-1].getKey( j , 2 )  == nKey3No ){
                    if( Keys[nType-1].getURL( j ).compareTo("")!=0)szSelURL = Keys[nType-1].getURL( j );
                    szFName = Keys[nType-1].getFName(j);
                }

            }
// IIS End
        }else{
            szFName = "AllList.csv";;
        }
        Lists.getData(DATA_PATH,szFName);


        nSort = 0;
        n = vt.size();
        for( i = 0 ; i < n ; i++ ){
            ld = (ListDsp)vt.elementAt(i);
            if( ld.szFName.equals(szFName) ){
                Lists.lrRec[0].nPos = ld.nPos;
                Lists.lrRec[0].nWidth = ld.nWidth;
                nSort = ld.nSort;
                if( nSort != 0 ){
                    Lists.csort(nSort);
                }
            }
        }

        javax.swing.table.TableModel model = new NotEditModel( Lists );
        jTable = new javax.swing.JTable(model);
        jTable.setRowHeight(30);

        LyRec =  Lys.FindRec("KHDSP_AREABK");
        if( LyRec != null ){
            jTable.setBackground( new java.awt.Color( LyRec.r,LyRec.g,LyRec.b ) );
        }


        jTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jTable.setFont(new java.awt.Font ("ＭＳ 明朝", 0, FONT_SIZE));
        jTable.getTableHeader().setFont(new java.awt.Font ("ＭＳ 明朝", 0, FONT_SIZE));
        jTable.getTableHeader().setReorderingAllowed( false );
        jTable.setAutoResizeMode(jTable.AUTO_RESIZE_OFF);




        javax.swing.AbstractListModel fixed = new FixedModel( Lists );
        jList = new JList(fixed);
        jList.setFixedCellHeight(jTable.getRowHeight());
        jList.setCellRenderer(new RowHeaderRenderer(jTable));
        jList.setBackground( jTable.getTableHeader().getBackground() );
        jList.setBounds(0, 0, 140, SCREEN_Y-280);


        javax.swing.table.DefaultTableCellRenderer dc;


        // 列ヘッダの幅変更
        n = 0;
        for( i = 0 ; i < Lists.nCol-1; i++ ){
            for( j = 0 ; j < Lists.nCol-1 ; j++ ){
                if( Lists.lrRec[0].nPos[j] != i )continue;
                if( Lists.lrRec[0].nWidth[j] == 0 ){
                    szBuff = Lists.lrRec[0].szName[j];
                    Lists.lrRec[0].nWidth[j] = szBuff.length()*FONT_SIZE;

                }
                jTable.getTableHeader().getColumnModel().getColumn(n).setPreferredWidth(Lists.lrRec[0].nWidth[j]);
                dc = (javax.swing.table.DefaultTableCellRenderer)jTable.getCellRenderer(2,n);
                n++;
                break;
            }
        }
        if( Lists.nRow > 0 ){
            szBuff = Lists.lrRec[0].szName[Lists.nCol-1];
            Lists.lrRec[0].nWidth[Lists.nCol-1] = szBuff.length()*FONT_SIZE;
        }


        jScrollPane = new javax.swing.JScrollPane(jTable);

        // 行ヘッダ設定
        if( Lists.nRow > 0 && Lists.lrRec[0].nPos[Lists.nCol-1] != -1 ){
            jScrollPane.setRowHeaderView(jList);
        }

        // 列ヘッダ高さ設定
        Dimension dim = jTable.getTableHeader().getPreferredSize();
        dim.height = jTable.getRowHeight();
        jTable.getTableHeader().setPreferredSize(dim);

        if( Lists.nRow > 0 && Lists.lrRec[0].nPos[Lists.nCol-1] != -1 ){
            // 行ヘッダの幅変更
            szBuff = Lists.lrRec[0].szName[Lists.nCol-1];
            Dimension dm = jScrollPane.getRowHeader().getPreferredSize();
            dm.width = szBuff.length()*FONT_SIZE;
            jScrollPane.getRowHeader().setPreferredSize(dm);

            // 左上隅コーナーの変更
            jl = new JLabel(szBuff );
            jl.setBorder(UIManager.getBorder("TableHeader.cellBorder"));
            jl.setForeground(jTable.getForeground());
            jl.setBackground(jTable.getBackground());
            jl.setFont(jTable.getFont());
            jScrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER,jl);

            jl.addMouseListener( (MouseListener)new java.awt.event.MouseAdapter() {
                    public void mouseClicked(java.awt.event.MouseEvent e) {
                        JTHeadMouseClicked(e);
                    }
                }
            );
        }
        jScrollPane.setBounds(20, 170-22, SCREEN_X-40, SCREEN_Y-280);

        jBack.add(jScrollPane );





        nMouse = 0;
        java.awt.event.MouseListener hmouseListener = new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent e) {
                if( nMouse == 1 ){
                    int nHbak = jScrollPane.getHorizontalScrollBar().getValue();
                    int nHmax = jScrollPane.getHorizontalScrollBar().getMaximum();
                    int nVbak = jScrollPane.getVerticalScrollBar().getValue();
                    int nVmax = jScrollPane.getVerticalScrollBar().getMaximum();
                    setHeaderSize();
                    jBack.remove(jScrollPane);
                    redispList();

                    jScrollPane.getHorizontalScrollBar().setMaximum(nHmax);
                    jScrollPane.getHorizontalScrollBar().setValue(nHbak);
                    jScrollPane.getVerticalScrollBar().setMaximum(nVmax);
                    jScrollPane.getVerticalScrollBar().setValue(nVbak);
                }
                nMouse = 0;
            }
            public void mouseClicked(java.awt.event.MouseEvent e) {
                JTHeadMouseClicked(e);
            }
        };
        jTable.getTableHeader().addMouseListener(hmouseListener);


        java.awt.event.MouseMotionListener hmouseMListener = new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent e) {
                nMouse = 1;
            }
        };
        jTable.getTableHeader().addMouseMotionListener(hmouseMListener);





        java.awt.event.MouseListener mouseListener = new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent e) {
                JTableMouseClicked(e);
            }
        };
        jTable.addMouseListener(mouseListener);






        for( i = 0 ; i < jTable.getColumnCount(); i++ ){
            dc = (javax.swing.table.DefaultTableCellRenderer)jTable.getTableHeader().getColumnModel().getColumn(i).getHeaderRenderer();
            jTable.getTableHeader().getColumnModel().getColumn(i).setHeaderRenderer(new MyCellRenderer() );

        }

        if( nSelBk != -1 && nPageBk != -1 ){
            jTable.addRowSelectionInterval(nSelBk,nSelBk);
            jScrollPane.getVerticalScrollBar().setValue(nPageBk);
            nSelBk = -1;
            nPageBk = -1;
        }
    }
    /*----------------------------------------------------------------*/
    // 個表：列幅取得処理
    /*----------------------------------------------------------------*/
    private void setHeaderSize()
    {
        ListDsp     ld;
        int         i,j,n;

        // 追加
        if( Lists.nRow < 1)return;
        n = vt.size();
        ld = null;
        for( i = 0 ; i < n ; i++ ){
            ld = (ListDsp)vt.elementAt(i);
            if( !ld.szFName.equals(Lists.szFName) )continue;
            vt.removeElementAt(i);
            break;
        }
        if( i >= n )ld = new ListDsp(Lists.szFName,Lists.nCol);
        ld.nPos = Lists.lrRec[0].nPos;
        ld.nSort = nSort;

        n = 0;
        for( i = 0 ; i < Lists.nCol-1; i++ ){
            for( j = 0 ; j < Lists.nCol-1 ; j++ ){
                if( Lists.lrRec[0].nPos[j] != i )continue;
                Lists.lrRec[0].nWidth[j] = jTable.getTableHeader().getColumnModel().getColumn(n).getPreferredWidth();
                n++;
                break;
            }
        }
        ld.nWidth = Lists.lrRec[0].nWidth;
        vt.addElement(ld);
    }
    /*----------------------------------------------------------------*/
    // 個表：ダブルクリック処理
    /*----------------------------------------------------------------*/
    private void JTableMouseClicked(java.awt.event.MouseEvent e){
        if (e.getClickCount() == 2) {
            int no = jTable.rowAtPoint(e.getPoint());
            if( no >=  Lists.nRow) return;
// IIS Start 複数文献対応
            szSelFName = DATA_PATH + Lists.getName(no+1,Lists.nCol-1) + "-1.txt";
            sBunkenNo = Lists.getName(no+1,Lists.nCol-1); //IIS
// IIS End
            File fi = new File(szSelFName);
            if( fi.exists() == false )return;

            setHeaderSize();
            this.getContentPane().removeAll();
            nSelBk = no;
            nPageBk = jScrollPane.getVerticalScrollBar().getValue();
            nScrNo = nScrNo | 32;
            setComponentsDisp();
        }
    }
    /*----------------------------------------------------------------*/
    // 個表：ソート処理
    /*----------------------------------------------------------------*/
    private void JTHeadMouseClicked(java.awt.event.MouseEvent e){
        int col;
        int i;

        if( e.getSource().equals( jTable.getTableHeader() ) ){
            col = jTable.getTableHeader().columnAtPoint(e.getPoint());
            for( i = 0; i < Lists.nCol - 1 ; i++ ){
                if( Lists.lrRec[0].nPos[i] != col )continue;
                break;
            }
            if( i >= ( Lists.nCol - 1) )return;
            col = i;
        }else{
            col = Lists.nCol - 1;
        }
        if( nSort >= 0 ){
            if( col != (nSort-1) ) nSort = col + 1;
            else                   nSort = (col+1)* -1;
        }else{
            nSort = col + 1;
        }
        Lists.csort(nSort);
        jTable.getTableHeader().repaint();
        jTable.repaint();
        jList.repaint();
    }
    /*----------------------------------------------------------------*/
    // 表示設定表示
    /*----------------------------------------------------------------*/
    private void setComponentsMente() {
        int         i,j;
        LayOutRec   LyRec;
        String     szFName;

// IIS Start バグフィックス
//        if( ( nScrNo & (8 | 16) ) != 0 ){
        if( ( nScrNo & 2 )== 2 ){
// IIS End
            szFName = DATA_PATH + Lys.FindRec("KHEST_BACK").szImg1;
        }else{
            szFName = DATA_PATH + Lys.FindRec("BKEST_BACK").szImg1;
        }
        jBack = new JLabel( new ImageIcon( szFName ) );
        getContentPane().add( jBack );
        jBack.setBounds(0,0,SCREEN_X,SCREEN_Y);

        dButton = new DrawButton[9];


        // 未登録列
        vc = new Vector();
        jList = new JList(vc);
        if( Lists.lrRec[0].nPos[Lists.nCol-1] == -1 ){
            vc.addElement(Lists.lrRec[0].szName[Lists.nCol-1]);
        }
        for( i = 0 ; i < ( Lists.nCol - 1) ; i++ ){
            if( Lists.lrRec[0].nPos[i] == - 1){
                vc.addElement(Lists.lrRec[0].szName[i]);
            }
        }
        jList.setFont(new java.awt.Font ("ＭＳ 明朝", 0, FONT_SIZE));
        jScrollPane = new javax.swing.JScrollPane();
        jBack.add(jScrollPane);
        jScrollPane.setBounds(30, 160-22, (SCREEN_X-200)/2 , SCREEN_Y-280);
        jList.setBounds(0, 0, (SCREEN_X-200)/2 , SCREEN_Y-280);
        LyRec =  Lys.FindRec("KHEST_LAREABK");
        if( LyRec != null ){
            jList.setBackground( new java.awt.Color( LyRec.r,LyRec.g,LyRec.b ) );
        }
        jScrollPane.setViewportView(jList);







        // 登録列
        vcS = new Vector();
        jListS = new JList(vcS);
        for( i = 0 ; i < Lists.nCol ; i++ ){
            if( i == 0 ){
                if( Lists.lrRec[0].nPos[Lists.nCol-1] != -1 ){
                    vcS.addElement(Lists.lrRec[0].szName[Lists.nCol-1]);
                }
                continue;
            }
            for( j = 0 ; j < ( Lists.nCol - 1) ; j++ ){
                if( Lists.lrRec[0].nPos[j] != (i-1) )continue;
                vcS.addElement(Lists.lrRec[0].szName[j]);
                break;
            }
        }
        jListS.setFont(new java.awt.Font ("ＭＳ 明朝", 0, FONT_SIZE));
        LyRec =  Lys.FindRec("KHEST_RAREABK");
        if( LyRec != null ){
            jListS.setBackground( new java.awt.Color( LyRec.r,LyRec.g,LyRec.b ) );
        }
        jScrollPaneS = new javax.swing.JScrollPane();
        jBack.add(jScrollPaneS);
        jScrollPaneS.setBounds((SCREEN_X-200)/2 + 170, 160-22, (SCREEN_X-200)/2 , SCREEN_Y-280);
        jListS.setBounds(0, 0, (SCREEN_X-200)/2 , SCREEN_Y-280);
        jScrollPaneS.setViewportView(jListS);


        i = 0;
        // 全追加ボタン作成
        LyRec =  Lys.FindRec("KHEST_ALLADD");
        if( LyRec != null ){
            dButton[i] = new DrawButton(DATA_PATH, LyRec);
            jBack.add( dButton[i] );
            dButton[i].setActionCommand("ALLADD");
            dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseReleased( MouseEvent evt) {
                        menteButtonClicked(evt);
                    }
                }
            );
            i++;
        }
        // 追加ボタン作成
        LyRec =  Lys.FindRec("KHEST_ADD");
        if( LyRec != null ){
            dButton[i] = new DrawButton(DATA_PATH, LyRec);
            jBack.add( dButton[i] );
            dButton[i].setActionCommand("ADD");
            dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseReleased( MouseEvent evt) {
                        menteButtonClicked(evt);
                    }
                }
            );
            i++;
        }
        // 削除ボタン作成
        LyRec =  Lys.FindRec("KHEST_DEL");
        if( LyRec != null ){
            dButton[i] = new DrawButton(DATA_PATH, LyRec);
            jBack.add( dButton[i] );
            dButton[i].setActionCommand("DEL");
            dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseReleased( MouseEvent evt) {
                        menteButtonClicked(evt);
                    }
                }
            );
            i++;
        }
        // 全削除ボタン作成
        LyRec =  Lys.FindRec("KHEST_ALLDEL");
        if( LyRec != null ){
            dButton[i] = new DrawButton(DATA_PATH, LyRec);
            jBack.add( dButton[i] );
            dButton[i].setActionCommand("ALLDEL");
            dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseReleased( MouseEvent evt) {
                        menteButtonClicked(evt);
                    }
                }
            );
            i++;
        }
        // 前に移動ボタン作成
        LyRec =  Lys.FindRec("KHEST_PREMOV");
        if( LyRec != null ){
            dButton[i] = new DrawButton(DATA_PATH, LyRec);
            jBack.add( dButton[i] );
            dButton[i].setActionCommand("PREMOV");
            dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseReleased( MouseEvent evt) {
                        menteButtonClicked(evt);
                    }
                }
            );
            i++;
        }
        // 後に移動ボタン作成
        LyRec =  Lys.FindRec("KHEST_NXTMOV");
        if( LyRec != null ){
            dButton[i] = new DrawButton(DATA_PATH, LyRec);
            jBack.add( dButton[i] );
            dButton[i].setActionCommand("NXTMOV");
            dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseReleased( MouseEvent evt) {
                        menteButtonClicked(evt);
                    }
                }
            );
            i++;
        }


        // 取消ボタン作成
        LyRec =  Lys.FindRec("KHEST_CANCEL");
        if( LyRec != null ){
            dButton[i] = new DrawButton(DATA_PATH, LyRec);
            jBack.add( dButton[i] );
            dButton[i].setActionCommand("CANCEL");
            dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseReleased( MouseEvent evt) {
                        menteButtonClicked(evt);
                    }
                }
            );
            i++;
        }
        // 確定ボタン作成
        LyRec =  Lys.FindRec("KHEST_OK");
        if( LyRec != null ){
            dButton[i] = new DrawButton(DATA_PATH, LyRec);
            jBack.add( dButton[i] );
            dButton[i].setActionCommand("OK");
            dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseReleased( MouseEvent evt) {
                        menteButtonClicked(evt);
                    }
                }
            );
            i++;
        }
        // メニューへ戻るボタン作成
        LyRec =  Lys.FindRec("KHEST_MENU");
        if( LyRec != null ){
            dButton[i] = new DrawButton(DATA_PATH, LyRec);
            jBack.add( dButton[i] );
            dButton[i].setActionCommand("MENU");
            dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseReleased( MouseEvent evt) {
                        menteButtonClicked(evt);
                    }
                }
            );
            i++;
        }
    }
    /*----------------------------------------------------------------*/
    // 表示設定：ボタン処理
    /*----------------------------------------------------------------*/
    public void menteButtonClicked( MouseEvent evt) {
        int         n;
        int         i;
        int         j;
        Object      s;
        int         sel;
        ListDsp     ld;

        DrawButton db = (DrawButton)evt.getSource();
        if( db.isClicked() == false )return;

        if( db.szCmd.compareTo("MENU") == 0 ){
            this.getContentPane().removeAll();
            nScrNo = 0;
            setComponentsTop ();
            return;
        }
        if( db.szCmd.compareTo("CANCEL") == 0 ){
            this.getContentPane().removeAll();
            nScrNo = nScrNo & ~16;
            nSelBk = -1;
            nPageBk = -1;
            setComponentsList ();
            return;
        }
        if( db.szCmd.compareTo("OK") == 0 ){
            // 文献番号はあるか？
            n = vcS.indexOf( Lists.lrRec[0].szName[Lists.nCol -1] );
            if( n >= 0 ){
                Lists.lrRec[0].nPos[Lists.nCol -1] = Lists.nCol -1;
            }else{
                Lists.lrRec[0].nPos[Lists.nCol -1] = -1;
            }
            // 表示順番設定
            for( i = 0 ; i < (Lists.nCol-1);i++ ){
                j = vcS.indexOf( Lists.lrRec[0].szName[i] );
                if( n >= 0 && j >= 0 )j--;
                Lists.lrRec[0].nPos[i] = j;
            }
            // 追加
            n = vt.size();
            ld = null;
            for( i = 0 ; i < n ; i++ ){
                ld = (ListDsp)vt.elementAt(i);
                if( !ld.szFName.equals(Lists.szFName) )continue;
                vt.removeElementAt(i);
                break;
            }
            if( i >= n )ld = new ListDsp(Lists.szFName,Lists.nCol);
            ld.nPos = Lists.lrRec[0].nPos;
            ld.nWidth = Lists.lrRec[0].nWidth;
            ld.nSort = nSort;
            vt.addElement(ld);



            this.getContentPane().removeAll();
            nScrNo = nScrNo & ~16;
            nSelBk = -1;
            nPageBk = -1;
            setComponentsList ();
            return;
        }

        s = null;
        if( db.szCmd.compareTo("DEL") == 0 ){
            n = jListS.getSelectedIndex();
            if( n == -1 )return;
            vc.addElement( vcS.elementAt(n) );
            vcS.removeElementAt(n);
        }
        if( db.szCmd.compareTo("ADD") == 0 ){
            n = jList.getSelectedIndex();
            if( n == -1 )return;

            s = vc.elementAt(n);
            vcS.addElement( s );
            vc.removeElementAt(n);
        }
        if( db.szCmd.compareTo("ALLADD") == 0 ){
            n = vc.size();
            for( i = 0 ; i<n;i++ )vcS.addElement( vc.elementAt(i) );
            vc.removeAllElements();
        }
        if( db.szCmd.compareTo("ALLDEL") == 0 ){
            n = vcS.size();
            for( i = 0 ; i<n;i++ )vc.addElement( vcS.elementAt(i) );
            vcS.removeAllElements();
        }

        if( db.szCmd.compareTo("PREMOV") == 0 ){
            n = jListS.getSelectedIndex();
            if( n < 1 )return;
            s = vcS.elementAt(n);
            vcS.removeElementAt(n);
            vcS.insertElementAt(s, n-1);
        }
        if( db.szCmd.compareTo("NXTMOV") == 0 ){
            n = jListS.getSelectedIndex();
            if( n  >= (vcS.size()-1) )return;
            s = vcS.elementAt(n);
            vcS.removeElementAt(n);
            vcS.insertElementAt(s,n+1);
        }
        // 文献番号は常に先頭
        n = vcS.indexOf( Lists.lrRec[0].szName[ Lists.nCol -1] );
        if( n > 0 ){
            Object p = vcS.elementAt(n);
            vcS.removeElementAt(n);
            vcS.insertElementAt(p,0);
        }
        jList.setListData(vc);
        jListS.setListData(vcS);
        // 操作後の選択処理
        if( s != null ){
            n = vcS.indexOf( s );
            jListS.setSelectedIndex(n);
        }
        return;
    }
    /*----------------------------------------------------------------*/
    // メニュー画面表示
    /*----------------------------------------------------------------*/
    private void setComponentsTop() {
        int             i;
        LayOutRec       LyRec;


        Lys = new LayOut(DATA_PATH + "Layout.txt");
        String szFName = DATA_PATH + Lys.FindRec("MENU_BACK").szImg1;
        jBack = new JLabel( new ImageIcon( szFName ) );
        getContentPane().add( jBack );
        jBack.setBounds(0,0,SCREEN_X,SCREEN_Y);


        dButton = new DrawButton[6+4];
        i = 0;

        for( i = 0 ; i < 5+4 ; i++ ){
            dButton[i] = new DrawButton(jBack, DATA_PATH, Lys.FindRec("MENU_BOTTON" + Integer.toString(i+1)));
            jBack.add( dButton[i] );
            dButton[i].setActionCommand(Integer.toString(i+1));
            dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseReleased( MouseEvent evt) {
                        topButtonClicked(evt);
                    }
            }
            );
        }
        // 閉じるボタン作成
        LyRec =  Lys.FindRec("MENU_CLOSE");
        if( LyRec != null ){
            dButton[i] = new DrawButton(DATA_PATH, LyRec);
            jBack.add( dButton[i] );

            dButton[i].setActionCommand("CLOSE");
            dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseReleased( MouseEvent evt) {
                        topButtonClicked(evt);
                    }
                }
            );
            i++;
        }

  //      for( i-- ; i>=0 ; i-- )dButton[i].repaint();
        this.setSize(SCREEN_X,SCREEN_Y);
    }
    /*----------------------------------------------------------------*/
    // スタートアップ:ボタン処理
    /*----------------------------------------------------------------*/
    public void topButtonClicked( MouseEvent evt) {
        int     n;
        OpenHtml op;


        DrawButton db = (DrawButton)evt.getSource();
        if( db.isClicked() == false )return;

        if( db.szCmd.compareTo("CLOSE") == 0 ){
            System.exit(0);
            return;
        }
        n = Integer.parseInt( db.szCmd );
        switch(n){
        case 1:
// IIS Start メニュー追加
        case 2:     // 工程フロー
        case 3:     // 工程フロー
// IIS End
            this.getContentPane().removeAll();
            nScrNo = 1;
// IIS Start
            // チーズの種類設定
            nType = n;
// IIS End
            setComponentsMenu();
            break;
        case 4:
// IIS Start メニュー追加
        case 5:     // 個票一覧
        case 6:     // 個票一覧
// IIS End
            this.getContentPane().removeAll();
            nKey1No = 1;
            nKey2No = -1;
            nKey3No = -1;
            nScrNo = 2;
            TreeNum = 0;
// IIS Start
            // チーズの種類設定
            nType = n-3;
// IIS End
            setComponentsDiv();
            break;
        case 7:     // 文献一覧
            nScrNo = 8;
            this.getContentPane().removeAll();
            nSelBk = -1;
            nPageBk = -1;
            setComponentsList();
            break;
        case 8:     // リンク集
//            try{
//                Runtime.getRuntime().exec("explorer " +  "\"" + DATA_PATH.replace('/','\\' ) + "link.html" + "\"" );
//            }catch (IOException e){
//                System.out.println("Can't Exec" );
//           }
            op = new OpenHtml(DATA_PATH + "link.html" );
            break;
        case 9:     // 用語集、定義
            op = new OpenHtml(DATA_PATH + "yougo.html" );
//            try{
//                Runtime.getRuntime().exec("explorer " +  "\"" + DATA_PATH.replace('/','\\' ) + "yougo.html" + "\"" );
//            }catch (IOException e){
//                System.out.println("Can't Exec" );
//            }
            break;
        }
    }
    /*----------------------------------------------------------------*/
    // キー選択画面表示
    /*----------------------------------------------------------------*/
    private void setComponentsMenu() {
        int             i,j,n;
        LayOutRec       LyRec;

        nKey1No = -1;
        nKey2No = -1;
        nKey3No = -1;

// IIS Start 複数化
        String szFName = DATA_PATH + Lys.FindRec("FLOW"+(nType)+"_BACK").szImg1;
// IIS End
        jBack = new JLabel( new ImageIcon( szFName ) );
        getContentPane().add( jBack );
        jBack.setBounds(0,0,SCREEN_X,SCREEN_Y);



        // 大分類数の取得
        n = 0 ;
// IIS Start 複数化
        for( j = 0 ; j < Keys[nType-1].nCnt ; j++ ){
            if( Keys[nType-1].getKey( j , 1 )  != 0 )continue;
            if( Keys[nType-1].getKey( j , 2 )  != 0 )continue;
            n++;
        }
// IIS End

        // 大分類ボタン作成
        dButton = new DrawButton[n+4];
        i = 0;
// IIS Start 複数化
        for( j = 0 ; j < Keys[nType-1].nCnt ; j++ ){
            if( Keys[nType-1].getKey( j , 1 )  != 0 )continue;
            if( Keys[nType-1].getKey( j , 2 )  != 0 )continue;
            LyRec =  Lys.FindRec("FLOW"+(nType)+"_KEY" + Integer.toString( Keys[nType-1].getKey( j , 0 )));
            if( LyRec == null )continue;

            dButton[i] = new DrawButton(DATA_PATH, LyRec);
            jBack.add( dButton[i] );
            dButton[i].setActionCommand(Integer.toString(Keys[nType-1].getKey( j , 0 )));
            dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseReleased( MouseEvent evt) {
                        menuButtonClicked(evt);
                    }
                }
            );
            i++;
        }
// IIS End

        // 戻るボタン作成
        LyRec =  Lys.FindRec("FLOW_RETURN");
        if( LyRec != null ){
            dButton[i] = new DrawButton(DATA_PATH, LyRec);
            jBack.add( dButton[i] );
            dButton[i].setActionCommand("RETURN");
            dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseReleased( MouseEvent evt) {
                        menuButtonClicked(evt);
                    }
                }
            );
            i++;
        }
        // 印刷ボタン作成
        LyRec =  Lys.FindRec("FLOW_PRINT");
        if( LyRec != null ){
            dButton[i] = new DrawButton(DATA_PATH, LyRec);
            jBack.add( dButton[i] );
            dButton[i].setActionCommand("PRINT");
            dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseReleased( MouseEvent evt) {
                        menuButtonClicked(evt);
                    }
                }
            );
            i++;
        }
        // メニューへ戻るボタン作成
        LyRec =  Lys.FindRec("FLOW_MENU");
        if( LyRec != null ){
            dButton[i] = new DrawButton(DATA_PATH, LyRec);
            jBack.add( dButton[i] );
            dButton[i].setActionCommand("MENU");
            dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseReleased( MouseEvent evt) {
                        menuButtonClicked(evt);
                    }
                }
            );
            i++;
        }
// IIS Start 総括表示
        // 総括表示ボタン作成
        LyRec =  Lys.FindRec("FLOW_SUMM");
        if( LyRec != null ){
            dButton[i] = new DrawButton(DATA_PATH, LyRec);
            jBack.add( dButton[i] );
            dButton[i].setActionCommand("SUMM");
            dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseReleased( MouseEvent evt) {
                        menuButtonClicked(evt);
                    }
                }
            );
            i++;
        }
// IIS End
    }
    /*----------------------------------------------------------------*/
    // キー選択：ボタン処理
    /*----------------------------------------------------------------*/
    public void menuButtonClicked( MouseEvent evt) {
        DrawButton db = (DrawButton)evt.getSource();
        if( db.isClicked() == false )return;

        if( db.szCmd.compareTo("MENU") == 0 ){
            this.getContentPane().removeAll();
            nScrNo = 0;
            setComponentsTop();
            return;
        }
// IIS Start 総括表示
        if( db.szCmd.compareTo("SUMM") == 0 ){
            this.getContentPane().removeAll();
            nScrNo = nScrNo | 64;
            szSumFName = Lys.FindRec("FLOW"+(nType)+"_SUMM").szImg1;
            setComponentsSum();
            return;
        }
// IIS End
        if( db.szCmd.compareTo("PRINT") == 0 ){

// IIS Start 複数化
            String szFName = DATA_PATH + Lys.FindRec("FLOW"+(nType)+"_BACK").szImg1;
// IIS End

            PrintJob pjob = getToolkit().getPrintJob(new Frame(),"Test", null, null );
            if( pjob == null )return;
            Graphics g = pjob.getGraphics();
            if( g != null ){




                Image img =  getToolkit().getImage(szFName);
                PrintGraphics pg = (PrintGraphics)g;
                Dimension dim = pg.getPrintJob().getPageDimension();

                int x = dim.width * 7 / 62;
                int y = dim.width * 5 / 62;
                int w = (int)(1024  * 0.7);
                int h = (int)(768  * 0.7);
                g.drawImage( img, x, y, w, h, this );
                g.dispose();
            }
            pjob.end();
            return;
        }

        if( db.szCmd.compareTo("RETURN") == 0 ){
            this.getContentPane().removeAll();
            nScrNo = 0;
            setComponentsTop();
            return;
        }
        this.getContentPane().removeAll();
        nScrNo = nScrNo | 2;
        nKey1No = Integer.parseInt(db.szCmd);
        TreeNum = 0;
        setComponentsDiv();
    }
    /*----------------------------------------------------------------*/
    // 説明文選択画面表示
    /*----------------------------------------------------------------*/
    private void setComponentsExp() {
        int     m;
        int     i;
        LayOutRec   LyRec;

        String szFName = DATA_PATH + Lys.FindRec("CAPT_BACK").szImg1;
        jBack = new JLabel( new ImageIcon( szFName ) );
        getContentPane().add( jBack );
        jBack.setBounds(0,0,SCREEN_X,SCREEN_Y);


        dButton = new DrawButton[4];
// IIS Start 複数化
        for( i = 0 ; i < Keys[nType-1].nCnt ; i++ ){
            if( Keys[nType-1].getKey( i , 0 )  != nKey1No )continue;
            if( Keys[nType-1].getKey( i , 1 )  != 0 )continue;
            if( Keys[nType-1].getKey( i , 2 )  != 0 )continue;
            break;
        }
// IIS End


// IIS Start 複数化
        for( m = 0 ; m < Keys[nType-1].nCnt ; m++ ){
            if( Keys[nType-1].getKey( m , 0 )  != nKey1No )continue;
            if( Keys[nType-1].getKey( m , 1 )  != nKey2No )continue;
            if( Keys[nType-1].getKey( m , 2 )  != 0 )continue;
            break;
        }
// IIS End


// IIS Start 複数化
        if( nKey2No != 0 ){
            expPanel = new ExpPanel(Keys[nType-1].getExp(m), "説明文：" + sType[nType-1] + "：" + Keys[nType-1].getTitle(i) + " - " + Keys[nType-1].getTitle(m) );
        }else{
            expPanel = new ExpPanel(Keys[nType-1].getExp(m), "説明文：" + sType[nType-1] + "：" + Keys[nType-1].getTitle(m) );
        }
// IIS End
        expPanel.setLayout(null);
        expPanel.setFont(new java.awt.Font ("ＭＳ 明朝", 0, FONT_SIZE));

        LyRec =  Lys.FindRec("CAPT_AREABK");
        if( LyRec != null ){
            expPanel.setBackground( new java.awt.Color( LyRec.r,LyRec.g,LyRec.b ) );
        }else{
            expPanel.setBackground(java.awt.Color.white );
        }
        expPanel.setForeground(java.awt.Color.black);
        java.awt.event.MouseListener mouseListener = new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent e) {
                ExpMouseClicked(e);
            }
        };
        expPanel.addMouseListener(mouseListener);


        expPanel.setSize( SCREEN_X-60, SCREEN_Y-230 );


        jScrollPane = new javax.swing.JScrollPane();
        jScrollPane.setBounds(20, 150-22,  SCREEN_X - 40, SCREEN_Y-230);
        jBack.add(jScrollPane);
        jScrollPane.setViewportView(expPanel);
        expPanel.setPreferredSize( new Dimension( SCREEN_X-60, expPanel.getHeightArea() ) );

        jScrollPane.getVerticalScrollBar().setUnitIncrement(expPanel.getLineHeight());
        jScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);


        // 戻るボタン作成
        i = 0;
        LyRec =  Lys.FindRec("CAPT_RETURN");
        if( LyRec != null ){
            dButton[i] = new DrawButton(DATA_PATH, LyRec);
            jBack.add( dButton[i] );
            dButton[i].setActionCommand("RETURN");
            dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseReleased( MouseEvent evt) {
                        expButtonClicked(evt);
                    }
                }
            );
            i++;
        }
        // 印刷ボタン作成
        LyRec =  Lys.FindRec("CAPT_PRINT");
        if( LyRec != null ){
            dButton[i] = new DrawButton(DATA_PATH, LyRec);
            jBack.add( dButton[i] );
            dButton[i].setActionCommand("PRINT");
            dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseReleased( MouseEvent evt) {
                        expButtonClicked(evt);
                    }
                }
            );
            i++;
        }
        // メニューへ戻るボタン作成
        LyRec =  Lys.FindRec("CAPT_MENU");
        if( LyRec != null ){
            dButton[i] = new DrawButton(DATA_PATH, LyRec);
            jBack.add( dButton[i] );
            dButton[i].setActionCommand("MENU");
            dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseReleased( MouseEvent evt) {
                        expButtonClicked(evt);
                    }
                }
            );
            i++;
        }
    }
    /*----------------------------------------------------------------*/
    // 説明文：ボタン処理
    /*----------------------------------------------------------------*/
    public void expButtonClicked( MouseEvent evt) {
        DrawButton db = (DrawButton)evt.getSource();
        if( db.isClicked() == false )return;

        if( db.szCmd.compareTo("MENU") == 0 ){
            this.getContentPane().removeAll();
            nScrNo = 0;
            setComponentsTop();
            return;
        }
        if( db.szCmd.compareTo("PRINT") == 0 ){
            PrintJob    pjob = getToolkit().getPrintJob(this,"Test", null, null );
            if( pjob == null )return;
            Graphics pg =pjob.getGraphics();
            if( pg != null ){
                expPanel.print(pg);
//                pg.dispose();
            }
            pjob.end();
            return;
        }
        if( db.szCmd.compareTo("RETURN") == 0 ){
            this.getContentPane().removeAll();
            nScrNo = nScrNo & ~4;
            setComponentsDiv ();
            return;
        }
    }
    /*----------------------------------------------------------------*/
    // 説明文：マウス処理
    /*----------------------------------------------------------------*/
    private void ExpMouseClicked(java.awt.event.MouseEvent e) {
        KeyNo   key;

        key = expPanel.getKeyAtPoint(e.getX(),e.getY());
        if( key != null ){
            nKey1NoBk = nKey1No;
            nKey2NoBk = nKey2No;
            nKey3NoBk = nKey3No;

            nKey1No = key.keys[0];
            nKey2No = key.keys[1];
            nKey3No = key.keys[2];
            this.getContentPane().removeAll();

            nScrNo = nScrNo | 8;
            nSelBk = -1;
            nPageBk = -1;
            setComponentsList();

        }
    }
// IIS Start 総括画面
    /*----------------------------------------------------------------*/
    // 総括画面表示
    /*----------------------------------------------------------------*/
    private void setComponentsSum() {
        int     m;
        int     i;
        LayOutRec   LyRec;

        String szFName = DATA_PATH + Lys.FindRec("SUMM_BACK").szImg1;
        jBack = new JLabel( new ImageIcon( szFName ) );
        getContentPane().add( jBack );
        jBack.setBounds(0,0,SCREEN_X,SCREEN_Y);

        dButton = new DrawButton[20];
        java.awt.Dimension dim = this.getSize();

/*** 表示倍率変更機能を実装する場合、以下のコメントを有効にすること。
        //  縮小率
        ButtonGroup bgroup = new ButtonGroup();

        jRadioSum = new JRadioButton[3];
        jRadioSum[0] = new JRadioButton( "75%" );
        jRadioSum[0].setFont(new java.awt.Font ("ＭＳ 明朝", 0, FONT_SIZE));
        jRadioSum[0].setForeground(java.awt.Color.black);
        jRadioSum[0].setBackground(java.awt.Color.white);
        jRadioSum[0].setOpaque(false);
        bgroup.add( jRadioSum[0] );
        jRadioSum[1] = new JRadioButton( "100%", true );
        jRadioSum[1].setFont(new java.awt.Font ("ＭＳ 明朝", 0, FONT_SIZE));
        jRadioSum[1].setForeground(java.awt.Color.black);
        jRadioSum[1].setBackground(java.awt.Color.white);
        jRadioSum[1].setOpaque(false);
        bgroup.add( jRadioSum[1] );
        jRadioSum[2] = new JRadioButton( "125%" );
        jRadioSum[2].setFont(new java.awt.Font ("ＭＳ 明朝", 0, FONT_SIZE));
        jRadioSum[2].setForeground(java.awt.Color.black);
        jRadioSum[2].setBackground(java.awt.Color.white);
        jRadioSum[2].setOpaque(false);
        bgroup.add( jRadioSum[2] );


        jBack.add(jRadioSum[0]);
        jRadioSum[0].setBounds(120, dim.height-90-22, 60, 20);
        jBack.add(jRadioSum[1]);
        jRadioSum[1].setBounds(180, dim.height-90-22, 70, 20);
        jBack.add(jRadioSum[2]);
        jRadioSum[2].setBounds(250, dim.height-90-22, 70, 20);


        jRadioSum[0].addItemListener(new java.awt.event.ItemListener() {
                public void itemStateChanged(java.awt.event.ItemEvent evt) {
                    SumchkBoxsItemActionPerformed(evt);
                }
            }
        );
        jRadioSum[1].addItemListener(new java.awt.event.ItemListener() {
                public void itemStateChanged(java.awt.event.ItemEvent evt) {
                    SumchkBoxsItemActionPerformed(evt);
                }
            }
        );
        jRadioSum[2].addItemListener(new java.awt.event.ItemListener() {
                public void itemStateChanged(java.awt.event.ItemEvent evt) {
                    SumchkBoxsItemActionPerformed(evt);
                }
            }
        );

        JLabel jLabel;
        jLabel = new JLabel("表示倍率");
        jLabel.setFont(new java.awt.Font ("ＭＳ 明朝", 0, FONT_SIZE));
        jLabel.setForeground(java.awt.Color.black);
        jBack.add( jLabel );
        jLabel.setBounds(30, dim.height-90-22, 80, 20);
***/

        for( i = 0 ; i < Keys[nType-1].nCnt ; i++ ){
            if( Keys[nType-1].getKey( i , 0 )  != nKey1No )continue;
            if( Keys[nType-1].getKey( i , 1 )  != 0 )continue;
            if( Keys[nType-1].getKey( i , 2 )  != 0 )continue;
            break;
        }


        for( m = 0 ; m < Keys[nType-1].nCnt ; m++ ){
            if( Keys[nType-1].getKey( m , 0 )  != nKey1No )continue;
            if( Keys[nType-1].getKey( m , 1 )  != nKey2No )continue;
            if( Keys[nType-1].getKey( m , 2 )  != 0 )continue;
            break;
        }

        String sSumFName = "";
        String sSumTitle = "";
        if (szSumFName != null) {
            sSumFName = szSumFName;
        }
        else {
            if( nKey2No != 0 ){
                sSumFName = Keys[nType-1].getSum(m).trim();
                sSumTitle = Keys[nType-1].getTitle(i);
            }else{
                sSumFName = Keys[nType-1].getSum(m).trim();
                sSumTitle = Keys[nType-1].getTitle(m);
            }
        }

        // 総括
        sumPanel = new SumDrawPanel(DATA_PATH + sSumFName, DATA_PATH );

        sumPanel.setFont(new java.awt.Font ("ＭＳ 明朝", 0, FONT_SIZE-1));
        LyRec =  Lys.FindRec("SUMM_AREABK");
        if( LyRec != null ){
            sumPanel.setBackground( new java.awt.Color( LyRec.r,LyRec.g,LyRec.b ) );
        }else{
            sumPanel.setBackground(java.awt.Color.white);
        }
        sumPanel.setForeground(java.awt.Color.black);
        jBack.add(sumPanel);
        sumPanel.setBounds(21, 160-21, SCREEN_X - 70, SCREEN_Y - 280 );

        int nHeight = sumPanel.getHeightArea();
        int nWidth = sumPanel.getWidthArea();


        jScrollPane = new javax.swing.JScrollPane();
        jScrollPane.setBounds(20, 160-22, SCREEN_X - 50, SCREEN_Y - 280 );
        jBack.add(jScrollPane);
        jScrollPane.setViewportView(sumPanel);
        sumPanel.setPreferredSize( new Dimension( nWidth, nHeight ) );
        sumPanel.setSize(nWidth,nHeight);

        jScrollPane.getVerticalScrollBar().setUnitIncrement(FONT_SIZE);
        jScrollPane.getHorizontalScrollBar().setUnitIncrement(FONT_SIZE);
        jScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

        jScrollPane.requestDefaultFocus();

        i=0;
        // 戻るボタン作成
        LyRec =  Lys.FindRec("SUMM_RETURN");
        if( LyRec != null ){
            dButton[i] = new DrawButton(DATA_PATH, LyRec);
            jBack.add( dButton[i] );
            dButton[i].setActionCommand("RETURN");
            dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseReleased( MouseEvent evt) {
                        sumButtonClicked(evt);
                    }
                }
            );
            i++;
        }
        // 印刷ボタン作成
        LyRec =  Lys.FindRec("SUMM_PRINT");
        if( LyRec != null ){
            dButton[i] = new DrawButton(DATA_PATH, LyRec);
            jBack.add( dButton[i] );
            dButton[i].setActionCommand("PRINT");
            dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseReleased( MouseEvent evt) {
                        sumButtonClicked(evt);
                    }
                }
            );
            i++;
        }

        // メニューへ戻るボタン作成
        LyRec =  Lys.FindRec("SUMM_MENU");
        if( LyRec != null ){
            dButton[i] = new DrawButton(DATA_PATH, LyRec);
            jBack.add( dButton[i] );
            dButton[i].setActionCommand("MENU");
            dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseReleased( MouseEvent evt) {
                        sumButtonClicked(evt);
                    }
                }
            );
            i++;
        }

    }
    /*----------------------------------------------------------------*/
    // 総括：ボタン処理
    /*----------------------------------------------------------------*/
    public void sumButtonClicked( MouseEvent evt) {

        DrawButton db = (DrawButton)evt.getSource();
        if( db.isClicked() == false )return;


        if( db.szCmd.compareTo("MENU") == 0 ){
            this.getContentPane().removeAll();
            nScrNo = 0;
            setComponentsTop();
            return;
        }
        if( db.szCmd.compareTo("PRINT") == 0 ){
            PrintJob    pjob = getToolkit().getPrintJob(this,"Test", null, null );
            if( pjob == null )return;
            sumPanel.printDoc( pjob );
            pjob.end();
            return;
        }
        if( db.szCmd.compareTo("RETURN") == 0 ){
            szSumFName = null;
            this.getContentPane().removeAll();
            nScrNo = nScrNo & ~64;
            if( nScrNo == 1 ){
                setComponentsMenu();
            }else{
                setComponentsDiv();
            }

            return;
        }
    }
    /*----------------------------------------------------------------*/
    // 総括：縮小・拡大処理
    /*----------------------------------------------------------------*/
    public void SumchkBoxsItemActionPerformed(java.awt.event.ItemEvent evt) {
        if( evt.getSource() == jRadioSum[0] )sumPanel.setScale( 75.0 );
        if( evt.getSource() == jRadioSum[1] )sumPanel.setScale( 100.0 );
        if( evt.getSource() == jRadioSum[2] )sumPanel.setScale( 125.0 );

        sumPanel.setPreferredSize( new Dimension( sumPanel.getWidthArea(), sumPanel.getHeightArea() ) );
        sumPanel.revalidate();
    }
// IIS End
    /*----------------------------------------------------------------*/
    // 項目選択画面表示
    /*----------------------------------------------------------------*/
    private void setComponentsDiv() {
        int     i;
        int     j;
        int     k;
        int     n;
        int     m;
        LayOutRec   LyRec;

// IIS Start 複数化
        String szFName = DATA_PATH + Lys.FindRec("KHTBL"+(nType)+"_BACK").szImg1;
// IIS End
        jBack = new JLabel( new ImageIcon( szFName ) );
        getContentPane().add( jBack );
        jBack.setBounds(0,0,SCREEN_X,SCREEN_Y);

        dButton = new DrawButton[4];

        DefaultMutableTreeNode root1;

        root1 = new DefaultMutableTreeNode( );
        DefaultMutableTreeNode tree1;
        DefaultMutableTreeNode tree2;
// IIS Start 複数化
        for( m = 0 ; m < Keys[nType-1].nCnt ; m++ ){
            if( Keys[nType-1].getKey( m , 1 )  != 0 )continue;
            if( Keys[nType-1].getKey( m , 2 )  != 0 )continue;
            tree1 = new DefaultMutableTreeNode( Keys[nType-1].getRec(m) );
            root1.add( tree1 );
            for( n = 0 ; n < Keys[nType-1].nCnt ; n++ ){
                if( Keys[nType-1].getKey( n , 0 )  != Keys[nType-1].getKey( m , 0 ) )continue;
                if( Keys[nType-1].getKey( n , 1 )  == 0 )continue;
                if( Keys[nType-1].getKey( n , 2 )  != 0 )continue;

                for( j = 0 ; j < Keys[nType-1].nCnt ; j++ ){
                    if( Keys[nType-1].getKey( j , 0 )  != Keys[nType-1].getKey( m , 0 ) )continue;
                    if( Keys[nType-1].getKey( j , 1 )  != Keys[nType-1].getKey( n , 1 ) )continue;
                    if( Keys[nType-1].getKey( j , 2 )  == 0 )continue;
                    break;
                }
                if( j >= Keys[nType-1].nCnt )continue;
                tree2 = new DefaultMutableTreeNode( Keys[nType-1].getRec(n) );
                tree1.add( tree2 );
            }
        }
// IIS End

        jTree1 = new javax.swing.JTree(root1);
        jTree1.setFont(new java.awt.Font ("ＭＳ 明朝",0, FONT_SIZE+1));

        LyRec =  Lys.FindRec("KHTBL_LAREABK");
        if( LyRec!=null ){
            jTree1.setBackground(new Color(LyRec.r,LyRec.g,LyRec.b) );
            DefaultTreeCellRenderer rd =
                ( DefaultTreeCellRenderer ) jTree1.getCellRenderer();
            rd.setBackgroundNonSelectionColor(new Color(LyRec.r,LyRec.g,LyRec.b));
            LyRec =  Lys.FindRec("KHTBL_CHILDICON");
            if( LyRec != null ){
                rd.setLeafIcon( new javax.swing.ImageIcon(DATA_PATH + LyRec.szImg1) );
            }
            LyRec =  Lys.FindRec("KHTBL_FOLDICON");
            if( LyRec != null ){
                rd.setClosedIcon( new javax.swing.ImageIcon(DATA_PATH + LyRec.szImg1) );
                rd.setOpenIcon( new javax.swing.ImageIcon(DATA_PATH + LyRec.szImg1) );
            }
        }
        jTree1.setRootVisible(false);

        jTree1.addTreeSelectionListener(new TreeSelectionListener() {
                public void valueChanged(TreeSelectionEvent evt) {
                    treeDivValueChanged(evt);
                }
            }
        );
        jScrollPane = new javax.swing.JScrollPane();
        jScrollPane.setBounds(80, 180, (SCREEN_X-170)/2, SCREEN_Y-280);
        jBack.add(jScrollPane);
        jScrollPane.setViewportView(jTree1);

        //
        jScrollPaneS = new javax.swing.JScrollPane();
        jScrollPaneS.setBounds((SCREEN_X-170)/2+85, 180, (SCREEN_X-170)/2, SCREEN_Y-280);
        jBack.add(jScrollPaneS);

        // 選択処理
        if( TreeNum == 0 ){
            i = 0;
// IIS Start 複数化
            for( m = 0 ; m < Keys[nType-1].nCnt ; m++ ){
                if( Keys[nType-1].getKey( m , 1 )  != 0 )continue;
                if( Keys[nType-1].getKey( m , 2 )  != 0 )continue;
                if( Keys[nType-1].getKey( m , 0 )  == nKey1No ){
                    jTree1.addSelectionRow(i);
                    jTree1.expandRow(i);
                }
                i++;
                for( n = 0 ; n < Keys[nType-1].nCnt ; n++ ){
                    if( Keys[nType-1].getKey( n , 0 )  != Keys[nType-1].getKey( m , 0 ) )continue;
                    if( Keys[nType-1].getKey( n , 1 )  == 0 )continue;
                    if( Keys[nType-1].getKey( n , 2 )  != 0 )continue;
                    for( j = 0 ; j < Keys[nType-1].nCnt ; j++ ){
                        if( Keys[nType-1].getKey( j , 0 )  != Keys[nType-1].getKey( m , 0 ) )continue;
                        if( Keys[nType-1].getKey( j , 1 )  != Keys[nType-1].getKey( n , 1 ) )continue;
                        if( Keys[nType-1].getKey( j , 2 )  == 0 )continue;
                        break;
                    }
                    if( j >= Keys[nType-1].nCnt )continue;
                    if( Keys[nType-1].getKey( n , 0 )  == nKey1No ){
                        jTree1.expandRow(i);
                        i++;
                    }
                }
            }
// IIS End
        }else{
            for( i = 0 ; i < TreeNum; i++ ){
                if( expTree[i])jTree1.expandRow(i);
            }
            jTree1.setSelectionRow(selTree);
        }
        // 戻るボタン作成
        i = 0;
        LyRec =  Lys.FindRec("KHTBL_RETURN");
        if( LyRec != null ){
            dButton[i] = new DrawButton(DATA_PATH, LyRec);
            jBack.add( dButton[i] );
            dButton[i].setActionCommand("RETURN");
            dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseReleased( MouseEvent evt) {
                        divButtonClicked(evt);
                    }
                }
            );
            i++;
        }
        // 印刷ボタン作成
        LyRec =  Lys.FindRec("KHTBL_PRINT");
        if( LyRec != null ){
            dButton[i] = new DrawButton(DATA_PATH, LyRec);
            jBack.add( dButton[i] );
            dButton[i].setActionCommand("PRINT");
            dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseReleased( MouseEvent evt) {
                        divButtonClicked(evt);
                    }
                }
            );
            i++;
        }
        // メニューへ戻るボタン作成
        LyRec =  Lys.FindRec("KHTBL_MENU");
        if( LyRec != null ){
            dButton[i] = new DrawButton(DATA_PATH, LyRec);
            jBack.add( dButton[i] );
            dButton[i].setActionCommand("MENU");
            dButton[i].addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseReleased( MouseEvent evt) {
                        divButtonClicked(evt);
                    }
                }
            );
            i++;
        }
    }
    /*----------------------------------------------------------------*/
    // 項目選択：ボタン処理
    /*----------------------------------------------------------------*/
    public void divButtonClicked( MouseEvent evt) {
        DrawButton db = (DrawButton)evt.getSource();
        if( db.isClicked() == false )return;
        String      szTitle = "";

        if( db.szCmd.compareTo("MENU") == 0 ){
            this.getContentPane().removeAll();
            nScrNo = 0;
            setComponentsTop();
            return;
        }
        if( db.szCmd.compareTo("PRINT") == 0 ){
// IIS Start 複数化
            szTitle = sType[nType-1] + "：個票一覧";
            TreeList_Print Tree_Print = new TreeList_Print(new Frame(), Keys[nType-1], szTitle );
// IIS End
            Tree_Print.PrtOut();

            return;
        }
        if( db.szCmd.compareTo("RETURN") == 0 ){
            this.getContentPane().removeAll();
            nScrNo = nScrNo & ~2;
            if( nScrNo == 0 ){
                setComponentsTop();
            }else{
                setComponentsMenu();
            }
            return;
        }
    }
    /*----------------------------------------------------------------*/
    // 項目選択：ツリー選択処理
    /*----------------------------------------------------------------*/
    private void treeDivValueChanged(TreeSelectionEvent evt) {
        KeyRec      ky;
        int         m,n;
        LayOutRec   LyRec;
        int         i;

        DefaultMutableTreeNode node = (DefaultMutableTreeNode)jTree1.getLastSelectedPathComponent();

        ky = (KeyRec)node.getUserObject();

        DefaultMutableTreeNode root1;
        root1 = new DefaultMutableTreeNode( );
        DefaultMutableTreeNode tree1;


        if( !ky.szExp.equals("") ){
            KeyRec expKey = new KeyRec();
            expKey.szTitle = "説明文...";
            expKey.nKey = ky.nKey;
            tree1 = new DefaultMutableTreeNode( expKey, true );
            root1.add( tree1 );
// IIS Start 総括画面
            expKey = new KeyRec();
            expKey.szTitle = "総括...";
            expKey.nKey = ky.nKey;
            tree1 = new DefaultMutableTreeNode( expKey, true );
            root1.add( tree1 );
// IIS End
        }

// IIS Start 複数化
        for( m = 0 ; m < Keys[nType-1].nCnt ; m++ ){
            if( Keys[nType-1].getKey( m , 0 )  != ky.nKey[0] )continue;
            // 中項目のとき
            if( ky.nKey[1] != 0 ){
                if( Keys[nType-1].getKey( m , 1 )  != ky.nKey[1] )continue;
                if( Keys[nType-1].getKey( m , 2 )  == 0 )continue;
                tree1 = new DefaultMutableTreeNode( Keys[nType-1].getRec(m), false );
                root1.add( tree1 );
                continue;
            }
            // 大項目のとき
            if( Keys[nType-1].getKey( m , 1 )  == 0 )continue;
            if( Keys[nType-1].getKey( m , 2 )  != 0 )continue;
            for( n = 0 ; n < Keys[nType-1].nCnt ; n++ ){
                if( Keys[nType-1].getKey( n , 0 )  != ky.nKey[0] )continue;
                if( Keys[nType-1].getKey( n , 1 )  != Keys[nType-1].getKey( m , 1 ) )continue;
                if( Keys[nType-1].getKey( n , 2 )  == 0 )continue;
                break;
            }
            if( n < Keys[nType-1].nCnt )continue;
            tree1 = new DefaultMutableTreeNode( Keys[nType-1].getRec(m), false );
            root1.add( tree1 );
        }
// IIS End


        jTree2 = new javax.swing.JTree(root1,true);
        jTree2.setFont(new java.awt.Font ("ＭＳ 明朝",0, FONT_SIZE+1));




        LyRec =  Lys.FindRec("KHTBL_RAREABK");
        if( LyRec!=null ){
            jTree2.setBackground(new Color(LyRec.r,LyRec.g,LyRec.b) );
            DefaultTreeCellRenderer rd =
                ( DefaultTreeCellRenderer ) jTree2.getCellRenderer();

            rd.setBackgroundNonSelectionColor(new Color(LyRec.r,LyRec.g,LyRec.b));
            LyRec =  Lys.FindRec("KHTBL_DATAICON");
            if( LyRec != null ){
                rd.setLeafIcon( new javax.swing.ImageIcon(DATA_PATH + LyRec.szImg1) );
            }
            LyRec =  Lys.FindRec("KHTBL_CAPTICON");
            if( LyRec != null ){
                rd.setClosedIcon( new javax.swing.ImageIcon(DATA_PATH + LyRec.szImg1) );
                rd.setOpenIcon( new javax.swing.ImageIcon(DATA_PATH + LyRec.szImg1) );
            }
        }

        jTree2.setRootVisible(false);
        jTree2.addTreeSelectionListener(new TreeSelectionListener() {
                public void valueChanged(TreeSelectionEvent evt) {
                    treeSubValueChanged(evt);
                }
            }
        );
        jScrollPaneS.setViewportView(jTree2);
    }
    /*----------------------------------------------------------------*/
    // 項目選択：ツリー選択処理
    /*----------------------------------------------------------------*/
    private void treeSubValueChanged(TreeSelectionEvent evt) {
        KeyRec  ky;
        int     m,n;
        int     i;

        DefaultMutableTreeNode node = (DefaultMutableTreeNode)jTree2.getLastSelectedPathComponent();
        ky = (KeyRec)node.getUserObject();

        TreeNum = jTree1.getRowCount();
        expTree = new boolean[TreeNum];
        for( i = 0 ; i < TreeNum;i++ ){
            if( jTree1.isExpanded(i) )expTree[i] = true;
        }
        int[]  s = jTree1.getSelectionRows();
        selTree = s[0];

        nKey1No = ky.nKey[0];
        nKey2No = ky.nKey[1];
        nKey3No = ky.nKey[2];
        // 説明文
        if( ky.toString().equals("説明文...") ){
            this.getContentPane().removeAll();
            nScrNo = nScrNo | 4;
            setComponentsExp();
            return;
        }

// IIS Start 総括画面
        // 総括
        if( ky.toString().equals("総括...") ){
            this.getContentPane().removeAll();
            nScrNo = nScrNo | 64;
            setComponentsSum();
            return;
        }
// IIS End

        this.getContentPane().removeAll();
        nScrNo = nScrNo | 8;
        nSelBk = -1;
        nPageBk = -1;
        setComponentsList();
    }
    /*----------------------------------------------------------------*/
    /*----------------------------------------------------------------*/

    private void initComponents() {//GEN-BEGIN:initComponents

        getContentPane().setLayout(null);

        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                exitForm(evt);
            }
        });

        pack();
    }//GEN-END:initComponents

    /** Exit the Application */
    private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
        System.exit(0);
    }//GEN-LAST:event_exitForm

    /**
    * @param args the command line arguments
    */
    /*----------------------------------------------------------------*/
    // メイン（引数処理）
    /*----------------------------------------------------------------*/
    public static void main (String args[]) {

        int     i;
        int     n;
        Haccp   haccp;

        nKind = 1;
// IIS Start 複数化
        nType = 0;
// IIS End
        DATA_PATH = "Data/";
        for( i = 0 ; i < args.length ; i++ ){
            n = args[i].indexOf("/Type=");
            if( n != -1 ){
                nKind = Integer.parseInt(args[i].substring(n+6));
            }else{
                DATA_PATH = args[i];
            }
        }
        if( nKind < 1 || nKind > 4 )nKind = 1;
        haccp = new Haccp();


//        new Haccp ().show ();
    }


    // 変数宣言 - 編集不可//GEN-BEGIN:variables
    // 変数宣言の終わり//GEN-END:variables

}
/*--------------------------------------------------------------------*/
// リスト表示変更クラス
/*--------------------------------------------------------------------*/
class RowHeaderRenderer extends JLabel implements ListCellRenderer {

    RowHeaderRenderer(JTable table) {
        javax.swing.table.JTableHeader header = table.getTableHeader();
        setOpaque(true);
        setBorder(UIManager.getBorder("TableHeader.cellBorder"));
        setForeground(header.getForeground());
        setBackground(header.getBackground());
        setFont(header.getFont());
    }
    public Component getListCellRendererComponent( JList list,
        Object value, int index, boolean isSelected, boolean cellHasFocus) {

        setText((value == null) ? "" : ( value.toString()));
        return this;

    }
}
/*--------------------------------------------------------------------*/
// 文献番号リストクラス
/*--------------------------------------------------------------------*/
class FixedModel extends javax.swing.AbstractListModel{
    ListData    ld;
    public FixedModel(ListData ld){
        this.ld  = ld;
    }
    public java.lang.Object getElementAt(int index){
        if( ld.nRow < 1 )return "";
        return ld.lrRec[index+1].szName[ld.nCol-1] ;
    }
    public int getSize(){
        if( ld.nRow < 1 )return 0;
        return ld.nRow -1 ;
    }
}
/*--------------------------------------------------------------------*/
// 個票列表示クラス
/*--------------------------------------------------------------------*/
class MyCellRenderer extends JLabel implements javax.swing.table.TableCellRenderer {
    public Component getTableCellRendererComponent(
                JTable table, Object data, boolean isSelected, boolean hasFocus,
                int row, int column) {
        setOpaque(true);
        setHorizontalAlignment(JLabel.LEFT);
        setText((String)data);

        setBorder(UIManager.getBorder("TableHeader.cellBorder"));
        setForeground(table.getTableHeader().getForeground());
        setBackground(table.getTableHeader().getBackground());
        setFont(table.getFont());
        return this;
    }

}
/*--------------------------------------------------------------------*/
// 個票表示クラス
/*--------------------------------------------------------------------*/
class NotEditModel extends javax.swing.table.AbstractTableModel{
    ListData    ld;

    public NotEditModel(ListData ld){
        this.ld  = ld;
    }
    public int getRowCount(){
        if( ld.nRow < 1 )return 0;
        return ld.nRow - 1;
    }
    public int getColumnCount(){
        int     n;
        int     i;

        for( n = 0; n < (ld.nCol-1) ; n++ ){
            for( i = 0; i < (ld.nCol-1) ; i++ ){
                if( ld.lrRec[0].nPos[i] == n )break;
            }
            if( i >= (ld.nCol-1) )break;
        }
        return n;
    }
    public java.lang.Object getValueAt(int row, int col){
        int     i;

        if( ld.nRow < 1 )return null;
        for( i = 0 ; i < (ld.nCol-1) ; i++ ){
            if( ld.lrRec[0].nPos[i] != col )continue;
            return ld.lrRec[row+1].szName[i];
        }
        return null;
    }
    public String getColumnName(int col ){
        int     i;
        if( ld.nRow < 1 )return "";
        for( i = 0 ; i < (ld.nCol-1) ; i++ ){
            if( ld.lrRec[0].nPos[i] != col )continue;
            return ld.lrRec[0].szName[i];
        }
        return "";
    }
    public Class getColumnClass( int col )
    {
        if( ld.nRow < 1 )return null;
        return String.class;
    }
    public boolean isCellEditable(int row, int col ){
        return false;
    }
    public void setValueAt(Object value, int row, int col ){
        int i;
        if( ld.nRow < 1 )return;
        for( i = 0 ; i < (ld.nCol-1) ; i++ ){
            if( ld.lrRec[0].nPos[i] != col )continue;
            ld.lrRec[row+1].szName[i] = (String)value;
            break;
        }
    }
}
/*--------------------------------------------------------------------*/
// キーデータレコードクラス
/*--------------------------------------------------------------------*/
class KeyRec extends Object {
    public int[] nKey = new int[3];
    public String szTitle;
    public String szExp;
// IIS Start 総括画面
    public String szSum;
// IIS End
    public String szFName;
    public String szURL;
    public KeyRec() {
    }
    public String toString()
    {
        return szTitle;
    }
}
/*--------------------------------------------------------------------*/
// キーデータクラス
/*--------------------------------------------------------------------*/
class KeyData extends Object {
    static int MAX_ROW = 120;
    public int nCnt;
    public KeyRec[] krRec = new KeyRec[MAX_ROW];

    public KeyData(String s) {
        int i;

        try {
            File fI;
            FileInputStream fin;
            byte byDataBuff[];
            fI = new File(s);
            int nDataLen;
            StringTokenizer stReadData;
            String szLine;


            byDataBuff = new byte[(int)fI.length()];
            fin = new FileInputStream(fI);
            nDataLen = fin.read(byDataBuff);

            // １行づつ取り出し
            stReadData = new StringTokenizer( new String(byDataBuff,0,nDataLen),"\r\n");
            nCnt = 0;
            while( stReadData.hasMoreTokens()){
                szLine = stReadData.nextToken();
                if( szLine.startsWith("<Key ")==true ){
                    krRec[nCnt] = new KeyRec();
                    int ofs = szLine.indexOf('>',3);
                    krRec[nCnt].szFName = "";
                    krRec[nCnt].szTitle = szLine.substring( ofs+1 );


                    int gt = krRec[nCnt].szTitle.indexOf("#Goto ");
                    if( gt != -1 ) {
                        krRec[nCnt].szFName = krRec[nCnt].szTitle.substring(gt+6);
                        krRec[nCnt].szTitle = krRec[nCnt].szTitle.substring(0,gt);
                    }



                    int nt = krRec[nCnt].szTitle.indexOf("#URL ");
                    if( nt != -1 ) {
                        krRec[nCnt].szURL = krRec[nCnt].szTitle.substring(nt+5);
                        krRec[nCnt].szTitle = krRec[nCnt].szTitle.substring(0,nt);
                    }else{
                        krRec[nCnt].szURL = "";
                    }

                    krRec[nCnt].szExp = "";
// IIS Start 総括画面
                    krRec[nCnt].szSum = "";
// IIS End

                    String Keys = szLine.substring( 5,ofs );

                    StringTokenizer stKeyData = new StringTokenizer(Keys,"-");
                    i = 0;
                    while( stKeyData.hasMoreTokens()){
                        krRec[nCnt].nKey[i]=Integer.parseInt(stKeyData.nextToken());
                        i++;
                    }
                    nCnt++;
                    continue;
                }
// IIS Start 総括画面
// 説明文ファイル、総括ファイルの指定例：CEEX0001.txt,SUMM1001.txt
// 説明文ファイルのみの指定例：CEEX0001.txt
// 総括ファイルのみの指定例：,SUMM1001.txt（カンマをつけること）
//
//                krRec[nCnt-1].szExp = krRec[nCnt-1].szExp.concat(szLine).concat("\n");
                int nPos = szLine.indexOf(",");
                String sExp = "";
                String sSum = "";
                if (nPos >= 0) {
                    sExp = szLine.substring(0, nPos);
                    krRec[nCnt-1].szExp = krRec[nCnt-1].szExp.concat(sExp).concat("\n");
                    if (szLine.length() > nPos+1) {
                        sSum = szLine.substring(nPos+1);
                        krRec[nCnt-1].szSum = krRec[nCnt-1].szSum.concat(sSum).concat("\n");
                    }
                } else {
                    krRec[nCnt-1].szExp = krRec[nCnt-1].szExp.concat(szLine).concat("\n");
                }
//System.out.println("szExp=["+krRec[nCnt-1].szExp+"]");
//System.out.println("sSum=["+krRec[nCnt-1].szSum+"]");
// IIS End
            }
            fin.close();
        }
        catch(IOException err){
            System.out.println("ERR");
        }
        for( i = 0 ; i < nCnt; i++ ){
            String  path;

            if( krRec[i].szExp.length() < 4 )continue;
            if( krRec[i].szExp.length() > 64 )continue;

            int n = s.lastIndexOf("/");
            path = "";
            if( n >= 0 ){
                path = s.substring(0,n+1);
            }
            path = path.concat(krRec[i].szExp);
            n = path.lastIndexOf("\n");
            if( n > 0 )path = path.substring(0,n);

            try {
                File fI;
                FileInputStream fin;
                byte byDataBuff[];
                int nDataLen;
                StringTokenizer stReadData;
                String szLine;

                fI=new File(path);
                byDataBuff = new byte[(int)fI.length()];
                fin = new FileInputStream(fI);
                nDataLen = fin.read(byDataBuff);
                stReadData = new StringTokenizer( new String(byDataBuff,0,nDataLen),"\r\n");
                krRec[i].szExp = "";
                while( stReadData.hasMoreTokens()){
                    szLine = stReadData.nextToken();
                    krRec[i].szExp = krRec[i].szExp.concat(szLine).concat("\n");
                }
                fin.close();
            }
            catch(IOException err){
            }

        }
    }
    public static void main (String args[]) {
        new KeyData("c:\\forte4j\\Development\\Htss\\KeyDataFile.txt");
    }
    public int getKey( int i, int j ){
        return krRec[i].nKey[j];
    }
    public String getTitle( int i ){
        return krRec[i].szTitle;
    }
    public String getURL( int i ){
        return krRec[i].szURL;
    }
    public String getExp( int i ){
        return krRec[i].szExp;
    }
// IIS Start 総括画面
    public String getSum( int i ){
        return krRec[i].szSum;
    }
// IIS End
    public String getFName( int i ){
        return krRec[i].szFName;
    }
    public KeyRec getRec( int i ){
        return krRec[i];
    }
}
/*--------------------------------------------------------------------*/
// キー番号クラス
/*--------------------------------------------------------------------*/
class KeyNo extends Object {
    public int keys[] = new int[3];
    public KeyNo() {
        keys[0] = 0;
        keys[1] = 0;
        keys[2] = 0;
    }
}
/*--------------------------------------------------------------------*/
// 説明文クラス
/*--------------------------------------------------------------------*/
//class ExpPanel extends java.awt.Panel {
class ExpPanel extends JPanel {
    static int MARGIN   = 8;
    static int COLUMN_NUM   = 61;
    private String cData;
    private Rectangle rcJump[] = new Rectangle[100];
    private KeyNo key[] = new KeyNo[100];
    private int     cx;
    private int nNum;
    private int nHeight;
    private String szTitle;

    /*----------------------------------------------------------------*/
    // コンストラクタ
    /*----------------------------------------------------------------*/
    public ExpPanel( String cData , String title) {
        super();
        int     i;
        this.cData = cData;
        initComponents ();
        nNum = 0;
        for( i = 0 ; i < 100 ; i++ ){
            rcJump[i] = new Rectangle();
            key[i] = new KeyNo();
        }
        nHeight = 0;
        szTitle = title;
    }
    /*----------------------------------------------------------------*/
    /*----------------------------------------------------------------*/
    public int getLineHeight(){
        return MARGIN + this.getGraphics().getFont().getSize();
    }
    /*----------------------------------------------------------------*/
    // 高さ取得メソッド
    /*----------------------------------------------------------------*/
    public int getHeightArea( ){
        return paintArea( this.getGraphics() );
    }
    /*----------------------------------------------------------------*/
    // 描画メソッド
    /*----------------------------------------------------------------*/
    public void paintComponent(java.awt.Graphics g ){
        super.paintComponent( g );
        paintArea( g );
    }
    /*----------------------------------------------------------------*/
    // 描画メソッド
    /*----------------------------------------------------------------*/
    public int paintArea( java.awt.Graphics g ){
        int     sx,sy;
        int     bx;
        int     by;
        StringBuffer    s = new StringBuffer();
        StringBuffer    p = new StringBuffer();
        int     i,j,k,n;
        int     c;
        int     m;
        String  szBuff;
        StringTokenizer stKeyData;
        StringTokenizer stReadData;
        StringTokenizer st;
        int     px;
        Font    of;
        Font    nf;
        Font    tf;
        Font    af;
        Dimension dim;
        int     msx,msy;
        PrintGraphics pg;
        int     nSw;


        msx = 0;
        msy = 0;
        if( g instanceof PrintGraphics ){
            pg = (PrintGraphics)g;
            dim =pg.getPrintJob().getPageDimension();
            of = new Font( "ＭＳ 明朝", 0, dim.width/COLUMN_NUM);
            g.setFont( of );
            cx = of.getSize();
            dim.width = cx * COLUMN_NUM;
            dim.width += cx / 2;
//            dim.width -= cx * 2;
            msx = 7*cx;
            msy = 6*cx;
            g.drawRect( msx, msy, dim.width - msx - ( cx * 0 ), dim.height - msy - ( cx * 5 ) );
            g.drawString(szTitle, msx, msy - cx );
            of = g.getFont();
            cx = of.getSize();
            px = cx/2;
        }else{
            dim = this.getSize();
            of = g.getFont();
            cx = of.getSize();
            px = cx/2;
        }
        nf = new Font("ＭＳ 明朝", Font.BOLD , cx );
        tf = new Font("ＭＳ 明朝", Font.ITALIC , cx );
        af = new Font("ＭＳ 明朝", Font.BOLD | Font.ITALIC , cx );




        stReadData = new StringTokenizer( cData,"\n");


        nSw = 0;
        sy = ( cx + MARGIN/2) + msy;
        m = 0;
        while( stReadData.hasMoreTokens()){
            bx = 0;
            by = 0;
            sx = px + msx;

            s.setLength(0);
            p.setLength(0);
            szBuff = stReadData.nextToken();
            s.append(szBuff);
            n = s.length();
            for( i = 0 ; i < n ;i++ ){
                if( s.toString().substring(i).startsWith("<B>") ){
                    nSw = nSw | 1;i+=2;continue;
                }
                if( s.toString().substring(i).startsWith("</B>") ){
                    nSw = nSw & ~1;i+=3;continue;
                }
                if( s.toString().substring(i).startsWith("<I>") ){
                    nSw = nSw | 2;i+=2;continue;
                }
                if( s.toString().substring(i).startsWith("</I>") ){
                    nSw = nSw & ~2;i+=3;continue;
                }
                if( s.toString().substring(i).startsWith("<A>") ){
                    nSw = nSw | 4;i+=2;continue;
                }
                if( s.toString().substring(i).startsWith("</A>") ){
                    nSw = nSw & ~4;i+=3;continue;
                }
                if( i<(n-1) && s.charAt(i) == '\\' && s.charAt(i+1) == 'S' ){
                    for( j = i+2 ; j < n; j++ ){
                        if( j<(n-1) && s.charAt(j) == '\\' && s.charAt(j+1) == 'E' ){
                            rcJump[m].x = bx;
                            rcJump[m].y = by-(cx+MARGIN);

                            rcJump[m].width = sx;
                            rcJump[m].height = sy;
                            m++;
                            bx = 0;
                            i = j+1;
                            break;
                        }
                        if( s.charAt(j)=='#'){
                            for( k=j+1 ; k < n ; k++ ){
                                if( k<(n-1) && s.charAt(k) == '\\' && s.charAt(k+1) == 'E' ){
                                    j = k-1;
                                    break;
                                }
                                p.append(s.charAt(k));
                            }
                            stKeyData = new StringTokenizer(p.toString(),"-");
                            c = 0;
                            while( stKeyData.hasMoreTokens()){
                                key[m].keys[c]=Integer.parseInt(stKeyData.nextToken());
                                c++;
                            }
                            p.setLength(0);


                            continue;
                        }

                        if( (sx + g.getFontMetrics().charWidth(s.charAt(j))) >= (dim.width-cx) ){
                            sy += ( cx + MARGIN);
                            sx = px + msx;
                        }
                       if( g instanceof PrintGraphics && sy >= (dim.height - ( cx * 5 )) ){
                            pg = (PrintGraphics)g;
                            g = pg.getPrintJob().getGraphics();
                            sy = ( cx + MARGIN/2) + msy;
                            g.drawRect( msx, msy, dim.width - msx - ( cx * 0 ), dim.height - msy - ( cx * 5 ) );
                            g.setFont( of );
                            g.drawString(szTitle, msx, msy - cx );
                       }
                        if( bx == 0 ){
                            bx = sx;
                            by = sy;
                        }

                        p.append(s.charAt(j));
                        g.setColor(java.awt.Color.blue);
                        g.drawString(p.toString(),sx,sy);
                        sx += g.getFontMetrics().charWidth(s.charAt(j));
                        p.setLength(0);
                    }
                }else{
                    if( (sx + g.getFontMetrics().charWidth(s.charAt(i))) >= (dim.width-cx) ){
                        sy += ( cx + MARGIN);
                        sx = px + msx;
                    }
                   if( g instanceof PrintGraphics && sy >= (dim.height - ( cx * 5 ) ) ){
                       pg = (PrintGraphics)g;
                       g = pg.getPrintJob().getGraphics();
                       sy = ( cx + MARGIN/2) + msy;
                       g.drawRect( msx, msy, dim.width - msx - ( cx * 0 ), dim.height - msy - ( cx * 5 ) );
                       g.setFont( of );
                       g.drawString(szTitle, msx, msy - cx );
                   }
                    p.append(s.charAt(i));
                    g.setColor(java.awt.Color.black);

                    if( (nSw & 3)==3 ){
                        g.setFont(af);
                    }else{
                        if( (nSw & 1)==1 )g.setFont(nf);
                        if( (nSw & 2)==2 )g.setFont(tf);
                    }
                    g.drawString(p.toString(),sx,sy);
                    if( (nSw & 4)==4 )g.drawLine(sx,sy+MARGIN/4,sx+g.getFontMetrics().charWidth(s.charAt(i)), sy+MARGIN/4);
                    sx += g.getFontMetrics().charWidth(s.charAt(i));
                    g.setFont(of);
                    p.setLength(0);
                }
            }
            sy +=( cx + MARGIN);
         }
        nNum = m;
        if( g instanceof PrintGraphics ){
            g.dispose();
        }
        return sy;
    }





    public KeyNo getKeyAtPoint( int x, int y ){
        int     i;

        if( cx == 0 )return null;
        for( i = 0 ; i < nNum ;i++ ){

             if( y < rcJump[i].y || y > rcJump[i].height )continue;
             if( y < (rcJump[i].y + cx)  ){
                 if( x < rcJump[i].x )continue;
             }
             if( y > (rcJump[i].height - cx)  ){
                 if( x > rcJump[i].width )continue;
             }
             return key[i];
         }
        return null;
    }
    private void initComponents() {
        setLayout(null);
    }



}
/*--------------------------------------------------------------------*/
// 文字列書式変換
/*--------------------------------------------------------------------*/
class ExpFormat extends Object{
    public ExpFormat( String f, String s ){
        int     i,j;
        int     n;
        char[] fc = f.toCharArray();
        char[] sc = s.toCharArray();

        n = f.length();
        for( i = 0 ; i < n ;i++ ){
            j = i+1;
            switch( fc[i] ){
            case 'A':
                for( j=i ; j < n && fc[j]=='A';j++ );
                break;
            case '-':
                continue;
            case '#':
                for( j=i ; j < n && ( fc[j]=='#' || fc[j]=='9' || fc[j]==',' );j++ );
            case 'Z':
                for( j=i ; j < n && ( fc[j]=='Z' || fc[j]=='9' || fc[j]==',' );j++ );
                break;
            case '9':
                for( j=i ; j < n && ( fc[j]==',' || fc[j]=='9' );j++ );
                break;
            }
            i = j-1;
        }
    }
}
/*--------------------------------------------------------------------*/
// 文献リスト表示項目クラス
/*--------------------------------------------------------------------*/
class ListDsp extends Object {
    public int  nCol;
    public int  nPos[];
    public int  nWidth[];
    public int  nSort;
    public String szFName;
    public ListDsp(String s, int n) {
        nCol = n;
        nPos = new int[n];
        nWidth = new int[n];
        szFName = s;
        nSort = -1;
    }
}

/*--------------------------------------------------------------------*/
// 文献リストレコードクラス
/*--------------------------------------------------------------------*/
class ListRec {
    public int nCol;
    public String szName[];
    public String szFormat[];

    public int    nPos[];
    public int    nWidth[];
    public ListRec(int n) {
        nCol = n;
        szName = new String[n];
        szFormat = new String[n];
        nPos = new int[n];
        nWidth = new int[n];
    }
}
/*--------------------------------------------------------------------*/
// 文献リストクラス
/*--------------------------------------------------------------------*/
class ListData extends Object {
    public int nCol;
    public int nRow;
    public ListRec[] lrRec = new ListRec[500];
    public String szFName;

    public ListData() {
        nCol = 0;
        nRow = 0;
    }
    public ListData(String p,String s) {
        getData(p,s);
    }

    public void getData(String p,String s) {
        int     i;
        int     j;

        nCol = 0;
        nRow = 0;
        szFName = s;

        try {
            File fI=new File(p+s);

            byte byDataBuff[] = new byte[(int)fI.length()];
            FileInputStream fin = new FileInputStream(fI);
            int nDataLen = fin.read(byDataBuff);


            StringTokenizer stReadData = new StringTokenizer( new String(byDataBuff,0,nDataLen),"\r\n");

            String szLine = new String();

            nRow = 0;
            i = stReadData.countTokens();
            while( stReadData.hasMoreTokens()){
                szLine = stReadData.nextToken();
                if( nRow == 0 ){
                    StringTokenizer stItemData = new StringTokenizer(szLine,",",true);
                    nCol = 0;
                    while( stItemData.hasMoreTokens()){
                        if( stItemData.nextToken().compareTo(",")!=0 )nCol++;
                    }

                }


                lrRec[nRow] = new ListRec(nCol);

                StringTokenizer stItemData = new StringTokenizer(szLine,",",true);
                i = 0;
                String szBuff = ",";
                while( stItemData.hasMoreTokens()){
                    String szItem = stItemData.nextToken();
                     lrRec[nRow].nPos[i] = i;
                    if( szItem.compareTo(",")==0 ){
                        if( szBuff.compareTo(",")==0 ){
                            lrRec[nRow].szName[i]="";
                            szBuff = "";
                            i++;
                        }else{
                            szBuff = szItem;
                        }
                    }else{
                        lrRec[nRow].szName[i]=szItem;
                        i++;
                        szBuff = szItem;
                    }
                }
                for( ; i < nCol ; i++){
                    lrRec[nRow].szName[i]="";
                    lrRec[nRow].nPos[i] = i;
                }
                nRow++;
                if( nRow >= 500)break;
            }
            fin.close();
        }
        catch(IOException err){
            System.out.println("ERR");
        }
        if( nRow == 0 )return;
        for( i = 0 ;i < nCol ;i++){
            int n = lrRec[0].szName[i].indexOf("\\%");
            lrRec[0].szFormat[i] = lrRec[0].szName[i];
            for( j = 1 ;j < nRow;j++){
                lrRec[j].szFormat[i] = lrRec[j].szName[i];
                if( n > 0 ){
                    FormatBuff fb = new FormatBuff( lrRec[0].szName[i].substring(n+2), lrRec[j].szName[i] );
                    lrRec[j].szFormat[i] = fb.toString();
//                    lrRec[j].szName[i] = lrRec[j].szFormat[i];
                }
            }
            if( n > 0 ){
                lrRec[0].szName[i] = lrRec[0].szName[i].substring(0,n-1);
            }
        }
    }
    private void qsort(int  li, int ri, int c, int op ){
        int     i;
        int     l = li;
        int     r = ri;
        int     p = (li+ri)/2;
        String  vp;


        vp = lrRec[p].szFormat[c];
        while( l <= r ){
            if( op > 0 ){
                for( ;lrRec[l].szFormat[c].compareTo(vp) < 0 ; l++);
                for( ;lrRec[r].szFormat[c].compareTo(vp) > 0 ; r--);
            }else{
                for( ;lrRec[l].szFormat[c].compareTo(vp) > 0 ; l++);
                for( ;lrRec[r].szFormat[c].compareTo(vp) < 0 ; r--);
            }
            if( l <= r ){
                ListRec b;
                b = lrRec[l];

                lrRec[l] = lrRec[r];
                lrRec[r] = b;

//                    lrRec[r].szFormat[i] = b;


//                String b;
//                for( i = 0 ; i < lrRec[l].nCol;i++){
//                    b = lrRec[l].szFormat[i];
//                    lrRec[l].szFormat[i] = lrRec[r].szFormat[i];
//                    lrRec[r].szFormat[i] = b;
//                }
                l++;
                r--;
            }
        }
        if( r > li )qsort(li,r,c,op);
        if( l < ri )qsort(l,ri,c,op);
    }
    public void csort(int col ) {
        int     i;

        if( col > 0 ){
            qsort( 1, nRow-1, col - 1, 1);
        }else{
            qsort( 1, nRow-1, (col  * (-1) ) - 1, -1);
        }
    }
    public String getName( int i, int j ){
        return lrRec[i].szName[j];
    }
}
/*--------------------------------------------------------------------*/
// グラフィックボタンクラス
/*--------------------------------------------------------------------*/
class DrawButton extends JComponent implements MouseListener{

    private Image[]   image = new Image[3];   //
    public  String    szCmd;   //
    private int       sts;
    private int       tx,ty;

    private ImageIcon  ic;
    private JLabel     jl;

    private boolean    bClick = false;

    public DrawButton( JLabel parent, String DATA_PATH, LayOutRec Lys ) {
        super();
        image[0] = getToolkit().getImage( DATA_PATH + Lys.szImg1 );
        image[1] = getToolkit().getImage( DATA_PATH + Lys.szImg2 );
        image[2] = getToolkit().getImage( DATA_PATH + Lys.szImg3 );

        jl = null;
        if( Lys.szTip != null ){
            ic = new ImageIcon( DATA_PATH + Lys.szTip );
            jl = new JLabel( ic );
//            jl.setLocation( Lys.tx, Lys.ty );
            tx = Lys.tx;
            ty = Lys.ty;
            jl.setSize(ic.getIconWidth(),ic.getIconHeight());
            jl.setOpaque(false);
            parent.add( jl );
            jl.setVisible(false);
        }
        sts = 0;
        this.addMouseListener(this);
        setOpaque( true );
        setBounds( Lys.x - 3, Lys.y, Lys.w, Lys.h );
    }

    public DrawButton( String DATA_PATH, LayOutRec Lys ) {
        super();
        image[0] = getToolkit().getImage( DATA_PATH + Lys.szImg1 );
        image[1] = getToolkit().getImage( DATA_PATH + Lys.szImg2 );
        image[2] = getToolkit().getImage( DATA_PATH + Lys.szImg3 );
        jl = null;
        sts = 0;
        this.addMouseListener(this);

//        if( System.getProperty("os.name").indexOf("Win") >= 0 ){
        setOpaque( true );
        setBounds( Lys.x - 3, Lys.y, Lys.w, Lys.h );
    }
    public void setActionCommand( String cmd ) {
        szCmd = cmd;
    }
    /*----------------------------------------------------------------*/
    // 描画メソッド
    /*----------------------------------------------------------------*/
    public void paint( java.awt.Graphics g ){
        setOpaque( false );
        MediaTracker mt = new MediaTracker(this);
        mt.addImage(image[sts], 0);
        try {
            mt.waitForID(0);
        } catch (InterruptedException e) {
            return;
        }
        g.drawImage( image[sts], 0,0, this );
    }
    public void mouseClicked(java.awt.event.MouseEvent p1) {
        bClick = true;
    }
    public void mouseReleased(java.awt.event.MouseEvent p1) {
        if( sts == 2 || sts == 1 ){
            bClick = true;
        }else{
            bClick = false;
        }
        sts = 0;
        paint( this.getGraphics() );
    }
    public boolean isClicked()
    {
        return bClick;
    }
    public void mouseEntered(java.awt.event.MouseEvent p1) {
        bClick = false;
        if( jl != null ){
            jl.setLocation(tx-3, ty-22);
            jl.setVisible(true);
        }
        sts = 1;
        paint( this.getGraphics() );
    }
    public void mousePressed(java.awt.event.MouseEvent p1) {
        sts = 2;
        paint( this.getGraphics() );
    }
    public void mouseExited(java.awt.event.MouseEvent p1) {
        if( jl != null ){
            jl.setVisible(false);
        }
        sts = 0;
        paint( this.getGraphics() );
    }
}
/*--------------------------------------------------------------------*/
// 描画クラス
/*--------------------------------------------------------------------*/
class DrawPanel extends JPanel {
   int bsw;

    static int FONT_SIZE = 18;
    static int MARGIN    = 8;
    static int MAX_TEXT  = 10;
    public int          nList;                  //付図数
    private double      dScale;                 //描画スケール
    private int         sx;                     //開始Ｘ座標
    private int         sy;                     //開始Ｙ座標
    private int         cx;                     //文字単位幅
    private int         cy;                     //文字単位高
    private String[]    Texts = new String[MAX_TEXT];  //文献内容
    private String[]    Items = new String[MAX_TEXT];  //文献内容

    private Image[]     image = new Image[MAX_TEXT];   //付図
    private Point[]     ipos = new Point[MAX_TEXT];
    private int[]       pos  = new int[MAX_TEXT];     //付図描画位置
    private String      URL;                    //URL
    private String      PUB;                    //PUB
    private boolean    bEnable;
    private int         py_ofs;

    private Font        ft;                     //描画フォント
    private Font        nf;                     //描画フォント
    private Font        tf;                     //描画フォント
    private Font        af;                     //描画フォント
    private Image[]     pimg = new Image[MAX_TEXT];   //付図

    private boolean    bPrt = false;                     //描画フォント

    /*----------------------------------------------------------------*/
    // コンストラクタ
    /*----------------------------------------------------------------*/
    public DrawPanel(String s, String Path) {
        super();
        int     mode;
        int     n;

        dScale = 100.0;
        cx = FONT_SIZE;
        cy = FONT_SIZE + MARGIN;
        sx = 0;
        sy = 0;
        int     nText;

        ft = new Font( "ＭＳ 明朝", 0, FONT_SIZE );

        this.setOpaque(true);
        initComponents ();
        byte byDataBuff[];
        int nDataLen = 0;

        PUB="";
        nText = 0;
        nList = 0;
        bEnable = false;
        try {
            File fL=new File(s);
            FileInputStream fin = new FileInputStream(fL);

            byDataBuff = new byte[(int)fL.length()];
            nDataLen = fin.read(byDataBuff);

            Texts[nText] = "";
            StringTokenizer stReadData = new StringTokenizer( new String(byDataBuff,0,nDataLen),"\r\n");
            mode = 0;
            while( stReadData.hasMoreTokens()){
                String szLine = stReadData.nextToken();


                if( szLine.startsWith("<LIST")==true ){
                    if( stReadData.hasMoreTokens() == false )break;
                    szLine = stReadData.nextToken();
                    image[nList] = getToolkit().getImage( Path + szLine);

                    this.prepareImage(image[nList],this);
                    nList++;
                    continue;
                }
                if( szLine.startsWith("<ITEM")==true ){
                    n = szLine.indexOf(">");
                    if( n == -1 )continue;
                    nText = Integer.parseInt(szLine.substring(5,n));
                    if( nText < 1 || nText >= MAX_TEXT ){
                        nText = 0;
                        continue;
                    }
                    Texts[nText] = "";

                    // デフォルト項目名
                    switch( nText ){
                    case 1:Items[nText] = "  \n検体名";break;
                    case 2:Items[nText] = "  \n調査の目的";break;
                    case 3:Items[nText] = "  \nサンプルサイズ\n及び採集方法";break;
                    case 4:Items[nText] = "  \n調査対象微生物";break;
                    case 5:Items[nText] = "  \n検査法\n増菌の有無\n培地";break;
                    case 6:Items[nText] = "  \n結果\n汚染実態\n汚染菌の性状\n防除対策等";break;
                    default:Items[nText] ="";break;
                    }
                    // 項目名取得
                    if( szLine.length() > n+1 ){
                        Items[nText] = szLine.substring(n+1);
                        // 改行処理
                        while( true ){
                            n = Items[nText].indexOf("\\n");
                            if( n == -1 )break;
                            StringBuffer sb = new StringBuffer(Items[nText]);
                            sb.replace(n,n+2,"\n");
                            Items[nText] = sb.toString();
                        }
                    }
                    mode = 0;
                    continue;
                }
                if( szLine.startsWith("<URL>")==true ){
                    URL = "";
                    mode = 1;
                    continue;
                }
                if( szLine.startsWith("<PUBMED>")==true ){
                    PUB = "";
                    mode = 2;
                    continue;
                }
                if(mode == 0 ){
                    Texts[nText] = Texts[nText].concat(szLine) + "\n";

                }else if( mode == 1 ){
                    URL = szLine;
                }else{
                    PUB = szLine;
                }
                bEnable = true;
            }
            fin.close();
        }
        catch(IOException err){
          System.out.println("ERR "+ err.getMessage() );
        }
        bsw = 0;
    }
    /*----------------------------------------------------------------*/
    // 文字列描画
    /*----------------------------------------------------------------*/
    private int drawText( java.awt.Graphics g, String s, int x, int y, int w, int mh ){
        int             h;
        int             i,n;
        int             px,py;
        StringBuffer    sb = new StringBuffer();
        StringBuffer    pb = new StringBuffer();
        StringTokenizer stReadData;
        String          szBuff;
        Rectangle       rc;
        Rectangle       cc;
        int             nSw;
        Font            of;



        rc = g.getClipBounds();

        if( s == null )return 0;
        stReadData = new StringTokenizer( s,"\n");

        if( g instanceof PrintGraphics )rc = null;

        py = y + cy;
        h = 0;
        nSw = 0;
        while( stReadData.hasMoreTokens()){
            px = cx/2 + x;
            sb.setLength(0);
            pb.setLength(0);
            szBuff = stReadData.nextToken();
            sb.append(szBuff);
            n = sb.length();
            for( i = 0 ; i < n ;i++ ){
                if( sb.toString().substring(i).startsWith("<B>") ){
                    nSw = nSw | 1;i+=2;continue;
                }
                if( sb.toString().substring(i).startsWith("</B>") ){
                    nSw = nSw & ~1;i+=3;continue;
                }
                if( sb.toString().substring(i).startsWith("<I>") ){
                    nSw = nSw | 2;i+=2;continue;
                }
                if( sb.toString().substring(i).startsWith("</I>") ){
                    nSw = nSw & ~2;i+=3;continue;
                }
                if( sb.toString().substring(i).startsWith("<A>") ){
                    nSw = nSw | 4;i+=2;continue;
                }
                if( sb.toString().substring(i).startsWith("</A>") ){
                    nSw = nSw & ~4;i+=3;continue;
                }

                if( (px + g.getFontMetrics().charWidth(sb.charAt(i)) -x - cx/2) >= (cx * w - cx) ){
                    py += cy;
                    px = cx/2 + x;
                    h++;
                }
                pb.append(sb.charAt(i));

                cc = new Rectangle(px,py, g.getFontMetrics().charWidth(sb.charAt(i)) , cy );
//                if( rc == null || rc.intersects(cc) == true ){
                    of = g.getFont();
                    if( ( nSw & 3 ) == 3 ){
                        g.setFont(af);
                    }else{
                        if( ( nSw & 1 ) == 1 )g.setFont(nf);
                        if( ( nSw & 2 ) == 2 )g.setFont(tf);
                    }
                    if( g instanceof PrintGraphics ){
                        g.drawString(pb.toString(),px,py-(MARGIN/4) );
                    }else{
                        g.drawString(pb.toString(),px,py-(MARGIN/2) );
                    }
                    if( ( nSw & 4 ) == 4 )g.drawLine(px,py-(MARGIN/4),px+g.getFontMetrics().charWidth(sb.charAt(i)), py-(MARGIN/4) );
                    g.setFont(of);
//                }
                px += g.getFontMetrics().charWidth(sb.charAt(i));
                pb.setLength(0);
            }
            py += cy;
            h++;
         }

        if( mh > h )h = mh;
        cc = new Rectangle(x, y, cx * w , cy * h );
        if( rc == null || rc.intersects(cc) == true ){
            g.drawRect( x, y, cx * w , cy * h );
        }
        return h;
    }
    /*----------------------------------------------------------------*/
    // スクロールメソッド
    /*----------------------------------------------------------------*/
    public void setOffset( int x, int y ){
        sx = x;
        sy = y;
//        this.repaint();
    }
    /*----------------------------------------------------------------*/
    // スケール変更メソッド
    /*----------------------------------------------------------------*/
    public void setScale( double dSetScale ){
        if( dSetScale < 10.0 )return;
        if( dSetScale > 300.0 )return;

        dScale = dSetScale;
        cx =(int)Math.floor( FONT_SIZE *  dSetScale / 100.0 );
        ft = new Font( "ＭＳ 明朝", 0, cx);
//        this.repaint();
    }
    /*----------------------------------------------------------------*/
    // 付図位置取得メソッド
    /*----------------------------------------------------------------*/
    public int getPos( int n ){
        if( n > nList )return 0;
        if( n < 1 )return 0;
        return pos[n-1];
    }
    public String getURL( ){
        return URL;
    }
    public String getPUB( ){
        return PUB;
    }
    /*----------------------------------------------------------------*/
    /*----------------------------------------------------------------*/
    public int getHeightArea()
    {
        return paintArea( this.getGraphics() );
    }
    public int getWidthArea()
    {
        return (( 51 + 2 ) * cx);
    }
    /*----------------------------------------------------------------*/
    // 描画メソッド
    /*----------------------------------------------------------------*/
    public void paintComponent( java.awt.Graphics g ){
        super.paintComponent(g);
        paintArea( g );
    }
    public void print( java.awt.Graphics g ){
        paintArea( g );
        System.out.println( "call print" );
    }
    public void printAll( java.awt.Graphics g ){
        paintArea( g );
        System.out.println( "call printAll" );
    }

    /*----------------------------------------------------------------*/
    // 印刷メソッド
    /*----------------------------------------------------------------*/
    public void printDoc( PrintJob pjob ){
        Graphics    pg;
        int         y;

        bPrt = true;
        py_ofs = 0;
        while( true ){
            pg = pjob.getGraphics();
            if( pg == null )break;

            y = paintArea( pg );
            pg.dispose();
            if( y <= 0 )break;
        }
        bPrt = false;
    }
    /*----------------------------------------------------------------*/
    // 描画メソッド
    /*----------------------------------------------------------------*/
    public int paintArea( java.awt.Graphics g ){
        int     x,y;
        int     mx;
        int     px,py;
        int     i,n;
        Font    pft;                     //描画フォント
        int     wx,wy;
        Rectangle rc;
        Rectangle cc;
        Dimension dm;


        wx = sx;
        wy = sy;
        mx = 51;
        dm = null;
        if( g instanceof PrintGraphics ){
            PrintGraphics pg=(PrintGraphics)g;
            dm =pg.getPrintJob().getPageDimension();
            System.out.println("print"+ dm.width + "x" + dm.height);



            pft = new Font( "ＭＳ 明朝", 0, dm.width/(mx+7));
            g.setFont( pft );
            cx = pft.getSize();
            sx = 5*cx;
            sy = 4*cx;
            g.setClip( sx, sy, dm.width - sx, dm.height - (10 * cx) );

            if( py_ofs == 0 ){
                for( i = 0 ; i < nList; i++ ){
//                    int w = (int)(image[i].getWidth(this)*cx/FONT_SIZE);
                    int w = mx * cx;
                    pimg[i] = image[i].getScaledInstance( w, -1, Image.SCALE_SMOOTH );
                }
            }
            cy = cx + MARGIN/2;
        }else{
            if( bPrt == true )return 0;

            g.setFont( ft );
            cx = ft.getSize();
            java.awt.Dimension dim = this.getSize();

            g.drawRect( 0,0,dim.width-1,dim.height-1 );
            py_ofs = 0;
            cy = cx + MARGIN;
        }
        nf = new Font("ＭＳ 明朝", Font.BOLD , cx );
        tf = new Font("ＭＳ 明朝", Font.ITALIC , cx );
        af = new Font("ＭＳ 明朝", Font.ITALIC | Font.BOLD , cx );



        if( bEnable == false )return 0;
        //  タイトル
        x = 1;
        y = 1;
        px = sx + (x * cx);
        py = sy + (y * cy) - py_ofs;
        y += drawText( g, Texts[0], px, py , mx, 2 );
        //

        for( n = 1 ; n < MAX_TEXT ; n++ ){
            if( Items[n] == null )continue;
            x = 11;
            px = sx + (x * cx);
            py = sy + (y * cy)  - py_ofs;
            i = drawText( g, Texts[n], px, py , mx-10, 3 );

            x = 1;
            px = sx + (x * cx);
            py = sy + (y * cy)  - py_ofs;
            y += drawText( g, Items[n], px, py , 10, i );
        }

        y++;


        px = sx + (x * cx);
        py = sy + (y * cy)  - py_ofs;

        rc = g.getClipBounds();
        if( nList > 0 ){
            MediaTracker mt = new MediaTracker(this);

            if( g instanceof PrintGraphics ){
                for( i = 0 ; i < nList; i++ ){
                    mt.addImage(pimg[i],i );
                }
            }else{
//                rc = g.getClipBounds();
                for( i = 0 ; i < nList; i++ ){
                    int w,h;
                    w = (int)(image[i].getWidth(this)*dScale/100.0);
                    h = (int)(image[i].getHeight(this)*dScale/100.0);
                    mt.addImage(image[i],i, w, h );
                }
            }

            try {
                mt.waitForAll();
            } catch (InterruptedException e) {
                return 0;
            }


            for( i = 0 ; i < nList; i++ ){
                int     w, h;
                if( !(g instanceof PrintGraphics) )pos[i] = py - sy;

                py += cy;

                cc = new Rectangle(px,py,cx*4,cx);
//                if( rc == null || rc.intersects(cc) == true ){
                    g.drawString("図" + (i+1), px,py );
//                }
                py += cy / 2;

                if( g instanceof PrintGraphics ){


                    h = pimg[i].getHeight(this);
                    w = pimg[i].getWidth(this);

                    cc = new Rectangle(px,py, w, h );
                    if( rc == null || rc.intersects(cc) == true ){
/*
                        for( int ph = 0 ; ph < h ;  ph+= 100 ){
                            int  rh = ph + 100;
                            if( rh > h )rh = h;
                            g.drawImage( pimg[i], px, py+ph, px+w, py+rh, 0, ph, w, rh, this );

                        }
  */
                        g.drawImage( pimg[i], px, py, this );
//                        g.drawImage( image[i], px, py, w, h, this );

                    }
                    py += h;
                    System.out.println( "i = " + i + " h = " + h );
                }else{
//                    cc = new Rectangle(px,py,(int)(image[i].getWidth(this.getParent())*dScale/100.0),(int)(image[i].getHeight(this.getParent())*dScale/100.0));
//                    if( rc == null || rc.intersects(cc) == true ){
                        g.drawImage( image[i],px,py, (int)(image[i].getWidth(this)*dScale/100.0),(int)(image[i].getHeight(this)*dScale/100.0), this );
//                    }
                    py += image[i].getHeight(this)*dScale/100.0;

                }
                py += cy;
            }
        }


        if( g instanceof PrintGraphics ){
            PrintGraphics pg=(PrintGraphics)g;
            py_ofs += (dm.height - (10 * cx));
            py -= (dm.height - (10 * cx));


            System.out.println( "py_ofs = " + py_ofs + " py = " + py );
            sx = wx;
            sy = wy;
        }
        return py;
    }

    private void initComponents() {
//        setLayout(null);
    }
}
/*--------------------------------------------------------------------*/
// レイアウト部品クラス
/*--------------------------------------------------------------------*/
class LayOutRec {
    public String szName;
    public String szImg1;
    public String szImg2;
    public String szImg3;
    public String szTip;
    public int x;
    public int y;
    public int w;
    public int h;
    public int r;
    public int g;
    public int b;
    public int tx;
    public int ty;
    public int tw;
    public int th;

}

/*--------------------------------------------------------------------*/
// 図描画クラス
/*--------------------------------------------------------------------*/
class LayOut extends Object {
    static int  MAX_N = 400;
    public int nCnt;
    public LayOutRec[] LyRec = new LayOutRec[MAX_N];


    public LayOut(String s) {
        int i;

        try {
            File fI=new File(s);

            byte byDataBuff[] = new byte[(int)fI.length()];
            FileInputStream fin = new FileInputStream(fI);
            int nDataLen = fin.read(byDataBuff);


            StringTokenizer stReadData = new StringTokenizer( new String(byDataBuff,0,nDataLen),"\r\n");
            nCnt = 0;
            while( stReadData.hasMoreTokens()){
                int     n;

                String szLine = stReadData.nextToken();

                n = szLine.indexOf("#");
                if( n >= 0 )szLine = szLine.substring(0,n);

                if( szLine.startsWith("<")== false )continue;
                n = szLine.indexOf(">");
                if( n < 0 )continue;

                LyRec[nCnt] = new LayOutRec();
                LyRec[nCnt].szName = szLine.substring(1,n);



                StringTokenizer stKeyData = new StringTokenizer(szLine.substring(n+1),",");
                i = 0;
                while( stKeyData.hasMoreTokens()){
                    String szData = stKeyData.nextToken();
                    if( LyRec[nCnt].szName.endsWith("AREABK")== true ){
                        switch(i){
                        case 0 :LyRec[nCnt].r = Integer.parseInt(szData);break;
                        case 1 :LyRec[nCnt].g = Integer.parseInt(szData);break;
                        case 2 :LyRec[nCnt].b = Integer.parseInt(szData);break;
                        }
                        i++;
                        continue;
                    }
                    if( LyRec[nCnt].szName.endsWith("COMBBK")== true ){
                        switch(i){
                        case 0 :LyRec[nCnt].r = Integer.parseInt(szData);break;
                        case 1 :LyRec[nCnt].g = Integer.parseInt(szData);break;
                        case 2 :LyRec[nCnt].b = Integer.parseInt(szData);break;
                        }
                        i++;
                        continue;
                    }
                    if( LyRec[nCnt].szName.endsWith("STARTUP_BACK")== true){
                        switch(i){
                        case 0 :LyRec[nCnt].szImg1 = szData;break;
                        case 1 :LyRec[nCnt].w = Integer.parseInt(szData);break;
                        case 2 :LyRec[nCnt].h = Integer.parseInt(szData);break;
                        }
                        i++;
                        continue;
                    }
                    if( LyRec[nCnt].szName.endsWith("BACK")== true && i == 0){
                        LyRec[nCnt].szImg1 = szData;
                        i++;
                        continue;
                    }

                    szData = szData.trim();
                    switch(i){
                    case 0 :LyRec[nCnt].szImg1 = szData;break;
                    case 1 :LyRec[nCnt].szImg2 = szData;break;
                    case 2 :LyRec[nCnt].szImg3 = szData;break;
                    case 3 :LyRec[nCnt].x = Integer.parseInt(szData);break;
                    case 4 :LyRec[nCnt].y = Integer.parseInt(szData);break;
                    case 5 :LyRec[nCnt].w = Integer.parseInt(szData);break;
                    case 6 :LyRec[nCnt].h = Integer.parseInt(szData);break;
                    case 7 :LyRec[nCnt].szTip = szData;break;
                    case 8 :LyRec[nCnt].tx = Integer.parseInt(szData);break;
                    case 9 :LyRec[nCnt].ty = Integer.parseInt(szData);break;
                    case 10 :LyRec[nCnt].tw = Integer.parseInt(szData);break;
                    case 11 :LyRec[nCnt].th = Integer.parseInt(szData);break;

                    }
                    i++;
                }
                nCnt++;
            }
            fin.close();
        }
        catch(IOException err){
            System.out.println("ERR");
        }
    }
    public LayOutRec FindRec(String s)
    {
        int     i;

        for( i = 0 ; i < nCnt ;i++ ){
            if( s.compareTo( LyRec[i].szName ) == 0 )break;
        }
        if( i >= nCnt )return null;
        return LyRec[i];
    }
}


/*******************************************************************************
 *  印刷クラス
 ******************************************************************************/
class TreeList_Print extends Panel {

//    private static final	int		XX_MAX = 47;  // 最大横方向印刷可能文字定数
    private static final	int		XX_MAX = 55;  // 最大横方向印刷可能文字定数

    private int     m_dm_Width;
    private int     m_dm_Height;
    private int     Y_LINE_MAX = 0;               // MAX行数
    private int     PRT_MAX_ROW= 0;               // 印刷最終行
    private int		X_OFS      = 0;
    private int		Y_OFS      = 0;
    private int     Font_W     = 0;
    private int     Font_W2    = 0;
    private int     Font_H     = 0;

    private int		Y_COUNT_OFS = 1;
    private int     m_PageCount = 1;
    private int     m_MaxPage   = 1;

    private KeyData m_TreeListData = null;
    private Frame   p_frame;
    private String  MainTitle="";

    private int     m_lineInfoNo1[];
    private int     m_lineInfoNo2[];
    private int     m_nKey1No;

    public  TreeList_Print(){
    }

    public  TreeList_Print(Frame f, KeyData key, String Title){
      p_frame = f;
      m_TreeListData = key;
      MainTitle = Title;
    }

    public  TreeList_Print(Frame f){
      p_frame = f;
    }
    public  void setKeyData(KeyData key){
      m_TreeListData = key;
    }
    public  void setTitle(String s){
      MainTitle = s;
    }

    /***************************************************************************
     * プリント出力
     */
    public void PrtOut()
    {
        m_lineInfoNo1 = new int[m_TreeListData.nCnt];
        m_lineInfoNo2 = new int[m_TreeListData.nCnt];
        m_nKey1No = 0 ;

        // プリンタジョブ作成
        PrintJob    pjob = getToolkit().getPrintJob( p_frame, "Test", null, null );
        if( pjob == null )return;

        Graphics pg = null;
        pg = pjob.getGraphics();
        if( pg != null ) {
          PrintGraphics prtg=(PrintGraphics)pg;
          Dimension dm =prtg.getPrintJob().getPageDimension();
          m_dm_Width  = dm.width;
          m_dm_Height = dm.height;

          Font_W = dm.width / XX_MAX;
          pg.setFont(new Font("ＭＳ 明朝", 0, Font_W));
          FontMetrics fm = pg.getFontMetrics() ;
	      //Font_W  = fm.stringWidth("　");
          Font_W2 = Font_W / 2;
          Font_H  = Font_W + 2;
          Y_LINE_MAX = dm.height / Font_H;
          // 印刷開始オフセット算出
          X_OFS = Font_W * 7;
          Y_OFS = Font_H * 4;
          Y_COUNT_OFS = 3;
          // 印刷最終行算出
          PRT_MAX_ROW = Y_LINE_MAX - 10;

          m_MaxPage = 0;
          m_MaxPage = m_TreeListData.nCnt / PRT_MAX_ROW;
          int amari = PRT_MAX_ROW % m_TreeListData.nCnt;
          if ( m_MaxPage == 0 ) {
            m_MaxPage=1;
          }
          else if ( amari > 0 ) {
            m_MaxPage++;
          }
       }

          getLineInfo();
          for ( int pgCount = 0 ;  pgCount < m_MaxPage ; pgCount++ ) {
             if ( pg == null ) pg = pjob.getGraphics();

              m_PageCount = pgCount+1;
              TreeListPrintOut(pg);
              pg.dispose();
              pg.finalize();
              pg = null;
          }

        pjob.end();
        return;
    }

  /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*
   * 印刷処理
   *@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
  public void TreeListPrintOut( Graphics g ) {
    int i,j;
    int step        = 2;               //
    int hosei       = 2;               //
    int font_w      = 0;               //
    int font_h      = 0;               //
    int font_w2     = 0;               //

    int LineCnt = 1;                   //ラインカウンタ
    int keyPos = 0;                    //
    String      LineBuf=null;

    g.setFont(new Font("ＭＳ 明朝", 0, Font_W));
    g.setColor(Color.black);
    //this.setBackground(Color.white);
	font_w  = Font_W;
    font_w2 = Font_W / 2;
    font_h  = Font_H;

    int   LineCntMax=0;
    if ( m_PageCount <= 1 ) {
      keyPos = 0;                     // ﾃﾞｰﾀ取得KEYﾎﾟｼﾞｼｮﾝ
      if (m_TreeListData.nCnt > PRT_MAX_ROW ) {
          LineCntMax = PRT_MAX_ROW;
      }
      else {
          LineCntMax = m_TreeListData.nCnt;
      }
      m_PageCount = 1;
    }
    else {
                                      // ﾃﾞｰﾀ取得KEYﾎﾟｼﾞｼｮﾝ
      keyPos = (m_PageCount-1)*PRT_MAX_ROW;
      LineCntMax = m_TreeListData.nCnt - ((m_PageCount-1)*PRT_MAX_ROW);
      if ( LineCntMax > PRT_MAX_ROW ) LineCntMax = PRT_MAX_ROW;
    }


    int x1,x2,y1,y2;
    // 枠線表示
    x1 = X_OFS - Font_W;
    y1 = Y_OFS ;
    x2 = m_dm_Width - (Font_W*3);
    y2 = y1;

    g.drawLine(x1, y1, x2, y2);

    y2 = m_dm_Height - Y_OFS + (Font_H/2);
    g.drawLine( x1, y1, x1, y2);
    g.drawLine( x2, y1, x2, y2);

      g.drawLine(x1, y2, x2, y2 );

    // タイトル表示
    g.drawString( MainTitle, X_OFS, Y_OFS + (font_h*LineCnt) + 3);

    LineCnt = Y_COUNT_OFS;

    int no2_Sy =0;
    int no2_Ey =0;
    int no3_Sy =0;
    int no3_Ey =0;

    for ( i = 0 ; i < LineCntMax ; i++ ) {
        j = (keyPos) + i;
        x1 = X_OFS + font_w2;
        if ( m_lineInfoNo1[j] > 1 ) {
          no2_Sy = Y_OFS+(font_h*(LineCnt-2)) + (font_h/2);
          no2_Ey = Y_OFS+(font_h*(LineCnt-1)) + (font_h/2)+hosei;
          g.drawLine(x1, no2_Sy, x1, no2_Ey);
        }
        if ( m_lineInfoNo1[j] == 1 ) {
          no2_Sy = Y_OFS+(font_h*(LineCnt-1)) + (font_h/2);
          no2_Ey = Y_OFS+(font_h*(LineCnt-1)) + (font_h/2)+hosei;
          g.drawLine(x1, no2_Sy, x1, no2_Ey);
        }
        if ( m_lineInfoNo1[j] >= 1 && m_lineInfoNo2[j] == 0 ) {
          y1 = Y_OFS+(font_h*LineCnt) - (Font_W2-1) ;
          g.drawLine( x1, y1, x1+(font_w*11), y1);  // ライン
        }
        //----------------------------------------------------------------------
        if ( m_lineInfoNo2[j] > 0 ) {
          x1 = X_OFS+(font_w*12)+(Font_W2-1);
          if ( m_lineInfoNo2[j] > 1 ) {
            no2_Sy = Y_OFS+(font_h*(LineCnt-2)) + (font_h/2);
            no2_Ey = Y_OFS+(font_h*(LineCnt-1)) + (font_h/2)+hosei;
            g.drawLine(x1, no2_Sy, x1, no2_Ey);
          }
          x1 = X_OFS +(font_w*12)+(Font_W2-1);
          y1 = Y_OFS+(font_h*LineCnt) - (Font_W2-1) ;
          g.drawLine( x1, y1, x1+(font_w*11), y1);  // ライン
        }

        // タイトル取得
        String str = m_TreeListData.getTitle(j);
        if ( str.length() == 0 ) break;
        //----------------------------------------------------------------------
        if( m_TreeListData.getKey( j , 0 )  != m_nKey1No ) {
            // 第３タイトル出力
            no2_Sy = Y_OFS+(font_h*(LineCnt)) + (font_h/2);

            // ＫＥＹ１タイトル出力
            g.drawString( str, X_OFS, Y_OFS+(font_h*LineCnt)+step );
            m_nKey1No += 1;             // キー更新
            LineCnt += 1;
            continue;
        }
        //----------------------------------------------------------------------
        if( m_TreeListData.getKey( j , 1 )  == 0 ) {
            continue;
        }
        //----------------------------------------------------------------------
        if( m_TreeListData.getKey( j , 2 )  != 0 ) {
            // 第３タイトル出力
            // 縦線ライン
            x1 = X_OFS+(font_w*12)+Font_W2;
            // 横線ライン
            y1 = Y_OFS+(font_h*LineCnt) - (Font_W2) ;
            // 第３タイトル
            g.drawString( str, x1+(font_w*11)+(font_w/2), Y_OFS+(font_h*LineCnt)+step );
            LineCnt += 1;
            continue;
        }
        //----------------------------------------------------------------------
        // 第２タイトル出力
        x1 = X_OFS+font_w2;
        y1 = Y_OFS+(font_h*LineCnt) - (Font_W2) ;

        g.drawString( str, X_OFS+font_w+(font_w*11), Y_OFS+(font_h*LineCnt)+step );
        LineCnt += 1;

        no3_Sy = Y_OFS + (font_h*(LineCnt-1))+(font_h/2);
    }

  } // of for

  /*****************************************************************************
   * ライン出力情報作成
   */
  private void getLineInfo() {

    int nKey1No = 0;
    int oldPos = 0;
    int oldPos2 = 0;

    for ( int j = 0 ; j < m_TreeListData.nCnt ; j++ ) {
        // タイトル取得
        String str = m_TreeListData.getTitle(j);
        if ( str.length() == 0 ) break;
        //----------------------------------------------------------------------
        if( m_TreeListData.getKey( j , 0 )  != nKey1No ) {
            // ＫＥＹ１タイトル
            nKey1No += 1;             // キー更新
            oldPos  = 0;
            oldPos2 = 0;
            continue;
        }
        //----------------------------------------------------------------------
        if( m_TreeListData.getKey( j , 1 )  == 0 ) {
            continue;
        }
        //----------------------------------------------------------------------
        if( m_TreeListData.getKey( j , 2 )  != 0 ) {
            // 第３タイトル
            if ( oldPos2 > 0 ) {
              m_lineInfoNo2[j] = 2;
            }
            else {
              m_lineInfoNo2[j] = 1;
            }
            oldPos2 = j+1;
            continue;
        }
        //----------------------------------------------------------------------
        // 第２タイトル出力
        if ( oldPos > 0 ) { //前回第２タイトル印刷あり
          for ( int k = oldPos; k <= j ; k++ ) {
            m_lineInfoNo1[k] = 2;
          }
        }
        else {
          m_lineInfoNo1[j] = 1;
        }
        oldPos  = j+1;
        oldPos2 = 0;
    }
  }

}
/*******************************************************************************
 *  印刷クラス
 ******************************************************************************/
class ListData_Print extends Panel {

    private static final	int		XX_MAX = 70;  // 最大横方向印刷可能文字定数

    private int     m_dm_Width;
    private int     m_dm_Height;
    private int     Y_LINE_MAX = 0;               // MAX行数
    private int     PRT_MAX_ROW= 0;               // 印刷最終行
    private int	    X_OFS      = 0;
    private int	    Y_OFS      = 0;
    private int     Font_W     = 0;
    private int     Font_W2    = 0;
    private int     Font_H     = 0;

    private int	    Y_COUNT_OFS = 1;
    private int     m_PageCount = 1;
    private int     m_MaxPage   = 1;

    private Frame   p_frame;
    private String  p_DataFname;
    private String  p_DataPath;
    private String  p_MainTitle;
    private String  p_SubTitle;
    private String  p_MidashiTitle=null;

    private int     p_FontSize = 0;
    private int     p_ListRec_Row;
    private int     p_ListRec_Col;

    public  ListData p_Lists;// =  new ListData();

    private int   p_x_wigth_cnt=0;
    public int    p_x_wigth[];
    public String p_Title[];

    private int	    X_NEXT      = 0;
    /***************************************************************************
     *
     */
    public  ListData_Print(Frame f, int FontSize, ListData list, String Title,String SubTitle){
      p_frame = f;
      p_Lists     = list;
      p_MainTitle = Title;
      p_SubTitle = SubTitle;
      p_FontSize  = FontSize;
    }


    /***************************************************************************
     * プリント出力
     */
    public void PrtOut()
    {
        boolean     bNext;

        if ( p_Lists == null ) return;
        if ( p_Lists.nCol == 0 || p_Lists.nRow == 0) return;
        p_ListRec_Col = p_Lists.nCol;
        p_ListRec_Row = p_Lists.nRow;

        p_x_wigth = new int[p_Lists.nCol+1];
        p_Title   = new String[p_Lists.nCol];
        //------------------------------------------------------------------------
        // プリンタジョブ作成
        PrintJob    pjob = getToolkit().getPrintJob( p_frame, "Test", null, null );
        if( pjob == null ) return;

        Graphics pg = null;
        pg = pjob.getGraphics();
        if( pg != null ) {
          PrintGraphics prtg=(PrintGraphics)pg;
          Dimension dm =prtg.getPrintJob().getPageDimension();


          m_dm_Width  = dm.width;
          m_dm_Height = dm.height;

          Font_W = m_dm_Width / XX_MAX;
          pg.setFont(new Font("ＭＳ 明朝", 0, Font_W));
          FontMetrics fm = pg.getFontMetrics() ;
              //Font_W  = fm.stringWidth("　");
          Font_W2 = 5;

          int     hoseiA = Font_W / 5;
          Font_H  = Font_W + hoseiA;
          Y_LINE_MAX = m_dm_Height / Font_H;
          // 印刷開始オフセット算出
          X_OFS = Font_W * 5;
          Y_OFS = Font_H * 4;
          Y_COUNT_OFS = 3;
          // 印刷最終行算出
          PRT_MAX_ROW = Y_LINE_MAX - 10;

          m_MaxPage = 0;
          m_MaxPage = p_ListRec_Row / PRT_MAX_ROW;
          int amari = PRT_MAX_ROW % p_ListRec_Row;
          if ( m_MaxPage == 0 ) {
            m_MaxPage=1;
          }
          else if ( amari > 0 ) {
            m_MaxPage++;
          }

          m_dm_Width  -= (X_OFS * 2);
          for ( int pgCount = 0 ;  pgCount < m_MaxPage ; pgCount++ ) {
              X_NEXT = 0;
              while( true ){
                 if ( pg == null ) pg = pjob.getGraphics();
                  m_PageCount = pgCount+1;
                  bNext = ListData_PrintOut(pg);
                  pg.dispose();
                  pg.finalize();
                  pg = null;
                  if( bNext == false )break;
                  X_NEXT -= ( m_dm_Width );
              }
          }
        }
        pjob.end();

        return;
    }

  /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*
   * 印刷処理
   *@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
  public boolean ListData_PrintOut( Graphics g ) {
    int i,j;
    int step        = 2;               //
    int hosei       = 2;               //
    int font_w      = 0;               //
    int font_h      = 0;               //
    int font_w2     = 0;               //
    int x1,x2,y1,y2;

    int LineCnt     = 1;                   //ラインカウンタ
    int keyPos      = 0;                    //
    String          LineBuf=null;
    boolean         bNext = false;

    g.setFont(new Font("ＭＳ 明朝", 0, Font_W));
    g.setColor(Color.black);
    font_w  = Font_W;
    font_w2 = Font_W / 2;
    font_h  = Font_H;
    int     hoseiA = Font_H / 5;
    Rectangle  rc;


   rc = new Rectangle( X_OFS,   0,  m_dm_Width, m_dm_Height - Y_OFS );
   g.setClip(rc);


    int   LineCntMax=0;
    if ( m_PageCount <= 1 ) {
      keyPos = 0;                     // ﾃﾞｰﾀ取得KEYﾎﾟｼﾞｼｮﾝ
      if ( p_ListRec_Row > PRT_MAX_ROW ) {
          LineCntMax = PRT_MAX_ROW;
      }
      else {
          LineCntMax = p_ListRec_Row;
      }
      m_PageCount = 1;
    }
    else {
                                      // ﾃﾞｰﾀ取得KEYﾎﾟｼﾞｼｮﾝ
      keyPos = (m_PageCount-1)*PRT_MAX_ROW;
      LineCntMax = p_ListRec_Row - ((m_PageCount-1)*PRT_MAX_ROW);
      if ( LineCntMax > PRT_MAX_ROW ) LineCntMax = PRT_MAX_ROW;
    }

    // タイトル表示
    x1 = X_OFS;
    y1 = Y_OFS + (font_h*LineCnt);
    g.drawString( p_MainTitle, x1, y1-font_h);
    g.drawString( p_SubTitle, x1, y1);



    LineCnt++;
    if ( m_PageCount > 1 ) {         // ２ページ以降か？
      LineCnt++;
      // 縦線印字
      for ( i = 0 ; i < p_Lists.nCol ; i++ ) {
        x1 = p_x_wigth[i];
        y1 = Y_OFS + (font_h*(LineCnt));
        y2 = Y_OFS + (font_h*(LineCnt+1));
        // 項目印字
        g.drawString( p_Title[i], x1+font_w2 + X_NEXT, y1);

        y1 = Y_OFS + (font_h*(LineCnt))+hoseiA;
        y2 = Y_OFS + (font_h*(LineCnt+1)+hoseiA);
        g.drawLine(x1 + X_NEXT, y1, x1 + X_NEXT, y2);
      }
      y1 = Y_OFS + (font_h*(LineCnt))+hoseiA;
      g.drawLine(p_x_wigth[0] + X_NEXT, y1, p_x_wigth[p_x_wigth_cnt] + X_NEXT, y1);
    }

    String  szBuff;
    int     nWidth;
    int     lp;
    int     s_xx=0;




   p_x_wigth_cnt = 0;
   // 行数分繰り返し
  for( i = 0, lp = 0; lp < LineCntMax ; lp++ ) {
      LineCnt++;
      i = keyPos + lp;
      //System.out.println( "i = " + i );

      szBuff = "";
      for( j = 0 ; j < p_Lists.nCol ; j++ ){
        if( j == 0 ) {
          if( p_Lists.lrRec[0].nPos[p_Lists.nCol-1] != -1 ){
		    // １列目
            szBuff = p_Lists.lrRec[i].szName[p_Lists.nCol-1];
            //x1 = X_OFS; s_xx = x1;font_w2
            x1 = X_OFS;
            s_xx = x1;
            y1 = Y_OFS + (font_h*LineCnt);
            g.drawString( szBuff, x1 + font_w2 + X_NEXT, y1);


            if ( i == 0 ) {
                p_Title[0] = szBuff;    // タイトル保持
            }
//p_ListTbl.vTitle.addElement(szBuff);
            // dummy
	    //p_Lists.lrRec[i].nWidth[p_Lists.nCol-1] = p_Lists.lrRec[0].szName[p_Lists.nCol-1].length()*p_FontSize;
	    nWidth = p_Lists.lrRec[0].nWidth[p_Lists.nCol-1] * font_w / p_FontSize;

            //szBuff = szBuff.concat( "(" + nWidth + ")");

            x2 = x1 + nWidth + font_w2;
            s_xx = x2;
            // 上ライン
            //if ( i == 0 ) {
            //y1 = Y_OFS + font_h*(LineCnt-1);
            //g.drawLine(x1, y1, x2, y1);
            //}
            // 下ライン
            y1 = Y_OFS + (font_h*LineCnt)+hoseiA;
            g.drawLine(x1 + X_NEXT, y1, x2+X_NEXT, y1);
            p_x_wigth[0] = x1;        // X座標保持
            p_x_wigth[1] = x1+nWidth+font_w2; // X座標保持
          }
          continue;
        }
        for( int k = 0 ; k < (p_Lists.nCol-1) ; k++ ) {

            if( p_Lists.lrRec[0].nPos[k] != j-1 )continue;
            p_x_wigth_cnt = j+1;
            // ２列目以降
            String  tit2 = p_Lists.lrRec[i].szName[k];

	    // dummy
	    //p_Lists.lrRec[i].nWidth[k] = p_Lists.lrRec[0].szName[k].length()*p_FontSize;
	    nWidth = p_Lists.lrRec[0].nWidth[k] * font_w / p_FontSize;

            x1 = s_xx ; s_xx = x1;
            y1 = Y_OFS + (font_h*LineCnt);
            // 項目印字




//            if( x1 + X_NEXT < X_OFS  && (x1 + X_NEXT + nWidth) > X_OFS  ){
//                g.setClip( X_OFS, y1 - font_h, nWidth - (X_OFS - x1 - X_NEXT), font_h );
//            }else{
//                g.setClip( x1 + X_NEXT ,y1 - font_h, nWidth, font_h );
//            }

           g.clipRect( x1 + X_NEXT ,y1 - font_h, nWidth, font_h );



            g.drawString( tit2, x1+font_w2 + X_NEXT, y1);
            g.setClip( rc );
            if( (x1+nWidth + X_NEXT) > (m_dm_Width + X_OFS) )bNext = true;

            // 下ライン
            x2 = x1 + nWidth + font_w2; s_xx = x2;
            y1 = Y_OFS + (font_h*LineCnt)+hoseiA;
            g.drawLine(x1+X_NEXT, y1, x2+X_NEXT, y1);
            if ( i == 0 ) {
                p_Title[j] = tit2;        // タイトル保持
                System.out.println( "p_Title=[" + j +  "]=" + tit2 );
                p_x_wigth[j+1] = x2;      // X座標保持
            }
             break;
         }
      }
    }

    // 縦線印字
    for ( i = 0 ; i <= p_x_wigth_cnt ; i++ ) {
        x1 = p_x_wigth[i];
        y1 = Y_OFS + font_h * 2 ;
        y2 = Y_OFS + font_h*(LineCnt)+hoseiA;
        g.drawLine(x1+X_NEXT, y1, x1+X_NEXT, y2);
    }
    y1 = Y_OFS + font_h * 2 ;
    g.drawLine(p_x_wigth[0]+X_NEXT, y1, p_x_wigth[p_x_wigth_cnt]+X_NEXT, y1);

    return bNext;
  }

}
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
class OpenHtml{
    public OpenHtml(String fname ){
        try{
            Runtime.getRuntime().exec("explorer " +  "\"" + fname.replace('/','\\') + "\"" );
        }catch (IOException e){
            System.out.println("Can't Exec" );
        }
    }
}
// IIS Start 総括画面
/*--------------------------------------------------------------------*/
// 総括描画クラス
/*--------------------------------------------------------------------*/
class SumDrawPanel extends JPanel {
   int bsw;

    static int FONT_SIZE = 14;
    static int MARGIN    = 8;
    static int MAX_TEXT  = 10;
    private double      dScale;                 //描画スケール
    private int         sx;                     //開始Ｘ座標
    private int         sy;                     //開始Ｙ座標
    private int         cx;                     //文字単位幅
    private int         cy;                     //文字単位高

    private String[]    sItem = new String[MAX_TEXT];   //総括項目
    private int[]       nItem = new int[MAX_TEXT];      //総括項目桁数
    private int         nRecNum = 0;            //総括レコード数
    private int[]       nMaxHeight;             //レコードごとの最大行数
    private String[][]  sText;                  //総括内容
    private boolean[][] bExistData;             //総括内容の有無
    private String      sTitle;                 //総括タイトル
    private boolean     bEnable;
    private int         py_ofs;

    private Font        ft;                     //描画フォント
    private Font        nf;                     //描画フォント
    private Font        tf;                     //描画フォント
    private Font        af;                     //描画フォント

    private boolean     bPrt = false;

    /*----------------------------------------------------------------*/
    // コンストラクタ
    /*----------------------------------------------------------------*/
    public SumDrawPanel(String s, String Path) {
        super();
        int     cnt;
        int     n;
        String sBuf;

        dScale = 100.0;
        cx = FONT_SIZE;
        cy = FONT_SIZE + MARGIN;
        sx = 0;
        sy = 0;
        int     nText;

        ft = new Font( "ＭＳ 明朝", 0, FONT_SIZE );

        this.setOpaque(true);
        initComponents ();
        byte byDataBuff[];
        int nDataLen = 0;

        nText = 0;
        bEnable = false;
        try {
            File fL=new File(s);
            if (!fL.isFile()) return;
            FileInputStream fin = new FileInputStream(fL);

            byDataBuff = new byte[(int)fL.length()];
            nDataLen = fin.read(byDataBuff);

            StringTokenizer stReadData = new StringTokenizer( new String(byDataBuff,0,nDataLen),"\r\n");
            cnt = 0;
            while( stReadData.hasMoreTokens()){
                String szLine = stReadData.nextToken();
                if (szLine.startsWith("TITLE=")) {
                    sTitle = szLine.substring(6);
                }
                else if (szLine.startsWith("REC_NUM=")) {
                    nRecNum = Integer.parseInt(szLine.substring(8));
                   nMaxHeight = new int[nRecNum];                  //レコードごとの最大行数
                    sText = new String[nRecNum][MAX_TEXT];          //総括内容
                    bExistData = new boolean[nRecNum][MAX_TEXT];    //総括内容の有無
                } else {
                    nMaxHeight[cnt] = 0;
                    StringTokenizer token = new StringTokenizer(szLine, ",");
                    int nItems = 0;
                    while( token.hasMoreTokens()){
                        sBuf = token.nextToken();
                        // 区切り文字以外の『,』は文字として扱う
                        if (!sBuf.substring(sBuf.length()-1).equals("\"")) {
                            if (token.hasMoreTokens()) {
                                sBuf = sBuf + "," + token.nextToken();
                            }
                        }
                        sBuf = sBuf.substring(1, sBuf.length()-1).trim();
                        // 改行処理
                        while( true ){
                            n = sBuf.indexOf("\\n");
                            if( n == -1 )break;
                            StringBuffer sb = new StringBuffer(sBuf);
                            sb.replace(n,n+2,"\n");
                            sBuf = sb.toString();
                        }
                        sText[cnt][nItems] = sBuf;
                        bExistData[cnt][nItems] = true;
                        if (sBuf.equals("")) {
                            bExistData[cnt][nItems] = false;
                        }
                        nItems++;
                        if (nItems >= MAX_TEXT) break;
                    }
                    cnt++;

                }
                bEnable = true;
            }
            fin.close();
        }
        catch(IOException err){
          System.out.println("ERR "+ err.getMessage() );
          err.printStackTrace();
        }
        catch(Exception err){
          System.out.println("ERR "+ err.getMessage() );
          err.printStackTrace();
        }
        bsw = 0;
    }
    /*----------------------------------------------------------------*/
    // 文字列描画（枠付き）
    /*----------------------------------------------------------------*/
    private int drawTextRect( java.awt.Graphics g, String s, int x, int y, int w, int mh ){
        int             h;
        int             i,n;
        int             px,py;
        StringBuffer    sb = new StringBuffer();
        StringBuffer    pb = new StringBuffer();
        StringTokenizer stReadData;
        String          szBuff;
        Rectangle       rc;
        Rectangle       cc;
        int             nSw;
        Font            of;



        rc = g.getClipBounds();

        if( s == null )return 0;
        stReadData = new StringTokenizer( s,"\n");

        if( g instanceof PrintGraphics )rc = null;

        py = y + cy;
        h = 0;
        nSw = 0;
        while( stReadData.hasMoreTokens()){
            px = cx/2 + x;
            sb.setLength(0);
            pb.setLength(0);
            szBuff = stReadData.nextToken();
            sb.append(szBuff);
            n = sb.length();
            for( i = 0 ; i < n ;i++ ){
                if( sb.toString().substring(i).startsWith("<B>") ){
                    nSw = nSw | 1;i+=2;continue;
                }
                if( sb.toString().substring(i).startsWith("</B>") ){
                    nSw = nSw & ~1;i+=3;continue;
                }
                if( sb.toString().substring(i).startsWith("<I>") ){
                    nSw = nSw | 2;i+=2;continue;
                }
                if( sb.toString().substring(i).startsWith("</I>") ){
                    nSw = nSw & ~2;i+=3;continue;
                }
                if( sb.toString().substring(i).startsWith("<A>") ){
                    nSw = nSw | 4;i+=2;continue;
                }
                if( sb.toString().substring(i).startsWith("</A>") ){
                    nSw = nSw & ~4;i+=3;continue;
                }

//                if( (px + g.getFontMetrics().charWidth(sb.charAt(i)) -x - cx/2) >= (cx * w - cx) ){
                if( (px + g.getFontMetrics().charWidth(sb.charAt(i)) -x - cx/2) > (cx * w - cx) ){
                    py += cy;
                    px = cx/2 + x;
                    h++;
                }
                pb.append(sb.charAt(i));

                cc = new Rectangle(px,py, g.getFontMetrics().charWidth(sb.charAt(i)) , cy );
//                if( rc == null || rc.intersects(cc) == true ){
                    of = g.getFont();
                    if( ( nSw & 3 ) == 3 ){
                        g.setFont(af);
                    }else{
                        if( ( nSw & 1 ) == 1 )g.setFont(nf);
                        if( ( nSw & 2 ) == 2 )g.setFont(tf);
                    }
                    if( g instanceof PrintGraphics ){
                        g.drawString(pb.toString(),px,py-(MARGIN/4) );
                    }else{
                        g.drawString(pb.toString(),px,py-(MARGIN/2) );
                    }
                    if( ( nSw & 4 ) == 4 )g.drawLine(px,py-(MARGIN/4),px+g.getFontMetrics().charWidth(sb.charAt(i)), py-(MARGIN/4) );
                    g.setFont(of);
//                }
                px += g.getFontMetrics().charWidth(sb.charAt(i));
                pb.setLength(0);
            }
            py += cy;
            h++;
         }

        if( mh > h )h = mh;
        cc = new Rectangle(x, y, cx * w , cy * h );
        if( rc == null || rc.intersects(cc) == true ){
            g.drawRect( x, y, cx * w , cy * h );
        }
        return h;
    }
    /*----------------------------------------------------------------*/
    // 文字列描画
    /*----------------------------------------------------------------*/
    private int drawText( java.awt.Graphics g, String s, int x, int y, int w, int mh ){
        int             h;
        int             i,n;
        int             px,py;
        StringBuffer    sb = new StringBuffer();
        StringBuffer    pb = new StringBuffer();
        StringTokenizer stReadData;
        String          szBuff;
        Rectangle       rc;
        Rectangle       cc;
        int             nSw;
        Font            of;



        rc = g.getClipBounds();

        if( s == null )return 0;
        stReadData = new StringTokenizer( s,"\n");

        if( g instanceof PrintGraphics )rc = null;

        py = y + cy;
        h = 0;
        nSw = 0;
        while( stReadData.hasMoreTokens()){
            px = cx/2 + x;
            sb.setLength(0);
            pb.setLength(0);
            szBuff = stReadData.nextToken();
            sb.append(szBuff);
            n = sb.length();
            for( i = 0 ; i < n ;i++ ){
                if( sb.toString().substring(i).startsWith("<B>") ){
                    nSw = nSw | 1;i+=2;continue;
                }
                if( sb.toString().substring(i).startsWith("</B>") ){
                    nSw = nSw & ~1;i+=3;continue;
                }
                if( sb.toString().substring(i).startsWith("<I>") ){
                    nSw = nSw | 2;i+=2;continue;
                }
                if( sb.toString().substring(i).startsWith("</I>") ){
                    nSw = nSw & ~2;i+=3;continue;
                }
                if( sb.toString().substring(i).startsWith("<A>") ){
                    nSw = nSw | 4;i+=2;continue;
                }
                if( sb.toString().substring(i).startsWith("</A>") ){
                    nSw = nSw & ~4;i+=3;continue;
                }

//                if( (px + g.getFontMetrics().charWidth(sb.charAt(i)) -x - cx/2) >= (cx * w - cx) ){
                if( (px + g.getFontMetrics().charWidth(sb.charAt(i)) -x - cx/2) > (cx * w - cx) ){
                    py += cy;
                    px = cx/2 + x;
                    h++;
                }
                pb.append(sb.charAt(i));

                cc = new Rectangle(px,py, g.getFontMetrics().charWidth(sb.charAt(i)) , cy );
//                if( rc == null || rc.intersects(cc) == true ){
                    of = g.getFont();
                    if( ( nSw & 3 ) == 3 ){
                        g.setFont(af);
                    }else{
                        if( ( nSw & 1 ) == 1 )g.setFont(nf);
                        if( ( nSw & 2 ) == 2 )g.setFont(tf);
                    }
                    if( g instanceof PrintGraphics ){
                        g.drawString(pb.toString(),px,py-(MARGIN/4) );
                    }else{
                        g.drawString(pb.toString(),px,py-(MARGIN/2) );
                    }
                    if( ( nSw & 4 ) == 4 )g.drawLine(px,py-(MARGIN/4),px+g.getFontMetrics().charWidth(sb.charAt(i)), py-(MARGIN/4) );
                    g.setFont(of);
//                }
                px += g.getFontMetrics().charWidth(sb.charAt(i));
                pb.setLength(0);
            }
            py += cy;
            h++;
         }

        if( mh > h )h = mh;
        return h;
    }
    /*----------------------------------------------------------------*/
    // 矩形描画
    /*----------------------------------------------------------------*/
    private void drawRect( java.awt.Graphics g, int x, int y, int w, int h ){
        Rectangle       rc;
        Rectangle       cc;

        rc = g.getClipBounds();

        if( g instanceof PrintGraphics )rc = null;

        cc = new Rectangle(x, y, w, h );
        if( rc == null || rc.intersects(cc) == true ){
            g.drawRect( x, y, w, h );
        }
        return;
    }
    /*----------------------------------------------------------------*/
    // スクロールメソッド
    /*----------------------------------------------------------------*/
    public void setOffset( int x, int y ){
        sx = x;
        sy = y;
//        this.repaint();
    }
    /*----------------------------------------------------------------*/
    // スケール変更メソッド
    /*----------------------------------------------------------------*/
    public void setScale( double dSetScale ){
        if( dSetScale < 10.0 )return;
        if( dSetScale > 300.0 )return;

        dScale = dSetScale;
        cx =(int)Math.floor( FONT_SIZE *  dSetScale / 100.0 );
        ft = new Font( "ＭＳ 明朝", 0, cx);
//        this.repaint();
    }
    /*----------------------------------------------------------------*/
    /*----------------------------------------------------------------*/
    public int getHeightArea()
    {
        return paintArea( this.getGraphics() );
    }
    public int getWidthArea()
    {
        return (( 93 + 2 ) * cx);
    }
    /*----------------------------------------------------------------*/
    // 描画メソッド
    /*----------------------------------------------------------------*/
    public void paintComponent( java.awt.Graphics g ){
        super.paintComponent(g);
        paintArea( g );
    }
    public void print( java.awt.Graphics g ){
        paintArea( g );
        System.out.println( "call print" );
    }
    public void printAll( java.awt.Graphics g ){
        paintArea( g );
        System.out.println( "call printAll" );
    }

    /*----------------------------------------------------------------*/
    // 印刷メソッド
    /*----------------------------------------------------------------*/
    public void printDoc( PrintJob pjob ){
        Graphics    pg;
        int         y;

        bPrt = true;
        py_ofs = 0;
        while( true ){
            pg = pjob.getGraphics();
            if( pg == null )break;

            y = paintArea( pg );
            pg.dispose();
            if( y <= 0 )break;
        }
        bPrt = false;
    }
    /*----------------------------------------------------------------*/
    // 描画メソッド
    /*----------------------------------------------------------------*/
    public int paintArea( java.awt.Graphics g ){
        int     x,y;
        int     mx;
        int     px,py;
        int     i,n;
        Font    pft;                     //描画フォント
        int     wx,wy;
        Rectangle rc;
        Rectangle cc;
        Dimension dm;

        wx = sx;
        wy = sy;
        mx = 93;
        dm = null;
        if( g instanceof PrintGraphics ){
            PrintGraphics pg=(PrintGraphics)g;
            dm =pg.getPrintJob().getPageDimension();
            System.out.println("print"+ dm.width + "x" + dm.height);

            pft = new Font( "ＭＳ 明朝", 0, dm.width/(mx+7));
            g.setFont( pft );
            cx = pft.getSize();
            sx = 5*cx;
            sy = 4*cx;
            g.setClip( sx, sy, dm.width - sx, dm.height - (10 * cx) );

            cy = cx + MARGIN/2;
        }else{
            if( bPrt == true )return 0;

            g.setFont( ft );
            cx = ft.getSize();
            java.awt.Dimension dim = this.getSize();

            g.drawRect( 0,0,dim.width-1,dim.height-1 );
            py_ofs = 0;
            cy = cx + MARGIN;
        }
        nf = new Font("ＭＳ 明朝", Font.BOLD , cx );
        tf = new Font("ＭＳ 明朝", Font.ITALIC , cx );
        af = new Font("ＭＳ 明朝", Font.ITALIC | Font.BOLD , cx );



        if( bEnable == false )return 0;
        //  タイトル
        x = 1;
        y = 0;
        px = sx + (x * cx);
        py = sy + (y * cy) - py_ofs;
        y += drawText( g, this.sTitle, px, py , mx, 1 );

        String sItem[] = {"危害に関連する工程",
                        "　危害の原因物質",
                        "    危害の要因",
                        "     防止措置",
                        " 管理点",
                        "     管理基準",
                        "     確認方法",
                        "    改善措置方法",
                        "     検証方法",
                        "  記録文書名"
        };
        int nItem[] = {10,10,10,10,5,10,10,11,10,8};
        i=0;
        for( n = 0,x = 1; n < MAX_TEXT ; n++ ){
            px = sx + (x * cx);
            py = sy + (y * cy)  - py_ofs;
            i = drawTextRect( g, sItem[n], px, py , nItem[n], y );
            x += nItem[n];
        }
        y+=i;

        for( int m = 0; m < this.nRecNum ; m++ ){
            i = 1;
            for( n = 0,x = 1; n < MAX_TEXT ; n++ ){
                px = sx + (x * cx);
                py = sy + (y * cy)  - py_ofs;
                i = drawText( g, this.sText[m][n], px, py , nItem[n], i );
                x += nItem[n];
            }
            this.nMaxHeight[m] = i;
            y += i;
        }


        y++;
        px = sx + (x * cx);
        py = sy + (y * cy)  - py_ofs;

        int xx=0;
        int yy=0;
        int ww=0;
        int hh=0;
        for (int ii=0; ii < this.nRecNum; ii++) {
            for (int jj=0; jj < MAX_TEXT; jj++) {
                // 値あり
                if (this.bExistData[ii][jj]) {

                    if (ii == this.nRecNum-1 || this.bExistData[ii+1][jj]) {
                        xx = cx;
                        if( g instanceof PrintGraphics ){
                            xx += 5*cx;
                        }
                        for (n=0; n < jj; n++) xx += nItem[n]*cx;
                        yy = cy*2;
                        if( g instanceof PrintGraphics ){
                            yy += 4*cx;
                        }
                        for (n=0; n < ii; n++) yy += this.nMaxHeight[n]*cy;
                        yy -= py_ofs;
                        ww = cx * nItem[jj];
                        hh = cy * this.nMaxHeight[ii];
                        drawRect(g, xx, yy, ww, hh );
                    }
                }
                // 値なし
                else{
                    if (ii == this.nRecNum-1 || this.bExistData[ii+1][jj]) {
                        xx = cx;
                        if( g instanceof PrintGraphics ){
                            xx += 5*cx;
                        }
                        for (n=0; n < jj; n++) xx += nItem[n]*cx;
                        yy = cy*2;
                        if( g instanceof PrintGraphics ){
                            yy += 4*cx;
                        }
                        for (n=0; n < ii; n++) yy += this.nMaxHeight[n]*cy;
                        yy -= py_ofs;
                        ww = cx * nItem[jj];
                        hh = cy * this.nMaxHeight[ii];
                        for (n=ii-1; n >=0; n--) {
                            yy -= this.nMaxHeight[n]*cy;
                            hh += this.nMaxHeight[n]*cy;
                            if (this.bExistData[n][jj]) {
                                break;
                            }
                        }
                        drawRect(g, xx, yy, ww, hh );
                    }
                }
            }
        }

        if( g instanceof PrintGraphics ){
            PrintGraphics pg=(PrintGraphics)g;
            py_ofs += (dm.height - (10 * cx));
            py -= (dm.height - (10 * cx));


            System.out.println( "py_ofs = " + py_ofs + " py = " + py );
            sx = wx;
            sy = wy;
        }


        return py;
    }

    private void initComponents() {
//        setLayout(null);
    }
}
// IIS End 総括画面
/*--------------------------------------------------------------------*/
// End of File
/*--------------------------------------------------------------------*/
