Statistics
| Revision:

svn-gvsig-desktop / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / ui / raster / DataInputProps.java @ 2312

History | View | Annotate | Download (22.9 KB)

1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 * 
4
 * Copyright (C) 2004-5. 
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 2
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 * 
22
 * cresques@gmail.com
23
 */
24
package org.cresques.ui.raster;
25

    
26
import java.awt.BorderLayout;
27
import java.awt.FlowLayout;
28

    
29
import javax.swing.BoxLayout;
30
import javax.swing.JCheckBox;
31
import javax.swing.JComboBox;
32
import javax.swing.JLabel;
33
import javax.swing.JPanel;
34
import javax.swing.JSlider;
35
import javax.swing.JTextField;
36

    
37
import org.cresques.io.CXMLParser;
38
import org.cresques.io.GeoRasterWriter;
39
/*
40
 * Created on 04-mar-2005
41
 *
42
 */
43

    
44
/**
45
 * Panel que contiene las propiedades de un driver de escritura.
46
 * Este panel se monta a partir de un XML que es solicitado al driver
47
 * porque dependiendo del driver tendr? unas propiedades u otras.
48
 * Los elementos del panel son XMLObjects que se almacenan en
49
 * vectores. El XML se procesa con la clase ProcessXML que ser? la
50
 * encargada a partir del texto en XML de crear los XMLObjects que 
51
 * compondran el panel.
52
 * @author Nacho Brodin <brodin_ign@gva.es>
53
 */ 
