root / branches / v2_0_0_prep / applications / appgvSIG / src / com / iver / cit / gvsig / gui / panels / MappingFieldsToAnotation.java @ 23383
History | View | Annotate | Download (10.3 KB)
1 | 6117 | jaume | package com.iver.cit.gvsig.gui.panels; |
---|---|---|---|
2 | |||
3 | import java.sql.Types; |
||
4 | |||
5 | 7738 | jaume | import javax.swing.ButtonGroup; |
6 | import javax.swing.JButton; |
||
7 | import javax.swing.JComboBox; |
||
8 | import javax.swing.JLabel; |
||
9 | 6117 | jaume | import javax.swing.JPanel; |
10 | 7738 | jaume | import javax.swing.JRadioButton; |
11 | import javax.swing.JTextField; |
||
12 | 6117 | jaume | |
13 | 23383 | vcaballero | //import org.gvsig.fmap.datasources.SelectableDataSource;
|
14 | 20994 | jmvivo | import org.gvsig.fmap.mapcontext.layers.MappingAnnotation; |
15 | 23383 | vcaballero | //import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrAnnotation;
|
16 | 20994 | jmvivo | |
17 | 23383 | vcaballero | //import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
|
18 | 6117 | jaume | import com.iver.andami.PluginServices; |
19 | 6877 | cesar | import com.iver.andami.ui.mdiManager.IWindow; |
20 | 6880 | cesar | import com.iver.andami.ui.mdiManager.WindowInfo; |
21 | 6117 | jaume | |
22 | 23383 | vcaballero | //TODO comentado para que compile
|
23 | 6877 | cesar | public class MappingFieldsToAnotation extends JPanel implements IWindow{ |
24 | 6117 | jaume | |
25 | private JComboBox cmbText = null; |
||
26 | private JComboBox cmbAngle = null; |
||
27 | private JLabel jLabel = null; |
||
28 | private JLabel jLabel1 = null; |
||
29 | private JLabel jLabel2 = null; |
||
30 | private JComboBox cmbColor = null; |
||
31 | private JLabel jLabel3 = null; |
||
32 | private JComboBox cmbHeight = null; |
||
33 | private JLabel jLabel4 = null; |
||
34 | private JComboBox cmbFont = null; |
||
35 | private JButton bOk = null; |
||
36 | private JButton bCancel = null; |
||
37 | 23383 | vcaballero | // private SelectableDataSource sds=null;
|
38 | // private FLyrAnnotation la;
|
||
39 | 6117 | jaume | private int[] mapText; |
40 | private int[] mapAngle; |
||
41 | private int[] mapColor; |
||
42 | private int[] mapHeight; |
||
43 | private int[] mapFont; |
||
44 | private JPanel jPanel = null; |
||
45 | private JLabel jLabel5 = null; |
||
46 | private JTextField txtName = null; |
||
47 | //private JCheckBox chbPixels = null;
|
||
48 | private JRadioButton rbMapUnits = null; |
||
49 | private JRadioButton rbPixels = null; |
||
50 | private boolean isOk=false; |
||
51 | /**
|
||
52 | * This is the default constructor
|
||
53 | */
|
||
54 | 23383 | vcaballero | // public MappingFieldsToAnotation(FLyrAnnotation la) {
|
55 | // super();
|
||
56 | // this.la=la;
|
||
57 | // try {
|
||
58 | // this.sds=la.getRecordset();
|
||
59 | // initialize();
|
||
60 | // } catch (ReadDriverException e) {
|
||
61 | // e.printStackTrace();
|
||
62 | // }
|
||
63 | //
|
||
64 | // }
|
||
65 | 6117 | jaume | |
66 | /**
|
||
67 | * This method initializes this
|
||
68 | *
|
||
69 | * @return void
|
||
70 | */
|
||
71 | private void initialize() { |
||
72 | jLabel4 = new JLabel(); |
||
73 | jLabel4.setBounds(new java.awt.Rectangle(15,259,166,20)); |
||
74 | jLabel4.setText("fuente");
|
||
75 | jLabel3 = new JLabel(); |
||
76 | jLabel3.setBounds(new java.awt.Rectangle(15,197,166,20)); |
||
77 | jLabel3.setText("alto");
|
||
78 | jLabel2 = new JLabel(); |
||
79 | jLabel2.setBounds(new java.awt.Rectangle(15,135,166,20)); |
||
80 | jLabel2.setText("color");
|
||
81 | jLabel1 = new JLabel(); |
||
82 | jLabel1.setBounds(new java.awt.Rectangle(15,73,166,20)); |
||
83 | jLabel1.setText("angulo");
|
||
84 | jLabel = new JLabel(); |
||
85 | jLabel.setBounds(new java.awt.Rectangle(15,11,166,20)); |
||
86 | jLabel.setText("texto");
|
||
87 | this.setLayout(null); |
||
88 | this.setSize(544, 368); |
||
89 | this.add(getCmbText(), null); |
||
90 | this.add(getCmbAngle(), null); |
||
91 | this.add(jLabel, null); |
||
92 | this.add(jLabel1, null); |
||
93 | this.add(jLabel2, null); |
||
94 | this.add(getCmbColor(), null); |
||
95 | this.add(jLabel3, null); |
||
96 | this.add(getCmbHeight(), null); |
||
97 | this.add(jLabel4, null); |
||
98 | this.add(getCmbFont(), null); |
||
99 | this.add(getBOk(), null); |
||
100 | this.add(getBCancel(), null); |
||
101 | this.add(getJPanel(), null); |
||
102 | } |
||
103 | |||
104 | 6880 | cesar | public WindowInfo getWindowInfo() {
|
105 | WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
|
||
106 | 6117 | jaume | m_viewinfo.setTitle(PluginServices.getText(this,
|
107 | "indexar_campos"));
|
||
108 | |||
109 | return m_viewinfo;
|
||
110 | } |
||
111 | |||
112 | /**
|
||
113 | * This method initializes cmbOrigin
|
||
114 | *
|
||
115 | * @return javax.swing.JComboBox
|
||
116 | */
|
||
117 | private JComboBox getCmbText() { |
||
118 | if (cmbText == null) { |
||
119 | cmbText = new JComboBox(); |
||
120 | 23383 | vcaballero | // try {
|
121 | // mapText=new int[sds.getFieldCount()];
|
||
122 | // int num=-1;
|
||
123 | // for (int i = 0; i < sds.getFieldCount(); i++) {
|
||
124 | // cmbText.addItem(sds.getFieldName(i));
|
||
125 | // num++;
|
||
126 | // mapText[i]=num;
|
||
127 | // }
|
||
128 | // //cmbText.addItem("- Defaulf -");
|
||
129 | // } catch (ReadDriverException e) {
|
||
130 | // e.printStackTrace();
|
||
131 | // }
|
||
132 | 6117 | jaume | cmbText.setBounds(new java.awt.Rectangle(15,42,166,20)); |
133 | |||
134 | } |
||
135 | return cmbText;
|
||
136 | } |
||
137 | |||
138 | /**
|
||
139 | * This method initializes cmbEnd
|
||
140 | *
|
||
141 | * @return javax.swing.JComboBox
|
||
142 | */
|
||
143 | private JComboBox getCmbAngle() { |
||
144 | if (cmbAngle == null) { |
||
145 | cmbAngle = new JComboBox(); |
||
146 | 23383 | vcaballero | // try {
|
147 | // mapAngle=new int[sds.getFieldCount()];
|
||
148 | // int num=-1;
|
||
149 | // for (int i = 0; i < sds.getFieldCount(); i++) {
|
||
150 | // if (sds.getFieldType(i) == Types.DOUBLE){
|
||
151 | // cmbAngle.addItem(sds.getFieldName(i));
|
||
152 | // num++;
|
||
153 | // mapAngle[i]=num;
|
||
154 | // }
|
||
155 | // }
|
||
156 | // cmbAngle.addItem("- Default -");
|
||
157 | // cmbAngle.setSelectedItem("- Default -");
|
||
158 | // } catch (ReadDriverException e) {
|
||
159 | // e.printStackTrace();
|
||
160 | // }
|
||
161 | 6117 | jaume | cmbAngle.setBounds(new java.awt.Rectangle(15,104,166,20)); |
162 | } |
||
163 | return cmbAngle;
|
||
164 | } |
||
165 | |||
166 | /**
|
||
167 | * This method initializes cmbColor
|
||
168 | *
|
||
169 | * @return javax.swing.JComboBox
|
||
170 | */
|
||
171 | private JComboBox getCmbColor() { |
||
172 | if (cmbColor == null) { |
||
173 | cmbColor = new JComboBox(); |
||
174 | cmbColor.setBounds(new java.awt.Rectangle(15,166,166,20)); |
||
175 | 23383 | vcaballero | // try {
|
176 | // mapColor=new int[sds.getFieldCount()];
|
||
177 | // int num=-1;
|
||
178 | // for (int i = 0; i < sds.getFieldCount(); i++) {
|
||
179 | // if (sds.getFieldType(i) == Types.DOUBLE){
|
||
180 | // cmbColor.addItem(sds.getFieldName(i));
|
||
181 | // num++;
|
||
182 | // mapColor[i]=num;
|
||
183 | // }
|
||
184 | // }
|
||
185 | // cmbColor.addItem("- Default -");
|
||
186 | // cmbColor.setSelectedItem("- Default -");
|
||
187 | // } catch (ReadDriverException e) {
|
||
188 | // e.printStackTrace();
|
||
189 | // }
|
||
190 | 6117 | jaume | } |
191 | return cmbColor;
|
||
192 | } |
||
193 | |||
194 | /**
|
||
195 | * This method initializes cmbHeight
|
||
196 | *
|
||
197 | * @return javax.swing.JComboBox
|
||
198 | */
|
||
199 | private JComboBox getCmbHeight() { |
||
200 | if (cmbHeight == null) { |
||
201 | cmbHeight = new JComboBox(); |
||
202 | 23383 | vcaballero | // try {
|
203 | // mapHeight=new int[sds.getFieldCount()];
|
||
204 | // int num=-1;
|
||
205 | // for (int i = 0; i < sds.getFieldCount(); i++) {
|
||
206 | // if (sds.getFieldType(i) == Types.DOUBLE){
|
||
207 | // cmbHeight.addItem(sds.getFieldName(i));
|
||
208 | // num++;
|
||
209 | // mapHeight[i]=num;
|
||
210 | // }
|
||
211 | // }
|
||
212 | // cmbHeight.addItem("- Default -");
|
||
213 | // cmbHeight.setSelectedItem("- Default -");
|
||
214 | // } catch (ReadDriverException e) {
|
||
215 | // e.printStackTrace();
|
||
216 | // }
|
||
217 | 6117 | jaume | cmbHeight.setBounds(new java.awt.Rectangle(15,228,166,20)); |
218 | } |
||
219 | return cmbHeight;
|
||
220 | } |
||
221 | |||
222 | /**
|
||
223 | * This method initializes cmbFont
|
||
224 | *
|
||
225 | * @return javax.swing.JComboBox
|
||
226 | */
|
||
227 | private JComboBox getCmbFont() { |
||
228 | if (cmbFont == null) { |
||
229 | cmbFont = new JComboBox(); |
||
230 | 23383 | vcaballero | // try {
|
231 | // mapFont=new int[sds.getFieldCount()];
|
||
232 | // int num=-1;
|
||
233 | // for (int i = 0; i < sds.getFieldCount(); i++) {
|
||
234 | // if (sds.getFieldType(i) == Types.VARCHAR){
|
||
235 | // cmbFont.addItem(sds.getFieldName(i));
|
||
236 | // num++;
|
||
237 | // mapFont[i]=num;
|
||
238 | // }
|
||
239 | // }
|
||
240 | // cmbFont.addItem("- Default -");
|
||
241 | // cmbFont.setSelectedItem("- Default -");
|
||
242 | // } catch (ReadDriverException e) {
|
||
243 | // e.printStackTrace();
|
||
244 | // }
|
||
245 | 6117 | jaume | cmbFont.setBounds(new java.awt.Rectangle(15,290,166,20)); |
246 | } |
||
247 | return cmbFont;
|
||
248 | } |
||
249 | |||
250 | /**
|
||
251 | * This method initializes bOk
|
||
252 | *
|
||
253 | * @return javax.swing.JButton
|
||
254 | */
|
||
255 | private JButton getBOk() { |
||
256 | if (bOk == null) { |
||
257 | bOk = new JButton(); |
||
258 | bOk.setBounds(new java.awt.Rectangle(119,326,92,24)); |
||
259 | bOk.setText("Aceptar");
|
||
260 | bOk.addActionListener(new java.awt.event.ActionListener() {
|
||
261 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
262 | MappingAnnotation mapping=new MappingAnnotation();
|
||
263 | if (getCmbText().getSelectedItem().equals("")) |
||
264 | mapping.setColumnText(-1);
|
||
265 | else
|
||
266 | mapping.setColumnText(mapText[getCmbText().getSelectedIndex()]); |
||
267 | if (!getCmbAngle().getSelectedItem().equals("- Default -")) |
||
268 | mapping.setColumnRotate(mapAngle[getCmbAngle().getSelectedIndex()]); |
||
269 | if (!getCmbColor().getSelectedItem().equals("- Default -")) |
||
270 | mapping.setColumnColor(mapColor[getCmbColor().getSelectedIndex()]); |
||
271 | if (!getCmbHeight().getSelectedItem().equals("- Default -")) |
||
272 | mapping.setColumnHeight(mapHeight[getCmbHeight().getSelectedIndex()]); |
||
273 | if (!getCmbFont().getSelectedItem().equals("- Default -")) |
||
274 | mapping.setColumnTypeFont(mapFont[getCmbFont().getSelectedIndex()]); |
||
275 | //Falta el estilo, si es necesario.
|
||
276 | 23383 | vcaballero | // la.setInPixels(rbPixels.isSelected());
|
277 | // la.setMapping(mapping);
|
||
278 | // la.setName(getTxtName().getText());
|
||
279 | 6117 | jaume | isOk=true;
|
280 | 6880 | cesar | PluginServices.getMDIManager().closeWindow(MappingFieldsToAnotation.this); |
281 | 6117 | jaume | } |
282 | }); |
||
283 | } |
||
284 | return bOk;
|
||
285 | } |
||
286 | |||
287 | /**
|
||
288 | * This method initializes bCancel
|
||
289 | *
|
||
290 | * @return javax.swing.JButton
|
||
291 | */
|
||
292 | private JButton getBCancel() { |
||
293 | if (bCancel == null) { |
||
294 | bCancel = new JButton(); |
||
295 | bCancel.setBounds(new java.awt.Rectangle(330,325,93,25)); |
||
296 | bCancel.setText("cancelar");
|
||
297 | bCancel.addActionListener(new java.awt.event.ActionListener() {
|
||
298 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
299 | isOk=false;
|
||
300 | 6880 | cesar | PluginServices.getMDIManager().closeWindow(MappingFieldsToAnotation.this); |
301 | 6117 | jaume | } |
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 | public boolean isOk() { |
||
390 | return isOk;
|
||
391 | } |
||
392 | |||
393 | } // @jve:decl-index=0:visual-constraint="-150,10" |