svn-gvsig-desktop / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / ui / raster / DataInputProps.java @ 1750
History | View | Annotate | Download (22 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 |
* Panel que contiene las propiedades de un driver de escritura.
|
37 |
* Este panel se monta a partir de un XML que es solicitado al driver
|
38 |
* porque dependiendo del driver tendr? unas propiedades u otras.
|
39 |
* Los elementos del panel son XMLObjects que se almacenan en
|
40 |
* vectores. El XML se procesa con la clase ProcessXML que ser? la
|
41 |
* encargada a partir del texto en XML de crear los XMLObjects que
|
42 |
* compondran el panel.
|
43 |
*/
|
44 |
public class DataInputProps extends JPanel{ |
45 |
|
46 |
private GeoRasterWriter writer = null; |
47 |
private String formato = null; |
48 |
private JPanel jPanel = null; |
49 |
private JPanel panelSup = null; |
50 |
private JComboBox jComboBox = null; |
51 |
|
52 |
private XMLPanel[] panels = null; |
53 |
private XMLCombo[] combos = null; |
54 |
private XMLLabel[] labels = null; |
55 |
private XMLSlider[] sliders = null; |
56 |
private XMLCheck[] checks = null; |
57 |
private XMLText[] texts = null; |
58 |
|
59 |
public DataInputProps(GeoRasterWriter writer) {
|
60 |
|
61 |
super();
|
62 |
this.writer = writer;
|
63 |
this.formato = writer.getIdent();
|
64 |
ProcessXML pXML = new ProcessXML(writer.getXMLPropertiesDialog());
|
65 |
panels = pXML.getPanels(); |
66 |
labels = pXML.getLabels(); |
67 |
combos = pXML.getCombos(); |
68 |
sliders = pXML.getSliders(); |
69 |
checks = pXML.getChecks(); |
70 |
texts = pXML.getTexts(); |
71 |
initialize(); |
72 |
addComponents(); |
73 |
//showElements();
|
74 |
|
75 |
} |
76 |
|
77 |
/**
|
78 |
* Inicializa el panel central con los datos del primer panel de la lista
|
79 |
*/
|
80 |
private void initialize() { |
81 |
|
82 |
for(int i=0;i<this.panels.length;i++){ |
83 |
if(i==0){ |
84 |
if(panels[i].layout.equals("FlowLayout")) |
85 |
this.setLayout(new FlowLayout()); |
86 |
if(panels[i].layout.equals("BorderLayout")) |
87 |
this.setLayout(new BorderLayout()); |
88 |
this.setSize(panels[i].sizex, panels[i].sizey);
|
89 |
}else{
|
90 |
if(panels[i].position != null && !panels[i].position.equals("")) |
91 |
this.add(panels[i], panels[i].position);
|
92 |
else
|
93 |
this.add(panels[i]);
|
94 |
} |
95 |
|
96 |
} |
97 |
|
98 |
} |
99 |
|
100 |
public void addComponents(){ |
101 |
|
102 |
for(int iPanel=1;iPanel<panels.length;iPanel++){ |
103 |
int nElemInsert = 0; |
104 |
while(nElemInsert<panels[iPanel].nElements){
|
105 |
|
106 |
|
107 |
for(int i=0;i<labels.length;i++){ |
108 |
if(labels[i].numPanel==iPanel && labels[i].posIntoPanel==nElemInsert){
|
109 |
if(labels[i].position != null && !labels[i].position.equals("")) |
110 |
panels[iPanel].add(labels[i], labels[i].position); |
111 |
else
|
112 |
panels[iPanel].add(labels[i]); |
113 |
nElemInsert++; |
114 |
} |
115 |
}//for(int i=0;i<labels.length;i++)
|
116 |
|
117 |
for(int i=0;i<combos.length;i++){ |
118 |
if(combos[i].numPanel==iPanel && combos[i].posIntoPanel==nElemInsert){
|
119 |
if(combos[i].position != null && !combos[i].position.equals("")) |
120 |
panels[iPanel].add(combos[i], combos[i].position); |
121 |
else
|
122 |
panels[iPanel].add(combos[i]); |
123 |
nElemInsert++; |
124 |
} |
125 |
}//for(int i=0;i<combos.length;i++)
|
126 |
|
127 |
for(int i=0;i<sliders.length;i++){ |
128 |
if(sliders[i].numPanel==iPanel && sliders[i].posIntoPanel==nElemInsert){
|
129 |
if(sliders[i].position != null && !sliders[i].position.equals("")) |
130 |
panels[iPanel].add(sliders[i], sliders[i].position); |
131 |
else
|
132 |
panels[iPanel].add(sliders[i]); |
133 |
nElemInsert++; |
134 |
} |
135 |
}//for(int i=0;i<sliders.length;i++)
|
136 |
|
137 |
for(int i=0;i<checks.length;i++){ |
138 |
if(checks[i].numPanel==iPanel && checks[i].posIntoPanel==nElemInsert){
|
139 |
if(checks[i].position != null && !checks[i].position.equals("")) |
140 |
panels[iPanel].add(checks[i], checks[i].position); |
141 |
else
|
142 |
panels[iPanel].add(checks[i]); |
143 |
nElemInsert++; |
144 |
} |
145 |
}//for(int i=0;i<checks.length;i++)
|
146 |
|
147 |
for(int i=0;i<texts.length;i++){ |
148 |
if(texts[i].numPanel==iPanel && texts[i].posIntoPanel==nElemInsert){
|
149 |
if(texts[i].position != null && !texts[i].position.equals("")) |
150 |
panels[iPanel].add(texts[i], texts[i].position); |
151 |
else
|
152 |
panels[iPanel].add(texts[i]); |
153 |
nElemInsert++; |
154 |
} |
155 |
}//for(int i=0;i<checks.length;i++)
|
156 |
|
157 |
}//while(nElemInsert<panels[iPanel].nElements)
|
158 |
|
159 |
|
160 |
}//for(int iPanel=1;iPanel<panels.length;iPanel++)
|
161 |
} |
162 |
|
163 |
/**
|
164 |
* Obtiene el n?mero de componentes que recogen propiedades
|
165 |
* para el driver cargado
|
166 |
* @return N?mero de componentes
|
167 |
*/
|
168 |
public int getNElements(){ |
169 |
|
170 |
return (combos.length + sliders.length + checks.length + texts.length);
|
171 |
|
172 |
} |
173 |
|
174 |
/**
|
175 |
* Obtiene los identificadores de las propiedades del cuadro de dialogo
|
176 |
* @return Lista con los identificadores de propiedades
|
177 |
*/
|
178 |
public String[] getElements(){ |
179 |
|
180 |
String[] lista = new String[this.getNElements()]; |
181 |
for(int i=0;i<combos.length;i++) |
182 |
lista[i] = combos[i].id+"="+combos[i].getSelectedItem().toString();
|
183 |
for(int i=0;i<sliders.length;i++) |
184 |
lista[combos.length+i] = sliders[i].id+"="+sliders[i].getSlider().getValue();
|
185 |
for(int i=0;i<checks.length;i++){ |
186 |
String sel = null; |
187 |
if(checks[i].isSelected())
|
188 |
sel = new String("yes"); |
189 |
else
|
190 |
sel = new String("no"); |
191 |
lista[combos.length+sliders.length+i] = checks[i].id+"="+sel;
|
192 |
} |
193 |
for(int i=0;i<texts.length;i++) |
194 |
lista[i] = texts[i].id+"="+texts[i].getText();
|
195 |
return lista;
|
196 |
|
197 |
} |
198 |
|
199 |
public XMLCombo[] getCombos(){return combos;} |
200 |
public XMLSlider[] getSliders(){return sliders;} |
201 |
public XMLCheck[] getChecks(){return checks;} |
202 |
|
203 |
public void showElements(){ |
204 |
|
205 |
for(int i=0;i<panels.length;i++) |
206 |
System.out.println("PANEL "+i+" NElem="+panels[i].nElements); |
207 |
for(int i=0;i<labels.length;i++) |
208 |
System.out.println("LABEL "+i+" Panel="+labels[i].numPanel+" PosIntoPanel="+labels[i].posIntoPanel); |
209 |
for(int i=0;i<combos.length;i++) |
210 |
System.out.println("COMBO "+i+" Panel="+combos[i].numPanel+" PosIntoPanel="+combos[i].posIntoPanel); |
211 |
for(int i=0;i<checks.length;i++) |
212 |
System.out.println("CHECK "+i+" Panel="+checks[i].numPanel+" PosIntoPanel="+checks[i].posIntoPanel); |
213 |
for(int i=0;i<sliders.length;i++) |
214 |
System.out.println("SLIDER "+i+" Panel="+sliders[i].numPanel+" PosIntoPanel="+sliders[i].posIntoPanel); |
215 |
|
216 |
} |
217 |
|
218 |
} |
219 |
|
220 |
|
221 |
/**
|
222 |
* Clase para procesar el XML que manda un driver de escritura y
|
223 |
* que corresponde a la ventana de dialogo para las propiedades del mismo.
|
224 |
*
|
225 |
* @author Nacho Brodin <brodin_ign@gva.es>
|
226 |
*
|
227 |
*/
|
228 |
class ProcessXML { |
229 |
|
230 |
private XMLPanel[] panels = null; |
231 |
private XMLCombo[] combos = null; |
232 |
private XMLLabel[] labels = null; |
233 |
private XMLSlider[] sliders = null; |
234 |
private XMLCheck[] checks = null; |
235 |
private XMLText[] texts = null; |
236 |
private int contPanels = 0; |
237 |
private int contCombos = 0; |
238 |
private int contLabels = 0; |
239 |
private int contSliders = 0; |
240 |
private int contChecks = 0; |
241 |
private int contTexts = 0; |
242 |
|
243 |
/**
|
244 |
* Constructor
|
245 |
* @param XML XML correspondiente a la ventana de dialogo
|
246 |
*/
|
247 |
public ProcessXML(String XML) { |
248 |
|
249 |
CXMLParser parser = new CXMLParser(XML);
|
250 |
|
251 |
//Reservamos memoria para el n?mero de paneles
|
252 |
|
253 |
panels = new XMLPanel[parser.getNumTags("panel")]; |
254 |
combos = new XMLCombo[parser.getNumTags("combo")]; |
255 |
labels = new XMLLabel[parser.getNumTags("label")]; |
256 |
sliders = new XMLSlider[parser.getNumTags("slider")]; |
257 |
checks = new XMLCheck[parser.getNumTags("check")]; |
258 |
texts = new XMLText[parser.getNumTags("text")]; |
259 |
|
260 |
String valor = parser.getValue("window",true); |
261 |
|
262 |
while(!valor.equals("")){ |
263 |
String tag = parser.getTag();
|
264 |
|
265 |
if(tag.equals("panel")) |
266 |
processPanel(parser); |
267 |
else if(tag.equals("label")) |
268 |
processLabel(parser); |
269 |
else if(tag.equals("combo")) |
270 |
processCombo(parser); |
271 |
else if(tag.equals("check")) |
272 |
processCheck(parser); |
273 |
else if(tag.equals("slider")) |
274 |
processSlider(parser); |
275 |
else if(tag.equals("text")) |
276 |
processText(parser); |
277 |
else if(tag.equals("")) |
278 |
valor=new String(""); |
279 |
else
|
280 |
valor = parser.getXML(); |
281 |
} |
282 |
|
283 |
if(!valor.equals("")) |
284 |
System.err.println("Se ha interrumpido el proceso!!!"); |
285 |
|
286 |
} |
287 |
|
288 |
/**
|
289 |
* Obtiene los paneles leidos del XML como objetos XMLPanel
|
290 |
* @return Listado de XMLPanel
|
291 |
*/
|
292 |
public XMLPanel[] getPanels(){return panels;} |
293 |
|
294 |
/**
|
295 |
* Obtiene los combos leidos del XML como objetos XMLCombo
|
296 |
* @return Listado de XMLCombo
|
297 |
*/
|
298 |
public XMLCombo[] getCombos(){return combos;} |
299 |
|
300 |
/**
|
301 |
* Obtiene los label leidos del XML como objetos XMLLabel
|
302 |
* @return Listado de XMLLabel
|
303 |
*/
|
304 |
public XMLLabel[] getLabels(){return labels;} |
305 |
|
306 |
/**
|
307 |
* Obtiene los slider leidos del XML como objetos XMLSlider
|
308 |
* @return Listado de XMLSlider
|
309 |
*/
|
310 |
public XMLSlider[] getSliders(){return sliders;} |
311 |
|
312 |
/**
|
313 |
* Obtiene los checks leidos del XML como objetos XMLCheks
|
314 |
* @return Listado de XMLCheck
|
315 |
*/
|
316 |
public XMLCheck[] getChecks(){return checks;} |
317 |
|
318 |
/**
|
319 |
* Obtiene los texts leidos del XML como objetos XMLText
|
320 |
* @return Listado de XMLText
|
321 |
*/
|
322 |
public XMLText[] getTexts(){return texts;} |
323 |
|
324 |
/**
|
325 |
* Procesa un tag panel
|
326 |
* @param parser Objeto parser con el XML
|
327 |
*/
|
328 |
public void processPanel(CXMLParser parser){ |
329 |
|
330 |
panels[contPanels] = new XMLPanel();
|
331 |
String sizex = parser.getAttr("panel","sizex"); |
332 |
String sizey = parser.getAttr("panel","sizey"); |
333 |
if(sizex!=null && !sizex.equals("")) |
334 |
panels[contPanels].sizex = Integer.parseInt(sizex);
|
335 |
if(sizey!=null && !sizey.equals("")) |
336 |
panels[contPanels].sizey = Integer.parseInt(sizey);
|
337 |
panels[contPanels].layout = parser.getAttr("panel","layout"); |
338 |
panels[contPanels].border = parser.getAttr("panel","border"); |
339 |
panels[contPanels].position = parser.getAttr("panel","position"); |
340 |
panels[contPanels].align = parser.getAttr("panel","align"); |
341 |
panels[contPanels].init(); |
342 |
contPanels++; |
343 |
|
344 |
//System.out.println("PANEL="+sizex+"X"+sizey+" Layout="+layout+" Border="+border+" Pos="+position+" Align="+align);
|
345 |
parser.getValue("panel",true); |
346 |
|
347 |
} |
348 |
|
349 |
/**
|
350 |
* Procesa un tag label
|
351 |
* @param parser Objeto parser con el XML
|
352 |
*/
|
353 |
public void processLabel(CXMLParser parser){ |
354 |
|
355 |
labels[contLabels] = new XMLLabel();
|
356 |
|
357 |
//Posicionamiento. En q panel y su posici?n dentro de este
|
358 |
labels[contLabels].numPanel = contPanels-1;
|
359 |
panels[contPanels-1].nElements++;
|
360 |
labels[contLabels].posIntoPanel = panels[contPanels-1].nElements-1; |
361 |
|
362 |
labels[contLabels].position = parser.getAttr("label","position"); |
363 |
labels[contLabels].text = parser.getValue("label",true); |
364 |
labels[contLabels].init(); |
365 |
contLabels++; |
366 |
|
367 |
} |
368 |
|
369 |
/**
|
370 |
* Procesa un tag combo
|
371 |
* @param parser Objeto parser con el XML
|
372 |
*/
|
373 |
public void processCombo(CXMLParser parser){ |
374 |
|
375 |
combos[contCombos] = new XMLCombo();
|
376 |
|
377 |
//Posicionamiento. En q panel y su posici?n dentro de este
|
378 |
combos[contCombos].numPanel = contPanels-1;
|
379 |
panels[contPanels-1].nElements++;
|
380 |
combos[contCombos].posIntoPanel = panels[contPanels-1].nElements-1; |
381 |
|
382 |
combos[contCombos].selected = parser.getAttr("combo","selected"); |
383 |
combos[contCombos].position = parser.getAttr("combo","position"); |
384 |
combos[contCombos].id = parser.getAttr("combo","ident"); |
385 |
String sizex = parser.getAttr("combo","sizex"); |
386 |
String sizey = parser.getAttr("combo","sizey"); |
387 |
if(sizex!=null && !sizex.equals("")) |
388 |
combos[contCombos].sizex = Integer.parseInt(sizex);
|
389 |
if(sizey!=null && !sizey.equals("")) |
390 |
combos[contCombos].sizey = Integer.parseInt(sizey);
|
391 |
String valoresCombo = parser.getValue("combo",true); |
392 |
|
393 |
processComboValues(parser, combos[contCombos]); |
394 |
combos[contCombos].init(); |
395 |
contCombos++; |
396 |
|
397 |
} |
398 |
|
399 |
/**
|
400 |
* Procesa los elementos de un combo
|
401 |
* @param parser Objeto parser con el XML
|
402 |
* @param combo Objeto XMLCombo del cual se procesan los elementos
|
403 |
*/
|
404 |
public void processComboValues(CXMLParser parser, XMLCombo combo){ |
405 |
|
406 |
String elem = parser.getValue("elem",true); |
407 |
if(elem!=null) |
408 |
combo.addItem(elem); |
409 |
|
410 |
if(parser.getTag().equals("elem")) |
411 |
processComboValues(parser, combo); |
412 |
|
413 |
} |
414 |
|
415 |
/**
|
416 |
* Procesa un tag check
|
417 |
* @param parser Objeto parser con el XML
|
418 |
*/
|
419 |
public void processCheck(CXMLParser parser){ |
420 |
|
421 |
String select = parser.getAttr("check","selected"); |
422 |
|
423 |
if(select.equals("yes")) |
424 |
checks[contChecks] = new XMLCheck(parser.getAttr("check","text"), true); |
425 |
else
|
426 |
checks[contChecks] = new XMLCheck(parser.getAttr("check","text"), false); |
427 |
checks[contChecks].position = parser.getAttr("check","position"); |
428 |
checks[contChecks].id = parser.getAttr("check","ident"); |
429 |
String sizex = parser.getAttr("check","sizex"); |
430 |
String sizey = parser.getAttr("check","sizey"); |
431 |
if(sizex!=null && !sizex.equals("")) |
432 |
checks[contChecks].sizex = Integer.parseInt(sizex);
|
433 |
if(sizey!=null && !sizey.equals("")) |
434 |
checks[contChecks].sizey = Integer.parseInt(sizey);
|
435 |
|
436 |
|
437 |
parser.getValue("check",true); |
438 |
|
439 |
//Posicionamiento. En q panel y su posici?n dentro de este
|
440 |
checks[contChecks].numPanel = contPanels-1;
|
441 |
panels[contPanels-1].nElements++;
|
442 |
checks[contChecks].posIntoPanel = panels[contPanels-1].nElements-1; |
443 |
|
444 |
checks[contChecks].init(); |
445 |
contChecks++; |
446 |
|
447 |
} |
448 |
|
449 |
/**
|
450 |
* Procesa un tag slider
|
451 |
* @param parser Objeto parser con el XML
|
452 |
*/
|
453 |
public void processSlider(CXMLParser parser){ |
454 |
|
455 |
String min = null; |
456 |
String max = null; |
457 |
String value = null; |
458 |
String minorspacing = null; |
459 |
String majorspacing = null; |
460 |
String name = parser.getAttr("slider","name"); |
461 |
String id = parser.getAttr("slider","ident"); |
462 |
String position = parser.getAttr("slider","position"); |
463 |
String sizex = parser.getAttr("slider","sizex"); |
464 |
String sizey = parser.getAttr("slider","sizey"); |
465 |
String elem = parser.getValue("slider",true); |
466 |
|
467 |
String tag = parser.getTag();
|
468 |
while( tag.equals("min") || |
469 |
tag.equals("max") ||
|
470 |
tag.equals("value") ||
|
471 |
tag.equals("minorspacing") ||
|
472 |
tag.equals("majorspacing")){
|
473 |
if(tag.equals("min")) |
474 |
min = parser.getValue("min",true); |
475 |
if(tag.equals("max")) |
476 |
max = parser.getValue("max",true); |
477 |
if(tag.equals("value")) |
478 |
value = parser.getValue("value",true); |
479 |
if(tag.equals("minorspacing")) |
480 |
minorspacing = parser.getValue("minorspacing",true); |
481 |
if(tag.equals("majorspacing")) |
482 |
majorspacing = parser.getValue("majorspacing",true); |
483 |
tag = parser.getTag(); |
484 |
} |
485 |
|
486 |
sliders[contSliders] = new XMLSlider( name,
|
487 |
min, |
488 |
max, |
489 |
value, |
490 |
minorspacing, |
491 |
majorspacing); |
492 |
sliders[contSliders].position = position; |
493 |
sliders[contSliders].id = id; |
494 |
|
495 |
if(sizex!=null && !sizex.equals("")) |
496 |
sliders[contSliders].sizex = Integer.parseInt(sizex);
|
497 |
if(sizey!=null && !sizey.equals("")) |
498 |
sliders[contSliders].sizey = Integer.parseInt(sizey);
|
499 |
|
500 |
//Posicionamiento. En q panel y su posici?n dentro de este
|
501 |
sliders[contSliders].numPanel = contPanels-1;
|
502 |
panels[contPanels-1].nElements++;
|
503 |
sliders[contSliders].posIntoPanel = panels[contPanels-1].nElements-1; |
504 |
|
505 |
contSliders++; |
506 |
|
507 |
} |
508 |
|
509 |
/**
|
510 |
* Procesa un tag text
|
511 |
* @param parser Objeto parser con el XML
|
512 |
*/
|
513 |
public void processText(CXMLParser parser){ |
514 |
|
515 |
texts[contTexts] = new XMLText(parser.getAttr("text","text")); |
516 |
|
517 |
String sizex = parser.getAttr("text","sizex"); |
518 |
String sizey = parser.getAttr("text","sizey"); |
519 |
if(sizex!=null && !sizex.equals("")) |
520 |
texts[contTexts].sizex = Integer.parseInt(sizex);
|
521 |
if(sizey!=null && !sizey.equals("")) |
522 |
texts[contTexts].sizey = Integer.parseInt(sizey);
|
523 |
|
524 |
//Posicionamiento. En q panel y su posici?n dentro de este
|
525 |
texts[contTexts].numPanel = contPanels-1;
|
526 |
panels[contPanels-1].nElements++;
|
527 |
texts[contTexts].posIntoPanel = panels[contPanels-1].nElements-1; |
528 |
|
529 |
texts[contTexts].position = parser.getAttr("text","position"); |
530 |
texts[contTexts].text = parser.getValue("text",true); |
531 |
texts[contTexts].init(); |
532 |
contTexts++; |
533 |
|
534 |
} |
535 |
|
536 |
} |
537 |
|
538 |
/**
|
539 |
* Clase que representa a un panel obtenido a partir del XML
|
540 |
* que manda un driver de escritura.
|
541 |
*
|
542 |
* @author Nacho Brodin <brodin_ign@gva.es>
|
543 |
*
|
544 |
*/
|
545 |
class XMLPanel extends JPanel{ |
546 |
|
547 |
public int sizex = 0; |
548 |
public int sizey = 0; |
549 |
public String layout = null; |
550 |
public String border = null; |
551 |
public String position = null; |
552 |
public String align = null; |
553 |
public int nElements = 0; |
554 |
|
555 |
/**
|
556 |
* Inicializaci?n del XMLPanel
|
557 |
*
|
558 |
*/
|
559 |
public void init(){ |
560 |
|
561 |
if(layout.equals("FlowLayout")){ |
562 |
FlowLayout fl = new FlowLayout(); |
563 |
this.setLayout(fl);
|
564 |
if(align.equals("left")) |
565 |
fl.setAlignment(java.awt.FlowLayout.LEFT); |
566 |
else if(align.equals("center")) |
567 |
fl.setAlignment(java.awt.FlowLayout.CENTER); |
568 |
else if(align.equals("right")) |
569 |
fl.setAlignment(java.awt.FlowLayout.RIGHT); |
570 |
else if(align.equals("leading")) |
571 |
fl.setAlignment(java.awt.FlowLayout.LEADING); |
572 |
else if(align.equals("trailing")) |
573 |
fl.setAlignment(java.awt.FlowLayout.TRAILING); |
574 |
} |
575 |
else if(layout.equals("BorderLayout")) |
576 |
this.setLayout(new BorderLayout()); |
577 |
|
578 |
if(sizex!=0 && sizey!=0) |
579 |
this.setPreferredSize(new java.awt.Dimension(sizex,sizey)); |
580 |
|
581 |
if(border.equals("yes")) |
582 |
this.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray,1)); |
583 |
|
584 |
} |
585 |
|
586 |
} |
587 |
|
588 |
/**
|
589 |
* Clase que representa a un combo obtenido a partir del XML
|
590 |
* que manda un driver de escritura.
|
591 |
*
|
592 |
* @author Nacho Brodin <brodin_ign@gva.es>
|
593 |
*
|
594 |
*/
|
595 |
class XMLCombo extends JComboBox{ |
596 |
|
597 |
public int numPanel = -1; |
598 |
public int posIntoPanel = -1; |
599 |
public String position = null; |
600 |
public String selected = null; |
601 |
public int sizex = 0; |
602 |
public int sizey = 0; |
603 |
public String id = null; |
604 |
|
605 |
/**
|
606 |
* Inicializaci?n del XMLCombo
|
607 |
*/
|
608 |
public void init(){ |
609 |
|
610 |
if(sizex!=0 && sizey!=0) |
611 |
this.setPreferredSize(new java.awt.Dimension(sizex,sizey)); |
612 |
if(selected!=null) |
613 |
this.setSelectedItem(selected);
|
614 |
|
615 |
} |
616 |
} |
617 |
|
618 |
/**
|
619 |
* Clase que representa a un label obtenido a partir del XML
|
620 |
* que manda un driver de escritura.
|
621 |
*
|
622 |
* @author Nacho Brodin <brodin_ign@gva.es>
|
623 |
*
|
624 |
*/
|
625 |
class XMLLabel extends JLabel{ |
626 |
|
627 |
public int numPanel = -1; |
628 |
public int posIntoPanel = -1; |
629 |
public String position = null; |
630 |
public String text = null; |
631 |
|
632 |
/**
|
633 |
* Inicializaci?n del XMLLabel
|
634 |
*/
|
635 |
public void init(){ |
636 |
|
637 |
this.setText(text);
|
638 |
|
639 |
} |
640 |
} |
641 |
|
642 |
/**
|
643 |
* Clase que representa a un slider obtenido a partir del XML
|
644 |
* que manda un driver de escritura.
|
645 |
*
|
646 |
* @author Nacho Brodin <brodin_ign@gva.es>
|
647 |
*
|
648 |
*/
|
649 |
class XMLSlider extends JPanel{ |
650 |
|
651 |
public int numPanel = -1; |
652 |
public int posIntoPanel = -1; |
653 |
public int sizex = 0; |
654 |
public int sizey = 0; |
655 |
public String position = null; |
656 |
private JSlider slider = null; |
657 |
private JLabel label = null; |
658 |
public String id = null; |
659 |
|
660 |
/**
|
661 |
* Constructor
|
662 |
* @param text Texto de la barra
|
663 |
* @param smin Valor m?nimo de la barra
|
664 |
* @param smax Valor m?ximo de la barra
|
665 |
* @param sdefaultValue Valor por defecto de la barra.
|
666 |
* @param sminor Separaci?n menor de las secciones de la barra
|
667 |
* @param smajor Separaci?n mayor de las secciones de la barra
|
668 |
*/
|
669 |
public XMLSlider( String text, |
670 |
String smin,
|
671 |
String smax,
|
672 |
String sdefaultValue,
|
673 |
String sminor,
|
674 |
String smajor){
|
675 |
|
676 |
int min = 0; |
677 |
int max = 100; |
678 |
int defaultValue = 0; |
679 |
int minor = 5; |
680 |
int major = 10; |
681 |
|
682 |
//Obtenemos los valores de los par?metros
|
683 |
if(smin!=null) |
684 |
min = Integer.parseInt(smin);
|
685 |
if(smax!=null) |
686 |
max = Integer.parseInt(smax);
|
687 |
if(sdefaultValue!=null) |
688 |
defaultValue = Integer.parseInt(sdefaultValue);
|
689 |
if(sminor!=null) |
690 |
minor = Integer.parseInt(sminor);
|
691 |
if(smajor!=null) |
692 |
major = Integer.parseInt(smajor);
|
693 |
|
694 |
//Colocaci?n de elementos en el panel
|
695 |
label = new JLabel(text, JLabel.CENTER); |
696 |
slider = new JSlider(JSlider.HORIZONTAL, min, max, defaultValue); |
697 |
slider.setMajorTickSpacing(major); |
698 |
slider.setMinorTickSpacing(minor); |
699 |
slider.setPaintTicks(true);
|
700 |
slider.setPaintLabels(true);
|
701 |
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
702 |
this.add(label);
|
703 |
this.add(slider);
|
704 |
if(sizex!=0 && sizey!=0) |
705 |
this.setPreferredSize(new java.awt.Dimension(sizex, sizey)); |
706 |
|
707 |
|
708 |
} |
709 |
|
710 |
/**
|
711 |
* Obtiene la barra
|
712 |
* @return Objeto JSlider
|
713 |
*/
|
714 |
public JSlider getSlider(){return slider;} |
715 |
|
716 |
} |
717 |
|
718 |
/**
|
719 |
* Clase que representa a un checkbox obtenido a partir del XML
|
720 |
* que manda un driver de escritura.
|
721 |
*
|
722 |
* @author Nacho Brodin <brodin_ign@gva.es>
|
723 |
*
|
724 |
*/
|
725 |
class XMLCheck extends JCheckBox{ |
726 |
|
727 |
public int numPanel = -1; |
728 |
public int posIntoPanel = -1; |
729 |
public String position = null; |
730 |
public String selected = null; |
731 |
public int sizex = 0; |
732 |
public int sizey = 0; |
733 |
public String text = null; |
734 |
public String id = null; |
735 |
|
736 |
/**
|
737 |
* Contructor
|
738 |
* @param text texto del checkbox
|
739 |
* @param select true si esta seleccionado y false si no lo est?.
|
740 |
*/
|
741 |
public XMLCheck(String text, boolean select){ |
742 |
|
743 |
super(text, select);
|
744 |
this.text = text;
|
745 |
if(select)
|
746 |
selected = new String("yes"); |
747 |
else
|
748 |
selected = new String("no"); |
749 |
|
750 |
} |
751 |
|
752 |
/**
|
753 |
* Inicializaci?n del XMLCheck
|
754 |
*/
|
755 |
public void init(){ |
756 |
|
757 |
if(sizex!=0 && sizey!=0) |
758 |
this.setPreferredSize(new java.awt.Dimension(sizex,sizey)); |
759 |
|
760 |
} |
761 |
} |
762 |
|
763 |
|
764 |
/**
|
765 |
* Clase que representa a un textfield obtenido a partir del XML
|
766 |
* que manda un driver de escritura.
|
767 |
*
|
768 |
* @author Nacho Brodin <brodin_ign@gva.es>
|
769 |
*
|
770 |
*/
|
771 |
class XMLText extends JTextField{ |
772 |
|
773 |
public int numPanel = -1; |
774 |
public int posIntoPanel = -1; |
775 |
public String position = null; |
776 |
public String selected = null; |
777 |
public int sizex = 0; |
778 |
public int sizey = 0; |
779 |
public String text = null; |
780 |
public String id = null; |
781 |
|
782 |
/**
|
783 |
* Contructor
|
784 |
* @param text texto del textfield
|
785 |
*/
|
786 |
public XMLText(String text){ |
787 |
|
788 |
super(text);
|
789 |
this.text = text;
|
790 |
|
791 |
} |
792 |
|
793 |
/**
|
794 |
* Inicializaci?n del XMLCheck
|
795 |
*/
|
796 |
public void init(){ |
797 |
|
798 |
if(sizex!=0 && sizey!=0) |
799 |
this.setPreferredSize(new java.awt.Dimension(sizex,sizey)); |
800 |
|
801 |
} |
802 |
} |