54
public class DataInputProps extends JPanel{
55

    
56
        private GeoRasterWriter writer = null;
57
        private String formato = null;
58
        private JPanel jPanel = null;
59
        private JPanel panelSup = null;
60
        private JComboBox jComboBox = null;
61
        
62
        private XMLPanel[] panels = null;
63
        private XMLCombo[] combos = null;
64
        private XMLLabel[] labels = null;
65
        private XMLSlider[] sliders = null;
66
        private XMLCheck[] checks = null;
67
        private XMLText[] texts = null;
68
        
69
        public DataInputProps(GeoRasterWriter writer) {
70
                
71
                super();
72
                this.writer = writer;
73
                this.formato = writer.getIdent();
74
                ProcessXML pXML = new ProcessXML(writer.getXMLPropertiesDialog());
75
                panels = pXML.getPanels();
76
                labels = pXML.getLabels();
77
                combos = pXML.getCombos();
78
                sliders = pXML.getSliders();
79
                checks = pXML.getChecks();
80
                texts = pXML.getTexts();
81
                initialize();
82
                addComponents();
83
                //showElements();
84
                
85
        }
86
        
87
        /**
88
         * Inicializa el panel central con los datos del primer panel de la lista
89
         */
90
        private  void initialize() {
91

    
92
                for(int i=0;i<this.panels.length;i++){
93
                        if(i==0){
94
                                if(panels[i].layout.equals("FlowLayout"))
95
                                        this.setLayout(new FlowLayout());
96
                                if(panels[i].layout.equals("BorderLayout"))
97
                                        this.setLayout(new BorderLayout());
98
                                this.setSize(panels[i].sizex, panels[i].sizey);
99
                        }else{
100
                                if(panels[i].position != null && !panels[i].position.equals(""))
101
                                        this.add(panels[i], panels[i].position);
102
                                else 
103
                                        this.add(panels[i]);
104
                        }
105
                        
106
                }
107
                
108
        }
109
        
110
        /**
111
         * A?ade los componentes de los vectores al panel
112
         *
113
         */
114
        public void addComponents(){
115
                                
116
                for(int iPanel=1;iPanel<panels.length;iPanel++){
117
                        int nElemInsert = 0;
118
                        while(nElemInsert<panels[iPanel].nElements){
119
                                
120
                                
121
                                for(int i=0;i<labels.length;i++){
122
                                        if(labels[i].numPanel==iPanel && labels[i].posIntoPanel==nElemInsert){
123
                                                if(labels[i].position != null && !labels[i].position.equals(""))
124
                                                        panels[iPanel].add(labels[i], labels[i].position);
125
                                                else 
126
                                                        panels[iPanel].add(labels[i]);
127
                                                nElemInsert++;
128
                                        }
129
                                }//for(int i=0;i<labels.length;i++)
130
                                
131
                                for(int i=0;i<combos.length;i++){
132
                                        if(combos[i].numPanel==iPanel && combos[i].posIntoPanel==nElemInsert){
133
                                                if(combos[i].position != null && !combos[i].position.equals(""))
134
                                                        panels[iPanel].add(combos[i], combos[i].position);
135
                                                else 
136
                                                        panels[iPanel].add(combos[i]);
137
                                                nElemInsert++;
138
                                        }
139
                                }//for(int i=0;i<combos.length;i++)
140
                                
141
                                for(int i=0;i<sliders.length;i++){
142
                                        if(sliders[i].numPanel==iPanel && sliders[i].posIntoPanel==nElemInsert){
143
                                                if(sliders[i].position != null && !sliders[i].position.equals(""))
144
                                                        panels[iPanel].add(sliders[i], sliders[i].position);
145
                                                else 
146
                                                        panels[iPanel].add(sliders[i]);
147
                                                nElemInsert++;
148
                                        }
149
                                }//for(int i=0;i<sliders.length;i++)
150
                                
151
                                for(int i=0;i<checks.length;i++){
152
                                        if(checks[i].numPanel==iPanel && checks[i].posIntoPanel==nElemInsert){
153
                                                if(checks[i].position != null && !checks[i].position.equals(""))
154
                                                        panels[iPanel].add(checks[i], checks[i].position);
155
                                                else 
156
                                                        panels[iPanel].add(checks[i]);
157
                                                nElemInsert++;
158
                                        }
159
                                }//for(int i=0;i<checks.length;i++)
160
                                
161
                                for(int i=0;i<texts.length;i++){
162
                                        if(texts[i].numPanel==iPanel && texts[i].posIntoPanel==nElemInsert){
163
                                                if(texts[i].position != null && !texts[i].position.equals(""))
164
                                                        panels[iPanel].add(texts[i], texts[i].position);
165
                                                else 
166
                                                        panels[iPanel].add(texts[i]);
167
                                                nElemInsert++;
168
                                        }
169
                                }//for(int i=0;i<checks.length;i++)
170
                                
171
                        }//while(nElemInsert<panels[iPanel].nElements)
172
                        
173
                        
174
                }//for(int iPanel=1;iPanel<panels.length;iPanel++)
175
        }
176

    
177
        /**
178
         * Obtiene el n?mero de componentes que recogen propiedades
179
         * para el driver cargado
180
         * @return        N?mero de componentes
181
         */
182
        public int getNElements(){
183
                
184
                return (combos.length + sliders.length + checks.length + texts.length);
185
                
186
        }
187
        
188
        /**
189
         * Obtiene los identificadores de las propiedades del cuadro de dialogo
190
         * @return        Lista con los identificadores de propiedades
191
         */
192
        public String[] getElements(){
193
                
194
                String[] lista = new String[this.getNElements()];
195
                for(int i=0;i<combos.length;i++)
196
                        lista[i] = combos[i].id+"="+combos[i].getSelectedItem().toString();
197
                for(int i=0;i<sliders.length;i++)
198
                        lista[combos.length+i] = sliders[i].id+"="+sliders[i].getSlider().getValue();
199
                for(int i=0;i<checks.length;i++){
200
                        String sel = null;
201
                        if(checks[i].isSelected())
202
                                sel = new String("yes");
203
                        else
204
                                sel = new String("no");
205
                        lista[combos.length+sliders.length+i] = checks[i].id+"="+sel;
206
                }
207
                for(int i=0;i<texts.length;i++)
208
                        lista[i] = texts[i].id+"="+texts[i].getText();
209
                return lista;
210
                
211
        }
212
        
213
        /**
214
         * Obtiene la lista de Combos
215
         * @return XMLCombo[]
216
         */
217
        public XMLCombo[] getCombos(){return combos;}
218
        
219
        /**
220
         * Obtiene la lista de Sliders
221
         * @return XMLSlider[]
222
         */
223
        public XMLSlider[] getSliders(){return sliders;}
224
        
225
        /**
226
         * Obtiene la lista de CheckBoxs
227
         * @return XMLCheck[]
228
         */
229
        public XMLCheck[] getChecks(){return checks;}
230
        
231
        /**
232
         * Muestra informaci?n sobre los elementos a?adidos al panel
233
         *
234
         */
235
        public void showElements(){
236
                
237
                for(int i=0;i<panels.length;i++)
238
                        System.out.println("PANEL "+i+" NElem="+panels[i].nElements);
239
                for(int i=0;i<labels.length;i++)
240
                        System.out.println("LABEL "+i+" Panel="+labels[i].numPanel+" PosIntoPanel="+labels[i].posIntoPanel);
241
                for(int i=0;i<combos.length;i++)
242
                        System.out.println("COMBO "+i+" Panel="+combos[i].numPanel+" PosIntoPanel="+combos[i].posIntoPanel);
243
                for(int i=0;i<checks.length;i++)
244
                        System.out.println("CHECK "+i+" Panel="+checks[i].numPanel+" PosIntoPanel="+checks[i].posIntoPanel);
245
                for(int i=0;i<sliders.length;i++)
246
                        System.out.println("SLIDER "+i+" Panel="+sliders[i].numPanel+" PosIntoPanel="+sliders[i].posIntoPanel);
247
                
248
        }
249
        
250
 }
