提交 | 用户 | 时间
ce910c 1 package com.netsdk.demo.frame;
H 2
3 import com.sun.jna.Pointer;
4 import com.netsdk.common.*;
5 import com.netsdk.demo.module.*;
6 import com.netsdk.lib.NetSDKLib;
7 import com.netsdk.lib.ToolKits;
8
9 import javax.swing.*;
10 import javax.swing.border.EmptyBorder;
11 import javax.swing.table.DefaultTableCellRenderer;
12 import javax.swing.table.DefaultTableModel;
13
14 import java.awt.*;
15 import java.awt.event.*;
16 import java.util.*;
17 import java.util.List;
18 import java.util.concurrent.ExecutorService;
19 import java.util.concurrent.Executors;
20
21 /**
22  * 人数统计事件 demo
23  */
24 class HumanNumberStatisticFrame extends JFrame {
25
26     private static final long serialVersionUID = 1L;
27
28
29     /*
30      * 界面、SDK初始化及登录
31      */
32     public HumanNumberStatisticFrame() {
33         setTitle(Res.string().getHumanNumberStatistic());
34         setLayout(new BorderLayout());
35         pack();
36         setSize(1080, 560);
37         setResizable(false);
38         setLocationRelativeTo(null);
39         LoginModule.init(disConnectCB, haveReConnectCB);   // 打开工程,SDK初始化,注册断线和重连回调函数
40
41         try {
42             UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
43         } catch (Exception e) {
44             e.printStackTrace();
45         }
46
47         loginPanel = new LoginPanel();
48         humanStatisticPanel = new HumanStatisticPanel();
49
50         add(loginPanel, BorderLayout.NORTH);
51         add(humanStatisticPanel, BorderLayout.CENTER);
52
53         // 调用按钮登录事件
54         loginPanel.addLoginBtnActionListener(new ActionListener() {
55             @Override
56             public void actionPerformed(ActionEvent e) {
57                 if (loginPanel.checkLoginText()) {
58                     if (login()) {
59                         mainFrame = ToolKits.getFrame(e);
60                         mainFrame.setTitle(Res.string().getHumanNumberStatistic() + " : " + Res.string().getOnline());
61                     }
62                 }
63             }
64         });
65         // 调用按钮登出事件
66         loginPanel.addLogoutBtnActionListener(new ActionListener() {
67             @Override
68             public void actionPerformed(ActionEvent e) {
69                 mainFrame.setTitle(Res.string().getHumanNumberStatistic());
70                 logout();
71             }
72         });
73
74         // 注册窗体清出事件
75         addWindowListener(new WindowAdapter() {
76             public void windowClosing(WindowEvent e) {
77                 RealPlayModule.stopRealPlay(m_hPlayHandle);   // 退出句柄
78                 TargetRecognitionModule.renderPrivateData(m_hPlayHandle, 0);  // 关闭规则框
79                 VideoStateSummaryModule.detachAllVideoStatSummary(); // 退订事件
80                 LoginModule.logout();    // 退出
81                 LoginModule.cleanup();   // 关闭工程,释放资源
82                 dispose();
83                 // 返回主菜单
84                 SwingUtilities.invokeLater(new Runnable() {
85                     public void run() {
86                         FunctionList demo = new FunctionList();
87                         demo.setVisible(true);
88                     }
89                 });
90             }
91         });
92     }
93
94     /////////////////////////////// 登录相关 //////////////////////////////////////
95     //////////////////////////////////////////////////////////////////////////////
96
97     // 设备断线通知回调
98     private static DisConnectCallBack disConnectCB = new DisConnectCallBack();
99
100     // 网络连接恢复
101     private static HaveReConnectCallBack haveReConnectCB = new HaveReConnectCallBack();
102
103     private Vector<String> chnList = new Vector<String>();
104
105     // 预览句柄
106     public static NetSDKLib.LLong m_hPlayHandle = new NetSDKLib.LLong(0);
107
108     // 设备断线回调: 通过 CLIENT_Init 设置该回调函数,当设备出现断线时,SDK会调用该函数
109     private static class DisConnectCallBack implements NetSDKLib.fDisConnect {
110         public void invoke(NetSDKLib.LLong m_hLoginHandle, String pchDVRIP, int nDVRPort, Pointer dwUser) {
111             System.out.printf("Device[%s] Port[%d] DisConnectCallBack!\n", pchDVRIP, nDVRPort);
112             // 断线提示
113             SwingUtilities.invokeLater(new Runnable() {
114                 public void run() {
115                     mainFrame.setTitle(Res.string().getHumanNumberStatistic() + " : " + Res.string().getDisConnectReconnecting());
116                 }
117             });
118         }
119
120     }
121
122     // 网络连接恢复,设备重连成功回调
123     // 通过 CLIENT_SetAutoReconnect 设置该回调函数,当已断线的设备重连成功时,SDK会调用该函数
124     private static class HaveReConnectCallBack implements NetSDKLib.fHaveReConnect {
125         public void invoke(NetSDKLib.LLong m_hLoginHandle, String pchDVRIP, int nDVRPort, Pointer dwUser) {
126             System.out.printf("ReConnect Device[%s] Port[%d]\n", pchDVRIP, nDVRPort);
127
128             // 重连提示
129             SwingUtilities.invokeLater(new Runnable() {
130                 public void run() {
131                     mainFrame.setTitle(Res.string().getHumanNumberStatistic() + " : " + Res.string().getOnline());
132                 }
133             });
134
135             // 断线后需要重新订阅
136             ExecutorService service = Executors.newSingleThreadExecutor();
137             service.execute(new Runnable() {
138                 @Override
139                 public void run() {
140
141                     if (b_RealPlay) {     // 如果断前正在预览
142                         stopRealPlay();   // 退出预览
143                         realPlay();       // 重新开启预览
144                     }
145
146                     if (b_Attachment) {   // 如果断前正在订阅
147                         // 重订阅事件
148                         VideoStateSummaryModule.reAttachAllVideoStatSummary(humanNumberStatisticCB);
149                         setAttachBtnTextEnable();
150                     }
151                 }
152             });
153             service.shutdown();
154         }
155
156     }
157
158     // 登录
159     public boolean login() {
160         if (LoginModule.login(loginPanel.ipTextArea.getText(),
161                 Integer.parseInt(loginPanel.portTextArea.getText()),
162                 loginPanel.nameTextArea.getText(),
163                 new String(loginPanel.passwordTextArea.getPassword()))) {
164
165             loginPanel.setButtonEnable(true);
166             setButtonEnable(true);
167
168             final int chanNum = LoginModule.m_stDeviceInfo.byChanNum;
169
170             SwingUtilities.invokeLater(new Runnable() {
171                 public void run() {
172                     // 更新列表长度
173                     int listSize = Math.max(chanNum, 32);
174                     groupListPanel.remove(scrollPane);
175                     groupListPanel.creatGroupInfoPanel(listSize);
176
177                     // 登陆成功,将通道添加到控件
178                     for (int i = 0; i < chanNum; i++) {
179                         chnList.add(Res.string().getChannel() + " " + String.valueOf(i + 1));
180                         SummaryInfo summaryInfo = new SummaryInfo();
181                         summaryInfo.nChannelID = i;
182                         EventDisplay.dataList.add(summaryInfo);
183                     }
184                     chnComboBox.setModel(new DefaultComboBoxModel(chnList));
185
186                     setEnableAllInnerComponent(controlPanel, true);
187
188                     EventDisplay.setEventInfo(groupInfoTable, EventDisplay.dataList);
189                 }
190             });
191
192         } else {
193             JOptionPane.showMessageDialog(null, Res.string().getLoginFailed() + ", " + ToolKits.getErrorCodeShow(), Res.string().getErrorMessage(), JOptionPane.ERROR_MESSAGE);
194             return false;
195         }
196         return true;
197     }
198
199     // 登出
200     public void logout() {
201
202         VideoStateSummaryModule.detachAllVideoStatSummary();  // 退订阅
203         stopRealPlay(); //退出播放
204         LoginModule.logout();  // 退出登录
205
206         chnList.clear();   // 清除通道号列表
207         EventDisplay.clearEventInfoList();  // 清除事件列表数据
208         chnComboBox.setModel(new DefaultComboBoxModel());
209
210         loginPanel.setButtonEnable(false);
211         setAttachBtnTextDisable();
212         setEnableAllInnerComponent(controlPanel, false);
213     }
214
215     /////////////////////////////// 人数统计事件  ////////////////////////////////
216     ////////////////////////////////////////////////////////////////////////////
217
218     private static boolean b_RealPlay = false;
219     private static boolean b_Attachment = false;
220
221     /*
222      * 一级面板:人数统计控制面板
223      */
224     private class HumanStatisticPanel extends JPanel {
225         private static final long serialVersionUID = 1L;
226
227         public HumanStatisticPanel() {
228             setLayout(new BorderLayout());
229             Dimension dim = getPreferredSize();
230             dim.width = 320;
231             setPreferredSize(dim);
232
233             humanStatisticAttachPanel = new HumanStatisticControlPanel(); // 人数统计控制面板
234             realPanel = new RealPanel();            // 实时显示面啊
235             groupListPanel = new GroupListPanel();  // 事件展示面板
236
237             add(humanStatisticAttachPanel, BorderLayout.NORTH);
238             add(realPanel, BorderLayout.EAST);
239             add(groupListPanel, BorderLayout.CENTER);
240         }
241     }
242
243     /*
244      * 二级面板: 控制面板 通道、码流设置,事件订阅
245      */
246     private class HumanStatisticControlPanel extends JPanel {
247         private static final long serialVersionUID = 1L;
248
249         public HumanStatisticControlPanel() {
250             BorderEx.set(this, Res.string().getHumanNumberStatisticAttach(), 2);
251             setLayout(new FlowLayout());
252
253             /* 预览控制面板 */
254             controlPanel = new Panel();
255             add(controlPanel);
256
257             chnLabel = new JLabel(Res.string().getChannel());
258             chnComboBox = new JComboBox();
259
260             streamLabel = new JLabel(Res.string().getStreamType());
261             String[] stream = {Res.string().getMasterStream(), Res.string().getSubStream()};
262             streamComboBox = new JComboBox(stream);
263             realPlayBtn = new JButton(Res.string().getStartRealPlay());
264             attachBtn = new JButton(Res.string().getAttach());
265             clearBtn = new JButton(Res.string().getHumanNumberStatisticEventClearOSD());
266
267             controlPanel.setLayout(new FlowLayout());
268             controlPanel.add(chnLabel);
269             controlPanel.add(chnComboBox);
270             controlPanel.add(streamLabel);
271             controlPanel.add(streamComboBox);
272             controlPanel.add(realPlayBtn);
273             controlPanel.add(attachBtn);
274             controlPanel.add(clearBtn);
275
276             chnComboBox.setPreferredSize(new Dimension(90, 20));
277             streamComboBox.setPreferredSize(new Dimension(120, 20));
278             realPlayBtn.setPreferredSize(new Dimension(120, 20));
279             attachBtn.setPreferredSize(new Dimension(120, 20));
280             clearBtn.setPreferredSize(new Dimension(120, 20));
281
282             chnComboBox.setEnabled(false);
283             streamComboBox.setEnabled(false);
284             realPlayBtn.setEnabled(false);
285             attachBtn.setEnabled(false);
286             clearBtn.setEnabled(false);
287
288             realPlayBtn.addActionListener(new ActionListener() {
289                 @Override
290                 public void actionPerformed(ActionEvent e) {
291                     realPlay();
292                 }
293             });
294
295             attachBtn.addActionListener(new ActionListener() {
296                 @Override
297                 public void actionPerformed(ActionEvent arg0) {
298
299                     int channel = chnComboBox.getSelectedIndex();
300
301                     if (!VideoStateSummaryModule.channelAttached(channel)) {
302                         if (VideoStateSummaryModule.attachVideoStatSummary(channel, humanNumberStatisticCB)) {
303                             setAttachBtnTextEnable();
304                         } else {
305                             JOptionPane.showMessageDialog(null, ToolKits.getErrorCodeShow(), Res.string().getErrorMessage(), JOptionPane.ERROR_MESSAGE);
306                         }
307                     } else {
308                         if (VideoStateSummaryModule.detachVideoStatSummary(channel)) {
309                             setAttachBtnTextDisable();
310                             SummaryInfo info = new SummaryInfo();
311                             info.nChannelID = channel;
312                             EventDisplay.dataList.add(channel, info);
313                             EventDisplay.dataList.remove(channel + 1);
314                             EventDisplay.setEventInfo(groupInfoTable, EventDisplay.dataList);
315                         } else {
316                             JOptionPane.showMessageDialog(null, ToolKits.getErrorCodeShow(), Res.string().getErrorMessage(), JOptionPane.ERROR_MESSAGE);
317                         }
318                     }
319                 }
320             });
321
322             // 添加下拉框事件监听器
323             chnComboBox.addItemListener(new ItemListener() {
324                 @Override
325                 public void itemStateChanged(ItemEvent e) {
326                     if (e.getStateChange() == ItemEvent.SELECTED) {
327                         int channel = chnComboBox.getSelectedIndex();
328                         if (VideoStateSummaryModule.channelAttached(channel)) {
329                             setAttachBtnTextEnable();
330                         } else {
331                             setAttachBtnTextDisable();
332                         }
333                     }
334                 }
335             });
336
337             clearBtn.addActionListener(new ActionListener() {
338                 @Override
339                 public void actionPerformed(ActionEvent e) {
340                     clearSummaryInfo();
341                 }
342             });
343         }
344     }
345
346     private static void setRealPlayBtnTextEnable() {
347         b_RealPlay = true;
348         realPlayBtn.setText(Res.string().getStopRealPlay());
349     }
350
351     private static void setRealPlayBtnTextDisable() {
352         b_RealPlay = false;
353         realPlayBtn.setText(Res.string().getStartRealPlay());
354     }
355
356     private static void setAttachBtnTextEnable() {
357         b_Attachment = VideoStateSummaryModule.getM_hAttachMap().size() > 0;
358         attachBtn.setText(Res.string().getDetach());
359     }
360
361     private static void setAttachBtnTextDisable() {
362         b_Attachment = VideoStateSummaryModule.getM_hAttachMap().size() > 0;
363         attachBtn.setText(Res.string().getAttach());
364     }
365
366     private static void setButtonEnable(boolean bln) {
367         realPlayWindow.setEnabled(bln);
368         chnComboBox.setEnabled(bln);
369         streamComboBox.setEnabled(bln);
370         realPlayBtn.setEnabled(bln);
371         attachBtn.setEnabled(bln);
372         clearBtn.setEnabled(bln);
373     }
374
375     // 启用/禁用 Container 内所有组件
376     public static void setEnableAllInnerComponent(Component container, boolean enable) {
377         for (Component component : getComponents(container)) {
378             component.setEnabled(enable);
379         }
380     }
381
382     // 获取 Swing Container 内所有的非 Container 组件
383     public static Component[] getComponents(Component container) {
384         ArrayList<Component> list = null;
385
386         try {
387             list = new ArrayList<Component>(Arrays.asList(
388                     ((Container) container).getComponents()));
389             for (int index = 0; index < list.size(); index++) {
390                 list.addAll(Arrays.asList(getComponents(list.get(index))));
391             }
392         } catch (ClassCastException e) {
393             list = new ArrayList<Component>();
394         }
395
396         return list.toArray(new Component[0]);
397     }
398
399     private void clearSummaryInfo() {
400         VideoStateSummaryModule.clearVideoStateSummary(chnComboBox.getSelectedIndex());
401     }
402
403     /*
404      * 二级面板:预览面板
405      */
406     private class RealPanel extends JPanel {
407         private static final long serialVersionUID = 1L;
408
409         public RealPanel() {
410             BorderEx.set(this, Res.string().getRealplay(), 2);
411             Dimension dim = this.getPreferredSize();
412             dim.width = 420;
413             this.setPreferredSize(dim);
414             this.setLayout(new BorderLayout());
415
416             realPlayPanel = new JPanel();
417             add(realPlayPanel, BorderLayout.CENTER);
418
419             /************ 预览面板 **************/
420             realPlayPanel.setLayout(new BorderLayout());
421             realPlayPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
422             realPlayWindow = new Panel();
423             realPlayWindow.setBackground(Color.GRAY);
424             realPlayWindow.setSize(480, 480);
425             realPlayPanel.add(realPlayWindow, BorderLayout.CENTER);
426         }
427     }
428
429     // 预览
430     public static void realPlay() {
431         if (!b_RealPlay) {
432             m_hPlayHandle = RealPlayModule.startRealPlay(
433                     chnComboBox.getSelectedIndex(),
434                     streamComboBox.getSelectedIndex() == 0 ? 0 : 3,
435                     realPlayWindow);
436
437             if (m_hPlayHandle.longValue() != 0) {     // 正常状态下句柄不为空
438                 TargetRecognitionModule.renderPrivateData(m_hPlayHandle, 1); // 开启规则框
439                 realPlayWindow.repaint();
440                 chnComboBox.setEnabled(false);
441                 streamComboBox.setEnabled(false);
442                 setRealPlayBtnTextEnable();
443             }
444         } else {
445             stopRealPlay();
446         }
447     }
448
449     public static void stopRealPlay() {
450         RealPlayModule.stopRealPlay(m_hPlayHandle);   // 为空则说明失败,退出拉流
451         TargetRecognitionModule.renderPrivateData(m_hPlayHandle, 0); // 关闭规则框
452         realPlayWindow.repaint();
453         chnComboBox.setEnabled(true);
454         streamComboBox.setEnabled(true);
455         setRealPlayBtnTextDisable();
456     }
457
458     // 搜索数据列表
459     public class GroupListPanel extends JPanel {
460
461         private Object[][] statisticData = null;    // 人脸库列表
462
463         private final String[] groupName = {
464                 Res.string().getHumanNumberStatisticEventChannel(),
465                 Res.string().getHumanNumberStatisticEventTime(),
466                 Res.string().getHumanNumberStatisticEventHourIn(),
467                 Res.string().getHumanNumberStatisticEventTodayIn(),
468                 Res.string().getHumanNumberStatisticEventTotalIn(),
469                 Res.string().getHumanNumberStatisticEventHourOut(),
470                 Res.string().getHumanNumberStatisticEventTodayOut(),
471                 Res.string().getHumanNumberStatisticEventTotalOut()
472         };
473         private DefaultTableModel groupInfoModel;
474
475         public GroupListPanel() {
476             BorderEx.set(this, Res.string().getHumanNumberStatisticEventTitle(), 2);
477             setLayout(new BorderLayout());
478
479             statisticData = new Object[32][9];
480             creatGroupInfoPanel(32);
481         }
482
483         private void creatGroupInfoPanel(int listSize) {
484             statisticData = new Object[listSize][9];    // 人脸库列表集合修改
485             groupInfoModel = new DefaultTableModel(statisticData, groupName);
486             groupInfoTable = new JTable(groupInfoModel) {
487                 @Override    // 不可编辑
488                 public boolean isCellEditable(int row, int column) {
489                     return false;
490                 }
491             };
492
493             groupInfoTable.getColumnModel().getColumn(0).setPreferredWidth(10);
494             groupInfoTable.getColumnModel().getColumn(1).setPreferredWidth(80);
495             groupInfoTable.getColumnModel().getColumn(2).setPreferredWidth(10);
496             groupInfoTable.getColumnModel().getColumn(3).setPreferredWidth(10);
497             groupInfoTable.getColumnModel().getColumn(4).setPreferredWidth(10);
498             groupInfoTable.getColumnModel().getColumn(5).setPreferredWidth(10);
499             groupInfoTable.getColumnModel().getColumn(6).setPreferredWidth(10);
500             groupInfoTable.getColumnModel().getColumn(7).setPreferredWidth(10);
501
502             groupInfoTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);  // 只能选中一行
503
504             // 列表显示居中
505             DefaultTableCellRenderer dCellRenderer = new DefaultTableCellRenderer();
506             dCellRenderer.setHorizontalAlignment(JLabel.CENTER);
507             groupInfoTable.setDefaultRenderer(Object.class, dCellRenderer);
508
509             scrollPane = new JScrollPane(groupInfoTable);
510             this.add(scrollPane, BorderLayout.CENTER);
511         }
512     }
513
514     // 人数统计回调事件
515     public static fHumanNumberStatisticCallBack humanNumberStatisticCB = fHumanNumberStatisticCallBack.getInstance();
516
517     public static class fHumanNumberStatisticCallBack implements NetSDKLib.fVideoStatSumCallBack {
518
519         private static fHumanNumberStatisticCallBack instance = new fHumanNumberStatisticCallBack();
520
521         public static fHumanNumberStatisticCallBack getInstance() {
522             return instance;
523         }
524
525         private EventTaskCommonQueue eventTaskQueue = new EventTaskCommonQueue();
526
527         public fHumanNumberStatisticCallBack() {
528             eventTaskQueue.init();
529         }
530
531         public void invoke(NetSDKLib.LLong lAttachHandle, NetSDKLib.NET_VIDEOSTAT_SUMMARY stVideoState, int dwBufLen, Pointer dwUser) {
532
533             SummaryInfo summaryInfo = new SummaryInfo(
534                     stVideoState.nChannelID, stVideoState.stuTime.toStringTime(),
535                     stVideoState.stuEnteredSubtotal.nToday,
536                     stVideoState.stuEnteredSubtotal.nHour,
537                     stVideoState.stuEnteredSubtotal.nTotal,
538                     stVideoState.stuExitedSubtotal.nToday,
539                     stVideoState.stuExitedSubtotal.nHour,
540                     stVideoState.stuExitedSubtotal.nTotal);
541             System.out.printf("Channel[%d] GetTime[%s]\n" +
542                             "People In  Information[Total[%d] Hour[%d] Today[%d]]\n" +
543                             "People Out Information[Total[%d] Hour[%d] Today[%d]]\n",
544                     summaryInfo.nChannelID, summaryInfo.eventTime,
545                     summaryInfo.enteredTotal, summaryInfo.enteredHour, summaryInfo.enteredToday,
546                     summaryInfo.exitedTotal, summaryInfo.exitedHour, summaryInfo.exitedToday);
547             eventTaskQueue.addEvent(new EventDisplay(summaryInfo));
548         }
549     }
550
551     private static class SummaryInfo {
552
553         public int nChannelID;
554         public String eventTime;
555         public int enteredToday;
556         public int enteredHour;
557         public int enteredTotal;
558         public int exitedToday;
559         public int exitedHour;
560         public int exitedTotal;
561
562         public SummaryInfo() {
563         }
564
565         public SummaryInfo(int nChannelID, String eventTime,
566                            int enteredToday, int enteredHour,
567                            int enteredTotal, int exitedToday,
568                            int exitedHour, int exitedTotal) {
569             this.nChannelID = nChannelID;
570             this.eventTime = eventTime;
571             this.enteredToday = enteredToday;
572             this.enteredHour = enteredHour;
573             this.enteredTotal = enteredTotal;
574             this.exitedToday = exitedToday;
575             this.exitedHour = exitedHour;
576             this.exitedTotal = exitedTotal;
577         }
578
579     }
580
581     private static class EventDisplay implements EventTaskHandler {
582
583         private static List<SummaryInfo> dataList = new LinkedList<SummaryInfo>();
584
585         private int getMaxSize() {
586             int channelNum = LoginModule.m_stDeviceInfo.byChanNum;
587             return Math.max(channelNum, 32);
588         }
589
590         private static final Object lockObj = new Object();
591
592         private final SummaryInfo summaryInfo;
593
594         public EventDisplay(SummaryInfo Info) {
595             this.summaryInfo = Info;
596         }
597
598         @Override
599         public void eventTaskProcess() {
600             InsertOrUpdateEventInfo(summaryInfo);
601         }
602
603         private void InsertOrUpdateEventInfo(SummaryInfo summaryInfo) {
604
605             synchronized (lockObj) {
606                 dataList.add(summaryInfo.nChannelID, summaryInfo);
607                 dataList.remove(summaryInfo.nChannelID + 1);
608                 if (dataList.size() > getMaxSize()) {
609                     dataList.remove(getMaxSize());
610                 }
611                 setEventInfo(groupInfoTable, dataList);
612             }
613         }
614
615         private static void setEventInfo(JTable groupInfoTable, List<SummaryInfo> dataList) {
616             clearTableModel(groupInfoTable);
617
618             for (int i = 0; i < dataList.size(); i++) {
619                 groupInfoTable.setValueAt(dataList.get(i).nChannelID + 1, i, 0);
620                 groupInfoTable.setValueAt(dataList.get(i).eventTime, i, 1);
621                 groupInfoTable.setValueAt(dataList.get(i).enteredHour, i, 2);
622                 groupInfoTable.setValueAt(dataList.get(i).enteredToday, i, 3);
623                 groupInfoTable.setValueAt(dataList.get(i).enteredTotal, i, 4);
624                 groupInfoTable.setValueAt(dataList.get(i).exitedHour, i, 5);
625                 groupInfoTable.setValueAt(dataList.get(i).exitedToday, i, 6);
626                 groupInfoTable.setValueAt(dataList.get(i).exitedTotal, i, 7);
627             }
628
629         }
630
631         // 清空 DefaultTableModel
632         public static void clearTableModel(JTable jTableModel) {
633             int rowCount = jTableModel.getRowCount();
634             int columnCount = jTableModel.getColumnCount();
635             //清空DefaultTableModel中的内容
636             for (int i = 0; i < rowCount; i++)//表格中的行数
637             {
638                 for (int j = 0; j < columnCount; j++) {//表格中的列数
639                     jTableModel.setValueAt(" ", i, j);//逐个清空
640                 }
641             }
642         }
643
644         private static void clearEventInfoList() {
645             synchronized (lockObj) {
646                 dataList.clear();
647                 setEventInfo(groupInfoTable, dataList);
648             }
649         }
650
651     }
652
653     /////////////////////////////// 界面控件定义  ////////////////////////////////
654     ////////////////////////////////////////////////////////////////////////////
655
656     /**********************************************************************
657      * 主界面窗口(mainFrame): mainFrame
658      *     1) 登录(login): loginPanel
659      *     2) 人数事件统计(humanStatistic): humanStatisticPanel
660      *        (1) 控制面板(HumanStatisticAttach): HumanStatisticControlPanel
661      *        (2) 预览(realPlay): realPanel
662      *        (3) 事件信息展示面板(eventInfo): groupListPanel
663      **********************************************************************/
664
665     ///////////////////// 主面板 /////////////////////
666
667     private static JFrame mainFrame = new JFrame();
668
669     ///////////////////// 一级面板 /////////////////////
670
671     /* 登录面板 */
672     private LoginPanel loginPanel;
673
674     /* 人数统计面板 */
675     private HumanStatisticPanel humanStatisticPanel;
676
677     ///////////////////// 二级面板 /////////////////////
678
679     /* 人数统计面板 */
680     private HumanStatisticControlPanel humanStatisticAttachPanel;
681     private Panel controlPanel;
682     private JLabel chnLabel;
683     private static JComboBox chnComboBox;
684     private JLabel streamLabel;
685     private static JComboBox streamComboBox;
686     private static JButton realPlayBtn;
687     private static JButton attachBtn;
688     private static JButton clearBtn;
689
690     /* 实时预览面板 */
691     private RealPanel realPanel;
692     private JPanel realPlayPanel;
693     private static Panel realPlayWindow;
694
695
696     /* 事件数据展示面板 */
697     private static JTable groupInfoTable;
698     private GroupListPanel groupListPanel;
699     private JScrollPane scrollPane;
700 }
701
702 public class HumanNumberStatistic {
703     public static void main(String[] args) {
704         SwingUtilities.invokeLater(new Runnable() {
705             public void run() {
706                 HumanNumberStatisticFrame demo = new HumanNumberStatisticFrame();
707                 demo.setVisible(true);
708             }
709         });
710     }
711 }