Statistics
| Revision:

root / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / ui / raster / DataInputProps.java @ 1739

History | View | Annotate | Download (21.6 KB)

1
package org.cresques.ui.raster;
2

    
3
import javax.swing.JPanel;
4
import java.awt.BorderLayout;
5
import java.awt.Container;
6

    
7
import javax.swing.JLabel;
8
import java.awt.FlowLayout;
9

    
10
import javax.swing.BoxLayout;
11
import javax.swing.JCheckBox;
12
import javax.swing.JScrollPane;
13
import javax.swing.JSlider;
14
import javax.swing.JTextField;
15
import javax.swing.JComboBox;
16
import javax.swing.DefaultComboBoxModel;
17
import javax.swing.plaf.basic.BasicComboBoxEditor;
18

    
19
import java.io.IOException;
20
import java.lang.String;
21
import java.util.Vector;
22

    
23
import javax.swing.JButton;
24

    
25
import org.cresques.io.CXMLParser;
26
import org.cresques.io.GeoRasterFile;
27
import org.cresques.io.GeoRasterWriter;
28
/*
29
 * Created on 04-mar-2005
30
 *
31
 */
32

    
33
/**
34
 * @author Nacho Brodin <brodin_ign@gva.es>
35
 *
36
 */ 
37
public class DataInputProps extends JPanel{
38

    
39
        private GeoRasterWriter writer = null;
40
        private String formato = null;
41
        private JPanel jPanel = null;
42
        private JPanel panelSup = null;
43
        private JComboBox jComboBox = null;
44
        
45
        private XMLPanel[] panels = null;
46
        private XMLCombo[] combos = null;
47
        private XMLLabel[] labels = null;
48
        private XMLSlider[] sliders = null;
49
        private XMLCheck[] checks = null;
50
        private XMLText[] texts = null;
51
        
52
        public DataInputProps(GeoRasterWriter writer) {
53
                super();
54
                this.writer = writer;
55
                this.formato = writer.getIdent();
56
                ProcessXML pXML = new ProcessXML(writer.getXMLPropertiesDialog());
57
                panels = pXML.getPanels();
58
                labels = pXML.getLabels();
59
                combos = pXML.getCombos();
60
                sliders = pXML.getSliders();
61
                checks = pXML.getChecks();
62
                texts = pXML.getTexts();
63
                initialize();
64
                addComponents();
65
                //showElements();
66
                
67
        }
68
        
69
        /**
70
         * Inicializa el panel central con los datos del primer panel de la lista
71
         */
72
        private  void initialize() {
73

    
74
                for(int i=0;i<this.panels.length;i++){
75
                        if(i==0){
76
                                if(panels[i].layout.equals("FlowLayout"))
77
                                        this.setLayout(new FlowLayout());
78
                                if(panels[i].layout.equals("BorderLayout"))
79
                                        this.setLayout(new BorderLayout());
80
                                this.setSize(panels[i].sizex, panels[i].sizey);
81
                        }else{
82
                                if(panels[i].position != null && !panels[i].position.equals(""))
83
                                        this.add(panels[i], panels[i].position);
84
                                else 
85
                                        this.add(panels[i]);
86
                        }
87
                        
88
                }
89
                
90
        }
91
        
92
        public void addComponents(){
93
                                
94
                for(int iPanel=1;iPanel<panels.length;iPanel++){
95
                        int nElemInsert = 0;
96
                        while(nElemInsert<panels[iPanel].nElements){
97
                                
98
                                
99
                                for(int i=0;i<labels.length;i++){
100
                                        if(labels[i].numPanel==iPanel && labels[i].posIntoPanel==nElemInsert){
101
                                                if(labels[i].position != null && !labels[i].position.equals(""))
102
                                                        panels[iPanel].add(labels[i], labels[i].position);
103
                                                else 
104
                                                        panels[iPanel].add(labels[i]);
105
                                                nElemInsert++;
106
                                        }
107
                                }//for(int i=0;i<labels.length;i++)
108
                                
109
                                for(int i=0;i<combos.length;i++){
110
                                        if(combos[i].numPanel==iPanel && combos[i].posIntoPanel==nElemInsert){
111
                                                if(combos[i].position != null && !combos[i].position.equals(""))
112
                                                        panels[iPanel].add(combos[i], combos[i].position);
113
                                                else 
114
                                                        panels[iPanel].add(combos[i]);
115
                                                nElemInsert++;
116
                                        }
117
                                }//for(int i=0;i<combos.length;i++)
118
                                
119
                                for(int i=0;i<sliders.length;i++){
120
                                        if(sliders[i].numPanel==iPanel && sliders[i].posIntoPanel==nElemInsert){
121
                                                if(sliders[i].position != null && !sliders[i].position.equals(""))
122
                                                        panels[iPanel].add(sliders[i], sliders[i].position);
123
                                                else 
124
                                                        panels[iPanel].add(sliders[i]);
125
                                                nElemInsert++;
126
                                        }
127
                                }//for(int i=0;i<sliders.length;i++)
128
                                
129
                                for(int i=0;i<checks.length;i++){
130
                                        if(checks[i].numPanel==iPanel && checks[i].posIntoPanel==nElemInsert){
131
                                                if(checks[i].position != null && !checks[i].position.equals(""))
132
                                                        panels[iPanel].add(checks[i], checks[i].position);
133
                                                else 
134
                                                        panels[iPanel].add(checks[i]);
135
                                                nElemInsert++;
136
                                        }
137
                                }//for(int i=0;i<checks.length;i++)
138
                                
139
                                for(int i=0;i<texts.length;i++){
140
                                        if(texts[i].numPanel==iPanel && texts[i].posIntoPanel==nElemInsert){
141
                                                if(texts[i].position != null && !texts[i].position.equals(""))
142
                                                        panels[iPanel].add(texts[i], texts[i].position);
143
                                                else 
144
                                                        panels[iPanel].add(texts[i]);
145
                                                nElemInsert++;
146
                                        }
147
                                }//for(int i=0;i<checks.length;i++)
148
                                
149
                        }//while(nElemInsert<panels[iPanel].nElements)
150
                        
151
                        
152
                }//for(int iPanel=1;iPanel<panels.length;iPanel++)
153
        }
154

    
155
        /**
156
         * Obtiene el n?mero de componentes que recogen propiedades
157
         * para el driver cargado
158
         * @return        N?mero de componentes
159
         */
160
        public int getNElements(){
161
                return (combos.length + sliders.length + checks.length + texts.length);
162
        }
163
        
164
        /**
165
         * Obtiene los identificadores de las propiedades del cuadro de dialogo
166
         * @return        Lista con los identificadores de propiedades
167
         */
168
        public String[] getElements(){
169
                
170
                String[] lista = new String[this.getNElements()];
171
                for(int i=0;i<combos.length;i++)
172
                        lista[i] = combos[i].id+"="+combos[i].getSelectedItem().toString();
173
                for(int i=0;i<sliders.length;i++)
174
                        lista[combos.length+i] = sliders[i].id+"="+sliders[i].getSlider().getValue();
175
                for(int i=0;i<checks.length;i++){
176
                        String sel = null;
177
                        if(checks[i].isSelected())
178
                                sel = new String("yes");
179
                        else
180
                                sel = new String("no");
181
                        lista[combos.length+sliders.length+i] = checks[i].id+"="+sel;
182
                }
183
                for(int i=0;i<texts.length;i++)
184
                        lista[i] = texts[i].id+"="+texts[i].getText();
185
                return lista;
186
                
187
        }
188
        
189
        public XMLCombo[] getCombos(){return combos;}
190
        public XMLSlider[] getSliders(){return sliders;}
191
        public XMLCheck[] getChecks(){return checks;}
192
        
193
        public void showElements(){
194
                
195
                for(int i=0;i<panels.length;i++)
196
                        System.out.println("PANEL "+i+" NElem="+panels[i].nElements);
197
                for(int i=0;i<labels.length;i++)
198
                        System.out.println("LABEL "+i+" Panel="+labels[i].numPanel+" PosIntoPanel="+labels[i].posIntoPanel);
199
                for(int i=0;i<combos.length;i++)
200
                        System.out.println("COMBO "+i+" Panel="+combos[i].numPanel+" PosIntoPanel="+combos[i].posIntoPanel);
201
                for(int i=0;i<checks.length;i++)
202
                        System.out.println("CHECK "+i+" Panel="+checks[i].numPanel+" PosIntoPanel="+checks[i].posIntoPanel);
203
                for(int i=0;i<sliders.length;i++)
204
                        System.out.println("SLIDER "+i+" Panel="+sliders[i].numPanel+" PosIntoPanel="+sliders[i].posIntoPanel);
205
                
206
        }
207
        
208
 }