251

    
252

    
253
/**
254
 * Clase para procesar el XML que manda un driver de escritura y
255
 * que corresponde a la ventana de dialogo para las propiedades del mismo.
256
 * 
257
 * @author Nacho Brodin <brodin_ign@gva.es>
258
 *
259
 */
260
class ProcessXML {
261
        
262
        private XMLPanel[] panels = null;
263
        private XMLCombo[] combos = null;
264
        private XMLLabel[] labels = null;
265
        private XMLSlider[] sliders = null;
266
        private XMLCheck[] checks = null;
267
        private XMLText[] texts = null;
268
        private int contPanels = 0;
269
        private int contCombos = 0;
270
        private int contLabels = 0;
271
        private int contSliders = 0;
272
        private int contChecks = 0;
273
        private int contTexts = 0;
274
        
275
        /**
276
         * Constructor
277
         * @param XML        XML correspondiente a la ventana de dialogo
278
         */
279
        public ProcessXML(String XML) {
280
                
281
                CXMLParser parser = new CXMLParser(XML);
282
                
283
                //Reservamos memoria para el n?mero de paneles
284

    
285
                panels = new XMLPanel[parser.getNumTags("panel")];
286
                combos = new XMLCombo[parser.getNumTags("combo")];
287
                labels = new XMLLabel[parser.getNumTags("label")];
288
                sliders = new XMLSlider[parser.getNumTags("slider")];
289
                checks = new XMLCheck[parser.getNumTags("check")];
290
                texts = new XMLText[parser.getNumTags("text")];
291
                                                                
292
                String valor = parser.getValue("window",true);
293
                 
294
                 while(!valor.equals("")){
295
                         String tag = parser.getTag();
296
                         
297
                        if(tag.equals("panel"))
298
                                processPanel(parser);
299
                        else if(tag.equals("label"))
300
                                processLabel(parser);
301
                        else if(tag.equals("combo"))
302
                                processCombo(parser);
303
                        else if(tag.equals("check"))
304
                                processCheck(parser);
305
                        else if(tag.equals("slider"))
306
                                processSlider(parser);
307
                        else if(tag.equals("text"))
308
                                processText(parser);
309
                         else if(tag.equals(""))
310
                                valor=new String("");
311
                        else
312
                                valor = parser.getXML();        
313
                 }
314
                 
315
                 if(!valor.equals(""))
316
                         System.err.println("Se ha interrumpido el proceso!!!");
317
                 
318
        }
319
        
320
        /**
321
         * Obtiene los paneles leidos del XML como objetos XMLPanel
322
         * @return        Listado de XMLPanel
323
         */
324
        public XMLPanel[] getPanels(){return panels;}
325
        
326
        /**
327
         * Obtiene los combos leidos del XML como objetos XMLCombo
328
         * @return        Listado de XMLCombo
329
         */
330
        public XMLCombo[] getCombos(){return combos;}
331
        
332
        /**
333
         * Obtiene los label leidos del XML como objetos XMLLabel
334
         * @return        Listado de XMLLabel
335
         */
336
        public XMLLabel[] getLabels(){return labels;}
337
        
338
        /**
339
         * Obtiene los slider leidos del XML como objetos XMLSlider
340
         * @return        Listado de XMLSlider
341
         */
342
        public XMLSlider[] getSliders(){return sliders;}
343
        
344
        /**
345
         * Obtiene los checks leidos del XML como objetos XMLCheks
346
         * @return        Listado de XMLCheck
347
         */
348
        public XMLCheck[] getChecks(){return checks;}
349
        
350
        /**
351
         * Obtiene los texts leidos del XML como objetos XMLText
352
         * @return        Listado de XMLText
353
         */
354
        public XMLText[] getTexts(){return texts;}
355
        
356
        /**
357
         * Procesa un tag panel
358
         * @param parser        Objeto parser con el XML
359
         */
360
    public void processPanel(CXMLParser parser){
361

    
362
                panels[contPanels] = new XMLPanel();
363
                String sizex = parser.getAttr("panel","sizex");
364
                String sizey = parser.getAttr("panel","sizey");
365
                if(sizex!=null && !sizex.equals(""))
366
                        panels[contPanels].sizex = Integer.parseInt(sizex);
367
                if(sizey!=null && !sizey.equals(""))
368
                        panels[contPanels].sizey = Integer.parseInt(sizey);
369
                panels[contPanels].layout = parser.getAttr("panel","layout");
370
                panels[contPanels].border = parser.getAttr("panel","border");
371
                panels[contPanels].position = parser.getAttr("panel","position");
372
                panels[contPanels].align = parser.getAttr("panel","align");                
373
                panels[contPanels].init();
374
                contPanels++;
375
                
376
                //System.out.println("PANEL="+sizex+"X"+sizey+" Layout="+layout+" Border="+border+" Pos="+position+" Align="+align);
377
                parser.getValue("panel",true);
378
                
379
        }
380
        
381
    /**
382
         * Procesa un tag label
383
         * @param parser        Objeto parser con el XML
384
         */
385
        public void processLabel(CXMLParser parser){
386
             
387
                     labels[contLabels] = new XMLLabel();
388
                     
389
                     //Posicionamiento. En q panel y su posici?n dentro de este
390
                     labels[contLabels].numPanel = contPanels-1;
391
                     panels[contPanels-1].nElements++;
392
                     labels[contLabels].posIntoPanel = panels[contPanels-1].nElements-1;
393
                     
394
                     labels[contLabels].position = parser.getAttr("label","position");
395
                     labels[contLabels].text = parser.getValue("label",true);
396
                     labels[contLabels].init();
397
                     contLabels++;
398
                
399
        }
400
        
401
        /**
402
         * Procesa un tag combo
403
         * @param parser        Objeto parser con el XML
404
         */     
405
        public void processCombo(CXMLParser parser){
406
                     
407
                        combos[contCombos] = new XMLCombo();
408
                        
409
                        //Posicionamiento. En q panel y su posici?n dentro de este
410
                        combos[contCombos].numPanel = contPanels-1;
411
                     panels[contPanels-1].nElements++;
412
                     combos[contCombos].posIntoPanel = panels[contPanels-1].nElements-1;
413
                     
414
                     combos[contCombos].selected = parser.getAttr("combo","selected");
415
                     combos[contCombos].position = parser.getAttr("combo","position");
416
                     combos[contCombos].id = parser.getAttr("combo","ident");
417
                     String sizex = parser.getAttr("combo","sizex");
418
                     String sizey = parser.getAttr("combo","sizey");
419
                     if(sizex!=null && !sizex.equals(""))
420
                             combos[contCombos].sizex = Integer.parseInt(sizex);
421
                     if(sizey!=null && !sizey.equals(""))
422
                             combos[contCombos].sizey = Integer.parseInt(sizey); 
423
                     String valoresCombo = parser.getValue("combo",true);
424
                     
425
                     processComboValues(parser, combos[contCombos]);
426
                     combos[contCombos].init();
427
                     contCombos++;
428
                     
429
        }
430
        
431
        /**
432
         * Procesa los elementos de un combo
433
         * @param parser        Objeto parser con el XML
434
         * @param combo        Objeto XMLCombo del cual se procesan los elementos
435
         */
436
        public void processComboValues(CXMLParser parser, XMLCombo combo){
437
                     
438
                     String elem = parser.getValue("elem",true);
439
                     if(elem!=null)
440
                             combo.addItem(elem);
441
                                
442
                     if(parser.getTag().equals("elem"))
443
                             processComboValues(parser, combo);
444
                     
445
        }
446
        
447
        /**
448
         * Procesa un tag check
449
         * @param parser        Objeto parser con el XML
450
         */     
451
        public void processCheck(CXMLParser parser){
452
                     
453
                        String select = parser.getAttr("check","selected");
454
                        
455
                        if(select.equals("yes"))
456
                                checks[contChecks] = new XMLCheck(parser.getAttr("check","text"), true);
457
                        else
458
                                checks[contChecks] = new XMLCheck(parser.getAttr("check","text"), false);
459
                        checks[contChecks].position = parser.getAttr("check","position");
460
                        checks[contChecks].id = parser.getAttr("check","ident");
461
                        String sizex = parser.getAttr("check","sizex");
462
                     String sizey = parser.getAttr("check","sizey");
463
                     if(sizex!=null && !sizex.equals(""))
464
                             checks[contChecks].sizex = Integer.parseInt(sizex);
465
                     if(sizey!=null && !sizey.equals(""))
466
                             checks[contChecks].sizey = Integer.parseInt(sizey); 
467
                     
468

    
469
                     parser.getValue("check",true);
470
                                           
471
                        //Posicionamiento. En q panel y su posici?n dentro de este
472
                        checks[contChecks].numPanel = contPanels-1;
473
                     panels[contPanels-1].nElements++;
474
                     checks[contChecks].posIntoPanel = panels[contPanels-1].nElements-1;
475
                     
476
                     checks[contChecks].init();
477
                     contChecks++;
478
                     
479
         }
480
             
481
        /**
482
         * Procesa un tag slider
483
         * @param parser        Objeto parser con el XML
484
         */               
485
         public void processSlider(CXMLParser parser){
486
                     
487
                          String min = null;
488
                          String max = null;
489
                          String value = null;
490
                          String minorspacing = null;
491
                          String majorspacing = null;
492
                     String name = parser.getAttr("slider","name");
493
                     String id = parser.getAttr("slider","ident");
494
                     String position = parser.getAttr("slider","position");
495
                     String sizex = parser.getAttr("slider","sizex");
496
                        String sizey = parser.getAttr("slider","sizey");
497
                     String elem = parser.getValue("slider",true);
498
                                     
499
                        String tag = parser.getTag();
500
                        while(        tag.equals("min") || 
501
                                tag.equals("max") || 
502
                                tag.equals("value") || 
503
                                tag.equals("minorspacing") ||
504
                                tag.equals("majorspacing")){
505
                                if(tag.equals("min"))
506
                                        min = parser.getValue("min",true);
507
                                if(tag.equals("max"))
508
                                        max = parser.getValue("max",true);
509
                                if(tag.equals("value"))
510
                                        value = parser.getValue("value",true);
511
                                if(tag.equals("minorspacing"))
512
                                        minorspacing = parser.getValue("minorspacing",true);
513
                                if(tag.equals("majorspacing"))
514
                                        majorspacing = parser.getValue("majorspacing",true);
515
                                tag = parser.getTag();                
516
                        }
517
                        
518
                        sliders[contSliders] = new XMLSlider(        name,
519
                                                                                                        min,
520
                                                                                                        max,
521
                                                                                                        value,
522
                                                                                                        minorspacing,
523
                                                                                                        majorspacing);
524
                        sliders[contSliders].position = position;
525
                        sliders[contSliders].id = id;
526
                        
527
                        if(sizex!=null && !sizex.equals(""))
528
                                sliders[contSliders].sizex = Integer.parseInt(sizex);
529
                        if(sizey!=null && !sizey.equals(""))
530
                                sliders[contSliders].sizey = Integer.parseInt(sizey);
531
        
532
                        //Posicionamiento. En q panel y su posici?n dentro de este
533
                        sliders[contSliders].numPanel = contPanels-1;
534
                     panels[contPanels-1].nElements++;
535
                     sliders[contSliders].posIntoPanel = panels[contPanels-1].nElements-1;
536
                     
537
                     contSliders++;
538
                        
539
         }
540
         
541
         /**
542
         * Procesa un tag text
543
         * @param parser        Objeto parser con el XML
544
         */               
545
        public void processText(CXMLParser parser){
546
                
547
                texts[contTexts] = new XMLText(parser.getAttr("text","text"));
548
                
549
                String sizex = parser.getAttr("text","sizex");
550
                String sizey = parser.getAttr("text","sizey");
551
                if(sizex!=null && !sizex.equals(""))
552
                        texts[contTexts].sizex = Integer.parseInt(sizex);
553
                if(sizey!=null && !sizey.equals(""))
554
                        texts[contTexts].sizey = Integer.parseInt(sizey);
555
                
556
             //Posicionamiento. En q panel y su posici?n dentro de este
557
             texts[contTexts].numPanel = contPanels-1;
558
             panels[contPanels-1].nElements++;
559
             texts[contTexts].posIntoPanel = panels[contPanels-1].nElements-1;
560
             
561
             texts[contTexts].position = parser.getAttr("text","position");
562
             texts[contTexts].text = parser.getValue("text",true);
563
             texts[contTexts].init();
564
             contTexts++;
565
             
566
        }
567
        
568
}
569

    
570
/**
571
 * Clase que representa a un panel obtenido a partir del XML
572
 * que manda un driver de escritura.
573
 * 
574
 * @author Nacho Brodin <brodin_ign@gva.es>
575
 *
576
 */
