-
Notifications
You must be signed in to change notification settings - Fork 0
/
ScreensFramework.java
296 lines (231 loc) · 7.54 KB
/
ScreensFramework.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
package CAM;
/*
* MK3随动控制系统-人机模块主程序入口
*
* Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
*
*/
import java.io.File;
import java.io.IOException;
import java.util.Locale;
import org.apache.log4j.Logger;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.stage.Screen;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.geometry.Rectangle2D;
/**
*
* @author DX
*/
//@DX1-软件优化标识
public class ScreensFramework extends Application {
//@1-主程序stage
public static Stage MK3_Stage;
//@2-主程序scene
public static Scene MK3_Scene;
//@3-主程序根root
public static Group root = new Group();
//@4-页面更改切换login->Main
public static SimpleStringProperty PageChange = new SimpleStringProperty();
//@5-主程序显示定时器
private static Servo_DisplayTimer Time_Displsy;
//@7-主页面运行标志
public static boolean Main_Falg=true;
//@8-页面位置指示
public static int App_Page=0; //0:login 1:main 2:performance test 3:help
//@9-界面主调度器
private ScreensController mainContainer;
//@10-界面常量
public static String screen1ID = "main";
public static String screen1File = "Cam.fxml";
// public static String screen2ID = "main";
// public static String screen2File = "Lottery.fxml";
// public static String screen3ID = "performance_test";
// public static String screen3File = "Performance_Test.fxml";
// public static String screen4ID = "checkdata";
// public static String screen4File = "CheckData.fxml";
// public static String screen5ID = "set";
// public static String screen5File = "Set.fxml";
// public static String screen6ID = "help";
// public static String screen6File = "Help.fxml";
//@12-数据存储路径常量
public static String MAIN_SaveData_Path = new String("D://");
//@13-数据文件存储路径
public static File MAIN_FileSave_Path; //数据存储路径
//@14-存储文件文件对象列表
public static File[] MAIN_SaveFileList;
//@15-记录文件存储数量
public static int MAIN_SaveFile_Num;
//@16-提示窗
private static Notification.Notifier Main_Noti;
private static Notification Noti_Targe;
//@17-窗口尺寸
private Rectangle2D bounds;
//@-自定义键盘键值
public static KeyCode Key_Code;
//@-自定义键盘层
public static int Main_Key_Level=0;
//@-键盘触发计数
public static int Key_Count=0;
@Override
public void start(Stage primaryStage) {
//@1-初始化Stage
MK3_Stage = new Stage(StageStyle.DECORATED);
MK3_Stage.setTitle("摄像头测试");
//@2-挂载页面控制器
mainContainer = new ScreensController();
mainContainer.loadScreen(screen1ID, screen1File);
// mainContainer.loadScreen(screen2ID, screen2File);
// mainContainer.loadScreen(screen3ID, screen3File);
// mainContainer.loadScreen(screen4ID, screen4File);
// mainContainer.loadScreen(screen5ID, screen5File);
// mainContainer.loadScreen(screen6ID, screen6File);
//@3-页面更改挂载更改监听器
PageChange.addListener(new ChangeListener<Object>(){
@Override
public void changed(ObservableValue<?> arg0, Object arg1, Object newval) {
// TODO Auto-generated method stub
//@-切换到主界面
if(newval.toString().equals(new String("main")))
{
Platform.runLater(new Runnable() {
@Override
public void run() {
if(Main_Falg==false)
Main_Falg=true;
// if(MainController.Page1_Run_Flag==true)
// MainController.curve_run_set(true);
//@-切换到主界面
mainContainer.setScreen(screen1ID);
App_Page=1;
MK3_Stage.setX(bounds.getMinX() + bounds.getWidth() / 2 - 1920 / 2);
MK3_Stage.setY(bounds.getMinY() + bounds.getHeight() / 2 - 1080 / 2);
MK3_Stage.setWidth(1280);
MK3_Stage.setHeight(720);
}
});
}
//@-切换到性能检测
else if(newval.toString().equals(new String("performance_test")))
{
}
//@-切换到帮助页面
else if(newval.toString().equals(new String("help")))
{
}
}});
//@3-初始化加载主页面
mainContainer.setScreen(screen1ID);
App_Page=1;
//@DX2-Log开始
// ScreensFramework.logger_FY.info("---------------Start----------------");
// ScreensFramework.logger_XH.info("---------------Start----------------");
//@5-开机检测存储数据数量
Check_File_Num();
//@6-scene加载页面
root = new Group();
root.getChildren().addAll(mainContainer);
MK3_Scene = new Scene(root);
//@8-stage加载
MK3_Stage.setScene(MK3_Scene);
bounds = Screen.getPrimary().getBounds();
MK3_Stage.setX(bounds.getMinX() + bounds.getWidth() / 2 - 1920 / 2);
MK3_Stage.setY(bounds.getMinY() + bounds.getHeight() / 2 - 1080 / 2);
//@9-stage显示
MK3_Stage.show();
//@10-启动全局定时器-50ms
Time_Displsy = new Servo_DisplayTimer(10);
}
/**
* The main() method is ignored in correctly deployed JavaFX application.
* main() serves only as fallback in case the application can not be
* launched through deployment artifacts, e.g., in IDEs with limited FX
* support. NetBeans ignores main().
*
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
/**提示信息显示
*
* @param Show_Mode
* @param Show_Info
*/
public static void Show_Noti(String Show_Mode, String Show_Info)
{
String Noti_Title=null;
Image Noti_Image=null;
//@1-Noti标号
switch(Show_Mode)
{
case "Info":
Noti_Title = new String("Info");
Noti_Image = new Image(ScreensFramework.class.getResourceAsStream("info.png"));
break;
case "Error":
Noti_Title = new String("Error");
Noti_Image = new Image(ScreensFramework.class.getResourceAsStream("error.png"));
break;
case "Warning":
Noti_Title = new String("Warning");
Noti_Image = new Image(ScreensFramework.class.getResourceAsStream("warning.png"));
break;
case "Success":
Noti_Title = new String("Success");
Noti_Image = new Image(ScreensFramework.class.getResourceAsStream("success.png"));
break;
default:break;
}
//@3-建立Noti
Noti_Targe = new Notification(Noti_Title, Show_Info, Noti_Image);
//@4-显示Noti
Platform.runLater(new Runnable() {
@Override
public void run() {
Main_Noti = Notification.Notifier.INSTANCE;
Main_Noti.notify(Noti_Targe);
}
});
}
/**检测存储数据文件数量
*
*/
public static void Check_File_Num()
{
MAIN_FileSave_Path = new File(MAIN_SaveData_Path);
if(MAIN_FileSave_Path.isDirectory())
{
//获取文件列表
MAIN_SaveFileList = MAIN_FileSave_Path.listFiles();
//获取文件数量
MAIN_SaveFile_Num=MAIN_SaveFileList.length;
//System.out.println("ok"+MAIN_SaveFile_Num);
}
}
/**程序退出
*
*/
public static void cleanAndQuit() {
Time_Displsy.task_dis.cancel();
MK3_Stage.close();
Platform.exit();
System.exit(0);
}
}