Statistics
| Revision:

root / tags / v2_0_0_Build_2050 / applications / appgvSIG / src / org / gvsig / app / gui / panels / MappingFieldsToAnotation.java @ 38653

History | View | Annotate | Download (10.2 KB)

1
package org.gvsig.app.gui.panels;
2

    
3
import javax.swing.ButtonGroup;
4
import javax.swing.JButton;
5
import javax.swing.JComboBox;
6
import javax.swing.JLabel;
7
import javax.swing.JPanel;
8
import javax.swing.JRadioButton;
9
import javax.swing.JTextField;
10

    
11
import org.gvsig.andami.PluginServices;
12
import org.gvsig.andami.ui.mdiManager.IWindow;
13
import org.gvsig.andami.ui.mdiManager.WindowInfo;
14
import org.gvsig.fmap.mapcontext.layers.MappingAnnotation;
15

    
16

    
17
//TODO comentado para que compile
18
public class MappingFieldsToAnotation extends JPanel implements IWindow{
19

    
20
        private JComboBox cmbText = null;
21
        private JComboBox cmbAngle = null;
22
        private JLabel jLabel = null;
23
        private JLabel jLabel1 = null;
24
        private JLabel jLabel2 = null;
25
        private JComboBox cmbColor = null;
26
        private JLabel jLabel3 = null;
27
        private JComboBox cmbHeight = null;
28
        private JLabel jLabel4 = null;
29
        private JComboBox cmbFont = null;
30
        private JButton bOk = null;
31
        private JButton bCancel = null;
32
//        private SelectableDataSource sds=null;
33
//        private FLyrAnnotation la;
34
        private int[] mapText;
35
        private int[] mapAngle;
36
        private int[] mapColor;
37
        private int[] mapHeight;
38
        private int[] mapFont;
39
        private JPanel jPanel = null;
40
        private JLabel jLabel5 = null;
41
        private JTextField txtName = null;
42
        //private JCheckBox chbPixels = null;
43
        private JRadioButton rbMapUnits = null;
44
        private JRadioButton rbPixels = null;
45
        private boolean isOk=false;
46
        /**
47
         * This is the default constructor
48
         */
49
//        public MappingFieldsToAnotation(FLyrAnnotation la) {
50
//                super();
51
//                this.la=la;
52
//                try {
53
//                        this.sds=la.getRecordset();
54
//                        initialize();
55
//                } catch (ReadDriverException e) {
56
//                        e.printStackTrace();
57
//                }
58
//
59
//        }
60

    
61
        /**
62
         * This method initializes this
63
         *
64
         * @return void
65
         */
66
        private void initialize() {
67
                jLabel4 = new JLabel();
68
                jLabel4.setBounds(new java.awt.Rectangle(15,259,166,20));
69
                jLabel4.setText("fuente");
70
                jLabel3 = new JLabel();
71
                jLabel3.setBounds(new java.awt.Rectangle(15,197,166,20));
72
                jLabel3.setText("alto");
73
                jLabel2 = new JLabel();
74
                jLabel2.setBounds(new java.awt.Rectangle(15,135,166,20));
75
                jLabel2.setText("color");
76
                jLabel1 = new JLabel();
77
                jLabel1.setBounds(new java.awt.Rectangle(15,73,166,20));
78
                jLabel1.setText("angulo");
79
                jLabel = new JLabel();
80
                jLabel.setBounds(new java.awt.Rectangle(15,11,166,20));
81
                jLabel.setText("texto");
82
                this.setLayout(null);
83
                this.setSize(544, 368);
84
                this.add(getCmbText(), null);
85
                this.add(getCmbAngle(), null);
86
                this.add(jLabel, null);
87
                this.add(jLabel1, null);
88
                this.add(jLabel2, null);
89
                this.add(getCmbColor(), null);
90
                this.add(jLabel3, null);
91
                this.add(getCmbHeight(), null);
92
                this.add(jLabel4, null);
93
                this.add(getCmbFont(), null);
94
                this.add(getBOk(), null);
95
                this.add(getBCancel(), null);
96
                this.add(getJPanel(), null);
97
        }
98

    
99
        public WindowInfo getWindowInfo() {
100
                WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
101
                m_viewinfo.setTitle(PluginServices.getText(this,
102
                                "indexar_campos"));
103

    
104
                return m_viewinfo;
105
        }
106

    
107
        /**
108
         * This method initializes cmbOrigin
109
         *
110
         * @return javax.swing.JComboBox
111
         */
112
        private JComboBox getCmbText() {
113
                if (cmbText == null) {
114
                        cmbText = new JComboBox();
115
//                        try {
116
//                                mapText=new int[sds.getFieldCount()];
117
//                                int num=-1;
118
//                                for (int i = 0; i < sds.getFieldCount(); i++) {
119
//                                        cmbText.addItem(sds.getFieldName(i));
120
//                                        num++;
121
//                                        mapText[i]=num;
122
//                                }
123
//                                //cmbText.addItem("- Defaulf -");
124
//                        } catch (ReadDriverException e) {
125
//                                e.printStackTrace();
126
//                        }
127
                        cmbText.setBounds(new java.awt.Rectangle(15,42,166,20));
128

    
129
                }
130
                return cmbText;
131
        }
132

    
133
        /**
134
         * This method initializes cmbEnd
135
         *
136
         * @return javax.swing.JComboBox
137
         */
138
        private JComboBox getCmbAngle() {
139
                if (cmbAngle == null) {
140
                        cmbAngle = new JComboBox();
141
//                        try {
142
//                                mapAngle=new int[sds.getFieldCount()];
143
//                                int num=-1;
144
//                        for (int i = 0; i < sds.getFieldCount(); i++) {
145
//                                if (sds.getFieldType(i) == Types.DOUBLE){
146
//                                        cmbAngle.addItem(sds.getFieldName(i));
147
//                                        num++;
148
//                                        mapAngle[i]=num;
149
//                                }
150
//                        }
151
//                        cmbAngle.addItem("- Default -");
152
//                        cmbAngle.setSelectedItem("- Default -");
153
//                        } catch (ReadDriverException e) {
154
//                                e.printStackTrace();
155
//                        }
156
                        cmbAngle.setBounds(new java.awt.Rectangle(15,104,166,20));
157
                }
158
                return cmbAngle;
159
        }
160

    
161
        /**
162
         * This method initializes cmbColor
163
         *
164
         * @return javax.swing.JComboBox
165
         */
166
        private JComboBox getCmbColor() {
167
                if (cmbColor == null) {
168
                        cmbColor = new JComboBox();
169
                        cmbColor.setBounds(new java.awt.Rectangle(15,166,166,20));
170
//                        try {
171
//                                mapColor=new int[sds.getFieldCount()];
172
//                                int num=-1;
173
//                                for (int i = 0; i < sds.getFieldCount(); i++) {
174
//                                        if (sds.getFieldType(i) == Types.DOUBLE){
175
//                                                cmbColor.addItem(sds.getFieldName(i));
176
//                                                num++;
177
//                                                mapColor[i]=num;
178
//                                        }
179
//                                }
180
//                                cmbColor.addItem("- Default -");
181
//                                cmbColor.setSelectedItem("- Default -");
182
//                        } catch (ReadDriverException e) {
183
//                                e.printStackTrace();
184
//                        }
185
                }
186
                return cmbColor;
187
        }
188

    
189
        /**
190
         * This method initializes cmbHeight
191
         *
192
         * @return javax.swing.JComboBox
193
         */
194
        private JComboBox getCmbHeight() {
195
                if (cmbHeight == null) {
196
                        cmbHeight = new JComboBox();
197
//                        try {
198
//                                mapHeight=new int[sds.getFieldCount()];
199
//                                int num=-1;
200
//                                for (int i = 0; i < sds.getFieldCount(); i++) {
201
//                                        if (sds.getFieldType(i) == Types.DOUBLE){
202
//                                                cmbHeight.addItem(sds.getFieldName(i));
203
//                                                num++;
204
//                                                mapHeight[i]=num;
205
//                                        }
206
//                                }
207
//                                cmbHeight.addItem("- Default -");
208
//                                cmbHeight.setSelectedItem("- Default -");
209
//                        } catch (ReadDriverException e) {
210
//                                e.printStackTrace();
211
//                        }
212
                        cmbHeight.setBounds(new java.awt.Rectangle(15,228,166,20));
213
                }
214
                return cmbHeight;
215
        }
216

    
217
        /**
218
         * This method initializes cmbFont
219
         *
220
         * @return javax.swing.JComboBox
221
         */
222
        private JComboBox getCmbFont() {
223
                if (cmbFont == null) {
224
                        cmbFont = new JComboBox();
225
//                        try {
226
//                                mapFont=new int[sds.getFieldCount()];
227
//                                int num=-1;
228
//                                for (int i = 0; i < sds.getFieldCount(); i++) {
229
//                                        if (sds.getFieldType(i) == Types.VARCHAR){
230
//                                                cmbFont.addItem(sds.getFieldName(i));
231
//                                                num++;
232
//                                                mapFont[i]=num;
233
//                                        }
234
//                                }
235
//                                cmbFont.addItem("- Default -");
236
//                                cmbFont.setSelectedItem("- Default -");
237
//                        } catch (ReadDriverException e) {
238
//                                e.printStackTrace();
239
//                        }
240
                        cmbFont.setBounds(new java.awt.Rectangle(15,290,166,20));
241
                }
242
                return cmbFont;
243
        }
244

    
245
        /**
246
         * This method initializes bOk
247
         *
248
         * @return javax.swing.JButton
249
         */
250
        private JButton getBOk() {
251
                if (bOk == null) {
252
                        bOk = new JButton();
253
                        bOk.setBounds(new java.awt.Rectangle(119,326,92,24));
254
                        bOk.setText("Aceptar");
255
                        bOk.addActionListener(new java.awt.event.ActionListener() {
256
                                public void actionPerformed(java.awt.event.ActionEvent e) {
257
                                        MappingAnnotation mapping=new MappingAnnotation();
258
                                        if (getCmbText().getSelectedItem().equals("")) {
259
                                                mapping.setColumnText(-1);
260
                                        } else {
261
                                                mapping.setColumnText(mapText[getCmbText().getSelectedIndex()]);
262
                                        }
263
                                        if (!getCmbAngle().getSelectedItem().equals("- Default -")) {
264
                                                mapping.setColumnRotate(mapAngle[getCmbAngle().getSelectedIndex()]);
265
                                        }
266
                                        if (!getCmbColor().getSelectedItem().equals("- Default -")) {
267
                                                mapping.setColumnColor(mapColor[getCmbColor().getSelectedIndex()]);
268
                                        }
269
                                        if (!getCmbHeight().getSelectedItem().equals("- Default -")) {
270
                                                mapping.setColumnHeight(mapHeight[getCmbHeight().getSelectedIndex()]);
271
                                        }
272
                                        if (!getCmbFont().getSelectedItem().equals("- Default -")) {
273
                                                mapping.setColumnTypeFont(mapFont[getCmbFont().getSelectedIndex()]);
274
                                        }
275
                                        //Falta el estilo, si es necesario.
276
//                                        la.setInPixels(rbPixels.isSelected());
277
//                                        la.setMapping(mapping);
278
//                                        la.setName(getTxtName().getText());
279
                                        isOk=true;
280
                                        PluginServices.getMDIManager().closeWindow(MappingFieldsToAnotation.this);
281
                                }
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
                                        PluginServices.getMDIManager().closeWindow(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
        public boolean isOk() {
390
                return isOk;
391
        }
392

    
393
        public Object getWindowProfile() {
394
                return WindowInfo.DIALOG_PROFILE;
395
        }
396
}  //  @jve:decl-index=0:visual-constraint="-150,10"