209

    
210

    
211
/**
212
 * Clase para procesar el XML que manda un driver de escritura y
213
 * que corresponde a la ventana de dialogo para las propiedades del mismo.
214
 * 
215
 * @author Nacho Brodin <brodin_ign@gva.es>
216
 *
217
 */
218
class ProcessXML {
219
        
220
        private XMLPanel[] panels = null;
221
        private XMLCombo[] combos = null;
222
        private XMLLabel[] labels = null;
223
        private XMLSlider[] sliders = null;
224
        private XMLCheck[] checks = null;
225
        private XMLText[] texts = null;
226
        private int contPanels = 0;
227
        private int contCombos = 0;
228
        private int contLabels = 0;
229
        private int contSliders = 0;
230
        private int contChecks = 0;
231
        private int contTexts = 0;
232
        
233
        /**
234
         * Constructor
235
         * @param XML        XML correspondiente a la ventana de dialogo
236
         */
237
        public ProcessXML(String XML) {
238
                CXMLParser parser = new CXMLParser(XML);
239
                
240
                //Reservamos memoria para el n?mero de paneles
241

    
242
                panels = new XMLPanel[parser.getNumTags("panel")];
243
                combos = new XMLCombo[parser.getNumTags("combo")];
244
                labels = new XMLLabel[parser.getNumTags("label")];
245
                sliders = new XMLSlider[parser.getNumTags("slider")];
246
                checks = new XMLCheck[parser.getNumTags("check")];
247
                texts = new XMLText[parser.getNumTags("text")];
248
                                                                
249
                String valor = parser.getValue("window",true);
250
                 
251
                 while(!valor.equals("")){
252
                         String tag = parser.getTag();
253
                         
254
                        if(tag.equals("panel"))
255
                                processPanel(parser);
256
                        else if(tag.equals("label"))
257
                                processLabel(parser);
258
                        else if(tag.equals("combo"))
259
                                processCombo(parser);
260
                        else if(tag.equals("check"))
261
                                processCheck(parser);
262
                        else if(tag.equals("slider"))
263
                                processSlider(parser);
264
                        else if(tag.equals("text"))
265
                                processText(parser);
266
                         else if(tag.equals(""))
267
                                valor=new String("");
268
                        else
269
                                valor = parser.getXML();        
270
                 }
271
                 
272
                 if(!valor.equals(""))
273
                         System.err.println("Se ha interrumpido el proceso!!!");
274
                 
275
        }
276
        
277
        /**
278
         * Obtiene los paneles leidos del XML como objetos XMLPanel
279
         * @return        Listado de XMLPanel
280
         */
281
        public XMLPanel[] getPanels(){return panels;}
282
        
283
        /**
284
         * Obtiene los combos leidos del XML como objetos XMLCombo
285
         * @return        Listado de XMLCombo
286
         */
287
        public XMLCombo[] getCombos(){return combos;}
288
        
289
        /**
290
         * Obtiene los label leidos del XML como objetos XMLLabel
291
         * @return        Listado de XMLLabel
292
         */
293
        public XMLLabel[] getLabels(){return labels;}
294
        
295
        /**
296
         * Obtiene los slider leidos del XML como objetos XMLSlider
297
         * @return        Listado de XMLSlider
298
         */
299
        public XMLSlider[] getSliders(){return sliders;}
300
        
301
        /**
302
         * Obtiene los checks leidos del XML como objetos XMLCheks
303
         * @return        Listado de XMLCheck
304
         */
305
        public XMLCheck[] getChecks(){return checks;}
306
        
307
        /**
308
         * Obtiene los texts leidos del XML como objetos XMLText
309
         * @return        Listado de XMLText
310
         */
311
        public XMLText[] getTexts(){return texts;}
312
        
313
        /**
314
         * Procesa un tag panel
315
         * @param parser        Objeto parser con el XML
316
         */
317
    public void processPanel(CXMLParser parser){
318

    
319
                panels[contPanels] = new XMLPanel();
320
                String sizex = parser.getAttr("panel","sizex");
321
                String sizey = parser.getAttr("panel","sizey");
322
                if(sizex!=null && !sizex.equals(""))
323
                        panels[contPanels].sizex = Integer.parseInt(sizex);
324
                if(sizey!=null && !sizey.equals(""))
325
                        panels[contPanels].sizey = Integer.parseInt(sizey);
326
                panels[contPanels].layout = parser.getAttr("panel","layout");
327
                panels[contPanels].border = parser.getAttr("panel","border");
328
                panels[contPanels].position = parser.getAttr("panel","position");
329
                panels[contPanels].align = parser.getAttr("panel","align");                
330
                panels[contPanels].init();
331
                contPanels++;
332
                
333
                //System.out.println("PANEL="+sizex+"X"+sizey+" Layout="+layout+" Border="+border+" Pos="+position+" Align="+align);
334
                parser.getValue("panel",true);
335
                
336
        }
337
        
338
    /**
339
         * Procesa un tag label
340
         * @param parser        Objeto parser con el XML
341
         */
342
        public void processLabel(CXMLParser parser){
343
             
344
                     labels[contLabels] = new XMLLabel();
345
                     
346
                     //Posicionamiento. En q panel y su posici?n dentro de este
347
                     labels[contLabels].numPanel = contPanels-1;
348
                     panels[contPanels-1].nElements++;
349
                     labels[contLabels].posIntoPanel = panels[contPanels-1].nElements-1;
350
                     
351
                     labels[contLabels].position = parser.getAttr("label","position");
352
                     labels[contLabels].text = parser.getValue("label",true);
353
                     labels[contLabels].init();
354
                     contLabels++;
355
                
356
        }
357
        
358
        /**
359
         * Procesa un tag combo
360
         * @param parser        Objeto parser con el XML
361
         */     
362
        public void processCombo(CXMLParser parser){
363
                     
364
                        combos[contCombos] = new XMLCombo();
365
                        
366
                        //Posicionamiento. En q panel y su posici?n dentro de este
367
                        combos[contCombos].numPanel = contPanels-1;
368
                     panels[contPanels-1].nElements++;
369
                     combos[contCombos].posIntoPanel = panels[contPanels-1].nElements-1;
370
                     
371
                     combos[contCombos].selected = parser.getAttr("combo","selected");
372
                     combos[contCombos].position = parser.getAttr("combo","position");
373
                     combos[contCombos].id = parser.getAttr("combo","ident");
374
                     String sizex = parser.getAttr("combo","sizex");
375
                     String sizey = parser.getAttr("combo","sizey");
376
                     if(sizex!=null && !sizex.equals(""))
377
                             combos[contCombos].sizex = Integer.parseInt(sizex);
378
                     if(sizey!=null && !sizey.equals(""))
379
                             combos[contCombos].sizey = Integer.parseInt(sizey); 
380
                     String valoresCombo = parser.getValue("combo",true);
381
                     
382
                     processComboValues(parser, combos[contCombos]);
383
                     combos[contCombos].init();
384
                     contCombos++;
385
                     
386
        }
387
        
388
        /**
389
         * Procesa los elementos de un combo
390
         * @param parser        Objeto parser con el XML
391
         * @param combo        Objeto XMLCombo del cual se procesan los elementos
392
         */
393
        public void processComboValues(CXMLParser parser, XMLCombo combo){
394
                     
395
                     String elem = parser.getValue("elem",true);
396
                     if(elem!=null)
397
                             combo.addItem(elem);
398
                                
399
                     if(parser.getTag().equals("elem"))
400
                             processComboValues(parser, combo);
401
                     
402
        }
403
        
404
        /**
405
         * Procesa un tag check
406
         * @param parser        Objeto parser con el XML
407
         */     
408
        public void processCheck(CXMLParser parser){
409
                     
410
                        String select = parser.getAttr("check","selected");
411
                        
412
                        if(select.equals("yes"))
413
                                checks[contChecks] = new XMLCheck(parser.getAttr("check","text"), true);
414
                        else
415
                                checks[contChecks] = new XMLCheck(parser.getAttr("check","text"), false);
416
                        checks[contChecks].position = parser.getAttr("check","position");
417
                        checks[contChecks].id = parser.getAttr("check","ident");
418
                        String sizex = parser.getAttr("check","sizex");
419
                     String sizey = parser.getAttr("check","sizey");
420
                     if(sizex!=null && !sizex.equals(""))
421
                             checks[contChecks].sizex = Integer.parseInt(sizex);
422
                     if(sizey!=null && !sizey.equals(""))
423
                             checks[contChecks].sizey = Integer.parseInt(sizey); 
424
                     
425

    
426
                     parser.getValue("check",true);
427
                                           
428
                        //Posicionamiento. En q panel y su posici?n dentro de este
429
                        checks[contChecks].numPanel = contPanels-1;
430
                     panels[contPanels-1].nElements++;
431
                     checks[contChecks].posIntoPanel = panels[contPanels-1].nElements-1;
432
                     
433
                     checks[contChecks].init();
434
                     contChecks++;
435
                     
436
         }
437
             
438
        /**
439
         * Procesa un tag slider
440
         * @param parser        Objeto parser con el XML
441
         */               
442
         public void processSlider(CXMLParser parser){
443
                     
444
                          String min = null;
445
                          String max = null;
446
                          String value = null;
447
                          String minorspacing = null;
448
                          String majorspacing = null;
449
                     String name = parser.getAttr("slider","name");
450
                     String id = parser.getAttr("slider","ident");
451
                     String position = parser.getAttr("slider","position");
452
                     String sizex = parser.getAttr("slider","sizex");
453
                        String sizey = parser.getAttr("slider","sizey");
454
                     String elem = parser.getValue("slider",true);
455
                                     
456
                        String tag = parser.getTag();
457
                        while(        tag.equals("min") || 
458
                                tag.equals("max") || 
459
                                tag.equals("value") || 
460
                                tag.equals("minorspacing") ||
461
                                tag.equals("majorspacing")){
462
                                if(tag.equals("min"))
463
                                        min = parser.getValue("min",true);
464
                                if(tag.equals("max"))
465
                                        max = parser.getValue("max",true);
466
                                if(tag.equals("value"))
467
                                        value = parser.getValue("value",true);
468
                                if(tag.equals("minorspacing"))
469
                                        minorspacing = parser.getValue("minorspacing",true);
470
                                if(tag.equals("majorspacing"))
471
                                        majorspacing = parser.getValue("majorspacing",true);
472
                                tag = parser.getTag();                
473
                        }
474
                        
475
                        sliders[contSliders] = new XMLSlider(        name,
476
                                                                                                        min,
477
                                                                                                        max,
478
                                                                                                        value,
479
                                                                                                        minorspacing,
480
                                                                                                        majorspacing);
481
                        sliders[contSliders].position = position;
482
                        sliders[contSliders].id = id;
483
                        
484
                        if(sizex!=null && !sizex.equals(""))
485
                                sliders[contSliders].sizex = Integer.parseInt(sizex);
486
                        if(sizey!=null && !sizey.equals(""))
487
                                sliders[contSliders].sizey = Integer.parseInt(sizey);
488
        
489
                        //Posicionamiento. En q panel y su posici?n dentro de este
490
                        sliders[contSliders].numPanel = contPanels-1;
491
                     panels[contPanels-1].nElements++;
492
                     sliders[contSliders].posIntoPanel = panels[contPanels-1].nElements-1;
493
                     
494
                     contSliders++;
495
                        
496
         }
497
         
498
         /**
499
         * Procesa un tag text
500
         * @param parser        Objeto parser con el XML
501
         */               
502
        public void processText(CXMLParser parser){
503
                
504
                texts[contTexts] = new XMLText(parser.getAttr("text","text"));
505
                
506
                String sizex = parser.getAttr("text","sizex");
507
                String sizey = parser.getAttr("text","sizey");
508
                if(sizex!=null && !sizex.equals(""))
509
                        texts[contTexts].sizex = Integer.parseInt(sizex);
510
                if(sizey!=null && !sizey.equals(""))
511
                        texts[contTexts].sizey = Integer.parseInt(sizey);
512
                
513
             //Posicionamiento. En q panel y su posici?n dentro de este
514
             texts[contTexts].numPanel = contPanels-1;
515
             panels[contPanels-1].nElements++;
516
             texts[contTexts].posIntoPanel = panels[contPanels-1].nElements-1;
517
             
518
             texts[contTexts].position = parser.getAttr("text","position");
519
             texts[contTexts].text = parser.getValue("text",true);
520
             texts[contTexts].init();
521
             contTexts++;
522
             
523
        }
524
        
525
}
526

    
527
/**
528
 * Clase que representa a un panel obtenido a partir del XML
529
 * que manda un driver de escritura.
530
 * 
531
 * @author Nacho Brodin <brodin_ign@gva.es>
532
 *
533
 */
