提交 | 用户 | 时间
|
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.event.ActionEvent; |
|
7 |
import java.awt.event.ActionListener; |
|
8 |
import java.awt.event.KeyEvent; |
|
9 |
import java.awt.event.KeyListener; |
|
10 |
|
|
11 |
import javax.swing.JButton; |
|
12 |
import javax.swing.JDialog; |
|
13 |
import javax.swing.JLabel; |
|
14 |
import javax.swing.JOptionPane; |
|
15 |
import javax.swing.JPanel; |
|
16 |
import javax.swing.JTextField; |
|
17 |
|
|
18 |
import com.netsdk.common.BorderEx; |
|
19 |
import com.netsdk.common.Res; |
|
20 |
import com.netsdk.demo.module.ThermalCameraModule; |
|
21 |
import com.netsdk.lib.ToolKits; |
|
22 |
import com.netsdk.lib.NetSDKLib.NET_RADIOMETRYINFO; |
|
23 |
|
|
24 |
/** |
|
25 |
* 查询测温点对话框 |
|
26 |
*/ |
|
27 |
public class PointQueryDialog extends JDialog{ |
|
28 |
|
|
29 |
/** |
|
30 |
* |
|
31 |
*/ |
|
32 |
private static final long serialVersionUID = 1L; |
|
33 |
|
|
34 |
public PointQueryDialog() { |
|
35 |
setTitle(Res.string().getShowInfo("POINT_TEMPER")); |
|
36 |
setLayout(new BorderLayout()); |
|
37 |
setModal(true); |
|
38 |
pack(); |
|
39 |
setSize(350, 300); |
|
40 |
setResizable(false); |
|
41 |
setLocationRelativeTo(null); |
|
42 |
setDefaultCloseOperation(DISPOSE_ON_CLOSE); |
|
43 |
|
|
44 |
/////////////////////////////// |
|
45 |
queryPanel = new QueryPanel(); |
|
46 |
showPanel = new QueryShowPanel(); |
|
47 |
|
|
48 |
add(queryPanel, BorderLayout.NORTH); |
|
49 |
add(showPanel, BorderLayout.CENTER); |
|
50 |
} |
|
51 |
|
|
52 |
|
|
53 |
/** |
|
54 |
* 查询界面 |
|
55 |
* */ |
|
56 |
public class QueryPanel extends JPanel { |
|
57 |
/** |
|
58 |
* |
|
59 |
*/ |
|
60 |
private static final long serialVersionUID = 1L; |
|
61 |
|
|
62 |
public QueryPanel() { |
|
63 |
BorderEx.set(this, Res.string().getShowInfo("QUERY_CONDITION"), 1); |
|
64 |
setLayout(new FlowLayout(FlowLayout.CENTER, 10, 10)); |
|
65 |
|
|
66 |
JLabel XLabel = new JLabel(Res.string().getShowInfo("X"), JLabel.CENTER); |
|
67 |
XTextField = new JTextField("0"); |
|
68 |
JLabel YLabel = new JLabel(Res.string().getShowInfo("Y"), JLabel.CENTER); |
|
69 |
YTextField = new JTextField("0"); |
|
70 |
queryBtn = new JButton(Res.string().getShowInfo("QUERY")); |
|
71 |
|
|
72 |
Dimension lableDimension = new Dimension(10, 20); |
|
73 |
Dimension textFieldDimension = new Dimension(70, 20); |
|
74 |
Dimension btnDimension = new Dimension(100, 20); |
|
75 |
|
|
76 |
XLabel.setPreferredSize(lableDimension); |
|
77 |
XTextField.setPreferredSize(textFieldDimension); |
|
78 |
YLabel.setPreferredSize(lableDimension); |
|
79 |
YTextField.setPreferredSize(textFieldDimension); |
|
80 |
queryBtn.setPreferredSize(btnDimension); |
|
81 |
|
|
82 |
add(XLabel); |
|
83 |
add(XTextField); |
|
84 |
add(YLabel); |
|
85 |
add(YTextField); |
|
86 |
add(queryBtn); |
|
87 |
|
|
88 |
listener = new NumberKeyListener(); |
|
89 |
XTextField.addKeyListener(listener); |
|
90 |
YTextField.addKeyListener(listener); |
|
91 |
|
|
92 |
queryBtn.addActionListener(new ActionListener() { |
|
93 |
|
|
94 |
@Override |
|
95 |
public void actionPerformed(ActionEvent e) { |
|
96 |
queryPointInfo(); |
|
97 |
} |
|
98 |
}); |
|
99 |
} |
|
100 |
|
|
101 |
private void queryPointInfo() { |
|
102 |
try { |
|
103 |
showPanel.clearData(); |
|
104 |
|
|
105 |
short x = Short.parseShort(XTextField.getText()); |
|
106 |
short y = Short.parseShort(YTextField.getText()); |
|
107 |
|
|
108 |
NET_RADIOMETRYINFO pointInfo = |
|
109 |
ThermalCameraModule.queryPointTemper(ThermalCameraFrame.THERMAL_CHANNEL, x, y); |
|
110 |
if (pointInfo == null) { |
|
111 |
JOptionPane.showMessageDialog(null, ToolKits.getErrorCodeShow(), Res.string().getErrorMessage(), JOptionPane.ERROR_MESSAGE); |
|
112 |
return; |
|
113 |
} |
|
114 |
|
|
115 |
showPanel.updateData(pointInfo); |
|
116 |
|
|
117 |
}catch(NumberFormatException e) { |
|
118 |
JOptionPane.showMessageDialog(null, Res.string().getShowInfo("COORDINATE_ILLEGAL"), Res.string().getErrorMessage(), JOptionPane.ERROR_MESSAGE); |
|
119 |
} |
|
120 |
} |
|
121 |
|
|
122 |
private NumberKeyListener listener; |
|
123 |
|
|
124 |
private JTextField XTextField; |
|
125 |
private JTextField YTextField; |
|
126 |
private JButton queryBtn; |
|
127 |
} |
|
128 |
|
|
129 |
/** |
|
130 |
* 查询显示界面 |
|
131 |
* */ |
|
132 |
public class QueryShowPanel extends JPanel { |
|
133 |
/** |
|
134 |
* |
|
135 |
*/ |
|
136 |
private static final long serialVersionUID = 1L; |
|
137 |
|
|
138 |
public QueryShowPanel() { |
|
139 |
BorderEx.set(this, Res.string().getShowInfo("QUERY_RESULT"), 1); |
|
140 |
setLayout(new FlowLayout(FlowLayout.CENTER, 5, 30)); |
|
141 |
|
|
142 |
JLabel meterTypeLabel = new JLabel(Res.string().getShowInfo("METER_TYPE"), JLabel.LEFT); |
|
143 |
meterTypeTextField = new JTextField(); |
|
144 |
JLabel temperUnitLabel = new JLabel(Res.string().getShowInfo("TEMPER_UNIT"), JLabel.LEFT); |
|
145 |
temperUnitTextField = new JTextField(); |
|
146 |
JLabel temperLabel = new JLabel(Res.string().getShowInfo("TEMPER"), JLabel.LEFT); |
|
147 |
temperTextField = new JTextField(); |
|
148 |
|
|
149 |
Dimension lableDimension = new Dimension(100, 20); |
|
150 |
Dimension textFieldDimension = new Dimension(130, 20); |
|
151 |
meterTypeLabel.setPreferredSize(lableDimension); |
|
152 |
temperUnitLabel.setPreferredSize(lableDimension); |
|
153 |
temperLabel.setPreferredSize(lableDimension); |
|
154 |
meterTypeTextField.setPreferredSize(textFieldDimension); |
|
155 |
temperUnitTextField.setPreferredSize(textFieldDimension); |
|
156 |
temperTextField.setPreferredSize(textFieldDimension); |
|
157 |
|
|
158 |
meterTypeTextField.setEditable(false); |
|
159 |
temperUnitTextField.setEditable(false); |
|
160 |
temperTextField.setEditable(false); |
|
161 |
|
|
162 |
add(meterTypeLabel); |
|
163 |
add(meterTypeTextField); |
|
164 |
add(temperUnitLabel); |
|
165 |
add(temperUnitTextField); |
|
166 |
add(temperLabel); |
|
167 |
add(temperTextField); |
|
168 |
} |
|
169 |
|
|
170 |
public void updateData(NET_RADIOMETRYINFO stPointInfo) { |
|
171 |
String[] data = new String[3]; |
|
172 |
|
|
173 |
String [] arrMeterType = Res.string().getMeterTypeList(); |
|
174 |
if (stPointInfo.nMeterType >= 1 && |
|
175 |
stPointInfo.nMeterType <= arrMeterType.length) { |
|
176 |
data[0] = arrMeterType[stPointInfo.nMeterType-1]; |
|
177 |
}else { |
|
178 |
data[0] = Res.string().getShowInfo("UNKNOWN"); |
|
179 |
} |
|
180 |
|
|
181 |
String [] arrTemperUnit = Res.string().getTemperUnitList(); |
|
182 |
if (stPointInfo.nTemperUnit >= 1 && |
|
183 |
stPointInfo.nTemperUnit <= arrTemperUnit.length) { |
|
184 |
data[1] = arrTemperUnit[stPointInfo.nTemperUnit-1]; |
|
185 |
}else { |
|
186 |
data[1] = Res.string().getShowInfo("UNKNOWN"); |
|
187 |
} |
|
188 |
|
|
189 |
data[2] = String.valueOf(stPointInfo.fTemperAver); |
|
190 |
|
|
191 |
setData(data); |
|
192 |
} |
|
193 |
|
|
194 |
public void clearData() { |
|
195 |
setData(new String[3]); |
|
196 |
} |
|
197 |
|
|
198 |
private void setData(String[] data) { |
|
199 |
|
|
200 |
if (data.length != 3) { |
|
201 |
System.err.printf("data length %d != 3", data.length); |
|
202 |
return; |
|
203 |
} |
|
204 |
|
|
205 |
meterTypeTextField.setText(data[0]); |
|
206 |
temperUnitTextField.setText(data[1]); |
|
207 |
temperTextField.setText(data[2]); |
|
208 |
} |
|
209 |
|
|
210 |
private JTextField meterTypeTextField; |
|
211 |
private JTextField temperUnitTextField; |
|
212 |
private JTextField temperTextField; |
|
213 |
} |
|
214 |
|
|
215 |
|
|
216 |
|
|
217 |
class NumberKeyListener implements KeyListener { |
|
218 |
|
|
219 |
public void keyTyped(KeyEvent e) { |
|
220 |
int key = e.getKeyChar(); |
|
221 |
if (key < 48 || key > 57) { |
|
222 |
e.consume(); |
|
223 |
} |
|
224 |
} |
|
225 |
|
|
226 |
public void keyPressed(KeyEvent e) {} |
|
227 |
|
|
228 |
public void keyReleased(KeyEvent e) {} |
|
229 |
} |
|
230 |
|
|
231 |
private QueryPanel queryPanel; |
|
232 |
private QueryShowPanel showPanel; |
|
233 |
} |