提交 | 用户 | 时间
|
ce910c
|
1 |
package com.netsdk.demo.frame.ThermalCamera; |
H |
2 |
|
|
3 |
import java.awt.BorderLayout; |
|
4 |
import java.awt.Dimension; |
|
5 |
import java.awt.FlowLayout; |
|
6 |
import java.awt.GridLayout; |
|
7 |
import java.awt.event.ActionEvent; |
|
8 |
import java.awt.event.ActionListener; |
|
9 |
import java.awt.event.WindowAdapter; |
|
10 |
import java.awt.event.WindowEvent; |
|
11 |
import java.io.UnsupportedEncodingException; |
|
12 |
import java.util.Enumeration; |
|
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.JDialog; |
|
19 |
import javax.swing.JLabel; |
|
20 |
import javax.swing.JOptionPane; |
|
21 |
import javax.swing.JPanel; |
|
22 |
import javax.swing.JScrollPane; |
|
23 |
import javax.swing.JSplitPane; |
|
24 |
import javax.swing.JTable; |
|
25 |
import javax.swing.ListSelectionModel; |
|
26 |
import javax.swing.SwingConstants; |
|
27 |
import javax.swing.SwingUtilities; |
|
28 |
import javax.swing.SwingWorker; |
|
29 |
import javax.swing.table.DefaultTableCellRenderer; |
|
30 |
import javax.swing.table.DefaultTableModel; |
|
31 |
import javax.swing.table.TableColumn; |
|
32 |
|
|
33 |
import com.netsdk.common.BorderEx; |
|
34 |
import com.netsdk.common.DateChooserJButton; |
|
35 |
import com.netsdk.common.Res; |
|
36 |
import com.netsdk.demo.module.ThermalCameraModule; |
|
37 |
import com.netsdk.lib.NetSDKLib.*; |
|
38 |
import com.netsdk.lib.ToolKits; |
|
39 |
|
|
40 |
public class TemperQueryDialog extends JDialog{ |
|
41 |
|
|
42 |
|
|
43 |
/** |
|
44 |
* |
|
45 |
*/ |
|
46 |
private static final long serialVersionUID = 1L; |
|
47 |
|
|
48 |
private NET_IN_RADIOMETRY_STARTFIND stuStartFind = new NET_IN_RADIOMETRY_STARTFIND(); |
|
49 |
|
|
50 |
public TemperQueryDialog() { |
|
51 |
setTitle(Res.string().getShowInfo("TEMPER_INFO")); |
|
52 |
setLayout(new BorderLayout()); |
|
53 |
setModal(true); |
|
54 |
pack(); |
|
55 |
setSize(800, 550); |
|
56 |
setResizable(false); |
|
57 |
setLocationRelativeTo(null); |
|
58 |
setDefaultCloseOperation(DISPOSE_ON_CLOSE); |
|
59 |
|
|
60 |
/////////////////////////////// |
|
61 |
queryPanel = new QueryPanel(); |
|
62 |
showPanel = new QueryShowPanel(); |
|
63 |
|
|
64 |
add(queryPanel, BorderLayout.NORTH); |
|
65 |
add(showPanel, BorderLayout.CENTER); |
|
66 |
|
|
67 |
addWindowListener(new WindowAdapter() { |
|
68 |
public void windowClosing(WindowEvent e){ |
|
69 |
try { |
|
70 |
ThermalCameraModule.stopFind(); |
|
71 |
}finally { |
|
72 |
dispose(); |
|
73 |
} |
|
74 |
} |
|
75 |
}); |
|
76 |
} |
|
77 |
|
|
78 |
public void setSearchEnable(boolean b) { |
|
79 |
showPanel.setButtonEnable(b); |
|
80 |
queryPanel.setButtonEnable(b); |
|
81 |
} |
|
82 |
|
|
83 |
public void queryHistoryInfo(final QUERY_TYPE type) { |
|
84 |
SwingUtilities.invokeLater(new Runnable() { |
|
85 |
@Override |
|
86 |
public void run() { |
|
87 |
setSearchEnable(false); |
|
88 |
if (type == QUERY_TYPE.FIRST_PAGE_QUERY) { |
|
89 |
showPanel.clearData(); |
|
90 |
} |
|
91 |
} |
|
92 |
}); |
|
93 |
new QuerySwingWorker(type).execute(); |
|
94 |
} |
|
95 |
|
|
96 |
/** |
|
97 |
* 查询界面 |
|
98 |
* */ |
|
99 |
public class QueryPanel extends JPanel { |
|
100 |
/** |
|
101 |
* |
|
102 |
*/ |
|
103 |
private static final long serialVersionUID = 1L; |
|
104 |
|
|
105 |
public QueryPanel() { |
|
106 |
BorderEx.set(this, Res.string().getShowInfo("QUERY_CONDITION"), 1); |
|
107 |
setLayout(new BorderLayout()); |
|
108 |
|
|
109 |
JLabel startTimeLabel = new JLabel(Res.string().getShowInfo("START_TIME"), JLabel.LEFT); |
|
110 |
startTimeBtn = new DateChooserJButton(); |
|
111 |
JLabel endTimeLabel = new JLabel(Res.string().getShowInfo("END_TIME"), JLabel.LEFT); |
|
112 |
endTimeBtn = new DateChooserJButton(); |
|
113 |
JLabel meterTypeLabel = new JLabel(Res.string().getShowInfo("METER_TYPE"), JLabel.LEFT); |
|
114 |
meterTypeComboBox = new JComboBox(); |
|
115 |
meterTypeComboBox.setModel(new DefaultComboBoxModel(Res.string().getMeterTypeList())); |
|
116 |
JLabel periodLabel = new JLabel(Res.string().getShowInfo("SAVE_PERIOD"), JLabel.LEFT); |
|
117 |
periodComboBox = new JComboBox(); |
|
118 |
periodComboBox.setModel(new DefaultComboBoxModel(Res.string().getPeriodList())); |
|
119 |
queryBtn = new JButton(Res.string().getShowInfo("QUERY")); |
|
120 |
|
|
121 |
Dimension lableDimension = new Dimension(85, 20); |
|
122 |
Dimension btnDimension = new Dimension(125, 20); |
|
123 |
|
|
124 |
startTimeLabel.setPreferredSize(lableDimension); |
|
125 |
startTimeBtn.setPreferredSize(btnDimension); |
|
126 |
endTimeLabel.setPreferredSize(lableDimension); |
|
127 |
endTimeBtn.setPreferredSize(btnDimension); |
|
128 |
meterTypeLabel.setPreferredSize(lableDimension); |
|
129 |
meterTypeComboBox.setPreferredSize(btnDimension); |
|
130 |
periodLabel.setPreferredSize(lableDimension); |
|
131 |
periodComboBox.setPreferredSize(btnDimension); |
|
132 |
queryBtn.setPreferredSize(btnDimension); |
|
133 |
|
|
134 |
JPanel startTimePanel = new JPanel(); |
|
135 |
startTimePanel.setLayout(new FlowLayout(FlowLayout.LEFT)); |
|
136 |
startTimePanel.add(startTimeLabel); |
|
137 |
startTimePanel.add(startTimeBtn); |
|
138 |
JPanel endTimePanel = new JPanel(); |
|
139 |
endTimePanel.setLayout(new FlowLayout(FlowLayout.LEFT)); |
|
140 |
endTimePanel.add(endTimeLabel); |
|
141 |
endTimePanel.add(endTimeBtn); |
|
142 |
JPanel topPanel = new JPanel(); |
|
143 |
topPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 30, 2)); |
|
144 |
topPanel.add(startTimePanel); |
|
145 |
topPanel.add(endTimePanel); |
|
146 |
|
|
147 |
JPanel meterTypePanel = new JPanel(); |
|
148 |
meterTypePanel.setLayout(new FlowLayout(FlowLayout.LEFT)); |
|
149 |
meterTypePanel.add(meterTypeLabel); |
|
150 |
meterTypePanel.add(meterTypeComboBox); |
|
151 |
JPanel periodPanel = new JPanel(); |
|
152 |
periodPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); |
|
153 |
periodPanel.add(periodLabel); |
|
154 |
periodPanel.add(periodComboBox); |
|
155 |
JPanel bottomPanel = new JPanel(); |
|
156 |
bottomPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 30, 2)); |
|
157 |
bottomPanel.add(meterTypePanel); |
|
158 |
bottomPanel.add(periodPanel); |
|
159 |
|
|
160 |
JPanel leftPanel = new JPanel(new GridLayout(2,1)); |
|
161 |
BorderEx.set(leftPanel, "", 1); |
|
162 |
leftPanel.add(topPanel); |
|
163 |
leftPanel.add(bottomPanel); |
|
164 |
|
|
165 |
JPanel rightPanel = new JPanel(); |
|
166 |
rightPanel.setLayout(null); |
|
167 |
BorderEx.set(rightPanel, "", 1); |
|
168 |
queryBtn.setBounds(50, 30, 125, 20); |
|
169 |
rightPanel.add(queryBtn); |
|
170 |
|
|
171 |
JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPanel, rightPanel); |
|
172 |
pane.setDividerSize(0); |
|
173 |
pane.setBorder(null); |
|
174 |
|
|
175 |
add(pane, BorderLayout.CENTER); |
|
176 |
|
|
177 |
queryBtn.addActionListener(new ActionListener() { |
|
178 |
|
|
179 |
@Override |
|
180 |
public void actionPerformed(ActionEvent e) { |
|
181 |
setStuStartFind(); |
|
182 |
queryHistoryInfo(QUERY_TYPE.FIRST_PAGE_QUERY); |
|
183 |
} |
|
184 |
}); |
|
185 |
} |
|
186 |
|
|
187 |
private void setStuStartFind() { |
|
188 |
|
|
189 |
setTime(stuStartFind.stStartTime, startTimeBtn.getText()); |
|
190 |
setTime(stuStartFind.stEndTime, endTimeBtn.getText()); |
|
191 |
stuStartFind.nMeterType = meterTypeComboBox.getSelectedIndex() + 1; |
|
192 |
stuStartFind.nChannel = ThermalCameraFrame.THERMAL_CHANNEL; |
|
193 |
int[] arrPeriod = {5, 10, 15, 30}; |
|
194 |
stuStartFind.emPeriod = arrPeriod[periodComboBox.getSelectedIndex()]; |
|
195 |
} |
|
196 |
|
|
197 |
private void setTime(NET_TIME netTime, String date) { |
|
198 |
|
|
199 |
String[] dateTime = date.split(" "); |
|
200 |
String[] arrDate = dateTime[0].split("-"); |
|
201 |
String[] arrTime = dateTime[1].split(":"); |
|
202 |
|
|
203 |
netTime.dwYear = Integer.parseInt(arrDate[0]); |
|
204 |
netTime.dwMonth = Integer.parseInt(arrDate[1]); |
|
205 |
netTime.dwDay = Integer.parseInt(arrDate[2]); |
|
206 |
netTime.dwHour = Integer.parseInt(arrTime[0]); |
|
207 |
netTime.dwMinute = Integer.parseInt(arrTime[1]); |
|
208 |
netTime.dwSecond = Integer.parseInt(arrTime[2]); |
|
209 |
} |
|
210 |
|
|
211 |
public void setButtonEnable(boolean b) { |
|
212 |
queryBtn.setEnabled(b); |
|
213 |
} |
|
214 |
|
|
215 |
private DateChooserJButton startTimeBtn; |
|
216 |
private DateChooserJButton endTimeBtn; |
|
217 |
private JComboBox meterTypeComboBox; |
|
218 |
private JComboBox periodComboBox; |
|
219 |
private JButton queryBtn; |
|
220 |
} |
|
221 |
|
|
222 |
/** |
|
223 |
* 热成像查询结果信息显示界面 |
|
224 |
* */ |
|
225 |
public class QueryShowPanel extends JPanel { |
|
226 |
/** |
|
227 |
* |
|
228 |
*/ |
|
229 |
private static final long serialVersionUID = 1L; |
|
230 |
public static final int INDEX = 0; |
|
231 |
public static final int RECORD_TIME = 1; |
|
232 |
public static final int PRESET_ID = 2; |
|
233 |
public static final int RULE_ID = 3; |
|
234 |
public static final int ITEM_NAME = 4; |
|
235 |
public static final int CHANNEL = 5; |
|
236 |
public static final int COORDINATE = 6; |
|
237 |
public static final int METER_TYPE = 7; |
|
238 |
public static final int TEMPER_UNIT = 8; |
|
239 |
public static final int TEMPER_AVER = 9; |
|
240 |
public static final int TEMPER_MAX = 10; |
|
241 |
public static final int TEMPER_MIN = 11; |
|
242 |
public static final int TEMPER_MID = 12; |
|
243 |
public static final int TEMPER_STD = 13; |
|
244 |
|
|
245 |
public final static int QUERY_SHOW_COUNT = 20; // 查询个数 |
|
246 |
private int currentIndex = 0; // 实际显示个数 |
|
247 |
|
|
248 |
private String [] arrMeterType = Res.string().getMeterTypeList(); |
|
249 |
private String [] arrTemperUnit = Res.string().getTemperUnitList(); // 减少次数 |
|
250 |
|
|
251 |
public QueryShowPanel() { |
|
252 |
BorderEx.set(this, Res.string().getShowInfo("QUERY_LIST"), 1); |
|
253 |
setLayout(new BorderLayout()); |
|
254 |
|
|
255 |
String[] columnNames = { |
|
256 |
Res.string().getShowInfo("INDEX"), Res.string().getShowInfo("RECORD_TIME"), |
|
257 |
Res.string().getShowInfo("PRESET_ID"), Res.string().getShowInfo("RULE_ID"), |
|
258 |
Res.string().getShowInfo("ITEM_NAME"), Res.string().getShowInfo("CHANNEL"), |
|
259 |
Res.string().getShowInfo("COORDINATE"), Res.string().getShowInfo("METER_TYPE"), |
|
260 |
Res.string().getShowInfo("TEMPER_UNIT"), Res.string().getShowInfo("TEMPER_AVER"), |
|
261 |
Res.string().getShowInfo("TEMPER_MAX"), Res.string().getShowInfo("TEMPER_MIN"), |
|
262 |
Res.string().getShowInfo("TEMPER_MID"), Res.string().getShowInfo("TEMPER_STD") |
|
263 |
}; |
|
264 |
|
|
265 |
tableModel = new DefaultTableModel(null, columnNames); |
|
266 |
table = new JTable(tableModel) { |
|
267 |
private static final long serialVersionUID = 1L; |
|
268 |
|
|
269 |
public boolean isCellEditable(int rowIndex, int columnIndex) { // 不可编辑 |
|
270 |
return false; |
|
271 |
} |
|
272 |
}; |
|
273 |
|
|
274 |
tableModel.setRowCount(QUERY_SHOW_COUNT); // 设置最小显示行 |
|
275 |
|
|
276 |
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // 只能选中一行 |
|
277 |
|
|
278 |
Enumeration<TableColumn> columns = table.getColumnModel().getColumns(); |
|
279 |
while (columns.hasMoreElements()) { |
|
280 |
columns.nextElement().setPreferredWidth(140); |
|
281 |
} |
|
282 |
|
|
283 |
table.getColumnModel().getColumn(RECORD_TIME).setPreferredWidth(140); |
|
284 |
table.getColumnModel().getColumn(ITEM_NAME).setPreferredWidth(180); |
|
285 |
|
|
286 |
((DefaultTableCellRenderer) |
|
287 |
table.getTableHeader().getDefaultRenderer()).setHorizontalAlignment(SwingConstants.CENTER); |
|
288 |
|
|
289 |
DefaultTableCellRenderer tcr = new DefaultTableCellRenderer(); |
|
290 |
tcr.setHorizontalAlignment(SwingConstants.CENTER); |
|
291 |
table.setDefaultRenderer(Object.class, tcr); |
|
292 |
|
|
293 |
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); |
|
294 |
|
|
295 |
JScrollPane scrollPane = new JScrollPane(table); |
|
296 |
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); |
|
297 |
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); |
|
298 |
|
|
299 |
JPanel functionPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 120, 5)); |
|
300 |
prePageBtn = new JButton(Res.string().getPreviousPage()); |
|
301 |
nextPageBtn = new JButton(Res.string().getNextPage()); |
|
302 |
prePageBtn.setPreferredSize(new Dimension(120, 20)); |
|
303 |
nextPageBtn.setPreferredSize(new Dimension(120, 20)); |
|
304 |
|
|
305 |
setButtonEnable(false); |
|
306 |
|
|
307 |
// functionPanel.add(prePageBtn); |
|
308 |
functionPanel.add(nextPageBtn); |
|
309 |
|
|
310 |
add(scrollPane, BorderLayout.CENTER); |
|
311 |
add(functionPanel, BorderLayout.SOUTH); |
|
312 |
|
|
313 |
prePageBtn.addActionListener(new ActionListener() { |
|
314 |
|
|
315 |
@Override |
|
316 |
public void actionPerformed(ActionEvent e) { |
|
317 |
queryHistoryInfo(QUERY_TYPE.PRE_PAGE_QUERY); |
|
318 |
} |
|
319 |
}); |
|
320 |
|
|
321 |
nextPageBtn.addActionListener(new ActionListener() { |
|
322 |
|
|
323 |
@Override |
|
324 |
public void actionPerformed(ActionEvent e) { |
|
325 |
queryHistoryInfo(QUERY_TYPE.NEXT_PAGE_QUERY); |
|
326 |
} |
|
327 |
}); |
|
328 |
} |
|
329 |
|
|
330 |
public void setButtonEnable(boolean b) { |
|
331 |
|
|
332 |
prePageBtn.setEnabled(false); |
|
333 |
nextPageBtn.setEnabled(false); |
|
334 |
|
|
335 |
if (b) { |
|
336 |
if (currentIndex < ThermalCameraModule.getTotalCount()) { |
|
337 |
nextPageBtn.setEnabled(true); |
|
338 |
} |
|
339 |
|
|
340 |
if (currentIndex > QUERY_SHOW_COUNT) { |
|
341 |
prePageBtn.setEnabled(true); |
|
342 |
} |
|
343 |
} |
|
344 |
} |
|
345 |
|
|
346 |
public int getIndex() { |
|
347 |
return currentIndex; |
|
348 |
} |
|
349 |
|
|
350 |
public void setIndex(int index) { |
|
351 |
currentIndex = index; |
|
352 |
} |
|
353 |
|
|
354 |
public void insertData(NET_OUT_RADIOMETRY_DOFIND stuDoFind) { |
|
355 |
if (stuDoFind == null) { |
|
356 |
return; |
|
357 |
} |
|
358 |
|
|
359 |
tableModel.setRowCount(0); |
|
360 |
for (int i = 0; i < stuDoFind.nFound; ++i) { |
|
361 |
insertData(stuDoFind.stInfo[i]); |
|
362 |
} |
|
363 |
|
|
364 |
tableModel.setRowCount(QUERY_SHOW_COUNT); |
|
365 |
table.updateUI(); |
|
366 |
} |
|
367 |
|
|
368 |
private void insertData(NET_RADIOMETRY_QUERY data) { |
|
369 |
++currentIndex; |
|
370 |
Vector<String> vector = new Vector<String>(); |
|
371 |
|
|
372 |
vector.add(String.valueOf(currentIndex)); |
|
373 |
vector.add(data.stTime.toStringTimeEx()); |
|
374 |
vector.add(String.valueOf(data.nPresetId)); |
|
375 |
vector.add(String.valueOf(data.nRuleId)); |
|
376 |
try { |
|
377 |
vector.add(new String(data.szName, "GBK").trim()); |
|
378 |
} catch (UnsupportedEncodingException e) { |
|
379 |
vector.add(new String(data.szName).trim()); |
|
380 |
} |
|
381 |
vector.add(String.valueOf(data.nChannel)); |
|
382 |
|
|
383 |
if (data.stTemperInfo.nMeterType == NET_RADIOMETRY_METERTYPE.NET_RADIOMETRY_METERTYPE_SPOT) { |
|
384 |
vector.add("(" + data.stCoordinates[0].nx + "," + data.stCoordinates[0].ny + ")"); |
|
385 |
}else if(data.stTemperInfo.nMeterType == NET_RADIOMETRY_METERTYPE.NET_RADIOMETRY_METERTYPE_LINE){ |
|
386 |
vector.add("(" + data.stCoordinates[0].nx + "," + data.stCoordinates[0].ny + "),(" + data.stCoordinates[1].nx + "," + data.stCoordinates[1].ny + ")"); |
|
387 |
}else{ |
|
388 |
switch(data.nCoordinateNum){ |
|
389 |
case 3: |
|
390 |
vector.add("(" + data.stCoordinates[0].nx + "," + data.stCoordinates[0].ny + ")," |
|
391 |
+ "(" + data.stCoordinates[1].nx + "," + data.stCoordinates[1].ny + ")," |
|
392 |
+ "(" + data.stCoordinates[2].nx + "," + data.stCoordinates[2].ny + ")"); |
|
393 |
break; |
|
394 |
case 4: |
|
395 |
vector.add("(" + data.stCoordinates[0].nx + "," + data.stCoordinates[0].ny + ")," |
|
396 |
+ "(" + data.stCoordinates[1].nx + "," + data.stCoordinates[1].ny + ")," |
|
397 |
+ "(" + data.stCoordinates[2].nx + "," + data.stCoordinates[2].ny + ")," |
|
398 |
+ "(" + data.stCoordinates[3].nx + "," + data.stCoordinates[3].ny + ")"); |
|
399 |
break; |
|
400 |
case 5: |
|
401 |
vector.add("(" + data.stCoordinates[0].nx + "," + data.stCoordinates[0].ny + ")," |
|
402 |
+ "(" + data.stCoordinates[1].nx + "," + data.stCoordinates[1].ny + ")," |
|
403 |
+ "(" + data.stCoordinates[2].nx + "," + data.stCoordinates[2].ny + ")," |
|
404 |
+ "(" + data.stCoordinates[3].nx + "," + data.stCoordinates[3].ny + ")," |
|
405 |
+ "(" + data.stCoordinates[4].nx + "," + data.stCoordinates[4].ny + ")"); |
|
406 |
break; |
|
407 |
case 6: |
|
408 |
vector.add("(" + data.stCoordinates[0].nx + "," + data.stCoordinates[0].ny + ")," |
|
409 |
+ "(" + data.stCoordinates[1].nx + "," + data.stCoordinates[1].ny + ")," |
|
410 |
+ "(" + data.stCoordinates[2].nx + "," + data.stCoordinates[2].ny + ")," |
|
411 |
+ "(" + data.stCoordinates[3].nx + "," + data.stCoordinates[3].ny + ")," |
|
412 |
+ "(" + data.stCoordinates[4].nx + "," + data.stCoordinates[4].ny + ")," |
|
413 |
+ "(" + data.stCoordinates[5].nx + "," + data.stCoordinates[5].ny + "),"); |
|
414 |
break; |
|
415 |
case 7: |
|
416 |
vector.add("(" + data.stCoordinates[0].nx + "," + data.stCoordinates[0].ny + ")," |
|
417 |
+ "(" + data.stCoordinates[1].nx + "," + data.stCoordinates[1].ny + ")," |
|
418 |
+ "(" + data.stCoordinates[2].nx + "," + data.stCoordinates[2].ny + ")," |
|
419 |
+ "(" + data.stCoordinates[3].nx + "," + data.stCoordinates[3].ny + ")," |
|
420 |
+ "(" + data.stCoordinates[4].nx + "," + data.stCoordinates[4].ny + ")," |
|
421 |
+ "(" + data.stCoordinates[5].nx + "," + data.stCoordinates[5].ny + ")," |
|
422 |
+ "(" + data.stCoordinates[6].nx + "," + data.stCoordinates[6].ny + ")"); |
|
423 |
break; |
|
424 |
case 8: |
|
425 |
vector.add("(" + data.stCoordinates[0].nx + "," + data.stCoordinates[0].ny + ")," |
|
426 |
+ "(" + data.stCoordinates[1].nx + "," + data.stCoordinates[1].ny + ")," |
|
427 |
+ "(" + data.stCoordinates[2].nx + "," + data.stCoordinates[2].ny + ")," |
|
428 |
+ "(" + data.stCoordinates[3].nx + "," + data.stCoordinates[3].ny + ")," |
|
429 |
+ "(" + data.stCoordinates[4].nx + "," + data.stCoordinates[4].ny + ")," |
|
430 |
+ "(" + data.stCoordinates[5].nx + "," + data.stCoordinates[5].ny + ")," |
|
431 |
+ "(" + data.stCoordinates[6].nx + "," + data.stCoordinates[6].ny + ")," |
|
432 |
+ "(" + data.stCoordinates[7].nx + "," + data.stCoordinates[7].ny + ")"); |
|
433 |
break; |
|
434 |
} |
|
435 |
} |
|
436 |
|
|
437 |
if (data.stTemperInfo.nMeterType >= 1 && |
|
438 |
data.stTemperInfo.nMeterType <= arrMeterType.length) { |
|
439 |
vector.add(arrMeterType[data.stTemperInfo.nMeterType-1]); |
|
440 |
}else { |
|
441 |
vector.add(Res.string().getShowInfo("UNKNOWN")); |
|
442 |
} |
|
443 |
|
|
444 |
if (data.stTemperInfo.nTemperUnit >= 1 && |
|
445 |
data.stTemperInfo.nTemperUnit <= arrTemperUnit.length) { |
|
446 |
vector.add(arrTemperUnit[data.stTemperInfo.nTemperUnit-1]); |
|
447 |
}else { |
|
448 |
vector.add(Res.string().getShowInfo("UNKNOWN")); |
|
449 |
} |
|
450 |
|
|
451 |
vector.add(String.valueOf(data.stTemperInfo.fTemperAver)); |
|
452 |
vector.add(String.valueOf(data.stTemperInfo.fTemperMax)); |
|
453 |
vector.add(String.valueOf(data.stTemperInfo.fTemperMin)); |
|
454 |
vector.add(String.valueOf(data.stTemperInfo.fTemperMid)); |
|
455 |
vector.add(String.valueOf(data.stTemperInfo.fTemperStd)); |
|
456 |
|
|
457 |
tableModel.addRow(vector); |
|
458 |
} |
|
459 |
|
|
460 |
public void clearData() { |
|
461 |
currentIndex = 0; |
|
462 |
tableModel.setRowCount(0); |
|
463 |
tableModel.setRowCount(QUERY_SHOW_COUNT); |
|
464 |
table.updateUI(); |
|
465 |
setButtonEnable(false); |
|
466 |
} |
|
467 |
|
|
468 |
private JTable table = null; |
|
469 |
private DefaultTableModel tableModel = null; |
|
470 |
public JButton prePageBtn; |
|
471 |
public JButton nextPageBtn; |
|
472 |
} |
|
473 |
|
|
474 |
/** |
|
475 |
* 查询类型 |
|
476 |
* */ |
|
477 |
public enum QUERY_TYPE { |
|
478 |
UNKNOWN, // 未知 |
|
479 |
FIRST_PAGE_QUERY, // 第一页 |
|
480 |
PRE_PAGE_QUERY, // 上一页 |
|
481 |
NEXT_PAGE_QUERY // 下一页 |
|
482 |
}; |
|
483 |
|
|
484 |
/** |
|
485 |
* 查找工作线程(完成异步搜索) |
|
486 |
*/ |
|
487 |
public class QuerySwingWorker extends SwingWorker<NET_OUT_RADIOMETRY_DOFIND, Object> { |
|
488 |
|
|
489 |
private QUERY_TYPE type; |
|
490 |
private int offset = 0; |
|
491 |
|
|
492 |
public QuerySwingWorker(QUERY_TYPE type) { |
|
493 |
this.type = type; |
|
494 |
} |
|
495 |
|
|
496 |
protected NET_OUT_RADIOMETRY_DOFIND doInBackground() { |
|
497 |
|
|
498 |
int currentIndex = showPanel.getIndex(); |
|
499 |
try { |
|
500 |
switch(type) { |
|
501 |
case FIRST_PAGE_QUERY: |
|
502 |
ThermalCameraModule.stopFind(); |
|
503 |
if (!ThermalCameraModule.startFind(stuStartFind)) { |
|
504 |
return null; |
|
505 |
} |
|
506 |
offset = 0; |
|
507 |
break; |
|
508 |
case PRE_PAGE_QUERY: |
|
509 |
offset = ((currentIndex-1)/QueryShowPanel.QUERY_SHOW_COUNT-1) * QueryShowPanel.QUERY_SHOW_COUNT; |
|
510 |
break; |
|
511 |
case NEXT_PAGE_QUERY: |
|
512 |
offset = currentIndex; |
|
513 |
break; |
|
514 |
default: |
|
515 |
break; |
|
516 |
} |
|
517 |
|
|
518 |
|
|
519 |
NET_OUT_RADIOMETRY_DOFIND stuDoFind = ThermalCameraModule.doFind(offset, QueryShowPanel.QUERY_SHOW_COUNT); |
|
520 |
|
|
521 |
return stuDoFind; |
|
522 |
}catch (Exception e) { |
|
523 |
System.out.println(" -------- doInBackground Exception -------- "); |
|
524 |
} |
|
525 |
return null; |
|
526 |
} |
|
527 |
|
|
528 |
@Override |
|
529 |
protected void done() { |
|
530 |
|
|
531 |
try { |
|
532 |
|
|
533 |
NET_OUT_RADIOMETRY_DOFIND stuDoFind = get(); |
|
534 |
if (stuDoFind == null) { |
|
535 |
JOptionPane.showMessageDialog(null, ToolKits.getErrorCodeShow(), Res.string().getErrorMessage(), JOptionPane.ERROR_MESSAGE); |
|
536 |
return; |
|
537 |
} |
|
538 |
|
|
539 |
// System.out.println("offset " + offset + " nFound " + stuDoFind.nFound + " Total " + ThermalCameraModule.getTotalCount()); |
|
540 |
|
|
541 |
if (stuDoFind.nFound == 0) { |
|
542 |
JOptionPane.showMessageDialog(null, Res.string().getFailed(), Res.string().getErrorMessage(), JOptionPane.ERROR_MESSAGE); |
|
543 |
return; |
|
544 |
} |
|
545 |
|
|
546 |
showPanel.setIndex(offset); |
|
547 |
showPanel.insertData(stuDoFind); |
|
548 |
} catch (Exception e) { |
|
549 |
// e.printStackTrace(); |
|
550 |
}finally { |
|
551 |
setSearchEnable(true); |
|
552 |
} |
|
553 |
} |
|
554 |
} |
|
555 |
|
|
556 |
private QueryPanel queryPanel; |
|
557 |
private QueryShowPanel showPanel; |
|
558 |
} |