534
class XMLPanel extends JPanel{
535
        
536
        public int                         sizex = 0;
537
        public int                         sizey = 0;
538
        public String                 layout = null;
539
        public String                 border = null;
540
        public String                 position = null;
541
        public String                 align = null;
542
        public int                         nElements = 0;
543
        
544
        /**
545
         * Inicializaci?n del XMLPanel
546
         *
547
         */
548
        public void init(){
549
                if(layout.equals("FlowLayout")){
550
                        FlowLayout fl = new FlowLayout();
551
                        this.setLayout(fl);
552
                        if(align.equals("left"))
553
                                fl.setAlignment(java.awt.FlowLayout.LEFT);
554
                        else if(align.equals("center"))
555
                                fl.setAlignment(java.awt.FlowLayout.CENTER);
556
                        else if(align.equals("right"))
557
                                fl.setAlignment(java.awt.FlowLayout.RIGHT);
558
                        else if(align.equals("leading"))
559
                                fl.setAlignment(java.awt.FlowLayout.LEADING);
560
                        else if(align.equals("trailing"))
561
                                fl.setAlignment(java.awt.FlowLayout.TRAILING);
562
                }
563
                else if(layout.equals("BorderLayout"))
564
                        this.setLayout(new BorderLayout());
565
                
566
                if(sizex!=0 && sizey!=0)
567
                        this.setPreferredSize(new java.awt.Dimension(sizex,sizey));
568
                
569
                if(border.equals("yes"))
570
                        this.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray,1));