577
class XMLPanel extends JPanel{
578
        
579
        public int                         sizex = 0;
580
        public int                         sizey = 0;
581
        public String                 layout = null;
582
        public String                 border = null;
583
        public String                 position = null;
584
        public String                 align = null;
585
        public int                         nElements = 0;
586
        
587
        /**
588
         * Inicializaci?n del XMLPanel
589
         *
590
         */
591
        public void init(){
592
                
593
                if(layout.equals("FlowLayout")){
594
                        FlowLayout fl = new FlowLayout();
595
                        this.setLayout(fl);
596
                        if(align.equals("left"))
597
                                fl.setAlignment(java.awt.FlowLayout.LEFT);
598
                        else if(align.equals("center"))
599
                                fl.setAlignment(java.awt.FlowLayout.CENTER);
600
                        else if(align.equals("right"))
601
                                fl.setAlignment(java.awt.FlowLayout.RIGHT);
602
                        else if(align.equals("leading"))
603
                                fl.setAlignment(java.awt.FlowLayout.LEADING);
604
                        else if(align.equals("trailing"))
605
                                fl.setAlignment(java.awt.FlowLayout.TRAILING);
606
                }
607
                else if(layout.equals("BorderLayout"))
608
                        this.setLayout(new BorderLayout());
609
                
610
                if(sizex!=0 && sizey!=0)
611
                        this.setPreferredSize(new java.awt.Dimension(sizex,sizey));
612
                
613
                if(border.equals("yes"))
614
                        this.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray,1));
