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