571
                
572
        }
573
        
574
}
575

    
576
/**
577
 * Clase que representa a un combo obtenido a partir del XML
578
 * que manda un driver de escritura.
579
 * 
580
 * @author Nacho Brodin <brodin_ign@gva.es>
581
 *
582
 */
583
class XMLCombo extends JComboBox{
584
        
585
        public int                         numPanel = -1;
586
        public int                         posIntoPanel = -1;
587
        public String                 position = null;
588
        public String                 selected = null;
589
        public int                         sizex = 0;
590
        public int                         sizey = 0;
591
        public String                id = null;
592

    
593
        /**
594
         * Inicializaci?n del XMLCombo
595
         *
596
         */
597
        public void init(){
598
                
599
                if(sizex!=0 && sizey!=0)
600
                        this.setPreferredSize(new java.awt.Dimension(sizex,sizey));
601
                if(selected!=null)
602
                        this.setSelectedItem(selected);
603
                
604
        }
605
}
606

    
607
/**
608
 * Clase que representa a un label obtenido a partir del XML
609
 * que manda un driver de escritura.
610
 * 
611
 * @author Nacho Brodin <brodin_ign@gva.es>
612
 *
613
 */
614
class XMLLabel extends JLabel{
615
        
616
        public int                         numPanel = -1;
617
        public int                         posIntoPanel = -1;
618
        public String                 position = null;
619
        public String                 text = null;
620
        
621
        /**
622
         * Inicializaci?n del XMLLabel
623
         */
624
        public void init(){
625
                this.setText(text);
626
        }
627
}
628

    
629
/**
630
 * Clase que representa a un slider obtenido a partir del XML
631
 * que manda un driver de escritura.
632
 * 
633
 * @author Nacho Brodin <brodin_ign@gva.es>
634
 *
635
 */