615
                
616
        }
617
        
618
}
619

    
620
/**
621
 * Clase que representa a un combo obtenido a partir del XML
622
 * que manda un driver de escritura.
623
 * 
624
 * @author Nacho Brodin <brodin_ign@gva.es>
625
 *
626
 */
627
class XMLCombo extends JComboBox{
628
        
629
        public int                         numPanel = -1;
630
        public int                         posIntoPanel = -1;
631
        public String                 position = null;
632
        public String                 selected = null;
633
        public int                         sizex = 0;
634
        public int                         sizey = 0;
635
        public String                id = null;
636

    
637
        /**
638
         * Inicializaci?n del XMLCombo
639
         */
640
        public void init(){
641
                
642
                if(sizex!=0 && sizey!=0)
643
                        this.setPreferredSize(new java.awt.Dimension(sizex,sizey));
644
                if(selected!=null)
645
                        this.setSelectedItem(selected);
646
                
647
        }
648
}
649

    
650
/**
651
 * Clase que representa a un label obtenido a partir del XML
652
 * que manda un driver de escritura.
653
 * 
654
 * @author Nacho Brodin <brodin_ign@gva.es>
655
 *
656
 */
657
class XMLLabel extends JLabel{
658
        
659
        public int                         numPanel = -1;
660
        public int                         posIntoPanel = -1;
661
        public String                 position = null;
662
        public String                 text = null;
663
        
664
        /**
665
         * Inicializaci?n del XMLLabel
666
         */
667
        public void init(){
668
                
669
                this.setText(text);
670
                
671
        }
672
}
673

    
674
/**
675
 * Clase que representa a un slider obtenido a partir del XML
676
 * que manda un driver de escritura.
677
 * 
678
 * @author Nacho Brodin <brodin_ign@gva.es>
679
 *
680
 */
