OSDN Git Service

new branch 'gui'
[importpicture/importpicture.git] / importPicture / src / hayashi / yuu / gpx / gui / TouchScreen.java
1 package hayashi.yuu.gpx.gui;
2
3 import java.awt.*;
4 import java.awt.event.*;
5
6 import javax.swing.*;
7
8
9 /**
10  * 「タッチパネル画面」
11  *
12  */
13 @SuppressWarnings("serial")
14 public class TouchScreen extends JFrame implements Runnable
15 {
16     MainPanel mainPanel;                                        // キャビネット内のキータグ状況を表す
17
18     /**
19      * コンストラクタ
20      *
21      * 画面サイズ: 800 x 600
22      *
23      */
24     public TouchScreen(String siteName) throws Exception {
25         super();
26         this.setUndecorated(true);
27
28         this.startModePanel = new StartModePanel(this);
29
30         setLayout(new BorderLayout());
31         this.setVisible(false);
32         this.setSize(800, 600);
33
34         /*
35          * タイトルパネル
36          *              'proxSafe Commander3'のロゴイメージと、ターミナル名称
37          *
38          * 画面サイズ: 800 x 600
39          */
40         TitlePanel titlePanel = new TitlePanel();
41         add(BorderLayout.NORTH, titlePanel);
42
43         /*
44          * メインパネル
45          *      [ニュートラル表示]パネル
46          *
47          * 画面サイズ: 800 x ?
48          */
49         printStartMessage();
50         add(BorderLayout.CENTER, mainPanel);
51
52         /*
53          * フッターパネル
54          *
55          */
56         FooterPanel footerPanel = new FooterPanel(siteName);
57         add(BorderLayout.SOUTH, footerPanel);
58         setVisible(true);
59
60         SymWindow aSymWindow = new SymWindow();
61         addWindowListener(aSymWindow);
62     }
63
64
65
66         /////////////////////////////////////////////////////////////////////////////////////////////////
67         //
68         //  Frame に関するメソッド
69         //
70
71         public void init()  {
72         setVisible(true);
73         //Thread threadA = new Thread(this);
74         //threadA.start();
75     }
76
77     public void setVisible(boolean b) {
78         if(b) {
79             // デスクトップ中央にJFrameを配置する
80             Dimension paneSize   = this.getSize();
81             Dimension screenSize = this.getToolkit().getScreenSize();
82             this.setLocation((screenSize.width  - paneSize.width)  / 2, (screenSize.height - paneSize.height) / 2);
83         }
84         super.setVisible(b);
85     }
86
87     public void addNotify() {
88         Dimension d = getSize();
89         super.addNotify();
90         setSize(getInsets().left + getInsets().right + d.width, getInsets().top + getInsets().bottom + d.height);
91         Component components[] = getComponents();
92         for(int i = 0; i < components.length; i++)  {
93             Point p = components[i].getLocation();
94             p.translate(getInsets().left, getInsets().top);
95             components[i].setLocation(p);
96         }
97     }
98
99     /**
100      * WindowClose 処理
101      * @param event
102      */
103     public void FrameClosing(WindowEvent event) {
104         // スレッドを停止する
105         setVisible(false);
106         dispose();
107     }
108
109     class SymWindow extends WindowAdapter
110     {
111         public void windowClosing(WindowEvent event) {
112             Object object = event.getSource();
113             if(object == TouchScreen.this) {
114                 FrameClosing(event);
115             }
116         }
117     }
118
119         /////////////////////////////////////////////////////////////////////////////////////////////////
120         //
121         //  モード に関するメソッド
122         //
123     protected StartModePanel startModePanel;
124     /*
125     protected UnregisteredModePanel unregisteredModePanel;
126     protected BusyModePanel busyModePanel;
127     */
128
129     /*
130      * スクリーン遷移モード
131      */
132     public int screenMode = START_MODE;         // 現在のスクリーンモードを保持する
133     static final int START_MODE = 0;                    // ニュートラル
134     static final int USER_MODE = 1;                     // ユーザー認証済み(キー選択)
135     static final int UNREGISTERED_MODE = 2;     // 未登録カードモード
136     static final int BUSY_MODE = 3;                     // データ更新処理中モード
137     static final int KEYTAG_MODE = 4;                   // キータグ返却モード(AUTO_RETURN)
138
139
140     /*
141      * 「ニュートラル」モード
142      * new ImageIcon("lib/card.gif"), "IDカードをかざしてください。"
143      *
144      */
145     public void printStartMessage()  {
146                 this.screenMode = TouchScreen.START_MODE;
147
148                 // 表示パネルを切り替える
149         if (this.mainPanel != null) {
150                 this.remove(this.mainPanel);
151         }
152
153             this.mainPanel = this.startModePanel;
154             this.add(BorderLayout.CENTER, mainPanel);
155             this.setVisible(true);
156             this.repaint();
157     }
158
159
160         @Override
161         public void run() {
162                 while (this.screenMode == TouchScreen.START_MODE) {
163                         // 表示パネルを切り替える
164                 if (this.mainPanel != null) {
165                         this.remove(this.mainPanel);
166                         this.mainPanel = null;
167
168                             this.setVisible(true);
169                             //this.repaint();
170
171                                 try {
172                                         Thread.sleep(300);
173                                 } catch (InterruptedException e) {}
174                 }
175                 else {
176                         this.mainPanel = this.startModePanel;
177                         this.add(BorderLayout.CENTER, mainPanel);
178
179                             this.setVisible(true);
180                             //this.repaint();
181
182                                 try {
183                                         Thread.sleep(2000);
184                                 } catch (InterruptedException e) {}
185                 }
186                 }
187         }
188
189 }