636
class XMLSlider extends JPanel{
637
        
638
        public int                        numPanel = -1;
639
        public int                         posIntoPanel = -1;
640
        public int                         sizex = 0;
641
        public int                         sizey = 0;
642
        public String                 position = null;
643
        private JSlider         slider = null;
644
        private JLabel                 label = null;
645
        public String                id = null;
646
        
647
        /**
648
         * Constructor
649
         * @param text        Texto de la barra
650
         * @param smin        Valor m?nimo de la barra
651
         * @param smax        Valor m?ximo de la barra
652
         * @param sdefaultValue        Valor por defecto de la barra.
653
         * @param sminor        Separaci?n menor de las secciones de la barra
654
         * @param smajor        Separaci?n mayor de las secciones de la barra
655
         */
656
        public XMLSlider(        String text, 
657
                                                String smin, 
658
                                                String smax, 
659
                                                String sdefaultValue, 
660
                                                String sminor, 
661
                                                String smajor){
662
                 
663
                         int min = 0;
664
                         int max = 100;
665
                         int defaultValue = 0;
666
                         int minor = 5;
667
                         int major = 10;
668
                         
669
                         //Obtenemos los valores de los par?metros
670
                         if(smin!=null)
671
                                 min = Integer.parseInt(smin);
672
                         if(smax!=null)
673
                                 max = Integer.parseInt(smax);
674
                         if(sdefaultValue!=null)
675
                                 defaultValue = Integer.parseInt(sdefaultValue);
676
                         if(sminor!=null)
677
                                 minor = Integer.parseInt(sminor);
678
                         if(smajor!=null)
679
                                 major = Integer.parseInt(smajor);
680
                         
681
                         //Colocaci?n de elementos en el panel
682
                          label = new JLabel(text, JLabel.CENTER);
683
                         slider = new JSlider(JSlider.HORIZONTAL, min, max, defaultValue);
684
                         slider.setMajorTickSpacing(major);
685
                     slider.setMinorTickSpacing(minor);
686
                         slider.setPaintTicks(true);
687
                         slider.setPaintLabels(true);
688
                         this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
689
                         this.add(label);
690
                     this.add(slider);
691
                     if(sizex!=0 && sizey!=0)
692
                             this.setPreferredSize(new java.awt.Dimension(sizex, sizey));
693
                     
694
                         
695
    }
696
        
697
        /**
698
         * Obtiene la barra 
699
         * @return        Objeto JSlider
700
         */
701
        public JSlider getSlider(){return slider;}
702
        
703
}
704

    
705
/**
706
 * Clase que representa a un checkbox obtenido a partir del XML
707
 * que manda un driver de escritura.
708
 * 
709
 * @author Nacho Brodin <brodin_ign@gva.es>
710
 *
711
 */
712
class XMLCheck extends JCheckBox{
713
        
714
        public int                         numPanel = -1;
715
        public int                         posIntoPanel = -1;
716
        public String                 position = null;
717
        public String                 selected = null;
718
        public int                         sizex = 0;
719
        public int                         sizey = 0;
720
        public String                text = null;
721
        public String                id = null;
722
        
723
        /**
724
         * Contructor
725
         * @param text        texto del checkbox
726
         * @param select        true si esta seleccionado y false si no lo est?.
727
         */
728
        public XMLCheck(String text, boolean select){
729
                
730
                super(text, select);
731
                this.text = text;
732
                if(select)
733
                        selected = new String("yes");
734
                else
735
                        selected = new String("no");
736
                
737
        }
738
        
739
        /**
740
         * Inicializaci?n del XMLCheck
741
         */
742
        public void init(){
743
                
744
                if(sizex!=0 && sizey!=0)
745
                        this.setPreferredSize(new java.awt.Dimension(sizex,sizey));
746
                
747
        }
748
}
749

    
750

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