681
class XMLSlider extends JPanel{
682
        
683
        public int                        numPanel = -1;
684
        public int                         posIntoPanel = -1;
685
        public int                         sizex = 0;
686
        public int                         sizey = 0;
687
        public String                 position = null;
688
        private JSlider         slider = null;
689
        private JLabel                 label = null;
690
        public String                id = null;
691
        
692
        /**
693
         * Constructor
694
         * @param text        Texto de la barra
695
         * @param smin        Valor m?nimo de la barra
696
         * @param smax        Valor m?ximo de la barra
697
         * @param sdefaultValue        Valor por defecto de la barra.
698
         * @param sminor        Separaci?n menor de las secciones de la barra
699
         * @param smajor        Separaci?n mayor de las secciones de la barra
700
         */
701
        public XMLSlider(        String text, 
702
                                                String smin, 
703
                                                String smax, 
704
                                                String sdefaultValue, 
705
                                                String sminor, 
706
                                                String smajor){
707
                 
708
                         int min = 0;
709
                         int max = 100;
710
                         int defaultValue = 0;
711
                         int minor = 5;
712
                         int major = 10;
713
                         
714
                         //Obtenemos los valores de los par?metros
715
                         if(smin!=null)
716
                                 min = Integer.parseInt(smin);
717
                         if(smax!=null)
718
                                 max = Integer.parseInt(smax);
719
                         if(sdefaultValue!=null)
720
                                 defaultValue = Integer.parseInt(sdefaultValue);
721
                         if(sminor!=null)
722
                                 minor = Integer.parseInt(sminor);
723
                         if(smajor!=null)
724
                                 major = Integer.parseInt(smajor);
725
                         
726
                         //Colocaci?n de elementos en el panel
727
                          label = new JLabel(text, JLabel.CENTER);
728
                         slider = new JSlider(JSlider.HORIZONTAL, min, max, defaultValue);
729
                         slider.setMajorTickSpacing(major);
730
                     slider.setMinorTickSpacing(minor);
731
                         slider.setPaintTicks(true);
732
                         slider.setPaintLabels(true);
733
                         this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
734
                         this.add(label);
735
                     this.add(slider);
736
                     if(sizex!=0 && sizey!=0)
737
                             this.setPreferredSize(new java.awt.Dimension(sizex, sizey));
738
                     
739
                         
740
    }
741
        
742
        /**
743
         * Obtiene la barra 
744
         * @return        Objeto JSlider
745
         */
746
        public JSlider getSlider(){return slider;}
747
        
748
}
749

    
750
/**
751
 * Clase que representa a un checkbox obtenido a partir del XML
752
 * que manda un driver de escritura.
753
 * 
754
 * @author Nacho Brodin <brodin_ign@gva.es>
755
 *
756
 */
