svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / Panels / MappingFieldsToAnotation.java @ 4258
History | View | Annotate | Download (9.88 KB)
1 |
package com.iver.cit.gvsig.gui.Panels; |
---|---|
2 |
|
3 |
import java.sql.Types; |
4 |
|
5 |
import javax.swing.JPanel; |
6 |
|
7 |
import com.hardcode.gdbms.engine.data.driver.DriverException; |
8 |
import com.iver.andami.PluginServices; |
9 |
import com.iver.andami.ui.mdiManager.View; |
10 |
import com.iver.andami.ui.mdiManager.ViewInfo; |
11 |
import com.iver.cit.gvsig.fmap.layers.FLyrAnnotation; |
12 |
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource; |
13 |
|
14 |
import javax.swing.ButtonGroup; |
15 |
import javax.swing.JComboBox; |
16 |
import javax.swing.JLabel; |
17 |
import javax.swing.JButton; |
18 |
import javax.swing.JTextField; |
19 |
import javax.swing.JCheckBox; |
20 |
import javax.swing.JRadioButton; |
21 |
|
22 |
public class MappingFieldsToAnotation extends JPanel implements View{ |
23 |
|
24 |
private JComboBox cmbText = null; |
25 |
private JComboBox cmbAngle = null; |
26 |
private JLabel jLabel = null; |
27 |
private JLabel jLabel1 = null; |
28 |
private JLabel jLabel2 = null; |
29 |
private JComboBox cmbColor = null; |
30 |
private JLabel jLabel3 = null; |
31 |
private JComboBox cmbHeight = null; |
32 |
private JLabel jLabel4 = null; |
33 |
private JComboBox cmbFont = null; |
34 |
private JButton bOk = null; |
35 |
private JButton bCancel = null; |
36 |
private SelectableDataSource sds=null; |
37 |
private FLyrAnnotation la;
|
38 |
private int[] mapText; |
39 |
private int[] mapAngle; |
40 |
private int[] mapColor; |
41 |
private int[] mapHeight; |
42 |
private int[] mapFont; |
43 |
private JPanel jPanel = null; |
44 |
private JLabel jLabel5 = null; |
45 |
private JTextField txtName = null; |
46 |
//private JCheckBox chbPixels = null;
|
47 |
private JRadioButton rbMapUnits = null; |
48 |
private JRadioButton rbPixels = null; |
49 |
/**
|
50 |
* This is the default constructor
|
51 |
*/
|
52 |
public MappingFieldsToAnotation(FLyrAnnotation la) {
|
53 |
super();
|
54 |
this.la=la;
|
55 |
this.sds=la.getRecordset();
|
56 |
initialize(); |
57 |
} |
58 |
|
59 |
/**
|
60 |
* This method initializes this
|
61 |
*
|
62 |
* @return void
|
63 |
*/
|
64 |
private void initialize() { |
65 |
jLabel4 = new JLabel(); |
66 |
jLabel4.setBounds(new java.awt.Rectangle(15,259,166,20)); |
67 |
jLabel4.setText("fuente");
|
68 |
jLabel3 = new JLabel(); |
69 |
jLabel3.setBounds(new java.awt.Rectangle(15,197,166,20)); |
70 |
jLabel3.setText("alto");
|
71 |
jLabel2 = new JLabel(); |
72 |
jLabel2.setBounds(new java.awt.Rectangle(15,135,166,20)); |
73 |
jLabel2.setText("color");
|
74 |
jLabel1 = new JLabel(); |
75 |
jLabel1.setBounds(new java.awt.Rectangle(15,73,166,20)); |
76 |
jLabel1.setText("angulo");
|
77 |
jLabel = new JLabel(); |
78 |
jLabel.setBounds(new java.awt.Rectangle(15,11,166,20)); |
79 |
jLabel.setText("texto");
|
80 |
this.setLayout(null); |
81 |
this.setSize(544, 368); |
82 |
this.add(getCmbText(), null); |
83 |
this.add(getCmbAngle(), null); |
84 |
this.add(jLabel, null); |
85 |
this.add(jLabel1, null); |
86 |
this.add(jLabel2, null); |
87 |
this.add(getCmbColor(), null); |
88 |
this.add(jLabel3, null); |
89 |
this.add(getCmbHeight(), null); |
90 |
this.add(jLabel4, null); |
91 |
this.add(getCmbFont(), null); |
92 |
this.add(getBOk(), null); |
93 |
this.add(getBCancel(), null); |
94 |
this.add(getJPanel(), null); |
95 |
} |
96 |
|
97 |
public ViewInfo getViewInfo() {
|
98 |
ViewInfo m_viewinfo = new ViewInfo(ViewInfo.MODALDIALOG);
|
99 |
m_viewinfo.setTitle(PluginServices.getText(this,
|
100 |
"indexar_campos"));
|
101 |
|
102 |
return m_viewinfo;
|
103 |
} |
104 |
|
105 |
/**
|
106 |
* This method initializes cmbOrigin
|
107 |
*
|
108 |
* @return javax.swing.JComboBox
|
109 |
*/
|
110 |
private JComboBox getCmbText() { |
111 |
if (cmbText == null) { |
112 |
cmbText = new JComboBox(); |
113 |
try {
|
114 |
mapText=new int[sds.getFieldCount()]; |
115 |
int num=-1; |
116 |
for (int i = 0; i < sds.getFieldCount(); i++) { |
117 |
cmbText.addItem(sds.getFieldName(i)); |
118 |
num++; |
119 |
mapText[i]=num; |
120 |
} |
121 |
//cmbText.addItem("- Defaulf -");
|
122 |
} catch (DriverException e) {
|
123 |
e.printStackTrace(); |
124 |
} |
125 |
cmbText.setBounds(new java.awt.Rectangle(15,42,166,20)); |
126 |
|
127 |
} |
128 |
return cmbText;
|
129 |
} |
130 |
|
131 |
/**
|
132 |
* This method initializes cmbEnd
|
133 |
*
|
134 |
* @return javax.swing.JComboBox
|
135 |
*/
|
136 |
private JComboBox getCmbAngle() { |
137 |
if (cmbAngle == null) { |
138 |
cmbAngle = new JComboBox(); |
139 |
try {
|
140 |
mapAngle=new int[sds.getFieldCount()]; |
141 |
int num=-1; |
142 |
for (int i = 0; i < sds.getFieldCount(); i++) { |
143 |
if (sds.getFieldType(i) == Types.DOUBLE){ |
144 |
cmbAngle.addItem(sds.getFieldName(i)); |
145 |
num++; |
146 |
mapAngle[i]=num; |
147 |
} |
148 |
} |
149 |
cmbAngle.addItem("- Default -");
|
150 |
cmbAngle.setSelectedItem("- Default -");
|
151 |
} catch (DriverException e) {
|
152 |
e.printStackTrace(); |
153 |
} |
154 |
cmbAngle.setBounds(new java.awt.Rectangle(15,104,166,20)); |
155 |
} |
156 |
return cmbAngle;
|
157 |
} |
158 |
|
159 |
/**
|
160 |
* This method initializes cmbColor
|
161 |
*
|
162 |
* @return javax.swing.JComboBox
|
163 |
*/
|
164 |
private JComboBox getCmbColor() { |
165 |
if (cmbColor == null) { |
166 |
cmbColor = new JComboBox(); |
167 |
cmbColor.setBounds(new java.awt.Rectangle(15,166,166,20)); |
168 |
try {
|
169 |
mapColor=new int[sds.getFieldCount()]; |
170 |
int num=-1; |
171 |
for (int i = 0; i < sds.getFieldCount(); i++) { |
172 |
if (sds.getFieldType(i) == Types.DOUBLE){ |
173 |
cmbColor.addItem(sds.getFieldName(i)); |
174 |
num++; |
175 |
mapColor[i]=num; |
176 |
} |
177 |
} |
178 |
cmbColor.addItem("- Default -");
|
179 |
cmbColor.setSelectedItem("- Default -");
|
180 |
} catch (DriverException e) {
|
181 |
e.printStackTrace(); |
182 |
} |
183 |
} |
184 |
return cmbColor;
|
185 |
} |
186 |
|
187 |
/**
|
188 |
* This method initializes cmbHeight
|
189 |
*
|
190 |
* @return javax.swing.JComboBox
|
191 |
*/
|
192 |
private JComboBox getCmbHeight() { |
193 |
if (cmbHeight == null) { |
194 |
cmbHeight = new JComboBox(); |
195 |
try {
|
196 |
mapHeight=new int[sds.getFieldCount()]; |
197 |
int num=-1; |
198 |
for (int i = 0; i < sds.getFieldCount(); i++) { |
199 |
if (sds.getFieldType(i) == Types.DOUBLE){ |
200 |
cmbHeight.addItem(sds.getFieldName(i)); |
201 |
num++; |
202 |
mapHeight[i]=num; |
203 |
} |
204 |
} |
205 |
cmbHeight.addItem("- Default -");
|
206 |
cmbHeight.setSelectedItem("- Default -");
|
207 |
} catch (DriverException e) {
|
208 |
e.printStackTrace(); |
209 |
} |
210 |
cmbHeight.setBounds(new java.awt.Rectangle(15,228,166,20)); |
211 |
} |
212 |
return cmbHeight;
|
213 |
} |
214 |
|
215 |
/**
|
216 |
* This method initializes cmbFont
|
217 |
*
|
218 |
* @return javax.swing.JComboBox
|
219 |
*/
|
220 |
private JComboBox getCmbFont() { |
221 |
if (cmbFont == null) { |
222 |
cmbFont = new JComboBox(); |
223 |
try {
|
224 |
mapFont=new int[sds.getFieldCount()]; |
225 |
int num=-1; |
226 |
for (int i = 0; i < sds.getFieldCount(); i++) { |
227 |
if (sds.getFieldType(i) == Types.VARCHAR){ |
228 |
cmbFont.addItem(sds.getFieldName(i)); |
229 |
num++; |
230 |
mapFont[i]=num; |
231 |
} |
232 |
} |
233 |
cmbFont.addItem("- Default -");
|
234 |
cmbFont.setSelectedItem("- Default -");
|
235 |
} catch (DriverException e) {
|
236 |
e.printStackTrace(); |
237 |
} |
238 |
cmbFont.setBounds(new java.awt.Rectangle(15,290,166,20)); |
239 |
} |
240 |
return cmbFont;
|
241 |
} |
242 |
|
243 |
/**
|
244 |
* This method initializes bOk
|
245 |
*
|
246 |
* @return javax.swing.JButton
|
247 |
*/
|
248 |
private JButton getBOk() { |
249 |
if (bOk == null) { |
250 |
bOk = new JButton(); |
251 |
bOk.setBounds(new java.awt.Rectangle(119,326,92,24)); |
252 |
bOk.setText("Aceptar");
|
253 |
bOk.addActionListener(new java.awt.event.ActionListener() {
|
254 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
255 |
int[] mapping=new int[5]; |
256 |
if (getCmbText().getSelectedItem().equals("")) |
257 |
mapping[0] = -1; |
258 |
else
|
259 |
mapping[0] = mapText[getCmbText().getSelectedIndex()];
|
260 |
if (getCmbAngle().getSelectedItem().equals("- Default -")) |
261 |
mapping[1] = -1; |
262 |
else
|
263 |
mapping[1] = mapAngle[getCmbAngle().getSelectedIndex()];
|
264 |
if (getCmbColor().getSelectedItem().equals("- Default -")) |
265 |
mapping[2] = -1; |
266 |
else
|
267 |
mapping[2] = mapColor[getCmbColor().getSelectedIndex()];
|
268 |
if (getCmbHeight().getSelectedItem().equals("- Default -")) |
269 |
mapping[3] = -1; |
270 |
else
|
271 |
mapping[3] = mapHeight[getCmbHeight()
|
272 |
.getSelectedIndex()]; |
273 |
if (getCmbFont().getSelectedItem().equals("- Default -")) |
274 |
mapping[4] = -1; |
275 |
else
|
276 |
mapping[4] = mapFont[getCmbFont().getSelectedIndex()];
|
277 |
|
278 |
la.setInPixels(rbPixels.isSelected()); |
279 |
la.setMapping(mapping); |
280 |
la.setName(getTxtName().getText()); |
281 |
PluginServices.getMDIManager().closeView(MappingFieldsToAnotation.this); |
282 |
} |
283 |
}); |
284 |
} |
285 |
return bOk;
|
286 |
} |
287 |
|
288 |
/**
|
289 |
* This method initializes bCancel
|
290 |
*
|
291 |
* @return javax.swing.JButton
|
292 |
*/
|
293 |
private JButton getBCancel() { |
294 |
if (bCancel == null) { |
295 |
bCancel = new JButton(); |
296 |
bCancel.setBounds(new java.awt.Rectangle(330,325,93,25)); |
297 |
bCancel.setText("cancelar");
|
298 |
bCancel.addActionListener(new java.awt.event.ActionListener() {
|
299 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
300 |
PluginServices.getMDIManager().closeView(MappingFieldsToAnotation.this); |
301 |
} |
302 |
}); |
303 |
} |
304 |
return bCancel;
|
305 |
} |
306 |
|
307 |
/**
|
308 |
* This method initializes jPanel
|
309 |
*
|
310 |
* @return javax.swing.JPanel
|
311 |
*/
|
312 |
private JPanel getJPanel() { |
313 |
if (jPanel == null) { |
314 |
jLabel5 = new JLabel(); |
315 |
jLabel5.setBounds(new java.awt.Rectangle(15,10,228,22)); |
316 |
jLabel5.setText("nombre");
|
317 |
jPanel = new JPanel(); |
318 |
jPanel.setLayout(null);
|
319 |
jPanel.setBounds(new java.awt.Rectangle(234,14,251,141)); |
320 |
jPanel.add(jLabel5, null);
|
321 |
jPanel.add(getTxtName(), null);
|
322 |
//jPanel.add(getChbPixels(), null);
|
323 |
jPanel.add(getRbMapUnits(), null);
|
324 |
jPanel.add(getRbPixels(), null);
|
325 |
ButtonGroup bg=new ButtonGroup(); |
326 |
bg.add(getRbMapUnits()); |
327 |
bg.add(getRbPixels()); |
328 |
} |
329 |
return jPanel;
|
330 |
} |
331 |
|
332 |
/**
|
333 |
* This method initializes txtName
|
334 |
*
|
335 |
* @return javax.swing.JTextField
|
336 |
*/
|
337 |
private JTextField getTxtName() { |
338 |
if (txtName == null) { |
339 |
txtName = new JTextField(); |
340 |
//txtName.setText(la.get.getName());
|
341 |
txtName.setBounds(new java.awt.Rectangle(15,42,227,22)); |
342 |
} |
343 |
return txtName;
|
344 |
} |
345 |
|
346 |
/**
|
347 |
* This method initializes chbPixels
|
348 |
*
|
349 |
* @return javax.swing.JCheckBox
|
350 |
*/
|
351 |
/*private JCheckBox getChbPixels() {
|
352 |
if (chbPixels == null) {
|
353 |
chbPixels = new JCheckBox();
|
354 |
chbPixels.setBounds(new java.awt.Rectangle(15,138,226,25));
|
355 |
chbPixels.setText("pixels");
|
356 |
}
|
357 |
return chbPixels;
|
358 |
}
|
359 |
*/
|
360 |
/**
|
361 |
* This method initializes rbMapUnits
|
362 |
*
|
363 |
* @return javax.swing.JRadioButton
|
364 |
*/
|
365 |
private JRadioButton getRbMapUnits() { |
366 |
if (rbMapUnits == null) { |
367 |
rbMapUnits = new JRadioButton(); |
368 |
rbMapUnits.setBounds(new java.awt.Rectangle(15,74,167,22)); |
369 |
rbMapUnits.setText("unidades_mapa");
|
370 |
} |
371 |
return rbMapUnits;
|
372 |
} |
373 |
|
374 |
/**
|
375 |
* This method initializes rbPixels
|
376 |
*
|
377 |
* @return javax.swing.JRadioButton
|
378 |
*/
|
379 |
private JRadioButton getRbPixels() { |
380 |
if (rbPixels == null) { |
381 |
rbPixels = new JRadioButton(); |
382 |
rbPixels.setBounds(new java.awt.Rectangle(15,106,167,22)); |
383 |
rbPixels.setText("pixels");
|
384 |
rbPixels.setSelected(true);
|
385 |
} |
386 |
return rbPixels;
|
387 |
} |
388 |
|
389 |
} // @jve:decl-index=0:visual-constraint="-150,10"
|