svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / gui / panels / MappingFieldsToAnotation.java @ 40558
History | View | Annotate | Download (11.2 KB)
1 | 40558 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | *
|
||
4 | * Copyright (C) 2007-2013 gvSIG Association.
|
||
5 | *
|
||
6 | * This program is free software; you can redistribute it and/or
|
||
7 | * modify it under the terms of the GNU General Public License
|
||
8 | * as published by the Free Software Foundation; either version 3
|
||
9 | * of the License, or (at your option) any later version.
|
||
10 | *
|
||
11 | * This program is distributed in the hope that it will be useful,
|
||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
14 | * GNU General Public License for more details.
|
||
15 | *
|
||
16 | * You should have received a copy of the GNU General Public License
|
||
17 | * along with this program; if not, write to the Free Software
|
||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||
19 | * MA 02110-1301, USA.
|
||
20 | *
|
||
21 | * For any additional information, do not hesitate to contact us
|
||
22 | * at info AT gvsig.com, or visit our website www.gvsig.com.
|
||
23 | */
|
||
24 | 40435 | jjdelcerro | package org.gvsig.app.gui.panels; |
25 | |||
26 | import javax.swing.ButtonGroup; |
||
27 | import javax.swing.JButton; |
||
28 | import javax.swing.JComboBox; |
||
29 | import javax.swing.JLabel; |
||
30 | import javax.swing.JPanel; |
||
31 | import javax.swing.JRadioButton; |
||
32 | import javax.swing.JTextField; |
||
33 | |||
34 | import org.gvsig.andami.PluginServices; |
||
35 | import org.gvsig.andami.ui.mdiManager.IWindow; |
||
36 | import org.gvsig.andami.ui.mdiManager.WindowInfo; |
||
37 | import org.gvsig.fmap.mapcontext.layers.MappingAnnotation; |
||
38 | |||
39 | |||
40 | //TODO comentado para que compile
|
||
41 | public class MappingFieldsToAnotation extends JPanel implements IWindow{ |
||
42 | |||
43 | private JComboBox cmbText = null; |
||
44 | private JComboBox cmbAngle = null; |
||
45 | private JLabel jLabel = null; |
||
46 | private JLabel jLabel1 = null; |
||
47 | private JLabel jLabel2 = null; |
||
48 | private JComboBox cmbColor = null; |
||
49 | private JLabel jLabel3 = null; |
||
50 | private JComboBox cmbHeight = null; |
||
51 | private JLabel jLabel4 = null; |
||
52 | private JComboBox cmbFont = null; |
||
53 | private JButton bOk = null; |
||
54 | private JButton bCancel = null; |
||
55 | // private SelectableDataSource sds=null;
|
||
56 | // private FLyrAnnotation la;
|
||
57 | private int[] mapText; |
||
58 | private int[] mapAngle; |
||
59 | private int[] mapColor; |
||
60 | private int[] mapHeight; |
||
61 | private int[] mapFont; |
||
62 | private JPanel jPanel = null; |
||
63 | private JLabel jLabel5 = null; |
||
64 | private JTextField txtName = null; |
||
65 | //private JCheckBox chbPixels = null;
|
||
66 | private JRadioButton rbMapUnits = null; |
||
67 | private JRadioButton rbPixels = null; |
||
68 | private boolean isOk=false; |
||
69 | /**
|
||
70 | * This is the default constructor
|
||
71 | */
|
||
72 | // public MappingFieldsToAnotation(FLyrAnnotation la) {
|
||
73 | // super();
|
||
74 | // this.la=la;
|
||
75 | // try {
|
||
76 | // this.sds=la.getRecordset();
|
||
77 | // initialize();
|
||
78 | // } catch (ReadDriverException e) {
|
||
79 | // e.printStackTrace();
|
||
80 | // }
|
||
81 | //
|
||
82 | // }
|
||
83 | |||
84 | /**
|
||
85 | * This method initializes this
|
||
86 | *
|
||
87 | * @return void
|
||
88 | */
|
||
89 | private void initialize() { |
||
90 | jLabel4 = new JLabel(); |
||
91 | jLabel4.setBounds(new java.awt.Rectangle(15,259,166,20)); |
||
92 | jLabel4.setText("fuente");
|
||
93 | jLabel3 = new JLabel(); |
||
94 | jLabel3.setBounds(new java.awt.Rectangle(15,197,166,20)); |
||
95 | jLabel3.setText("alto");
|
||
96 | jLabel2 = new JLabel(); |
||
97 | jLabel2.setBounds(new java.awt.Rectangle(15,135,166,20)); |
||
98 | jLabel2.setText("color");
|
||
99 | jLabel1 = new JLabel(); |
||
100 | jLabel1.setBounds(new java.awt.Rectangle(15,73,166,20)); |
||
101 | jLabel1.setText("angulo");
|
||
102 | jLabel = new JLabel(); |
||
103 | jLabel.setBounds(new java.awt.Rectangle(15,11,166,20)); |
||
104 | jLabel.setText("texto");
|
||
105 | this.setLayout(null); |
||
106 | this.setSize(544, 368); |
||
107 | this.add(getCmbText(), null); |
||
108 | this.add(getCmbAngle(), null); |
||
109 | this.add(jLabel, null); |
||
110 | this.add(jLabel1, null); |
||
111 | this.add(jLabel2, null); |
||
112 | this.add(getCmbColor(), null); |
||
113 | this.add(jLabel3, null); |
||
114 | this.add(getCmbHeight(), null); |
||
115 | this.add(jLabel4, null); |
||
116 | this.add(getCmbFont(), null); |
||
117 | this.add(getBOk(), null); |
||
118 | this.add(getBCancel(), null); |
||
119 | this.add(getJPanel(), null); |
||
120 | } |
||
121 | |||
122 | public WindowInfo getWindowInfo() {
|
||
123 | WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
|
||
124 | m_viewinfo.setTitle(PluginServices.getText(this,
|
||
125 | "indexar_campos"));
|
||
126 | |||
127 | return m_viewinfo;
|
||
128 | } |
||
129 | |||
130 | /**
|
||
131 | * This method initializes cmbOrigin
|
||
132 | *
|
||
133 | * @return javax.swing.JComboBox
|
||
134 | */
|
||
135 | private JComboBox getCmbText() { |
||
136 | if (cmbText == null) { |
||
137 | cmbText = new JComboBox(); |
||
138 | // try {
|
||
139 | // mapText=new int[sds.getFieldCount()];
|
||
140 | // int num=-1;
|
||
141 | // for (int i = 0; i < sds.getFieldCount(); i++) {
|
||
142 | // cmbText.addItem(sds.getFieldName(i));
|
||
143 | // num++;
|
||
144 | // mapText[i]=num;
|
||
145 | // }
|
||
146 | // //cmbText.addItem("- Defaulf -");
|
||
147 | // } catch (ReadDriverException e) {
|
||
148 | // e.printStackTrace();
|
||
149 | // }
|
||
150 | cmbText.setBounds(new java.awt.Rectangle(15,42,166,20)); |
||
151 | |||
152 | } |
||
153 | return cmbText;
|
||
154 | } |
||
155 | |||
156 | /**
|
||
157 | * This method initializes cmbEnd
|
||
158 | *
|
||
159 | * @return javax.swing.JComboBox
|
||
160 | */
|
||
161 | private JComboBox getCmbAngle() { |
||
162 | if (cmbAngle == null) { |
||
163 | cmbAngle = new JComboBox(); |
||
164 | // try {
|
||
165 | // mapAngle=new int[sds.getFieldCount()];
|
||
166 | // int num=-1;
|
||
167 | // for (int i = 0; i < sds.getFieldCount(); i++) {
|
||
168 | // if (sds.getFieldType(i) == Types.DOUBLE){
|
||
169 | // cmbAngle.addItem(sds.getFieldName(i));
|
||
170 | // num++;
|
||
171 | // mapAngle[i]=num;
|
||
172 | // }
|
||
173 | // }
|
||
174 | // cmbAngle.addItem("- Default -");
|
||
175 | // cmbAngle.setSelectedItem("- Default -");
|
||
176 | // } catch (ReadDriverException e) {
|
||
177 | // e.printStackTrace();
|
||
178 | // }
|
||
179 | cmbAngle.setBounds(new java.awt.Rectangle(15,104,166,20)); |
||
180 | } |
||
181 | return cmbAngle;
|
||
182 | } |
||
183 | |||
184 | /**
|
||
185 | * This method initializes cmbColor
|
||
186 | *
|
||
187 | * @return javax.swing.JComboBox
|
||
188 | */
|
||
189 | private JComboBox getCmbColor() { |
||
190 | if (cmbColor == null) { |
||
191 | cmbColor = new JComboBox(); |
||
192 | cmbColor.setBounds(new java.awt.Rectangle(15,166,166,20)); |
||
193 | // try {
|
||
194 | // mapColor=new int[sds.getFieldCount()];
|
||
195 | // int num=-1;
|
||
196 | // for (int i = 0; i < sds.getFieldCount(); i++) {
|
||
197 | // if (sds.getFieldType(i) == Types.DOUBLE){
|
||
198 | // cmbColor.addItem(sds.getFieldName(i));
|
||
199 | // num++;
|
||
200 | // mapColor[i]=num;
|
||
201 | // }
|
||
202 | // }
|
||
203 | // cmbColor.addItem("- Default -");
|
||
204 | // cmbColor.setSelectedItem("- Default -");
|
||
205 | // } catch (ReadDriverException e) {
|
||
206 | // e.printStackTrace();
|
||
207 | // }
|
||
208 | } |
||
209 | return cmbColor;
|
||
210 | } |
||
211 | |||
212 | /**
|
||
213 | * This method initializes cmbHeight
|
||
214 | *
|
||
215 | * @return javax.swing.JComboBox
|
||
216 | */
|
||
217 | private JComboBox getCmbHeight() { |
||
218 | if (cmbHeight == null) { |
||
219 | cmbHeight = new JComboBox(); |
||
220 | // try {
|
||
221 | // mapHeight=new int[sds.getFieldCount()];
|
||
222 | // int num=-1;
|
||
223 | // for (int i = 0; i < sds.getFieldCount(); i++) {
|
||
224 | // if (sds.getFieldType(i) == Types.DOUBLE){
|
||
225 | // cmbHeight.addItem(sds.getFieldName(i));
|
||
226 | // num++;
|
||
227 | // mapHeight[i]=num;
|
||
228 | // }
|
||
229 | // }
|
||
230 | // cmbHeight.addItem("- Default -");
|
||
231 | // cmbHeight.setSelectedItem("- Default -");
|
||
232 | // } catch (ReadDriverException e) {
|
||
233 | // e.printStackTrace();
|
||
234 | // }
|
||
235 | cmbHeight.setBounds(new java.awt.Rectangle(15,228,166,20)); |
||
236 | } |
||
237 | return cmbHeight;
|
||
238 | } |
||
239 | |||
240 | /**
|
||
241 | * This method initializes cmbFont
|
||
242 | *
|
||
243 | * @return javax.swing.JComboBox
|
||
244 | */
|
||
245 | private JComboBox getCmbFont() { |
||
246 | if (cmbFont == null) { |
||
247 | cmbFont = new JComboBox(); |
||
248 | // try {
|
||
249 | // mapFont=new int[sds.getFieldCount()];
|
||
250 | // int num=-1;
|
||
251 | // for (int i = 0; i < sds.getFieldCount(); i++) {
|
||
252 | // if (sds.getFieldType(i) == Types.VARCHAR){
|
||
253 | // cmbFont.addItem(sds.getFieldName(i));
|
||
254 | // num++;
|
||
255 | // mapFont[i]=num;
|
||
256 | // }
|
||
257 | // }
|
||
258 | // cmbFont.addItem("- Default -");
|
||
259 | // cmbFont.setSelectedItem("- Default -");
|
||
260 | // } catch (ReadDriverException e) {
|
||
261 | // e.printStackTrace();
|
||
262 | // }
|
||
263 | cmbFont.setBounds(new java.awt.Rectangle(15,290,166,20)); |
||
264 | } |
||
265 | return cmbFont;
|
||
266 | } |
||
267 | |||
268 | /**
|
||
269 | * This method initializes bOk
|
||
270 | *
|
||
271 | * @return javax.swing.JButton
|
||
272 | */
|
||
273 | private JButton getBOk() { |
||
274 | if (bOk == null) { |
||
275 | bOk = new JButton(); |
||
276 | bOk.setBounds(new java.awt.Rectangle(119,326,92,24)); |
||
277 | bOk.setText("Aceptar");
|
||
278 | bOk.addActionListener(new java.awt.event.ActionListener() {
|
||
279 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
280 | MappingAnnotation mapping=new MappingAnnotation();
|
||
281 | if (getCmbText().getSelectedItem().equals("")) { |
||
282 | mapping.setColumnText(-1);
|
||
283 | } else {
|
||
284 | mapping.setColumnText(mapText[getCmbText().getSelectedIndex()]); |
||
285 | } |
||
286 | if (!getCmbAngle().getSelectedItem().equals("- Default -")) { |
||
287 | mapping.setColumnRotate(mapAngle[getCmbAngle().getSelectedIndex()]); |
||
288 | } |
||
289 | if (!getCmbColor().getSelectedItem().equals("- Default -")) { |
||
290 | mapping.setColumnColor(mapColor[getCmbColor().getSelectedIndex()]); |
||
291 | } |
||
292 | if (!getCmbHeight().getSelectedItem().equals("- Default -")) { |
||
293 | mapping.setColumnHeight(mapHeight[getCmbHeight().getSelectedIndex()]); |
||
294 | } |
||
295 | if (!getCmbFont().getSelectedItem().equals("- Default -")) { |
||
296 | mapping.setColumnTypeFont(mapFont[getCmbFont().getSelectedIndex()]); |
||
297 | } |
||
298 | //Falta el estilo, si es necesario.
|
||
299 | // la.setInPixels(rbPixels.isSelected());
|
||
300 | // la.setMapping(mapping);
|
||
301 | // la.setName(getTxtName().getText());
|
||
302 | isOk=true;
|
||
303 | PluginServices.getMDIManager().closeWindow(MappingFieldsToAnotation.this); |
||
304 | } |
||
305 | }); |
||
306 | } |
||
307 | return bOk;
|
||
308 | } |
||
309 | |||
310 | /**
|
||
311 | * This method initializes bCancel
|
||
312 | *
|
||
313 | * @return javax.swing.JButton
|
||
314 | */
|
||
315 | private JButton getBCancel() { |
||
316 | if (bCancel == null) { |
||
317 | bCancel = new JButton(); |
||
318 | bCancel.setBounds(new java.awt.Rectangle(330,325,93,25)); |
||
319 | bCancel.setText("cancelar");
|
||
320 | bCancel.addActionListener(new java.awt.event.ActionListener() {
|
||
321 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
322 | isOk=false;
|
||
323 | PluginServices.getMDIManager().closeWindow(MappingFieldsToAnotation.this); |
||
324 | } |
||
325 | }); |
||
326 | } |
||
327 | return bCancel;
|
||
328 | } |
||
329 | |||
330 | /**
|
||
331 | * This method initializes jPanel
|
||
332 | *
|
||
333 | * @return javax.swing.JPanel
|
||
334 | */
|
||
335 | private JPanel getJPanel() { |
||
336 | if (jPanel == null) { |
||
337 | jLabel5 = new JLabel(); |
||
338 | jLabel5.setBounds(new java.awt.Rectangle(15,10,228,22)); |
||
339 | jLabel5.setText("nombre");
|
||
340 | jPanel = new JPanel(); |
||
341 | jPanel.setLayout(null);
|
||
342 | jPanel.setBounds(new java.awt.Rectangle(234,14,251,141)); |
||
343 | jPanel.add(jLabel5, null);
|
||
344 | jPanel.add(getTxtName(), null);
|
||
345 | //jPanel.add(getChbPixels(), null);
|
||
346 | jPanel.add(getRbMapUnits(), null);
|
||
347 | jPanel.add(getRbPixels(), null);
|
||
348 | ButtonGroup bg=new ButtonGroup(); |
||
349 | bg.add(getRbMapUnits()); |
||
350 | bg.add(getRbPixels()); |
||
351 | } |
||
352 | return jPanel;
|
||
353 | } |
||
354 | |||
355 | /**
|
||
356 | * This method initializes txtName
|
||
357 | *
|
||
358 | * @return javax.swing.JTextField
|
||
359 | */
|
||
360 | private JTextField getTxtName() { |
||
361 | if (txtName == null) { |
||
362 | txtName = new JTextField(); |
||
363 | //txtName.setText(la.get.getName());
|
||
364 | txtName.setBounds(new java.awt.Rectangle(15,42,227,22)); |
||
365 | } |
||
366 | return txtName;
|
||
367 | } |
||
368 | |||
369 | /**
|
||
370 | * This method initializes chbPixels
|
||
371 | *
|
||
372 | * @return javax.swing.JCheckBox
|
||
373 | */
|
||
374 | /*private JCheckBox getChbPixels() {
|
||
375 | if (chbPixels == null) {
|
||
376 | chbPixels = new JCheckBox();
|
||
377 | chbPixels.setBounds(new java.awt.Rectangle(15,138,226,25));
|
||
378 | chbPixels.setText("pixels");
|
||
379 | }
|
||
380 | return chbPixels;
|
||
381 | }
|
||
382 | */
|
||
383 | /**
|
||
384 | * This method initializes rbMapUnits
|
||
385 | *
|
||
386 | * @return javax.swing.JRadioButton
|
||
387 | */
|
||
388 | private JRadioButton getRbMapUnits() { |
||
389 | if (rbMapUnits == null) { |
||
390 | rbMapUnits = new JRadioButton(); |
||
391 | rbMapUnits.setBounds(new java.awt.Rectangle(15,74,167,22)); |
||
392 | rbMapUnits.setText("unidades_mapa");
|
||
393 | } |
||
394 | return rbMapUnits;
|
||
395 | } |
||
396 | |||
397 | /**
|
||
398 | * This method initializes rbPixels
|
||
399 | *
|
||
400 | * @return javax.swing.JRadioButton
|
||
401 | */
|
||
402 | private JRadioButton getRbPixels() { |
||
403 | if (rbPixels == null) { |
||
404 | rbPixels = new JRadioButton(); |
||
405 | rbPixels.setBounds(new java.awt.Rectangle(15,106,167,22)); |
||
406 | rbPixels.setText("pixels");
|
||
407 | rbPixels.setSelected(true);
|
||
408 | } |
||
409 | return rbPixels;
|
||
410 | } |
||
411 | |||
412 | public boolean isOk() { |
||
413 | return isOk;
|
||
414 | } |
||
415 | |||
416 | public Object getWindowProfile() { |
||
417 | return WindowInfo.DIALOG_PROFILE;
|
||
418 | } |
||
419 | } // @jve:decl-index=0:visual-constraint="-150,10" |