757
class XMLCheck extends JCheckBox{
758
        
759
        public int                         numPanel = -1;
760
        public int                         posIntoPanel = -1;
761
        public String                 position = null;
762
        public String                 selected = null;
763
        public int                         sizex = 0;
764
        public int                         sizey = 0;
765
        public String                text = null;
766
        public String                id = null;
767
        
768
        /**
769
         * Contructor
770
         * @param text        texto del checkbox
771
         * @param select        true si esta seleccionado y false si no lo est?.
772
         */
773
        public XMLCheck(String text, boolean select){
774
                
775
                super(text, select);
776
                this.text = text;
777
                if(select)
778
                        selected = new String("yes");
779
                else
780
                        selected = new String("no");
781
                
782
        }
783
        
784
        /**
785
         * Inicializaci?n del XMLCheck
786
         */
787
        public void init(){
788
                
789
                if(sizex!=0 && sizey!=0)
790
                        this.setPreferredSize(new java.awt.Dimension(sizex,sizey));
791
                
792
        }
793
}
794

    
795

    
796
/**
797
 * Clase que representa a un textfield obtenido a partir del XML
798
 * que manda un driver de escritura.
799
 * 
800
 * @author Nacho Brodin <brodin_ign@gva.es>
801
 *
802
 */
803
class XMLText extends JTextField{
804
        
805
        public int                         numPanel = -1;
806
        public int                         posIntoPanel = -1;
807
        public String                 position = null;
808
        public String                 selected = null;
809
        public int                         sizex = 0;
810
        public int                         sizey = 0;
811
        public String                text = null;
812
        public String                id = null;
813
        
814
        /**
815
         * Contructor
816
         * @param text        texto del textfield
817
         */
818
        public XMLText(String text){
819
                
820
                super(text);
821
                this.text = text;
822
                        
823
        }
824
        
825
        /**
826
         * Inicializaci?n del XMLCheck
827
         */
828
        public void init(){
829
                
830
                if(sizex!=0 && sizey!=0)
831
                        this.setPreferredSize(new java.awt.Dimension(sizex,sizey));
832
                                
833
        }
834
}