提交 | 用户 | 时间
|
149dd0
|
1 |
package com.iailab.netsdk.demo.frame.ThermalCamera; |
H |
2 |
|
|
3 |
import java.awt.BorderLayout; |
|
4 |
import java.awt.Color; |
|
5 |
import java.awt.Dimension; |
|
6 |
import java.awt.FlowLayout; |
|
7 |
import java.awt.GridLayout; |
|
8 |
import java.awt.Panel; |
|
9 |
import java.awt.event.ActionEvent; |
|
10 |
import java.awt.event.ActionListener; |
|
11 |
import java.awt.event.WindowAdapter; |
|
12 |
import java.awt.event.WindowEvent; |
|
13 |
import java.util.Vector; |
|
14 |
|
|
15 |
import javax.swing.DefaultComboBoxModel; |
|
16 |
import javax.swing.JButton; |
|
17 |
import javax.swing.JComboBox; |
|
18 |
import javax.swing.JFrame; |
|
19 |
import javax.swing.JLabel; |
|
20 |
import javax.swing.JOptionPane; |
|
21 |
import javax.swing.JPanel; |
|
22 |
import javax.swing.JSplitPane; |
|
23 |
import javax.swing.SwingUtilities; |
|
24 |
import javax.swing.UIManager; |
|
25 |
import javax.swing.border.EmptyBorder; |
|
26 |
|
|
27 |
import com.sun.jna.Pointer; |
|
28 |
|
|
29 |
import com.iailab.netsdk.common.BorderEx; |
|
30 |
import com.iailab.netsdk.common.FunctionList; |
|
31 |
import com.iailab.netsdk.common.LoginPanel; |
|
32 |
import com.iailab.netsdk.common.Res; |
|
33 |
import com.iailab.netsdk.demo.module.LoginModule; |
|
34 |
import com.iailab.netsdk.demo.module.RealPlayModule; |
|
35 |
import com.iailab.netsdk.lib.NetSDKLib; |
|
36 |
import com.iailab.netsdk.lib.NetSDKLib.LLong; |
|
37 |
import com.iailab.netsdk.lib.ToolKits; |
|
38 |
|
|
39 |
/** |
|
40 |
* 热成像 |
|
41 |
*/ |
|
42 |
class ThermalCameraFrame extends JFrame { |
|
43 |
|
|
44 |
/** |
|
45 |
* |
|
46 |
*/ |
|
47 |
private static final long serialVersionUID = 1L; |
|
48 |
|
|
49 |
public static int THERMAL_CHANNEL = 1; // thermal channel |
|
50 |
|
|
51 |
private Vector<String> chnlist = new Vector<String>(); |
|
52 |
|
|
53 |
private boolean isrealplayOne = false; |
|
54 |
private boolean isrealplayTwo = false; |
|
55 |
|
|
56 |
// 设备断线通知回调 |
|
57 |
private static DisConnect disConnect = new DisConnect(); |
|
58 |
|
|
59 |
// 网络连接恢复 |
|
60 |
private static HaveReConnect haveReConnect = new HaveReConnect(); |
|
61 |
|
|
62 |
// 预览句柄 |
|
63 |
public static LLong m_hPlayHandleOne = new LLong(0); |
|
64 |
|
|
65 |
public static LLong m_hPlayHandleTwo = new LLong(0); |
|
66 |
|
|
67 |
// 获取界面窗口 |
|
68 |
private static JFrame frame = new JFrame(); |
|
69 |
|
|
70 |
public ThermalCameraFrame() { |
|
71 |
setTitle(Res.string().getThermalCamera()); |
|
72 |
setLayout(new BorderLayout()); |
|
73 |
pack(); |
|
74 |
setSize(800, 560); |
|
75 |
setResizable(false); |
|
76 |
setLocationRelativeTo(null); |
|
77 |
LoginModule.init(disConnect, haveReConnect); // 打开工程,初始化 |
|
78 |
|
|
79 |
try { |
|
80 |
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); |
|
81 |
} catch (Exception e) { |
|
82 |
e.printStackTrace(); |
|
83 |
} |
|
84 |
|
|
85 |
loginPanel = new LoginPanel(); |
|
86 |
operatePanel = new ThermalOperatePanel(); |
|
87 |
realPanelOne = new RealPanelOne(); |
|
88 |
realPanelTwo = new RealPanelTwo(); |
|
89 |
|
|
90 |
JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, loginPanel, operatePanel); |
|
91 |
splitPane.setDividerSize(0); |
|
92 |
splitPane.setBorder(null); |
|
93 |
JPanel realPanel = new JPanel();; |
|
94 |
realPanel.setLayout(new GridLayout(1, 2)); |
|
95 |
realPanel.add(realPanelOne); |
|
96 |
realPanel.add(realPanelTwo); |
|
97 |
|
|
98 |
add(splitPane, BorderLayout.NORTH); |
|
99 |
add(realPanel, BorderLayout.CENTER); |
|
100 |
|
|
101 |
loginPanel.addLoginBtnActionListener(new ActionListener() { |
|
102 |
@Override |
|
103 |
public void actionPerformed(ActionEvent e) { |
|
104 |
if(loginPanel.checkLoginText()) { |
|
105 |
if(login()) { |
|
106 |
frame = ToolKits.getFrame(e); |
|
107 |
frame.setTitle(Res.string().getShowInfo("THERMAL_CAMERA") + " : " + Res.string().getOnline()); |
|
108 |
} |
|
109 |
} |
|
110 |
} |
|
111 |
}); |
|
112 |
|
|
113 |
loginPanel.addLogoutBtnActionListener(new ActionListener() { |
|
114 |
@Override |
|
115 |
public void actionPerformed(ActionEvent e) { |
|
116 |
frame.setTitle(Res.string().getShowInfo("THERMAL_CAMERA")); |
|
117 |
logout(); |
|
118 |
} |
|
119 |
}); |
|
120 |
|
|
121 |
addWindowListener(new WindowAdapter() { |
|
122 |
public void windowClosing(WindowEvent e) { |
|
123 |
RealPlayModule.stopRealPlay(m_hPlayHandleOne); |
|
124 |
RealPlayModule.stopRealPlay(m_hPlayHandleTwo); |
|
125 |
LoginModule.logout(); |
|
126 |
LoginModule.cleanup(); // 关闭工程,释放资源 |
|
127 |
dispose(); |
|
128 |
|
|
129 |
SwingUtilities.invokeLater(new Runnable() { |
|
130 |
public void run() { |
|
131 |
FunctionList demo = new FunctionList(); |
|
132 |
demo.setVisible(true); |
|
133 |
} |
|
134 |
}); |
|
135 |
} |
|
136 |
}); |
|
137 |
} |
|
138 |
|
|
139 |
/////////////////面板/////////////////// |
|
140 |
// 设备断线回调: 通过 CLIENT_Init 设置该回调函数,当设备出现断线时,SDK会调用该函数 |
|
141 |
private static class DisConnect implements NetSDKLib.fDisConnect { |
|
142 |
public void invoke(LLong m_hLoginHandle, String pchDVRIP, int nDVRPort, Pointer dwUser) { |
|
143 |
System.out.printf("Device[%s] Port[%d] DisConnect!\n", pchDVRIP, nDVRPort); |
|
144 |
// 断线提示 |
|
145 |
SwingUtilities.invokeLater(new Runnable() { |
|
146 |
public void run() { |
|
147 |
frame.setTitle(Res.string().getShowInfo("THERMAL_CAMERA") + " : " + Res.string().getDisConnectReconnecting()); |
|
148 |
} |
|
149 |
}); |
|
150 |
} |
|
151 |
} |
|
152 |
|
|
153 |
// 网络连接恢复,设备重连成功回调 |
|
154 |
// 通过 CLIENT_SetAutoReconnect 设置该回调函数,当已断线的设备重连成功时,SDK会调用该函数 |
|
155 |
private static class HaveReConnect implements NetSDKLib.fHaveReConnect { |
|
156 |
public void invoke(LLong m_hLoginHandle, String pchDVRIP, int nDVRPort, Pointer dwUser) { |
|
157 |
System.out.printf("ReConnect Device[%s] Port[%d]\n", pchDVRIP, nDVRPort); |
|
158 |
|
|
159 |
// 重连提示 |
|
160 |
SwingUtilities.invokeLater(new Runnable() { |
|
161 |
public void run() { |
|
162 |
frame.setTitle(Res.string().getShowInfo("THERMAL_CAMERA") + " : " + Res.string().getOnline()); |
|
163 |
} |
|
164 |
}); |
|
165 |
} |
|
166 |
} |
|
167 |
|
|
168 |
// 登录 |
|
169 |
public boolean login() { |
|
170 |
if(LoginModule.login(loginPanel.ipTextArea.getText(), |
|
171 |
Integer.parseInt(loginPanel.portTextArea.getText()), |
|
172 |
loginPanel.nameTextArea.getText(), |
|
173 |
new String(loginPanel.passwordTextArea.getPassword()))) { |
|
174 |
|
|
175 |
|
|
176 |
for(int i = 1; i < LoginModule.m_stDeviceInfo.byChanNum + 1; i++) { |
|
177 |
chnlist.add(Res.string().getChannel() + " " + String.valueOf(i)); |
|
178 |
} |
|
179 |
|
|
180 |
setEnable(true); |
|
181 |
|
|
182 |
} else { |
|
183 |
JOptionPane.showMessageDialog(null, Res.string().getLoginFailed() + ", " + ToolKits.getErrorCodeShow(), Res.string().getErrorMessage(), JOptionPane.ERROR_MESSAGE); |
|
184 |
return false; |
|
185 |
} |
|
186 |
return true; |
|
187 |
} |
|
188 |
|
|
189 |
// 登出 |
|
190 |
public void logout() { |
|
191 |
RealPlayModule.stopRealPlay(m_hPlayHandleOne); |
|
192 |
RealPlayModule.stopRealPlay(m_hPlayHandleTwo); |
|
193 |
LoginModule.logout(); |
|
194 |
|
|
195 |
setEnable(false); |
|
196 |
chnlist.clear(); |
|
197 |
} |
|
198 |
|
|
199 |
public void setEnable(boolean b) { |
|
200 |
loginPanel.setButtonEnable(b); |
|
201 |
realPanelOne.setRealPlayEnable(b); |
|
202 |
realPanelTwo.setRealPlayEnable(b); |
|
203 |
operatePanel.setOperateEnabled(b); |
|
204 |
isrealplayOne = false; |
|
205 |
isrealplayTwo = false; |
|
206 |
} |
|
207 |
|
|
208 |
/* |
|
209 |
* 热成像操作面板 |
|
210 |
*/ |
|
211 |
private class ThermalOperatePanel extends JPanel { |
|
212 |
|
|
213 |
private static final long serialVersionUID = 1L; |
|
214 |
|
|
215 |
public ThermalOperatePanel() { |
|
216 |
BorderEx.set(this, Res.string().getShowInfo("THERMAL_OPERATE"), 2); |
|
217 |
setLayout(new FlowLayout(FlowLayout.CENTER, 15, 5)); |
|
218 |
|
|
219 |
JLabel chnlabel = new JLabel(Res.string().getChn()); |
|
220 |
chnComboBox = new JComboBox(); |
|
221 |
|
|
222 |
pointQueryBtn = new JButton(Res.string().getShowInfo("POINT_QUERY")); |
|
223 |
itemQueryBtn = new JButton(Res.string().getShowInfo("ITEM_QUERY")); |
|
224 |
historyQueryBtn = new JButton(Res.string().getShowInfo("TEMPER_QUERY")); |
|
225 |
heatMapBtn = new JButton(Res.string().getShowInfo("HEATMAP")); |
|
226 |
|
|
227 |
Dimension btnDimension = new Dimension(140, 20); |
|
228 |
pointQueryBtn.setPreferredSize(btnDimension); |
|
229 |
itemQueryBtn.setPreferredSize(btnDimension); |
|
230 |
historyQueryBtn.setPreferredSize(btnDimension); |
|
231 |
heatMapBtn.setPreferredSize(btnDimension); |
|
232 |
chnComboBox.setPreferredSize(new Dimension(80, 20)); |
|
233 |
|
|
234 |
JPanel chnPanel = new JPanel(); |
|
235 |
chnPanel.add(chnlabel); |
|
236 |
chnPanel.add(chnComboBox); |
|
237 |
|
|
238 |
add(chnPanel); |
|
239 |
add(pointQueryBtn); |
|
240 |
add(pointQueryBtn); |
|
241 |
add(itemQueryBtn); |
|
242 |
add(historyQueryBtn); |
|
243 |
add(heatMapBtn); |
|
244 |
|
|
245 |
setOperateEnabled(false); |
|
246 |
|
|
247 |
listener = new ThermalOperateActionListener(); |
|
248 |
pointQueryBtn.addActionListener(listener); |
|
249 |
itemQueryBtn.addActionListener(listener); |
|
250 |
historyQueryBtn.addActionListener(listener); |
|
251 |
heatMapBtn.addActionListener(listener); |
|
252 |
} |
|
253 |
|
|
254 |
public void setOperateEnabled(boolean b) { |
|
255 |
pointQueryBtn.setEnabled(b); |
|
256 |
itemQueryBtn.setEnabled(b); |
|
257 |
historyQueryBtn.setEnabled(b); |
|
258 |
heatMapBtn.setEnabled(b); |
|
259 |
chnComboBox.setEnabled(b); |
|
260 |
if (b) { |
|
261 |
chnComboBox.setModel(new DefaultComboBoxModel(chnlist)); |
|
262 |
if (chnlist.size() > THERMAL_CHANNEL) { |
|
263 |
chnComboBox.setSelectedIndex(THERMAL_CHANNEL); |
|
264 |
} |
|
265 |
}else { |
|
266 |
chnComboBox.setModel(new DefaultComboBoxModel()); |
|
267 |
} |
|
268 |
} |
|
269 |
|
|
270 |
private JComboBox chnComboBox; |
|
271 |
private ThermalOperateActionListener listener; |
|
272 |
private JButton pointQueryBtn; |
|
273 |
private JButton itemQueryBtn; |
|
274 |
private JButton historyQueryBtn; |
|
275 |
private JButton heatMapBtn; |
|
276 |
} |
|
277 |
|
|
278 |
private enum ThermalOperate {UNKNOWN, POINT_QUERY, ITEM_QUERY, TEMPER_QUERY, HEATMAP} |
|
279 |
|
|
280 |
/** |
|
281 |
* 按键监听实现类 |
|
282 |
*/ |
|
283 |
private class ThermalOperateActionListener implements ActionListener { |
|
284 |
|
|
285 |
@Override |
|
286 |
public void actionPerformed(ActionEvent arg0) { |
|
287 |
|
|
288 |
THERMAL_CHANNEL = operatePanel.chnComboBox.getSelectedIndex(); |
|
289 |
ThermalOperate emType = getOperateType(arg0.getSource()); |
|
290 |
switch(emType) { |
|
291 |
case POINT_QUERY: |
|
292 |
new PointQueryDialog().setVisible(true); |
|
293 |
break; |
|
294 |
case ITEM_QUERY: |
|
295 |
new ItemQueryDialog().setVisible(true); |
|
296 |
break; |
|
297 |
case TEMPER_QUERY: |
|
298 |
new TemperQueryDialog().setVisible(true); |
|
299 |
break; |
|
300 |
case HEATMAP: |
|
301 |
new HeatMapDialog().setVisible(true); |
|
302 |
break; |
|
303 |
default: |
|
304 |
break; |
|
305 |
} |
|
306 |
} |
|
307 |
|
|
308 |
private ThermalOperate getOperateType(Object btn) { |
|
309 |
ThermalOperate type = ThermalOperate.UNKNOWN; |
|
310 |
|
|
311 |
if (btn == operatePanel.pointQueryBtn) { |
|
312 |
type = ThermalOperate.POINT_QUERY; |
|
313 |
}else if (btn == operatePanel.itemQueryBtn) { |
|
314 |
type = ThermalOperate.ITEM_QUERY; |
|
315 |
}else if (btn == operatePanel.historyQueryBtn) { |
|
316 |
type = ThermalOperate.TEMPER_QUERY; |
|
317 |
}else if (btn == operatePanel.heatMapBtn) { |
|
318 |
type = ThermalOperate.HEATMAP; |
|
319 |
}else{ |
|
320 |
System.err.println("Unknown Event: " + btn); |
|
321 |
} |
|
322 |
|
|
323 |
return type; |
|
324 |
|
|
325 |
} |
|
326 |
} |
|
327 |
|
|
328 |
/* |
|
329 |
* 预览界面通道、码流设置 以及抓图面板 |
|
330 |
*/ |
|
331 |
private class RealPanelOne extends JPanel { |
|
332 |
private static final long serialVersionUID = 1L; |
|
333 |
|
|
334 |
public RealPanelOne() { |
|
335 |
BorderEx.set(this, Res.string().getRealplay(), 2); |
|
336 |
setLayout(new BorderLayout()); |
|
337 |
|
|
338 |
channelPanelOne = new Panel(); |
|
339 |
realplayPanelOne = new JPanel(); |
|
340 |
|
|
341 |
add(channelPanelOne, BorderLayout.NORTH); |
|
342 |
add(realplayPanelOne, BorderLayout.CENTER); |
|
343 |
|
|
344 |
/************ 预览面板 **************/ |
|
345 |
realplayPanelOne.setLayout(new BorderLayout()); |
|
346 |
realplayPanelOne.setBorder(new EmptyBorder(5, 5, 5, 5)); |
|
347 |
realPlayWindowOne = new Panel(); |
|
348 |
realPlayWindowOne.setBackground(Color.GRAY); |
|
349 |
realplayPanelOne.add(realPlayWindowOne, BorderLayout.CENTER); |
|
350 |
|
|
351 |
/************ 通道、码流面板 **************/ |
|
352 |
chnlabelOne = new JLabel(Res.string().getChn()); |
|
353 |
chnComboBoxOne = new JComboBox(); |
|
354 |
|
|
355 |
streamLabelOne = new JLabel(Res.string().getStreamType()); |
|
356 |
String[] stream = {Res.string().getMasterStream(), Res.string().getSubStream()}; |
|
357 |
streamComboBoxOne = new JComboBox(stream); |
|
358 |
|
|
359 |
realplayBtnOne = new JButton(Res.string().getStartRealPlay()); |
|
360 |
|
|
361 |
channelPanelOne.setLayout(new FlowLayout()); |
|
362 |
channelPanelOne.add(chnlabelOne); |
|
363 |
channelPanelOne.add(chnComboBoxOne); |
|
364 |
channelPanelOne.add(streamLabelOne); |
|
365 |
channelPanelOne.add(streamComboBoxOne); |
|
366 |
channelPanelOne.add(realplayBtnOne); |
|
367 |
|
|
368 |
chnComboBoxOne.setPreferredSize(new Dimension(80, 20)); |
|
369 |
streamComboBoxOne.setPreferredSize(new Dimension(95, 20)); |
|
370 |
realplayBtnOne.setPreferredSize(new Dimension(115, 20)); |
|
371 |
|
|
372 |
realPlayWindowOne.setEnabled(false); |
|
373 |
chnComboBoxOne.setEnabled(false); |
|
374 |
streamComboBoxOne.setEnabled(false); |
|
375 |
realplayBtnOne.setEnabled(false); |
|
376 |
|
|
377 |
realplayBtnOne.addActionListener(new ActionListener() { |
|
378 |
@Override |
|
379 |
public void actionPerformed(ActionEvent e) { |
|
380 |
realPlay(); |
|
381 |
} |
|
382 |
}); |
|
383 |
} |
|
384 |
|
|
385 |
public void setRealPlayEnable(boolean bln) { |
|
386 |
realPlayWindowOne.setEnabled(bln); |
|
387 |
chnComboBoxOne.setEnabled(bln); |
|
388 |
streamComboBoxOne.setEnabled(bln); |
|
389 |
realplayBtnOne.setEnabled(bln); |
|
390 |
if (bln) { |
|
391 |
chnComboBoxOne.setModel(new DefaultComboBoxModel(chnlist)); |
|
392 |
}else { |
|
393 |
realPlayWindowOne.repaint(); |
|
394 |
realplayBtnOne.setText(Res.string().getStartRealPlay()); |
|
395 |
chnComboBoxOne.setModel(new DefaultComboBoxModel()); |
|
396 |
} |
|
397 |
} |
|
398 |
|
|
399 |
private void realPlay() { |
|
400 |
if(!isrealplayOne) { |
|
401 |
m_hPlayHandleOne = RealPlayModule.startRealPlay(chnComboBoxOne.getSelectedIndex(), |
|
402 |
streamComboBoxOne.getSelectedIndex()==0? 0:3, |
|
403 |
realPlayWindowOne); |
|
404 |
if(m_hPlayHandleOne.longValue() != 0) { |
|
405 |
changePlayStatus(true); |
|
406 |
} else { |
|
407 |
JOptionPane.showMessageDialog(null, ToolKits.getErrorCodeShow(), Res.string().getErrorMessage(), JOptionPane.ERROR_MESSAGE); |
|
408 |
} |
|
409 |
} else { |
|
410 |
RealPlayModule.stopRealPlay(m_hPlayHandleOne); |
|
411 |
changePlayStatus(false); |
|
412 |
} |
|
413 |
} |
|
414 |
|
|
415 |
private void changePlayStatus(boolean b) { |
|
416 |
realPlayWindowOne.repaint(); |
|
417 |
isrealplayOne = b; |
|
418 |
chnComboBoxOne.setEnabled(!b); |
|
419 |
streamComboBoxOne.setEnabled(!b); |
|
420 |
if (b) { |
|
421 |
realplayBtnOne.setText(Res.string().getStopRealPlay()); |
|
422 |
} else { |
|
423 |
m_hPlayHandleOne.setValue(0); |
|
424 |
realplayBtnOne.setText(Res.string().getStartRealPlay()); |
|
425 |
} |
|
426 |
} |
|
427 |
|
|
428 |
private JPanel realplayPanelOne; |
|
429 |
private Panel realPlayWindowOne; |
|
430 |
private Panel channelPanelOne; |
|
431 |
|
|
432 |
private JLabel chnlabelOne; |
|
433 |
private JComboBox chnComboBoxOne; |
|
434 |
private JLabel streamLabelOne; |
|
435 |
private JComboBox streamComboBoxOne; |
|
436 |
private JButton realplayBtnOne; |
|
437 |
} |
|
438 |
|
|
439 |
private class RealPanelTwo extends JPanel { |
|
440 |
private static final long serialVersionUID = 1L; |
|
441 |
|
|
442 |
public RealPanelTwo() { |
|
443 |
BorderEx.set(this, Res.string().getRealplay(), 2); |
|
444 |
setLayout(new BorderLayout()); |
|
445 |
|
|
446 |
channelPanelTwo = new Panel(); |
|
447 |
realplayPanelTwo = new JPanel(); |
|
448 |
|
|
449 |
add(channelPanelTwo, BorderLayout.NORTH); |
|
450 |
add(realplayPanelTwo, BorderLayout.CENTER); |
|
451 |
|
|
452 |
/************ 预览面板 **************/ |
|
453 |
realplayPanelTwo.setLayout(new BorderLayout()); |
|
454 |
realplayPanelTwo.setBorder(new EmptyBorder(5, 5, 5, 5)); |
|
455 |
realPlayWindowTwo = new Panel(); |
|
456 |
realPlayWindowTwo.setBackground(Color.GRAY); |
|
457 |
realplayPanelTwo.add(realPlayWindowTwo, BorderLayout.CENTER); |
|
458 |
|
|
459 |
/************ 通道、码流面板 **************/ |
|
460 |
chnlabelTwo = new JLabel(Res.string().getChn()); |
|
461 |
chnComboBoxTwo = new JComboBox(); |
|
462 |
|
|
463 |
streamLabelTwo = new JLabel(Res.string().getStreamType()); |
|
464 |
String[] stream = {Res.string().getMasterStream(), Res.string().getSubStream()}; |
|
465 |
streamComboBoxTwo = new JComboBox(stream); |
|
466 |
|
|
467 |
realplayBtnTwo = new JButton(Res.string().getStartRealPlay()); |
|
468 |
|
|
469 |
channelPanelTwo.setLayout(new FlowLayout()); |
|
470 |
channelPanelTwo.add(chnlabelTwo); |
|
471 |
channelPanelTwo.add(chnComboBoxTwo); |
|
472 |
channelPanelTwo.add(streamLabelTwo); |
|
473 |
channelPanelTwo.add(streamComboBoxTwo); |
|
474 |
channelPanelTwo.add(realplayBtnTwo); |
|
475 |
|
|
476 |
chnComboBoxTwo.setPreferredSize(new Dimension(80, 20)); |
|
477 |
streamComboBoxTwo.setPreferredSize(new Dimension(95, 20)); |
|
478 |
realplayBtnTwo.setPreferredSize(new Dimension(115, 20)); |
|
479 |
|
|
480 |
realPlayWindowTwo.setEnabled(false); |
|
481 |
chnComboBoxTwo.setEnabled(false); |
|
482 |
streamComboBoxTwo.setEnabled(false); |
|
483 |
realplayBtnTwo.setEnabled(false); |
|
484 |
|
|
485 |
realplayBtnTwo.addActionListener(new ActionListener() { |
|
486 |
@Override |
|
487 |
public void actionPerformed(ActionEvent e) { |
|
488 |
realPlay(); |
|
489 |
} |
|
490 |
}); |
|
491 |
} |
|
492 |
|
|
493 |
public void setRealPlayEnable(boolean bln) { |
|
494 |
realPlayWindowTwo.setEnabled(bln); |
|
495 |
chnComboBoxTwo.setEnabled(bln); |
|
496 |
streamComboBoxTwo.setEnabled(bln); |
|
497 |
realplayBtnTwo.setEnabled(bln); |
|
498 |
if (bln) { |
|
499 |
chnComboBoxTwo.setModel(new DefaultComboBoxModel(chnlist)); |
|
500 |
if (chnlist.size() > THERMAL_CHANNEL) { |
|
501 |
chnComboBoxTwo.setSelectedIndex(THERMAL_CHANNEL); |
|
502 |
} |
|
503 |
}else { |
|
504 |
realPlayWindowTwo.repaint(); |
|
505 |
realplayBtnTwo.setText(Res.string().getStartRealPlay()); |
|
506 |
chnComboBoxTwo.setModel(new DefaultComboBoxModel()); |
|
507 |
} |
|
508 |
} |
|
509 |
|
|
510 |
private void realPlay() { |
|
511 |
if(!isrealplayTwo) { |
|
512 |
m_hPlayHandleTwo = RealPlayModule.startRealPlay(chnComboBoxTwo.getSelectedIndex(), |
|
513 |
streamComboBoxTwo.getSelectedIndex()==0? 0:3, |
|
514 |
realPlayWindowTwo); |
|
515 |
if(m_hPlayHandleTwo.longValue() != 0) { |
|
516 |
changePlayStatus(true); |
|
517 |
} else { |
|
518 |
JOptionPane.showMessageDialog(null, ToolKits.getErrorCodeShow(), Res.string().getErrorMessage(), JOptionPane.ERROR_MESSAGE); |
|
519 |
} |
|
520 |
} else { |
|
521 |
RealPlayModule.stopRealPlay(m_hPlayHandleTwo); |
|
522 |
changePlayStatus(false); |
|
523 |
} |
|
524 |
} |
|
525 |
|
|
526 |
private void changePlayStatus(boolean b) { |
|
527 |
realPlayWindowTwo.repaint(); |
|
528 |
isrealplayTwo = b; |
|
529 |
chnComboBoxTwo.setEnabled(!b); |
|
530 |
streamComboBoxTwo.setEnabled(!b); |
|
531 |
if (b) { |
|
532 |
realplayBtnTwo.setText(Res.string().getStopRealPlay()); |
|
533 |
} else { |
|
534 |
m_hPlayHandleTwo.setValue(0); |
|
535 |
realplayBtnTwo.setText(Res.string().getStartRealPlay()); |
|
536 |
} |
|
537 |
} |
|
538 |
|
|
539 |
private JPanel realplayPanelTwo; |
|
540 |
private Panel realPlayWindowTwo; |
|
541 |
private Panel channelPanelTwo; |
|
542 |
|
|
543 |
private JLabel chnlabelTwo; |
|
544 |
private JComboBox chnComboBoxTwo; |
|
545 |
private JLabel streamLabelTwo; |
|
546 |
private JComboBox streamComboBoxTwo; |
|
547 |
private JButton realplayBtnTwo; |
|
548 |
} |
|
549 |
|
|
550 |
private LoginPanel loginPanel; |
|
551 |
private ThermalOperatePanel operatePanel; |
|
552 |
private RealPanelOne realPanelOne; |
|
553 |
private RealPanelTwo realPanelTwo; |
|
554 |
} |
|
555 |
|
|
556 |
|
|
557 |
public class ThermalCamera { |
|
558 |
public static void main(String[] args) { |
|
559 |
SwingUtilities.invokeLater(new Runnable() { |
|
560 |
public void run() { |
|
561 |
// Res.string().switchLanguage(LanguageType.English); |
|
562 |
ThermalCameraFrame demo = new ThermalCameraFrame(); |
|
563 |
demo.setVisible(true); |
|
564 |
} |
|
565 |
}); |
|
566 |
} |
|
567 |
} |