KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > it > businesslogic > ireport > ReportReader


1 /*
2  * Report.java
3  *
4  * iReport -- Visual designer for generating JasperReports Documents
5  * Copyright (C) 2002 Giulio Toffoli gt@businesslogic.it
6  *
7 * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.Styl
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  *
21  * Giulio Toffoli
22  * Via T.Aspetti, 233
23  * 35100 Padova ITALY
24  * gt@businesslogic.it
25  *
26  * Created on 10 febbraio 2003, 19.32
27  *
28  * Updated by Robert Lamping:
29  * dtd updated with the new package path net/sf/ etc...
30  * Added Try catch to catch a missing dtd.
31  * Changed Mainframe.openFile to catch this exception and stop opening a file in case of an exception.
32  */

33
34 package it.businesslogic.ireport;
35
36 //import java.util.*;
37
import it.businesslogic.ireport.ReportWriter;
38 import it.businesslogic.ireport.chart.SectionItemHyperlink;
39 import it.businesslogic.ireport.crosstab.CrosstabParameter;
40 import it.businesslogic.ireport.gui.event.ReportDocumentStatusChangedEvent;
41 import it.businesslogic.ireport.gui.event.ReportSubDatasetChangedEvent;
42 import it.businesslogic.ireport.util.I18n;
43 import java.io.ByteArrayInputStream JavaDoc;
44 import java.io.FileInputStream JavaDoc;
45 import java.io.FileOutputStream JavaDoc;
46 import java.util.Vector JavaDoc;
47 import java.util.Iterator JavaDoc;
48 import java.util.Properties JavaDoc;
49 import java.util.Enumeration JavaDoc;
50
51 //import it.businesslogic.ireport.util.*;
52
import it.businesslogic.ireport.util.Misc;
53 import it.businesslogic.ireport.util.PageSize;
54 import it.businesslogic.ireport.gui.JReportFrame;
55 import it.businesslogic.ireport.chart.*;
56 import it.businesslogic.ireport.crosstab.CrosstabCell;
57 import it.businesslogic.ireport.crosstab.CrosstabColumnGroup;
58 import it.businesslogic.ireport.crosstab.CrosstabGroup;
59 import it.businesslogic.ireport.crosstab.CrosstabRowGroup;
60 import it.businesslogic.ireport.crosstab.Measure;
61 import it.businesslogic.ireport.gui.event.StyleChangedEvent;
62 import it.businesslogic.ireport.gui.event.SubDatasetObjectChangedListener;
63 import net.sf.jasperreports.engine.JRReport;
64 import net.sf.jasperreports.engine.JasperReport;
65 import net.sf.jasperreports.engine.util.JRLoader;
66
67
68 import org.apache.xerces.parsers.DOMParser;
69
70 //import org.w3c.dom.*;
71
import org.w3c.dom.Document JavaDoc;
72 import org.w3c.dom.NamedNodeMap JavaDoc;
73 import org.w3c.dom.Node JavaDoc;
74 import org.w3c.dom.NodeList JavaDoc;
75
76 import org.xml.sax.SAXException JavaDoc;
77
78 import java.io.IOException JavaDoc;
79 import java.io.File JavaDoc;
80 import java.io.PrintWriter JavaDoc;
81
82 /**
83  *
84  * @author Administrator
85  */

86 public class ReportReader {
87
88     private Report report = null ;
89
90     public ReportReader ( Report report )
91     {
92         this.report = report ;
93     }
94
95     public Report getReport ()
96     {
97         return report ;
98     }
99
100     public void setReport ( Report report )
101     {
102         this.report = report ;
103     }
104
105     public Report readFile ( String JavaDoc xmlFile )
106             throws IOException JavaDoc
107     {
108
109         // Set the real default...
110
getReport ().setLanguage ( "java" ) ;
111
112
113         //reset bands, prevents page height overflow for unused bands
114
for ( int i = 0 ; i < getReport ().getBands ().size () ; i++ )
115         {
116             ( ( Band ) getReport ().getBands ().elementAt ( i ) ).setHeight ( 0 ) ;
117         }
118
119         java.io.InputStream JavaDoc input_source = null ;
120         try
121         {
122             if ( xmlFile.toLowerCase ().endsWith ( ".jasper" ) )
123             {
124                 try {
125                 java.io.ByteArrayOutputStream JavaDoc bos = new java.io.
126
JavaDoc                        ByteArrayOutputStream () ;
127                 // 1. We havo to load the design...
128
JRReport jreport = (JRReport)JRLoader.loadObject(xmlFile);
129                 
130                 net.sf.jasperreports.engine.JasperCompileManager.
131                         writeReportToXmlStream (
132                                 jreport , bos ) ;
133                 
134                 input_source = new ByteArrayInputStream JavaDoc ( bos.toByteArray () ) ;
135                 
136                 } catch (Throwable JavaDoc t)
137                 {
138                     t.printStackTrace();
139                 }
140             }
141             else
142             {
143
144                 // Create a Xerces DOM Parser
145
// Parse the Document
146
// and traverse the DOM
147

148                 getReport ().setFilename ( xmlFile ) ;
149                 getReport ().checkReadOnlyFlag () ;
150
151                 // set load time...
152
getReport ().setLoadTime ( Misc.getLastWriteTime ( xmlFile ) ) ;
153
154                 File JavaDoc ffile = new File JavaDoc ( xmlFile ) ;
155                 if ( ffile.exists () )
156                 {
157                     input_source = new java.io.FileInputStream JavaDoc ( ffile ) ;
158
159                 }
160                 else
161                 {
162
163                     input_source = getReport ().getClass ().getClassLoader ().
164                                    getResourceAsStream ( xmlFile ) ;
165                 }
166
167                 // Change to the file directory...
168

169                 
170             }
171             
172             return readFromStream(input_source); //Changed by Felix Firgau
173
} catch (IOException JavaDoc e) {
174             System.out.println(e);
175             e.printStackTrace();
176             throw e ;
177
178        // } catch (net.sf.jasperreports.engine.JRException e) {
179
// System.out.println(e);
180
// e.printStackTrace();
181

182         } catch (Exception JavaDoc e) {
183             System.err.println(e);
184             e.printStackTrace();
185         }
186         finally{
187             try {
188                 if (input_source != null)
189                 {
190                     input_source.close();
191                 }
192             } catch (Exception JavaDoc ex) {}
193         }
194         return getReport();
195     }
196     /**
197      * readFromStream
198      * reads an report from an InputStream
199      *
200      * Author: Felix Firgau
201      *
202      * @param input_source InputStream
203      * @return Report
204      * @throws IOException
205      */

206     public Report readFromStream(java.io.InputStream JavaDoc input_source)
207             throws IOException JavaDoc
208     {
209             try {
210                 DOMParser parser = new DOMParser();
211
212                 parser.setEntityResolver( new org.xml.sax.EntityResolver JavaDoc() {
213
214                     /* Code by Teodor Danciu */
215                     public org.xml.sax.InputSource JavaDoc resolveEntity( String JavaDoc publicId, String JavaDoc systemId )
216                            throws SAXException JavaDoc, IOException JavaDoc
217                     {
218                         org.xml.sax.InputSource JavaDoc inputSource = null;
219
220                         //System.out.println("Resolving : " + publicId + " " + systemId);
221

222                         if (systemId != null) {
223                             String JavaDoc dtd = null;
224
225                             if ( systemId.equals("http://jasperreports.sourceforge.net/dtds/jasperreport.dtd") ||
226                             systemId.equals("http://www.jasperreports.com/dtds/jasperreport.dtd") ) {
227                                 //dtd = "dori/jasper/engine/dtds/jasperreport.dtd";
228
dtd = "net/sf/jasperreports/engine/dtds/jasperreport.dtd";
229
230                             } else if (
231                             systemId.equals("http://jasperreports.sourceforge.net/dtds/jasperprint.dtd") ||
232                             systemId.equals("http://www.jasperreports.com/dtds/jasperprint.dtd") ) {
233                                 dtd = "net/sf/jasperreports/engine/dtds/jasperprint.dtd";
234                             } else {
235
236                                 return new org.xml.sax.InputSource JavaDoc(systemId);
237                             }
238
239
240                             ClassLoader JavaDoc classLoader = getReport().getClass().getClassLoader();
241                             java.net.URL JavaDoc url = null;
242
243                             if (classLoader != null) {
244                                 url = classLoader.getResource(dtd);
245                                 if (url == null) {
246                                     classLoader = getReport().getClass().getClassLoader();
247                                 }
248
249                             } else {
250                                 // url is certainly null
251
// classLoader stays null
252
}
253
254
255                             java.io.InputStream JavaDoc is = classLoader.getResourceAsStream(dtd);
256                             if (is != null) {
257                                 java.io.InputStreamReader JavaDoc isr = new java.io.InputStreamReader JavaDoc(is);
258                                 inputSource = new org.xml.sax.InputSource JavaDoc(isr);
259                             } else {
260                                 // dtd could not be found
261
// this error occurs e.g. when the package name / path changes to this dtd
262
// the error will be caught by MainFrame.openFile() en the report file won't open
263
throw new java.io.IOException JavaDoc( "iReport Internal error in report.java: Could not find: " + dtd + "\n" );
264                             }
265                         }
266                         return inputSource;
267
268                     }
269                 });
270                 /* End Code by Teodor Danciu */
271
272                     //String f = new java.io.File(xmlFile).toURI().toString();
273
org.xml.sax.InputSource JavaDoc input_sss = new org.xml.sax.InputSource JavaDoc( input_source );
274                     input_sss.setSystemId("file:///" + getReport().getFilename());
275
276                     parser.parse( input_sss );
277
278                     //System.out.println(parser.getFeature("http://apache.org/xml/features/dom/create-entity-ref-nodes"));
279

280                     Document JavaDoc document = parser.getDocument();
281                     getReport().setEncoding(Misc.nvl(input_sss.getEncoding(),"UTF-8"));
282
283                     traverse(document.getDocumentElement());
284
285
286
287             /* Begin Code by Robert Lamping
288              * 2 July 2004
289              * Now height and width are known and a format can be guessed.
290              * using PageSize.deductPageFormat();
291              */

292
293             getReport().setReportFormat( PageSize.deductPageFormat( getReport().getWidth(), getReport().getHeight()) );
294
295
296             for (int i = 0; i < getReport().getGroups().size(); i++) {
297                 it.businesslogic.ireport.Group grp = (it.businesslogic.ireport.Group)getReport().getGroups().elementAt(i);
298                 getReport().addGroup(grp,false);
299             }
300
301             /*
302             for (int i=0; i<getBands().size(); ++i)
303             {
304                 Band b = (Band)getBands().elementAt(i);
305                 getReport().elementGroupResort( b );
306             }
307              */

308
309             // Translate coords to iReport coord system...
310
for (int i =0; i < getReport().getElements().size(); ++i) {
311                 ReportElement re = (ReportElement)getReport().getElements().elementAt(i);
312
313
314                 if (re.getParentElement() != null)
315                 {
316                     re.trasform(new java.awt.Point JavaDoc((int)re.getParentElement().getPosition().getX(), (int)re.getParentElement().getPosition().getY()), TransformationType.TRANSFORMATION_MOVE);
317                 }
318                 else
319                 {
320                     re.trasform(new java.awt.Point JavaDoc(getReport().getLeftMargin()+10, getReport().getBandYLocation(re.getBand())+10), TransformationType.TRANSFORMATION_MOVE);
321                 }
322             }
323
324
325
326
327             // Scriptlet loading....
328

329             // Process custom properties (ireport.* properties).
330
// We cut out ireport properties...
331
//System.out.println("Analizing properties...");
332
//System.out.println("Possible file: "+getReport().getScriptletFileName());
333

334             if (getReport().getScriptletFileName() != null)
335             {
336                 getReport().setScriptletHandling( getReport().SCRIPTLET_CLASSIC_HANDLING);
337             }
338
339             for (int pk= 0; pk < getReport().getJRproperties().size(); ++pk) {
340                 JRProperty prop = (JRProperty)getReport().getJRproperties().elementAt( pk );
341
342                 //System.out.println(""+prop.getName());
343

344                 if (prop.getName().equals("ireport.scriptlethandling")) {
345                     if (prop.getValue().equals("0")) {
346                         getReport().setScriptletHandling(0);
347                     } else if (prop.getValue().equals("1")) {
348                         getReport().setScriptletHandling( getReport().SCRIPTLET_IREPORT_INTERNAL_HANDLING );
349                         // Try to load the source file...
350
File JavaDoc scriptletFile = new File JavaDoc(getReport().getScriptletFileName());
351                         if (scriptletFile.exists()) {
352                             getReport().setScripletCode( new ScriptletCode(getReport().getScriptletFileName()) );
353                             //System.out.println("Caricato scriptlet");
354
}
355                     }
356                 }
357
358                 if (prop.getName().equals("ireport.encoding")) {
359                     getReport().setEncoding(prop.getValue());
360                 }
361
362                 if (prop.getValue().startsWith("ireport.")) {
363                     getReport().getJRproperties().remove( prop );
364                     pk--;
365                 }
366             }
367
368             if (getReport().getScriptletHandling() == 2 &&
369                 (getReport().getScriptletClass() == null || getReport().getScriptletClass().equals("")) )
370                 {
371                     getReport().setScriptletHandling(0);
372                 }
373
374             // } catch (SAXException e) {
375
// System.err.println(e);
376
} catch (IOException JavaDoc e) {
377             System.out.println(e);
378             e.printStackTrace();
379             throw e ;
380
381         } catch (Exception JavaDoc e) {
382             System.err.println(e);
383             e.printStackTrace();
384         }
385
386         // Set the report status to Unchanged...
387
// This will thrown an ReportStateChanged
388
getReport().setReportChanges( 0 );
389
390         return getReport();
391     }
392
393
394     // Traverse DOM Tree. Print out Element Names
395
private void traverse(Node JavaDoc node) {
396
397         boolean seeInside = false;
398         if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("jasperReport")) {
399
400             seeInside = true;
401             // Find encoding...
402
NamedNodeMap JavaDoc nnm = node.getAttributes();
403
404             getReport().setName((( nnm.getNamedItem("name") != null) ? nnm.getNamedItem("name").getNodeValue() : ""));
405
406             if ( nnm.getNamedItem("columnCount") != null) {
407                 getReport().setColumnCount( Integer.parseInt(nnm.getNamedItem("columnCount").getNodeValue()));
408             }
409             if ( nnm.getNamedItem("printOrder") != null) {
410                 getReport().setPrintOrder( nnm.getNamedItem("printOrder").getNodeValue());
411             }
412             if ( nnm.getNamedItem("orientation") != null) {
413                 getReport().setOrientation( nnm.getNamedItem("orientation").getNodeValue());
414             }
415             if ( nnm.getNamedItem("scriptletClass") != null) {
416                 getReport().setScriptletClass( nnm.getNamedItem("scriptletClass").getNodeValue());
417             }
418             if ( nnm.getNamedItem("resourceBundle") != null) {
419                 getReport().setResourceBundleBaseName( nnm.getNamedItem("resourceBundle").getNodeValue());
420             }
421             if ( nnm.getNamedItem("pageWidth") != null) {
422                 getReport().setWidth( Integer.parseInt(nnm.getNamedItem("pageWidth").getNodeValue()));
423             }
424             if ( nnm.getNamedItem("pageHeight") != null) {
425                 getReport().setHeight( Integer.parseInt(nnm.getNamedItem("pageHeight").getNodeValue()));
426             }
427             if ( nnm.getNamedItem("columnWidth") != null) {
428                 getReport().setColumnWidth( Integer.parseInt(nnm.getNamedItem("columnWidth").getNodeValue()));
429             }
430             if ( nnm.getNamedItem("columnSpacing") != null) {
431                 getReport().setColumnSpacing( Integer.parseInt(nnm.getNamedItem("columnSpacing").getNodeValue()));
432             }
433             if ( nnm.getNamedItem("leftMargin") != null) {
434                 getReport().setLeftMargin( Integer.parseInt(nnm.getNamedItem("leftMargin").getNodeValue()));
435             }
436             if ( nnm.getNamedItem("rightMargin") != null) {
437                 getReport().setRightMargin( Integer.parseInt(nnm.getNamedItem("rightMargin").getNodeValue()));
438             }
439             if ( nnm.getNamedItem("topMargin") != null) {
440                 getReport().setTopMargin( Integer.parseInt(nnm.getNamedItem("topMargin").getNodeValue()));
441             }
442             if ( nnm.getNamedItem("bottomMargin") != null) {
443                 getReport().setBottomMargin( Integer.parseInt(nnm.getNamedItem("bottomMargin").getNodeValue()));
444             }
445             if ( nnm.getNamedItem("whenNoDataType") != null) {
446                 getReport().setWhenNoDataType( nnm.getNamedItem("whenNoDataType").getNodeValue());
447             }
448             if ( nnm.getNamedItem("isTitleNewPage") != null) {
449                 getReport().setIsTitleNewPage(nnm.getNamedItem("isTitleNewPage").getNodeValue().equalsIgnoreCase("true") );
450             }
451             if ( nnm.getNamedItem("isSummaryNewPage") != null) {
452                 getReport().setIsSummaryNewPage( nnm.getNamedItem("isSummaryNewPage").getNodeValue().equalsIgnoreCase("true"));
453             }
454
455             if ( nnm.getNamedItem("isFloatColumnFooter") != null) {
456                 getReport().setFloatColumnFooter(nnm.getNamedItem("isFloatColumnFooter").getNodeValue().equalsIgnoreCase("true") );
457             }
458
459             if ( nnm.getNamedItem("language") != null) {
460                 getReport().setLanguage( nnm.getNamedItem("language").getNodeValue());
461             }
462
463             if ( nnm.getNamedItem("whenResourceMissingType") != null) {
464                 getReport().setWhenResourceMissingType( nnm.getNamedItem("whenResourceMissingType").getNodeValue());
465             }
466
467             if ( nnm.getNamedItem("isIgnorePagination") != null) {
468                 getReport().setIgnorePagination( nnm.getNamedItem("isIgnorePagination").getNodeValue().equalsIgnoreCase("true"));
469             }
470             
471             if ( nnm.getNamedItem("formatFactoryClass") != null) {
472                 getReport().setFormatFactoryClass( nnm.getNamedItem("formatFactoryClass").getNodeValue());
473             }
474
475
476
477         } else if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("property")) {
478
479             // Load report property...
480
it.businesslogic.ireport.JRProperty property = readPropertyElement(node);
481             if (property.getName() != null && property.getName().length() != 0) {
482                     getReport().addJRProperty( property );
483             }
484         } else if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("import")) {
485
486             // Load report IMPORT...
487
NamedNodeMap JavaDoc nnm = node.getAttributes();
488             if ( nnm.getNamedItem("value") != null) {
489                 getReport().addImport( nnm.getNamedItem("value").getNodeValue() );
490             }
491         }
492         else if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("reportFont")) {
493
494             // Load report font...
495
boolean isDefaultFont = false;
496             IReportFont font = new IReportFont();
497
498             NamedNodeMap JavaDoc nnm = node.getAttributes();
499
500             for (int kkk=0; kkk<nnm.getLength(); ++kkk)
501             {
502                 //System.out.println( + " " + );
503

504                 String JavaDoc propName = nnm.item(kkk).getNodeName();
505                 String JavaDoc propValue = nnm.item(kkk).getNodeValue();
506                 if (propName != null && propValue != null)
507                 {
508                     if (propName.equals("name"))
509                         font.setReportFont(propValue);
510                     if (propName.equals("isDefault"))
511                     {
512                         isDefaultFont = propValue.equals("true");
513                         font.setDefaultFont(isDefaultFont);
514                     }
515                     if (propName.equals("fontName"))
516                         font.setFontName(propValue);
517                     else if (propName.equals("pdfFontName"))
518                         font.setPDFFontName(propValue);
519                     else if (propName.equals("size"))
520                         font.setFontSize( Integer.parseInt(""+propValue) );
521                     else if (propName.equals("isBold"))
522                         font.setBold( (new String JavaDoc(""+propValue)).equalsIgnoreCase("true") );
523                     else if (propName.equals("isItalic"))
524                         font.setItalic( (new String JavaDoc(""+propValue)).equalsIgnoreCase("true") );
525                     else if (propName.equals("isUnderline"))
526                         font.setUnderline( (new String JavaDoc(""+propValue)).equalsIgnoreCase("true") );
527                     else if (propName.equals("isStrikeThrough"))
528                         font.setStrikeTrought( (new String JavaDoc(""+propValue)).equalsIgnoreCase("true") );
529                     else if (propName.equals("isPdfEmbedded"))
530                         font.setPdfEmbedded((new String JavaDoc(""+propValue)).equalsIgnoreCase("true") );
531                     else if (propName.equals("pdfEncoding"))
532                         font.setPdfEncoding( ""+propValue );
533                 }
534             }
535
536
537             if (isDefaultFont){
538                 getReport().setDefaultFont( (IReportFont) font.clone() );
539             }
540
541             getReport().getFonts().addElement( font );
542         }
543         else if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("style")) {
544
545             Style style = readStyle(node);
546             getReport().getStyles().addElement( style );
547
548             // Update Styles parents...
549
for (int i=0; i<getReport().getStyles().size(); ++i)
550             {
551                Style s = (Style)getReport().getStyles().elementAt(i);
552                if (s.getAttribute(s.ATTRIBUTE_style) != null && !(s.getAttribute(s.ATTRIBUTE_style) instanceof Style))
553                {
554                    for (int j=0; j<getReport().getStyles().size(); ++j)
555                    {
556                         Style sparent = (Style)getReport().getStyles().elementAt(j);
557                         if (sparent.getName().equals( s.getAttribute(s.ATTRIBUTE_style)+""))
558                         {
559                             s.getAttributes().put(s.ATTRIBUTE_style, sparent);
560                         }
561                    }
562                }
563             }
564         }
565         else if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("parameter")) {
566
567             // Load parameter...
568
it.businesslogic.ireport.JRParameter parameter = readParameterElement(node);
569
570             if (parameter.getName() != null && parameter.getName().length() != 0) {
571                 getReport().addParameter( parameter );
572             }
573         }
574         else if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("queryString")) {
575             // Load queryString
576
NamedNodeMap JavaDoc nnm = node.getAttributes();
577             if ( nnm.getNamedItem("language") != null) {
578                 getReport().setQueryLanguage( nnm.getNamedItem("language").getNodeValue());
579             }
580
581             getReport().setQuery( readPCDATA(node) );
582         }
583         else if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("filterExpression")) {
584             getReport().setFilterExpression( readPCDATA(node) );
585         }
586         else if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("field")) {
587             // Load field
588
it.businesslogic.ireport.JRField field = readFieldElement(node);
589
590             if (field.getName() != null && field.getName().length() != 0) {
591                 getReport().addField( field );
592             }
593         }
594         else if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("variable")) {
595             // Load variable
596
it.businesslogic.ireport.JRVariable variable = readVariableElement( node );
597
598             if (variable.getName() != null && variable.getName().length() != 0) {
599                 getReport().addVariable( variable );
600             }
601         }
602         else if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("sortField")) {
603             it.businesslogic.ireport.SortField sortField = readSortFieldElement( node );
604             getReport().addSortField(sortField);
605         }
606         else if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("subDataset")) {
607             // Load field
608
it.businesslogic.ireport.SubDataset subDataset = new it.businesslogic.ireport.SubDataset();
609
610             NamedNodeMap JavaDoc nnm = node.getAttributes();
611             if ( nnm.getNamedItem("scriptletClass") != null) {
612                 subDataset.setScriptletClass( nnm.getNamedItem("scriptletClass").getNodeValue());
613             }
614             if ( nnm.getNamedItem("resourceBundle") != null) {
615                 subDataset.setResourceBundleBaseName( nnm.getNamedItem("resourceBundle").getNodeValue());
616             }
617             if ( nnm.getNamedItem("whenResourceMissingType") != null) {
618                 subDataset.setWhenResourceMissingType( nnm.getNamedItem("whenResourceMissingType").getNodeValue());
619             }
620             subDataset.setName((( nnm.getNamedItem("name") != null) ? nnm.getNamedItem("name").getNodeValue() : "SubDataset"));
621
622             NodeList JavaDoc children = node.getChildNodes();
623             if (children != null) {
624                 for (int k=0; k< children.getLength(); k++) {
625                     Node JavaDoc nodeChild = (Node JavaDoc)children.item(k);
626                     if (nodeChild.getNodeType() == Node.ELEMENT_NODE && nodeChild.getNodeName().equals("property")) {
627                         // Take the CDATA...
628
it.businesslogic.ireport.JRProperty property = readPropertyElement(nodeChild);
629                         if (property.getName() != null && property.getName().length() != 0) {
630                                 subDataset.addJRProperty( property );
631                         }
632                     }
633                     else if (nodeChild.getNodeType() == Node.ELEMENT_NODE && nodeChild.getNodeName().equals("parameter")) {
634                         // Take the CDATA...
635
it.businesslogic.ireport.JRParameter parameter = readParameterElement(nodeChild);
636                         if (parameter.getName() != null && parameter.getName().length() != 0) {
637                                 subDataset.addParameter( parameter );
638                         }
639                     }
640                     else if (nodeChild.getNodeType() == Node.ELEMENT_NODE && nodeChild.getNodeName().equals("field")) {
641                         // Take the CDATA...
642
it.businesslogic.ireport.JRField field = readFieldElement(nodeChild);
643
644                         if (field.getName() != null && field.getName().length() != 0) {
645                                 subDataset.addField( field );
646                         }
647                     }
648                     else if (nodeChild.getNodeType() == Node.ELEMENT_NODE && nodeChild.getNodeName().equals("variable")) {
649                         // Take the CDATA...
650
it.businesslogic.ireport.JRVariable variable = readVariableElement(nodeChild);
651                         if (variable.getName() != null && variable.getName().length() != 0) {
652                                 subDataset.addVariable( variable );
653                         }
654                     }
655                     else if (nodeChild.getNodeType() == Node.ELEMENT_NODE && nodeChild.getNodeName().equals("queryString")) {
656                         // Take the CDATA...
657
NamedNodeMap JavaDoc nnmChild = nodeChild.getAttributes();
658                         if ( nnmChild.getNamedItem("language") != null) {
659                             subDataset.setQueryLanguage( nnmChild.getNamedItem("language").getNodeValue());
660                         }
661                         subDataset.setQuery( readPCDATA(nodeChild) );
662                     }
663                     else if (nodeChild.getNodeType() == Node.ELEMENT_NODE && nodeChild.getNodeName().equals("filterExpression")) {
664                        subDataset.setFilterExpression( readPCDATA(nodeChild) );
665                     }
666                     else if (nodeChild.getNodeType() == Node.ELEMENT_NODE && nodeChild.getNodeName().equals("group")) {
667                         // Take the CDATA...
668
it.businesslogic.ireport.Group group = readGroupElement(subDataset, nodeChild, false);
669                         subDataset.getGroups().add(group);
670                     }
671                     else if (nodeChild.getNodeType() == Node.ELEMENT_NODE && nodeChild.getNodeName().equals("sortField")) {
672                         // Take the CDATA...
673
it.businesslogic.ireport.SortField sortField = readSortFieldElement( nodeChild );
674                         subDataset.addSortField(sortField);
675                     }
676                 }
677             }
678
679             getReport().addSubDataset(subDataset );
680
681         }
682         else if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("group")) {
683             // Load group
684

685             it.businesslogic.ireport.Group group = readGroupElement(getReport(), node, true);
686             if (group.getName() != null && group.getName().length() != 0) {
687                 getReport().getGroups().addElement(group); // We don't use here addGroup method!
688
}
689         }
690         else if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("background")) {
691             // Load background band
692
NodeList JavaDoc list_child = node.getChildNodes();
693             for (int ck=0; ck< list_child.getLength(); ck++) {
694                 Node JavaDoc bandNode = (Node JavaDoc)list_child.item(ck);
695                 if (bandNode.getNodeType() == Node.ELEMENT_NODE && bandNode.getNodeName().equals("band")) {
696                     // Read the band...
697
NamedNodeMap JavaDoc bandAttributes = bandNode.getAttributes();
698                     Band b = getReport().getBandByName("background");
699                     if ( bandAttributes.getNamedItem("height") != null) b.setHeight( Integer.parseInt(bandAttributes.getNamedItem("height").getNodeValue()) );
700                     if ( bandAttributes.getNamedItem("isSplitAllowed") != null) b.setSplitAllowed( bandAttributes.getNamedItem("isSplitAllowed").getNodeValue().equals("true") );
701                     readBandElements(bandNode,b);
702                 }
703             }
704         }
705         else if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("title")) {
706             // Load title band
707
NodeList JavaDoc list_child = node.getChildNodes();
708             for (int ck=0; ck< list_child.getLength(); ck++) {
709                 Node JavaDoc bandNode = (Node JavaDoc)list_child.item(ck);
710                 if (bandNode.getNodeType() == Node.ELEMENT_NODE && bandNode.getNodeName().equals("band")) {
711                     // Read the band...
712
NamedNodeMap JavaDoc bandAttributes = bandNode.getAttributes();
713                     Band b = getReport().getBandByName("title");
714                     if ( bandAttributes.getNamedItem("height") != null) b.setHeight( Integer.parseInt(bandAttributes.getNamedItem("height").getNodeValue()) );
715                     if ( bandAttributes.getNamedItem("isSplitAllowed") != null) b.setSplitAllowed( bandAttributes.getNamedItem("isSplitAllowed").getNodeValue().equals("true") );
716                     readBandElements(bandNode,b);
717                 }
718             }
719         }
720         else if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("pageHeader")) {
721             // Load pageHeader band
722
NodeList JavaDoc list_child = node.getChildNodes();
723             for (int ck=0; ck< list_child.getLength(); ck++) {
724                 Node JavaDoc bandNode = (Node JavaDoc)list_child.item(ck);
725                 if (bandNode.getNodeType() == Node.ELEMENT_NODE && bandNode.getNodeName().equals("band")) {
726                     // Read the band...
727
NamedNodeMap JavaDoc bandAttributes = bandNode.getAttributes();
728                     Band b = getReport().getBandByName("pageHeader");
729                     if ( bandAttributes.getNamedItem("height") != null) b.setHeight( Integer.parseInt(bandAttributes.getNamedItem("height").getNodeValue()) );
730                     if ( bandAttributes.getNamedItem("isSplitAllowed") != null) b.setSplitAllowed( bandAttributes.getNamedItem("isSplitAllowed").getNodeValue().equals("true") );
731                     readBandElements(bandNode,b);
732                 }
733             }
734         }
735         else if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("columnHeader")) {
736             // Load columnHeader band
737
NodeList JavaDoc list_child = node.getChildNodes();
738             for (int ck=0; ck< list_child.getLength(); ck++) {
739                 Node JavaDoc bandNode = (Node JavaDoc)list_child.item(ck);
740                 if (bandNode.getNodeType() == Node.ELEMENT_NODE && bandNode.getNodeName().equals("band")) {
741                     // Read the band...
742
NamedNodeMap JavaDoc bandAttributes = bandNode.getAttributes();
743                     Band b = getReport().getBandByName("columnHeader");
744                     if ( bandAttributes.getNamedItem("height") != null) b.setHeight( Integer.parseInt(bandAttributes.getNamedItem("height").getNodeValue()) );
745                     if ( bandAttributes.getNamedItem("isSplitAllowed") != null) b.setSplitAllowed( bandAttributes.getNamedItem("isSplitAllowed").getNodeValue().equals("true") );
746                     readBandElements(bandNode,b);
747                 }
748             }
749         }
750         else if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("detail")) {
751             // Load detail band
752
NodeList JavaDoc list_child = node.getChildNodes();
753             for (int ck=0; ck< list_child.getLength(); ck++) {
754                 Node JavaDoc bandNode = (Node JavaDoc)list_child.item(ck);
755                 if (bandNode.getNodeType() == Node.ELEMENT_NODE && bandNode.getNodeName().equals("band")) {
756                     // Read the band...
757
NamedNodeMap JavaDoc bandAttributes = bandNode.getAttributes();
758                     Band b = getReport().getBandByName("detail");
759                     if ( bandAttributes.getNamedItem("height") != null) b.setHeight( Integer.parseInt(bandAttributes.getNamedItem("height").getNodeValue()) );
760                     if ( bandAttributes.getNamedItem("isSplitAllowed") != null) b.setSplitAllowed( bandAttributes.getNamedItem("isSplitAllowed").getNodeValue().equals("true") );
761                     readBandElements(bandNode,b);
762                 }
763             }
764         }
765         else if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("columnFooter")) {
766             // Load columnFooter band
767
NodeList JavaDoc list_child = node.getChildNodes();
768             for (int ck=0; ck< list_child.getLength(); ck++) {
769                 Node JavaDoc bandNode = (Node JavaDoc)list_child.item(ck);
770                 if (bandNode.getNodeType() == Node.ELEMENT_NODE && bandNode.getNodeName().equals("band")) {
771                     // Read the band...
772
NamedNodeMap JavaDoc bandAttributes = bandNode.getAttributes();
773                     Band b = getReport().getBandByName("columnFooter");
774                     if ( bandAttributes.getNamedItem("height") != null) b.setHeight( Integer.parseInt(bandAttributes.getNamedItem("height").getNodeValue()) );
775                     if ( bandAttributes.getNamedItem("isSplitAllowed") != null) b.setSplitAllowed( bandAttributes.getNamedItem("isSplitAllowed").getNodeValue().equals("true") );
776                     readBandElements(bandNode,b);
777                 }
778             }
779         }
780         else if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("pageFooter")) {
781             // Load pageFooter band
782
NodeList JavaDoc list_child = node.getChildNodes();
783             for (int ck=0; ck< list_child.getLength(); ck++) {
784                 Node JavaDoc bandNode = (Node JavaDoc)list_child.item(ck);
785                 if (bandNode.getNodeType() == Node.ELEMENT_NODE && bandNode.getNodeName().equals("band")) {
786                     // Read the band...
787
NamedNodeMap JavaDoc bandAttributes = bandNode.getAttributes();
788                     Band b = getReport().getBandByName("pageFooter");
789                     if ( bandAttributes.getNamedItem("height") != null) b.setHeight( Integer.parseInt(bandAttributes.getNamedItem("height").getNodeValue()) );
790                     if ( bandAttributes.getNamedItem("isSplitAllowed") != null) b.setSplitAllowed( bandAttributes.getNamedItem("isSplitAllowed").getNodeValue().equals("true") );
791                     readBandElements(bandNode,b);
792                 }
793             }
794         }
795         else if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("lastPageFooter")) {
796             // Load title band
797
NodeList JavaDoc list_child = node.getChildNodes();
798             for (int ck=0; ck< list_child.getLength(); ck++) {
799                 Node JavaDoc bandNode = (Node JavaDoc)list_child.item(ck);
800                 if (bandNode.getNodeType() == Node.ELEMENT_NODE && bandNode.getNodeName().equals("band")) {
801                     // Read the band...
802
NamedNodeMap JavaDoc bandAttributes = bandNode.getAttributes();
803                     Band b = getReport().getBandByName("lastPageFooter");
804                     if ( bandAttributes.getNamedItem("height") != null) b.setHeight( Integer.parseInt(bandAttributes.getNamedItem("height").getNodeValue()) );
805                     if ( bandAttributes.getNamedItem("isSplitAllowed") != null) b.setSplitAllowed( bandAttributes.getNamedItem("isSplitAllowed").getNodeValue().equals("true") );
806                     readBandElements(bandNode,b);
807                 }
808             }
809         }
810         else if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("summary")) {
811             // Load summary band
812
NodeList JavaDoc list_child = node.getChildNodes();
813             for (int ck=0; ck< list_child.getLength(); ck++) {
814                 Node JavaDoc bandNode = (Node JavaDoc)list_child.item(ck);
815                 if (bandNode.getNodeType() == Node.ELEMENT_NODE && bandNode.getNodeName().equals("band")) {
816                     // Read the band...
817
NamedNodeMap JavaDoc bandAttributes = bandNode.getAttributes();
818                     Band b = getReport().getBandByName("summary");
819                     if ( bandAttributes.getNamedItem("height") != null) b.setHeight( Integer.parseInt(bandAttributes.getNamedItem("height").getNodeValue()) );
820                     if ( bandAttributes.getNamedItem("isSplitAllowed") != null) b.setSplitAllowed( bandAttributes.getNamedItem("isSplitAllowed").getNodeValue().equals("true") );
821
822                     readBandElements(bandNode,b);
823                 }
824             }
825         }
826         else
827         {
828             if (node.getNodeType() == node.ENTITY_REFERENCE_NODE)
829             {
830                 seeInside = true;
831             }
832         }
833
834         if (seeInside)
835         {
836             NodeList JavaDoc children = node.getChildNodes();
837             if (children != null) {
838                 for (int i=0; i< children.getLength(); i++)
839                     traverse(children.item(i));
840             }
841         }
842
843     }
844
845     private void readBandElements(Node JavaDoc bandNode, Band band) {
846             readBandElements("", bandNode, band, null,null,null);
847     }
848
849      private void readBandElements(String JavaDoc parentElementGroup, Node JavaDoc bandNode, Band band, ReportElement parent) {
850             readBandElements(parentElementGroup, bandNode, band, parent,null,null);
851     }
852
853     private it.businesslogic.ireport.JRParameter readParameterElement(Node JavaDoc parameterNode)
854     {
855         // Load parameter...
856
it.businesslogic.ireport.JRParameter parameter = new it.businesslogic.ireport.JRParameter("","java.lang.String",true,"");
857
858         NamedNodeMap JavaDoc nnm = parameterNode.getAttributes();
859         if ( nnm.getNamedItem("name") != null) {
860             parameter.setName( nnm.getNamedItem("name").getNodeValue());
861         }
862         if ( nnm.getNamedItem("class") != null) {
863             parameter.setClassType( nnm.getNamedItem("class").getNodeValue() );
864         }
865         if ( nnm.getNamedItem("isForPrompting") != null) {
866             parameter.setIsForPrompting( nnm.getNamedItem("isForPrompting").getNodeValue().equalsIgnoreCase("true") );
867         }
868
869         // Check for description and expression...
870
NodeList JavaDoc children = parameterNode.getChildNodes();
871         if (children != null) {
872             for (int k=0; k< children.getLength(); k++) {
873                 Node JavaDoc nodeChild = (Node JavaDoc)children.item(k);
874                 if (nodeChild.getNodeType() == Node.ELEMENT_NODE && nodeChild.getNodeName().equals("parameterDescription")) {
875                     // Take the CDATA...
876

877                     NodeList JavaDoc list_child = nodeChild.getChildNodes();
878                     for (int ck = 0; ck< list_child.getLength(); ck++) {
879                         Node JavaDoc child_child = (Node JavaDoc)list_child.item(ck);
880                         if (child_child.getNodeType() == Node.CDATA_SECTION_NODE ||
881                         child_child.getNodeType() == Node.TEXT_NODE) {
882                             parameter.setDescription( child_child.getNodeValue() );
883                         }
884                     }
885                 } else if (nodeChild.getNodeType() == Node.ELEMENT_NODE && nodeChild.getNodeName().equals("defaultValueExpression")) {
886                     // Take the CDATA...
887
NodeList JavaDoc list_child = nodeChild.getChildNodes();
888                     for (int ck = 0; ck < list_child.getLength(); ck++) {
889                         Node JavaDoc child_child = (Node JavaDoc)list_child.item(ck);
890                         if (child_child.getNodeType() == Node.CDATA_SECTION_NODE ||
891                         child_child.getNodeType() == Node.TEXT_NODE) {
892                             parameter.setDefaultValueExpression( child_child.getNodeValue() );
893                         }
894                     }
895                 }
896             }
897         }
898
899         return parameter;
900     }
901
902     private it.businesslogic.ireport.JRField readFieldElement(Node JavaDoc fieldNode)
903     {
904             it.businesslogic.ireport.JRField field = new it.businesslogic.ireport.JRField("","java.lang.String");
905             field.setDescription("");
906
907             NamedNodeMap JavaDoc nnm = fieldNode.getAttributes();
908             if ( nnm.getNamedItem("name") != null) {
909                 field.setName( nnm.getNamedItem("name").getNodeValue());
910             }
911             if ( nnm.getNamedItem("class") != null) {
912                 field.setClassType( nnm.getNamedItem("class").getNodeValue() );
913             }
914
915             NodeList JavaDoc children = fieldNode.getChildNodes();
916             if (children != null) {
917                 for (int k=0; k< children.getLength(); k++) {
918                     Node JavaDoc nodeChild = (Node JavaDoc)children.item(k);
919
920                     if (nodeChild.getNodeType() == Node.ELEMENT_NODE && nodeChild.getNodeName().equals("fieldDescription")) {
921                         // Take the CDATA...
922
NodeList JavaDoc list_child = nodeChild.getChildNodes();
923
924                         for (int ck=0; ck< list_child.getLength(); ck++) {
925
926                             Node JavaDoc child_child = (Node JavaDoc)list_child.item(ck);
927                             if (child_child.getNodeType() == Node.CDATA_SECTION_NODE ||
928                             child_child.getNodeType() == Node.TEXT_NODE) {
929                                 field.setDescription( child_child.getNodeValue() );
930                             }
931                         }
932                     }
933                 }
934
935             }
936
937             return field;
938     }
939
940     private SortField readSortFieldElement(Node JavaDoc fieldNode)
941     {
942             SortField field = new SortField();
943
944             NamedNodeMap JavaDoc nnm = fieldNode.getAttributes();
945             if ( nnm.getNamedItem("name") != null) {
946                 field.setFieldName( nnm.getNamedItem("name").getNodeValue());
947             }
948             if ( nnm.getNamedItem("order") != null) {
949                 field.setDesc( nnm.getNamedItem("order").getNodeValue().equals("Descending") );
950             }
951
952             return field;
953     }
954     
955     private it.businesslogic.ireport.JRProperty readPropertyElement(Node JavaDoc propertyNode)
956     {
957             // Load report property...
958
JRProperty property = new JRProperty();
959             NamedNodeMap JavaDoc nnm = propertyNode.getAttributes();
960             if ( nnm.getNamedItem("name") != null) {
961                 property.setName( nnm.getNamedItem("name").getNodeValue());
962             }
963             if ( nnm.getNamedItem("value") != null) {
964                 property.setValue( nnm.getNamedItem("value").getNodeValue());
965             }
966
967             return property;
968     }
969
970     private it.businesslogic.ireport.JRVariable readVariableElement(Node JavaDoc variableNode)
971     {
972         // Load variable
973
it.businesslogic.ireport.JRVariable variable = new it.businesslogic.ireport.JRVariable("",false);
974             variable.setResetType("Report"); //Default value...
975
variable.setResetGroup(""); //Default value...
976

977             variable.setIncrementType("None"); //Default value...
978
variable.setIncrementGroup(""); //Default value...
979

980             variable.setCalculation("Nothing"); //Default value...
981

982             NamedNodeMap JavaDoc nnm = variableNode.getAttributes();
983             if ( nnm.getNamedItem("name") != null) {
984                 variable.setName( nnm.getNamedItem("name").getNodeValue());
985             }
986             if ( nnm.getNamedItem("class") != null) {
987                 variable.setClassType( nnm.getNamedItem("class").getNodeValue() );
988             }
989             if ( nnm.getNamedItem("resetType") != null) {
990                 variable.setResetType( nnm.getNamedItem("resetType").getNodeValue() );
991             }
992             if ( nnm.getNamedItem("resetGroup") != null) {
993                 variable.setResetGroup( nnm.getNamedItem("resetGroup").getNodeValue() );
994             }
995             if ( nnm.getNamedItem("calculation") != null) {
996                 variable.setCalculation( nnm.getNamedItem("calculation").getNodeValue() );
997             }
998             if ( nnm.getNamedItem("incrementerFactoryClass") != null) {
999                 variable.setIncrementerFactoryClass( nnm.getNamedItem("incrementerFactoryClass").getNodeValue() );
1000            }
1001            if ( nnm.getNamedItem("incrementType") != null) {
1002                variable.setIncrementType( nnm.getNamedItem("incrementType").getNodeValue());
1003            }
1004            if ( nnm.getNamedItem("incrementGroup") != null) {
1005                variable.setIncrementGroup( nnm.getNamedItem("incrementGroup").getNodeValue());
1006            }
1007
1008            // Check for description and expression...
1009
NodeList JavaDoc children = variableNode.getChildNodes();
1010            if (children != null) {
1011                for (int k=0; k< children.getLength(); k++) {
1012                    Node JavaDoc nodeChild = (Node JavaDoc)children.item(k);
1013                    if (nodeChild.getNodeType() == Node.ELEMENT_NODE && nodeChild.getNodeName().equals("variableExpression")) {
1014                        // Take the CDATA...
1015
NodeList JavaDoc list_child = nodeChild.getChildNodes();
1016                        for (int ck=0; ck< list_child.getLength(); ck++) {
1017                            Node JavaDoc child_child = (Node JavaDoc)list_child.item(ck);
1018                            if (child_child.getNodeType() == Node.CDATA_SECTION_NODE ||
1019                            child_child.getNodeType() == Node.TEXT_NODE) {
1020                                variable.setExpression( child_child.getNodeValue() );
1021                            }
1022                        }
1023                    }
1024                    else if (nodeChild.getNodeType() == Node.ELEMENT_NODE && nodeChild.getNodeName().equals("initialValueExpression")) {
1025                        // Take the CDATA...
1026
NodeList JavaDoc list_child = nodeChild.getChildNodes();
1027                        for (int ck=0; ck< list_child.getLength(); ck++) {
1028                            Node JavaDoc child_child = (Node JavaDoc)list_child.item(ck);
1029                            if (child_child.getNodeType() == Node.CDATA_SECTION_NODE ||
1030                            child_child.getNodeType() == Node.TEXT_NODE) {
1031                                variable.setInitialValueExpression( child_child.getNodeValue() );
1032                            }
1033                        }
1034                    }
1035                }
1036            }
1037
1038            return variable;
1039    }
1040
1041    private it.businesslogic.ireport.crosstab.Measure readMeasureElement(Node JavaDoc measureNode)
1042    {
1043        // Load variable
1044
it.businesslogic.ireport.crosstab.Measure measure = new it.businesslogic.ireport.crosstab.Measure("");
1045
1046            NamedNodeMap JavaDoc nnm = measureNode.getAttributes();
1047            if ( nnm.getNamedItem("name") != null) {
1048                measure.setName( nnm.getNamedItem("name").getNodeValue());
1049            }
1050            if ( nnm.getNamedItem("class") != null) {
1051                measure.setClassType( nnm.getNamedItem("class").getNodeValue() );
1052            }
1053            if ( nnm.getNamedItem("calculation") != null) {
1054                measure.setCalculation( nnm.getNamedItem("calculation").getNodeValue() );
1055            }
1056            if ( nnm.getNamedItem("incrementerFactoryClass") != null) {
1057                measure.setIncrementerFactoryClass( nnm.getNamedItem("incrementerFactoryClass").getNodeValue() );
1058            }
1059            if ( nnm.getNamedItem("percentageOf") != null) {
1060                measure.setPercentageOf( nnm.getNamedItem("percentageOf").getNodeValue());
1061            }
1062            if ( nnm.getNamedItem("percentageCalculatorClass") != null) {
1063                measure.setPercentageCalculatorClass( nnm.getNamedItem("percentageCalculatorClass").getNodeValue());
1064            }
1065
1066            // Check for description and expression...
1067
NodeList JavaDoc children = measureNode.getChildNodes();
1068            if (children != null) {
1069                for (int k=0; k< children.getLength(); k++) {
1070                    Node JavaDoc nodeChild = (Node JavaDoc)children.item(k);
1071                    if (nodeChild.getNodeType() == Node.ELEMENT_NODE && nodeChild.getNodeName().equals("measureExpression")) {
1072                        measure.setExpression(readPCDATA(nodeChild));
1073                    }
1074                }
1075            }
1076
1077            return measure;
1078    }
1079
1080
1081
1082
1083
1084    private it.businesslogic.ireport.Style readStyle(Node JavaDoc styleNode)
1085    {
1086        return readStyle(styleNode, null);
1087    }
1088
1089    /**
1090     * If a ConditionedStyle, the style is interpreted like part of the tag conditionalStyle
1091     */

1092    private it.businesslogic.ireport.Style readStyle(Node JavaDoc styleNode, ConditionedStyle cStyle)
1093    {
1094        Style style = new Style();
1095        if (cStyle != null) style = cStyle;
1096        NamedNodeMap JavaDoc nnm = styleNode.getAttributes();
1097
1098        for (int i=0; i<Style.JRXMLStyleAttributes.length; ++i)
1099        {
1100             if ( nnm.getNamedItem(Style.JRXMLStyleAttributes[i]) != null) {
1101                style.getAttributes().put(Style.JRXMLStyleAttributes[i], nnm.getNamedItem(Style.JRXMLStyleAttributes[i]).getNodeValue());
1102             }
1103        }
1104
1105        //conditionalStyle
1106
// Check for description and expression...
1107
NodeList JavaDoc children = styleNode.getChildNodes();
1108        if (children != null) {
1109            for (int k=0; k< children.getLength(); k++) {
1110                Node JavaDoc nodeChild = (Node JavaDoc)children.item(k);
1111                if (nodeChild.getNodeType() == Node.ELEMENT_NODE && nodeChild.getNodeName().equals("conditionalStyle")) {
1112                    ConditionedStyle childStyle = readConditionalStyle(nodeChild);
1113                    style.getConditionedStyles().add(childStyle);
1114                }
1115            }
1116        }
1117
1118        return style;
1119    }
1120
1121    /**
1122     * If a ConditionedStyle, the style is interpreted like part of the tag conditionalStyle
1123     */

1124    private it.businesslogic.ireport.ConditionedStyle readConditionalStyle(Node JavaDoc styleNode)
1125    {
1126        ConditionedStyle style = new ConditionedStyle();
1127
1128        //conditionalStyle
1129
// Check for description and expression...
1130
NodeList JavaDoc children = styleNode.getChildNodes();
1131        if (children != null) {
1132            for (int k=0; k< children.getLength(); k++) {
1133                Node JavaDoc nodeChild = (Node JavaDoc)children.item(k);
1134                if (nodeChild.getNodeType() == Node.ELEMENT_NODE && nodeChild.getNodeName().equals("conditionExpression")) {
1135                    style.setCondition(readPCDATA(nodeChild));
1136                }
1137                else if (nodeChild.getNodeType() == Node.ELEMENT_NODE && nodeChild.getNodeName().equals("style")) {
1138                    style = (ConditionedStyle)readStyle(nodeChild, style);
1139                }
1140            }
1141        }
1142
1143        return style;
1144    }
1145
1146    private it.businesslogic.ireport.Group readGroupElement(SubDataset ds, Node JavaDoc groupNode, boolean fullRead)
1147    {
1148        NamedNodeMap JavaDoc nnm = groupNode.getAttributes();
1149        it.businesslogic.ireport.Group group = new it.businesslogic.ireport.Group(ds, ""+nnm.getNamedItem("name").getNodeValue());
1150
1151        if ( nnm.getNamedItem("isStartNewColumn") != null) group.setIsStartNewColumn( nnm.getNamedItem("isStartNewColumn").getNodeValue().equals("true") );
1152        if ( nnm.getNamedItem("isStartNewPage") != null) group.setIsStartNewPage( nnm.getNamedItem("isStartNewPage").getNodeValue().equals("true") );
1153        if ( nnm.getNamedItem("isResetPageNumber") != null) group.setIsResetPageNumber( nnm.getNamedItem("isResetPageNumber").getNodeValue().equals("true") );
1154        if ( nnm.getNamedItem("isReprintHeaderOnEachPage") != null) group.setIsReprintHeaderOnEachPage( nnm.getNamedItem("isReprintHeaderOnEachPage").getNodeValue().equals("true") );
1155        if ( nnm.getNamedItem("minHeightToStartNewPage") != null) group.setMinHeightToStartNewPage( Integer.parseInt(nnm.getNamedItem("minHeightToStartNewPage").getNodeValue()));
1156
1157        // Looking for header, footer and expression...
1158
NodeList JavaDoc children = groupNode.getChildNodes();
1159        if (children != null) {
1160            for (int k=0; k< children.getLength(); k++) {
1161                Node JavaDoc nodeChild = (Node JavaDoc)children.item(k);
1162                if (nodeChild.getNodeType() == Node.ELEMENT_NODE && nodeChild.getNodeName().equals("groupExpression")) {
1163                    // Take the CDATA...
1164
NodeList JavaDoc list_child = nodeChild.getChildNodes();
1165                    for (int ck=0; ck< list_child.getLength(); ck++) {
1166                        Node JavaDoc child_child = (Node JavaDoc)list_child.item(ck);
1167                        if (child_child.getNodeType() == Node.CDATA_SECTION_NODE ||
1168                        child_child.getNodeType() == Node.TEXT_NODE) {
1169                            group.setGroupExpression( child_child.getNodeValue() );
1170                        }
1171                    }
1172                }
1173                else if (fullRead && nodeChild.getNodeType() == Node.ELEMENT_NODE && nodeChild.getNodeName().equals("groupHeader")) {
1174                    // Take the band...
1175
NodeList JavaDoc list_child = nodeChild.getChildNodes();
1176                    for (int ck=0; ck< list_child.getLength(); ck++) {
1177                        Node JavaDoc bandNode = (Node JavaDoc)list_child.item(ck);
1178                        if (bandNode.getNodeType() == Node.ELEMENT_NODE && bandNode.getNodeName().equals("band")) {
1179                            // Read the band...
1180
NamedNodeMap JavaDoc bandAttributes = bandNode.getAttributes();
1181                            if ( bandAttributes.getNamedItem("height") != null) group.getGroupHeader().setHeight( Integer.parseInt(bandAttributes.getNamedItem("height").getNodeValue()) );
1182                            if ( bandAttributes.getNamedItem("isSplitAllowed") != null) group.getGroupHeader().setSplitAllowed( bandAttributes.getNamedItem("isSplitAllowed").getNodeValue().equals("true") );
1183                            readBandElements(bandNode,group.getGroupHeader());
1184                        }
1185                    }
1186                }
1187                else if (fullRead && nodeChild.getNodeType() == Node.ELEMENT_NODE && nodeChild.getNodeName().equals("groupFooter")) {
1188                    // Take the band...
1189
NodeList JavaDoc list_child = nodeChild.getChildNodes();
1190                    for (int ck=0; ck< list_child.getLength(); ck++) {
1191                        Node JavaDoc bandNode = (Node JavaDoc)list_child.item(ck);
1192                        if (bandNode.getNodeType() == Node.ELEMENT_NODE && bandNode.getNodeName().equals("band")) {
1193                            // Read the band...
1194
NamedNodeMap JavaDoc bandAttributes = bandNode.getAttributes();
1195                            if ( bandAttributes.getNamedItem("height") != null) group.getGroupFooter().setHeight( Integer.parseInt(bandAttributes.getNamedItem("height").getNodeValue()) );
1196                            if ( bandAttributes.getNamedItem("isSplitAllowed") != null) group.getGroupFooter().setSplitAllowed( bandAttributes.getNamedItem("isSplitAllowed").getNodeValue().equals("true") );
1197                            readBandElements(bandNode,group.getGroupFooter());
1198                        }
1199                    }
1200                }
1201            }
1202        }
1203
1204        return group;
1205    }
1206
1207
1208    private void readBandElements(String JavaDoc parentElementGroup, Node JavaDoc bandNode, Band band, ReportElement parentElement, CrosstabReportElement crosstabReportElement, CrosstabCell cell) {
1209
1210        ReportElement rElement = null;
1211        Style defualtStyle = getReport().getDefaultStyle();
1212
1213        NodeList JavaDoc list_child = bandNode.getChildNodes();
1214        for (int ck=0; ck< list_child.getLength(); ck++) {
1215            Node JavaDoc child = (Node JavaDoc)list_child.item(ck);
1216            if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("printWhenExpression")) {
1217                // Read the band...
1218
//NamedNodeMap bandAttributes = bandNode.getAttributes();
1219
//if ( bandAttributes.getNamedItem("height") != null) b.setHeight( Integer.parseInt(bandAttributes.getNamedItem("height").getNodeValue()) );
1220
// Take subelements and lloking for the expression...
1221
NodeList JavaDoc childsOfChild = child.getChildNodes();
1222                for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
1223                    Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
1224                    if (child_child.getNodeType() == Node.CDATA_SECTION_NODE ||
1225                    child_child.getNodeType() == Node.TEXT_NODE) {
1226                        band.setPrintWhenExpression(child_child.getNodeValue());
1227                    }
1228                }
1229            }
1230            else if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("staticText")) {
1231                StaticTextReportElement re = new StaticTextReportElement(0,0,0,0);
1232                re.setIReportFont( getReport().getDefaultFont());
1233
1234                if (defualtStyle != null) { re.setStyle(defualtStyle); re.setStyle(null); }
1235                re.setBand(band);
1236                re.setCell( cell );
1237                re.setElementGroup(parentElementGroup);
1238                re.setParentElement(parentElement);
1239                NodeList JavaDoc childsOfChild = child.getChildNodes();
1240                for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
1241                    Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
1242                    if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("reportElement")) {
1243                        readXMLReportElement(child_child,re);
1244                    }
1245                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("textElement")) {
1246                        readXMLTextElement(child_child,re);
1247                    }
1248                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("text")) {
1249                        re.setText( readPCDATA(child_child, false) );
1250                    }
1251                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("box")) {
1252                        readBoxElement(child_child,re);
1253                    }
1254                }
1255
1256                re.setPosition(re.position);
1257                re.trasform(new java.awt.Point JavaDoc(0,0),TransformationType.TRANSFORMATION_RESIZE_SE);
1258                //elements.addElement(re);
1259
rElement = re;
1260            }
1261            else if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("image")) {
1262                ImageReportElement re = new ImageReportElement(0,0,0,0);
1263                if (defualtStyle != null) { re.setStyle(defualtStyle); re.setStyle(null); }
1264                re.setBand(band);
1265                re.setCell( cell );
1266                re.setElementGroup(parentElementGroup);
1267                re.setParentElement(parentElement);
1268                NamedNodeMap JavaDoc nodeAttributes = child.getAttributes();
1269                if (nodeAttributes.getNamedItem("isUsingCache") != null)
1270                    re.setIsUsingCache( (""+nodeAttributes.getNamedItem("isUsingCache").getNodeValue()).equals("true") );
1271                if (nodeAttributes.getNamedItem("isLazy") != null)
1272                    re.setIsLazy( (""+nodeAttributes.getNamedItem("isLazy").getNodeValue()).equals("true") );
1273                if (nodeAttributes.getNamedItem("onErrorType") != null)
1274                    re.setOnErrorType(""+nodeAttributes.getNamedItem("onErrorType").getNodeValue());
1275                if (nodeAttributes.getNamedItem("scaleImage") != null)
1276                    re.setScaleImage(""+nodeAttributes.getNamedItem("scaleImage").getNodeValue());
1277                if (nodeAttributes.getNamedItem("vAlign") != null)
1278                    re.setVerticalAlignment( ""+nodeAttributes.getNamedItem("vAlign").getNodeValue());
1279                if (nodeAttributes.getNamedItem("hAlign") != null)
1280                    re.setHorizontalAlignment(""+nodeAttributes.getNamedItem("hAlign").getNodeValue());
1281                if (nodeAttributes.getNamedItem("evaluationTime") != null)
1282                    re.setEvaluationTime( ""+nodeAttributes.getNamedItem("evaluationTime").getNodeValue());
1283                if (nodeAttributes.getNamedItem("evaluationGroup") != null)
1284                    re.setEvaluationGroup( ""+nodeAttributes.getNamedItem("evaluationGroup").getNodeValue());
1285                //if (nodeAttributes.getNamedItem("hyperlinkType") != null)
1286
// re.setHyperlinkType(""+nodeAttributes.getNamedItem("hyperlinkType").getNodeValue());
1287
//if (nodeAttributes.getNamedItem("hyperlinkTarget") != null)
1288
// re.setHyperlinkTarget(""+nodeAttributes.getNamedItem("hyperlinkTarget").getNodeValue());
1289
//if (nodeAttributes.getNamedItem("bookmarkLevel") != null)
1290
// re.setBookmarkLevel( Integer.parseInt( nodeAttributes.getNamedItem("bookmarkLevel").getNodeValue() ) );
1291

1292                NodeList JavaDoc childsOfChild = child.getChildNodes();
1293                for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
1294                    Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
1295                    NamedNodeMap JavaDoc subNodeAttributes = child_child.getAttributes();
1296
1297                    if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("reportElement")) {
1298                        readXMLReportElement(child_child,re);
1299                    } // Element properties...
1300
else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("graphicElement")) {
1301                        if (subNodeAttributes.getNamedItem("pen") != null) {
1302                            re.setGraphicElementPen( ""+subNodeAttributes.getNamedItem("pen").getNodeValue());
1303                        }
1304                        if (subNodeAttributes.getNamedItem("fill") != null) {
1305                            re.setPropertyValue(GraphicReportElement.FILL, ""+subNodeAttributes.getNamedItem("fill").getNodeValue());
1306                        }
1307                        if (subNodeAttributes.getNamedItem("stretchType") != null) {
1308                            re.setStretchType(""+subNodeAttributes.getNamedItem("stretchType").getNodeValue());
1309                        }
1310                    }
1311                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("imageExpression")) {
1312                        if (subNodeAttributes.getNamedItem("class") != null) {
1313                            re.setImageClass(""+subNodeAttributes.getNamedItem("class").getNodeValue());
1314                        }
1315                        re.setImageExpression( readPCDATA(child_child));
1316                        re.setReportDirectory(new java.io.File JavaDoc(getReport().getFilename()).getParentFile());
1317                    }
1318                    /*
1319                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("anchorNameExpression")) {
1320                        re.setAnchorNameExpression( readPCDATA(child_child) );
1321                    }
1322                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("hyperlinkAnchorExpression")) {
1323                        re.setHyperlinkAnchorExpression( readPCDATA(child_child) );
1324                    }
1325                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("hyperlinkPageExpression")) {
1326                        re.setHyperlinkPageExpression( readPCDATA(child_child) );
1327                    }
1328                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("hyperlinkReferenceExpression")) {
1329                        re.setHyperlinkReferenceExpression( readPCDATA(child_child) );
1330                    }
1331                    */

1332                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("box")) {
1333                        readBoxElement(child_child,re);
1334                    }
1335                }
1336                readHyperlink(child, re);
1337                re.setPosition(re.position);
1338                re.trasform(new java.awt.Point JavaDoc(0,0),TransformationType.TRANSFORMATION_RESIZE_SE);
1339
1340                if (re.getImageExpression().indexOf("it.businesslogic.ireport.chart.DefaultChartFactory.drawChart(") >= 0) {
1341                    ChartReportElement chart = new ChartReportElement( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
1342                    chart.setBand( re.getBand() );
1343                    chart.setElementGroup( re.getElementGroup());
1344                    chart.setParentElement( re.getParentElement());
1345                    chart.setHyperlinkReferenceExpression( re.getHyperlinkReferenceExpression());
1346                    chart.setHyperlinkPageExpression( re.getHyperlinkPageExpression());
1347                    chart.setHyperlinkAnchorExpression( re.getHyperlinkAnchorExpression());
1348                    chart.setHyperlinkType( re.getHyperlinkType());
1349                    chart.setBgcolor( re.getBgcolor());
1350                    chart.setEvaluationGroup( re.getEvaluationGroup());
1351                    chart.setEvaluationTime( re.getEvaluationTime());
1352                    chart.setFgcolor( re.getFgcolor());
1353                    chart.setFill( re.getFill());
1354                    //chart.setGraphicElementPen( re.getGraphicElementPen());
1355
chart.setHorizontalAlignment( re.getHorizontalAlignment());
1356                    chart.setImageClass( re.getImageClass());
1357                    chart.setImageExpression( re.getImageExpression());
1358                    chart.setName( re.getName());
1359                    chart.setPositionType( re.getPositionType());
1360                    chart.setPrintWhenExpression( re.getPrintWhenExpression() );
1361                    chart.setPrintWhenGroupChanges( re.getPrintWhenGroupChanges());
1362                    chart.setScaleImage( re.getScaleImage());
1363                    chart.setStretchType( re.getStretchType());
1364                    chart.setTransparent( re.getTransparent());
1365                    chart.setVerticalAlignment( re.getVerticalAlignment());
1366                    chart.parseProperties( getReport().getJRproperties() );
1367                    re = chart;
1368                }
1369
1370                if (re.getImageExpression().indexOf("it.businesslogic.ireport.barcode.BcImage.getBarcodeImage(") >= 0) {
1371                    BarcodeReportElement bc = new BarcodeReportElement( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight());
1372                    bc.setBand( re.getBand() );
1373                    bc.setCell( cell );
1374                    bc.setElementGroup( re.getElementGroup());
1375                    bc.setParentElement( re.getParentElement());
1376                    bc.setHyperlinkReferenceExpression( re.getHyperlinkReferenceExpression());
1377                    bc.setHyperlinkPageExpression( re.getHyperlinkPageExpression());
1378                    bc.setHyperlinkAnchorExpression( re.getHyperlinkAnchorExpression());
1379                    bc.setHyperlinkType( re.getHyperlinkType());
1380                    bc.setBgcolor( re.getBgcolor());
1381                    bc.setEvaluationGroup( re.getEvaluationGroup());
1382                    bc.setEvaluationTime( re.getEvaluationTime());
1383                    bc.setFgcolor( re.getFgcolor());
1384                    bc.setFill( re.getFill());
1385                    //bc.setGraphicElementPen( re.getGraphicElementPen());
1386
bc.setHorizontalAlignment( re.getHorizontalAlignment());
1387                    bc.setImageClass( re.getImageClass());
1388                    bc.setImageExpression( re.getImageExpression());
1389                    bc.setName( re.getName());
1390                    bc.setPositionType( re.getPositionType());
1391                    bc.setPrintWhenExpression( re.getPrintWhenExpression() );
1392                    bc.setPrintWhenGroupChanges( re.getPrintWhenGroupChanges());
1393                    bc.setScaleImage( re.getScaleImage());
1394                    bc.setStretchType( re.getStretchType());
1395                    bc.setTransparent( re.getTransparent());
1396                    bc.setVerticalAlignment( re.getVerticalAlignment());
1397
1398                    re = bc;
1399                }
1400
1401                //elements.addElement(re);
1402
rElement = re;
1403            }
1404            else if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("rectangle")) {
1405                RectangleReportElement re = new RectangleReportElement(0,0,0,0);
1406                if (defualtStyle != null) { re.setStyle(defualtStyle); re.setStyle(null); }
1407                re.setBand(band);
1408                re.setCell( cell );
1409                re.setElementGroup(parentElementGroup);
1410                re.setParentElement(parentElement);
1411                NamedNodeMap JavaDoc nodeAttributes = child.getAttributes();
1412                /* CompatibilitySupport.saveRoundedRectangle */
1413                if (nodeAttributes.getNamedItem("radius") != null)
1414                    re.setRadius( Integer.parseInt( (""+nodeAttributes.getNamedItem("radius").getNodeValue())) );
1415                // Element properties...
1416
NodeList JavaDoc childsOfChild = child.getChildNodes();
1417                for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
1418                    Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
1419                    NamedNodeMap JavaDoc subNodeAttributes = child_child.getAttributes();
1420
1421                    if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("reportElement")) {
1422                        readXMLReportElement(child_child,re);
1423                    } // Element properties...
1424
else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("graphicElement")) {
1425                        if (subNodeAttributes.getNamedItem("pen") != null) {
1426                            re.setGraphicElementPen( ""+subNodeAttributes.getNamedItem("pen").getNodeValue());
1427                        }
1428                        if (subNodeAttributes.getNamedItem("fill") != null) {
1429                            re.setPropertyValue(GraphicReportElement.FILL, ""+subNodeAttributes.getNamedItem("fill").getNodeValue());
1430                        }
1431                        if (subNodeAttributes.getNamedItem("stretchType") != null) {
1432                            re.setStretchType(""+subNodeAttributes.getNamedItem("stretchType").getNodeValue());
1433                        }
1434                    }
1435                }
1436
1437                re.setPosition(re.position);
1438                re.trasform(new java.awt.Point JavaDoc(0,0),TransformationType.TRANSFORMATION_RESIZE_SE);
1439
1440                //elements.addElement(re);
1441
rElement = re;
1442            }
1443            else if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("line")) {
1444                LineReportElement re = new LineReportElement(0,0,0,0);
1445                if (defualtStyle != null) { re.setStyle(defualtStyle); re.setStyle(null); }
1446                re.setBand(band);
1447                re.setCell( cell );
1448                re.setElementGroup(parentElementGroup);
1449                re.setParentElement(parentElement);
1450                NamedNodeMap JavaDoc nodeAttributes = child.getAttributes();
1451                /* CompatibilitySupport.saveRoundedRectangle */
1452                if (nodeAttributes.getNamedItem("direction") != null)
1453                    re.setDirection( ""+nodeAttributes.getNamedItem("direction").getNodeValue() );
1454
1455                // Element properties...
1456
NodeList JavaDoc childsOfChild = child.getChildNodes();
1457                for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
1458                    Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
1459                    NamedNodeMap JavaDoc subNodeAttributes = child_child.getAttributes();
1460
1461                    if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("reportElement")) {
1462                        readXMLReportElement(child_child,re);
1463                    } // Element properties...
1464
else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("graphicElement")) {
1465                        if (subNodeAttributes.getNamedItem("pen") != null) {
1466                            re.setGraphicElementPen( ""+subNodeAttributes.getNamedItem("pen").getNodeValue());
1467                        }
1468                        if (subNodeAttributes.getNamedItem("fill") != null) {
1469                            re.setPropertyValue(GraphicReportElement.FILL, ""+subNodeAttributes.getNamedItem("fill").getNodeValue());
1470                        }
1471                        if (subNodeAttributes.getNamedItem("stretchType") != null) {
1472                            re.setStretchType(""+subNodeAttributes.getNamedItem("stretchType").getNodeValue());
1473                        }
1474                    }
1475                }
1476
1477                re.setPosition(re.position);
1478                re.trasform(new java.awt.Point JavaDoc(0,0),TransformationType.TRANSFORMATION_RESIZE_SE);
1479                //elements.addElement(re);
1480
rElement = re;
1481            }
1482            else if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("break")) {
1483                BreakReportElement re = new BreakReportElement(0,0,0,0);
1484                re.setBand(band);
1485                re.setCell( cell );
1486                re.setElementGroup(parentElementGroup);
1487                re.setParentElement(parentElement);
1488                NamedNodeMap JavaDoc nodeAttributes = child.getAttributes();
1489                /* CompatibilitySupport.saveRoundedRectangle */
1490                if (nodeAttributes.getNamedItem("type") != null)
1491                    re.setType( ""+nodeAttributes.getNamedItem("type").getNodeValue() );
1492
1493                // Element properties...
1494
NodeList JavaDoc childsOfChild = child.getChildNodes();
1495                for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
1496                    Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
1497                    NamedNodeMap JavaDoc subNodeAttributes = child_child.getAttributes();
1498
1499                    if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("reportElement")) {
1500                        readXMLReportElement(child_child,re);
1501                    } // Element properties...
1502
}
1503                
1504                // Fix height and position...
1505
re.setHeight(0);
1506                re.setWidth( report.getWidth() - report.getRightMargin() - report.getLeftMargin() );
1507                re.position.x=0;
1508                re.setPosition(re.position);
1509                re.trasform(new java.awt.Point JavaDoc(0,0),TransformationType.TRANSFORMATION_RESIZE_SE);
1510                //elements.addElement(re);
1511
rElement = re;
1512            }
1513            else if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("ellipse")) {
1514                EllipseReportElement re = new EllipseReportElement(0,0,0,0);
1515                if (defualtStyle != null) { re.setStyle(defualtStyle); re.setStyle(null); }
1516                re.setBand(band);
1517                re.setCell( cell );
1518                re.setElementGroup(parentElementGroup);
1519                re.setParentElement(parentElement);
1520                NamedNodeMap JavaDoc nodeAttributes = child.getAttributes();
1521                /* CompatibilitySupport.saveRoundedRectangle */
1522                //if (nodeAttributes.getNamedItem("direction") != null)
1523
// re.setDirection( ""+nodeAttributes.getNamedItem("direction").getNodeValue() );
1524

1525                // Element properties...
1526
NodeList JavaDoc childsOfChild = child.getChildNodes();
1527                for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
1528                    Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
1529                    NamedNodeMap JavaDoc subNodeAttributes = child_child.getAttributes();
1530
1531                    if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("reportElement")) {
1532                        readXMLReportElement(child_child,re);
1533                    } // Element properties...
1534
else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("graphicElement")) {
1535                        if (subNodeAttributes.getNamedItem("pen") != null) {
1536                            re.setGraphicElementPen( ""+subNodeAttributes.getNamedItem("pen").getNodeValue());
1537                        }
1538                        if (subNodeAttributes.getNamedItem("fill") != null) {
1539                            re.setPropertyValue(GraphicReportElement.FILL, ""+subNodeAttributes.getNamedItem("fill").getNodeValue());
1540                        }
1541                        if (subNodeAttributes.getNamedItem("stretchType") != null) {
1542                            re.setStretchType(""+subNodeAttributes.getNamedItem("stretchType").getNodeValue());
1543                        }
1544                    }
1545                }
1546
1547                re.setPosition(re.position);
1548                re.trasform(new java.awt.Point JavaDoc(0,0),TransformationType.TRANSFORMATION_RESIZE_SE);
1549                //elements.addElement(re);
1550
rElement = re;
1551            }
1552            else if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("textField")) {
1553                TextFieldReportElement re = new TextFieldReportElement(0,0,0,0);
1554
1555                re.setIReportFont( getReport().getDefaultFont());
1556                if (defualtStyle != null) { re.setStyle(defualtStyle); re.setStyle(null); }
1557                re.setBand(band);
1558                re.setCell( cell );
1559                re.setElementGroup(parentElementGroup);
1560                re.setParentElement(parentElement);
1561                NamedNodeMap JavaDoc nodeAttributes = child.getAttributes();
1562                /* CompatibilitySupport.saveRoundedRectangle */
1563                if (nodeAttributes.getNamedItem("evaluationTime") != null)
1564                    re.setEvaluationTime( ""+nodeAttributes.getNamedItem("evaluationTime").getNodeValue() );
1565                if (nodeAttributes.getNamedItem("evaluationGroup") != null)
1566                    re.setGroup( ""+nodeAttributes.getNamedItem("evaluationGroup").getNodeValue() );
1567                if (nodeAttributes.getNamedItem("isStretchWithOverflow") != null)
1568                    re.setStretchWithOverflow( nodeAttributes.getNamedItem("isStretchWithOverflow").getNodeValue().equals("true"));
1569                if (nodeAttributes.getNamedItem("isBlankWhenNull") != null)
1570                    re.setBlankWhenNull(nodeAttributes.getNamedItem("isBlankWhenNull").getNodeValue().equals("true") );
1571                if (nodeAttributes.getNamedItem("pattern") != null)
1572                    re.setPattern( ""+nodeAttributes.getNamedItem("pattern").getNodeValue() );
1573                //if (nodeAttributes.getNamedItem("hyperlinkType") != null)
1574
// re.setHyperlinkType( ""+nodeAttributes.getNamedItem("hyperlinkType").getNodeValue() );
1575
//if (nodeAttributes.getNamedItem("hyperlinkTarget") != null)
1576
// re.setHyperlinkTarget( ""+nodeAttributes.getNamedItem("hyperlinkTarget").getNodeValue() );
1577
//if (nodeAttributes.getNamedItem("bookmarkLevel") != null)
1578
// re.setBookmarkLevel( Integer.parseInt( nodeAttributes.getNamedItem("bookmarkLevel").getNodeValue() ) );
1579

1580                NodeList JavaDoc childsOfChild = child.getChildNodes();
1581                for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
1582                    Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
1583                    NamedNodeMap JavaDoc subNodeAttributes = child_child.getAttributes();
1584
1585                    if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("reportElement")) {
1586                        readXMLReportElement(child_child,re);
1587                    }
1588                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("textElement")) {
1589                        readXMLTextElement(child_child,re);
1590                    }
1591                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("textFieldExpression")) {
1592                        if (subNodeAttributes.getNamedItem("class") != null) {
1593                            re.setClassExpression(""+subNodeAttributes.getNamedItem("class").getNodeValue());
1594                        }
1595                        re.setText( readPCDATA(child_child).trim());
1596                    }
1597                    /*
1598                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("anchorNameExpression")) {
1599                        re.setAnchorNameExpression( readPCDATA(child_child) );
1600                    }
1601                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("hyperlinkAnchorExpression")) {
1602                        re.setHyperlinkAnchorExpression( readPCDATA(child_child) );
1603                    }
1604                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("hyperlinkPageExpression")) {
1605                        re.setHyperlinkPageExpression( readPCDATA(child_child) );
1606                    }
1607                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("hyperlinkReferenceExpression")) {
1608                        re.setHyperlinkReferenceExpression( readPCDATA(child_child) );
1609                    }
1610                    */

1611                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("box")) {
1612                        readBoxElement(child_child,re);
1613                    }
1614                }
1615                readHyperlink(child, re);
1616                re.setPosition(re.position);
1617                re.trasform(new java.awt.Point JavaDoc(0,0),TransformationType.TRANSFORMATION_RESIZE_SE);
1618                //elements.addElement(re);
1619
rElement = re;
1620            }
1621            else if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("frame")) {
1622                FrameReportElement re = new FrameReportElement(0,0,0,0);
1623                if (defualtStyle != null) { re.setStyle(defualtStyle); re.setStyle(null); }
1624                re.setBand(band);
1625                re.setCell( cell );
1626                re.setElementGroup(parentElementGroup);
1627                re.setParentElement(parentElement);
1628                NamedNodeMap JavaDoc nodeAttributes = child.getAttributes();
1629
1630                NodeList JavaDoc childsOfChild = child.getChildNodes();
1631                for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
1632                    Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
1633                    NamedNodeMap JavaDoc subNodeAttributes = child_child.getAttributes();
1634
1635                    if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("reportElement")) {
1636                        readXMLReportElement(child_child,re);
1637                    }
1638                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("box")) {
1639                        readBoxElement(child_child,re);
1640                    }
1641                }
1642
1643                re.setPosition(re.position);
1644                re.trasform(new java.awt.Point JavaDoc(0,0),TransformationType.TRANSFORMATION_RESIZE_SE);
1645                rElement = re;
1646
1647                if (crosstabReportElement != null)
1648                {
1649                    crosstabReportElement.getElements().addElement( rElement );
1650                }
1651                else
1652                {
1653                    getReport().getElements().addElement(rElement);
1654                }
1655
1656                readBandElements("", child,band, re, crosstabReportElement, cell);
1657            }
1658            else if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("elementGroup")) {
1659                String JavaDoc newgroup = getReport().createChildGroup(parentElementGroup);
1660                readBandElements(newgroup, child,band, parentElement, crosstabReportElement, cell);
1661            }
1662            else if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("subreport")) {
1663                SubReportElement re = new SubReportElement(0,0,0,0);
1664                if (defualtStyle != null) { re.setStyle(defualtStyle); re.setStyle(null); }
1665                re.setBand(band);
1666                re.setElementGroup(parentElementGroup);
1667                re.setParentElement(parentElement);
1668                NamedNodeMap JavaDoc nodeAttributes = child.getAttributes();
1669                if (nodeAttributes.getNamedItem("isUsingCache") != null)
1670                    re.setIsUsingCache(nodeAttributes.getNamedItem("isUsingCache").getNodeValue().equals("true") );
1671
1672                NodeList JavaDoc childsOfChild = child.getChildNodes();
1673                for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
1674                    Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
1675                    NamedNodeMap JavaDoc subNodeAttributes = child_child.getAttributes();
1676
1677                    if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("reportElement")) {
1678                        readXMLReportElement(child_child,re);
1679                    }
1680                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("parametersMapExpression")) {
1681                        re.setParametersMapExpression( readPCDATA(child_child) );
1682                    }
1683                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("returnValue")) {
1684                        it.businesslogic.ireport.JRSubreportReturnValue returnValue = new it.businesslogic.ireport.JRSubreportReturnValue();
1685
1686                        if (subNodeAttributes.getNamedItem("subreportVariable") != null) {
1687                            returnValue.setSubreportVariable( ""+subNodeAttributes.getNamedItem("subreportVariable").getNodeValue());
1688                        }
1689                        if (subNodeAttributes.getNamedItem("toVariable") != null) {
1690                            returnValue.setToVariable( ""+subNodeAttributes.getNamedItem("toVariable").getNodeValue());
1691                        }
1692                        if (subNodeAttributes.getNamedItem("calculation") != null) {
1693                            returnValue.setCalculation( ""+subNodeAttributes.getNamedItem("calculation").getNodeValue());
1694                        }
1695                        if (subNodeAttributes.getNamedItem("incrementerFactoryClass") != null) {
1696                            returnValue.setIncrementFactoryClass( ""+subNodeAttributes.getNamedItem("incrementerFactoryClass").getNodeValue());
1697                        }
1698                        re.getReturnValues().addElement(returnValue );
1699                    }
1700                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("subreportParameter")) {
1701                        String JavaDoc name = "";
1702                        if (subNodeAttributes.getNamedItem("name") != null) {
1703                            name = ""+subNodeAttributes.getNamedItem("name").getNodeValue();
1704                        }
1705                        // Find expression in childs......
1706
String JavaDoc expression = "";
1707                        NodeList JavaDoc childsOfChildOfChild = child_child.getChildNodes();
1708                        for (int c_count_2=0; c_count_2< childsOfChildOfChild.getLength(); c_count_2++) {
1709                            Node JavaDoc child_child_child = (Node JavaDoc)childsOfChildOfChild.item(c_count_2);
1710                            if (child_child_child.getNodeType() == Node.ELEMENT_NODE && child_child_child.getNodeName().equals("subreportParameterExpression")) {
1711                                expression = readPCDATA(child_child_child);
1712                                break;
1713                            }
1714                        }
1715                        re.getSubreportParameters().addElement( new it.businesslogic.ireport.JRSubreportParameter( name, expression));
1716                    }
1717                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("connectionExpression")) {
1718                        re.setConnectionExpression( readPCDATA(child_child));
1719                        re.setUseConnection(true);
1720                    }
1721                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("dataSourceExpression")) {
1722                        re.setDataSourceExpression(readPCDATA(child_child));
1723                        re.setUseConnection(false);
1724                    }
1725                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("subreportExpression")) {
1726                        re.setSubreportExpression(readPCDATA(child_child));
1727                        if (subNodeAttributes.getNamedItem("class") != null) {
1728                            re.setSubreportExpressionClass(""+subNodeAttributes.getNamedItem("class").getNodeValue());
1729                        }
1730                    }
1731                }
1732
1733                re.setPosition(re.position);
1734                re.trasform(new java.awt.Point JavaDoc(0,0),TransformationType.TRANSFORMATION_RESIZE_SE);
1735                //elements.addElement(re);
1736
rElement = re;
1737            }
1738            else if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("pieChart") ||
1739                     child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("pie3DChart") ||
1740                     child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("barChart") ||
1741                     child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("bar3DChart") ||
1742                     child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("xyBarChart") ||
1743                     child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("stackedBarChart") ||
1744                     child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("stackedBar3DChart") ||
1745                     child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("lineChart") ||
1746                     child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("xyLineChart") ||
1747                     child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("areaChart") ||
1748                     child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("xyAreaChart") ||
1749                     child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("scatterChart") ||
1750                     child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("bubbleChart") ||
1751                     child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("timeSeriesChart") ||
1752                     child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("highLowChart") ||
1753                     child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("candlestickChart") ||
1754                     child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("meterChart") ||
1755                     child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("thermometerChart") ||
1756                     child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("multiAxisChart")) {
1757                ChartReportElement2 re = new ChartReportElement2(0,0,0,0);
1758                if (defualtStyle != null) { re.setStyle(defualtStyle); re.setStyle(null); }
1759                re.setBand(band);
1760                re.setElementGroup(parentElementGroup);
1761                re.setParentElement(parentElement);
1762
1763                readChartReportElement(child, re);
1764
1765                re.setPosition(re.position);
1766                re.trasform(new java.awt.Point JavaDoc(0,0),TransformationType.TRANSFORMATION_RESIZE_SE);
1767                //elements.addElement(re);
1768
rElement = re;
1769            }
1770            else if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("crosstab")) {
1771                CrosstabReportElement re = new CrosstabReportElement(0,0,0,0);
1772                if (defualtStyle != null) { re.setStyle(defualtStyle); re.setStyle(null); }
1773                re.setBand(band);
1774                re.setElementGroup(parentElementGroup);
1775                re.setParentElement(parentElement);
1776                re.setReport( getReport() );
1777                NamedNodeMap JavaDoc nodeAttributes = child.getAttributes();
1778
1779                if (nodeAttributes.getNamedItem("isRepeatColumnHeaders") != null)
1780                    re.setRepeatColumnHeaders(nodeAttributes.getNamedItem("isRepeatColumnHeaders").getNodeValue().equals("true") );
1781
1782                if (nodeAttributes.getNamedItem("isRepeatRowHeaders") != null)
1783                    re.setRepeatRowHeaders(nodeAttributes.getNamedItem("isRepeatRowHeaders").getNodeValue().equals("true") );
1784
1785                if (nodeAttributes.getNamedItem("isRepeatRowHeaders") != null)
1786                {
1787                    try {
1788                        int columnBreakOffset = Integer.parseInt(nodeAttributes.getNamedItem("columnBreakOffset").getNodeValue() );
1789                        re.setColumnBreakOffset( columnBreakOffset );
1790                    } catch (Exception JavaDoc ex)
1791                    {
1792                        System.out.println("Invalid columnBreakOffset, using default");
1793                    }
1794                }
1795
1796                NodeList JavaDoc childsOfChild = child.getChildNodes();
1797                for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
1798                    Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
1799                    NamedNodeMap JavaDoc subNodeAttributes = child_child.getAttributes();
1800
1801                    if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("reportElement")) {
1802                        readXMLReportElement(child_child,re);
1803                    }
1804                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("parametersMapExpression")) {
1805                        re.setParametersMapExpression( readPCDATA(child_child) );
1806                    }
1807                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("crosstabParameter")) {
1808                        String JavaDoc name = "";
1809                        String JavaDoc clazz = "";
1810                        if (subNodeAttributes.getNamedItem("name") != null) {
1811                            name = ""+subNodeAttributes.getNamedItem("name").getNodeValue();
1812                        }
1813                        CrosstabParameter cp = new CrosstabParameter(name);
1814                        if (subNodeAttributes.getNamedItem("class") != null) {
1815                            clazz = ""+subNodeAttributes.getNamedItem("class").getNodeValue();
1816                            cp.setClassType(clazz);
1817                        }
1818
1819                        // Find expression in childs......
1820
String JavaDoc expression = "";
1821                        NodeList JavaDoc childsOfChildOfChild = child_child.getChildNodes();
1822                        for (int c_count_2=0; c_count_2< childsOfChildOfChild.getLength(); c_count_2++) {
1823                            Node JavaDoc child_child_child = (Node JavaDoc)childsOfChildOfChild.item(c_count_2);
1824                            if (child_child_child.getNodeType() == Node.ELEMENT_NODE && child_child_child.getNodeName().equals("parameterValueExpression")) {
1825                                expression = readPCDATA(child_child_child);
1826                                cp.setParameterValueExpression( expression );
1827                                break;
1828                            }
1829                        }
1830
1831                        re.getCrosstabParameters().addElement( cp );
1832                    }
1833                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("crosstabDataset")) {
1834
1835                        re.setUseDataset( true );
1836                        if (subNodeAttributes.getNamedItem("isDataPreSorted") != null) {
1837                            re.setPreSorted( subNodeAttributes.getNamedItem("isDataPreSorted").getNodeValue().equals("true") );
1838
1839                        }
1840
1841                        NodeList JavaDoc childsOfChildOfChild = child_child.getChildNodes();
1842                        for (int c_count_2=0; c_count_2< childsOfChildOfChild.getLength(); c_count_2++) {
1843                            Node JavaDoc child_child_child = (Node JavaDoc)childsOfChildOfChild.item(c_count_2);
1844                            if (child_child_child.getNodeType() == Node.ELEMENT_NODE && child_child_child.getNodeName().equals("dataset")) {
1845                                readDataset(child_child_child, re.getDataset());
1846                                break;
1847                            }
1848                        }
1849                    }
1850                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("rowGroup")) {
1851                        readCrosstabRowGroup(child_child, re);
1852                    }
1853                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("columnGroup")) {
1854                        readCrosstabColumnGroup(child_child, re);
1855                    }
1856                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("measure")) {
1857                        Measure measure = readMeasureElement(child_child);
1858                        re.getMeasures().add(measure);
1859                    }
1860                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("crosstabCell")) {
1861                        it.businesslogic.ireport.crosstab.CrosstabCell detailCell = new it.businesslogic.ireport.crosstab.CrosstabCell();
1862                        readCellContents(child_child, detailCell, re);
1863                        detailCell.setType( detailCell.DETAIL_CELL );
1864                        detailCell.setParent(re);
1865                        re.getCells().add( detailCell );
1866                    }
1867                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("whenNoDataCell")) {
1868                        it.businesslogic.ireport.crosstab.CrosstabCell detailCell = new it.businesslogic.ireport.crosstab.CrosstabCell();
1869                        readCellContents(child_child, detailCell, re);
1870                        detailCell.setType( detailCell.NODATA_CELL );
1871                        detailCell.setParent(re);
1872                        re.getCells().add( detailCell );
1873                    }
1874                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("crosstabHeaderCell")) {
1875                        it.businesslogic.ireport.crosstab.CrosstabCell detailCell = new it.businesslogic.ireport.crosstab.CrosstabCell();
1876                        readCellContents(child_child, detailCell, re);
1877                        detailCell.setType( detailCell.CT_HEADER_CELL );
1878                        detailCell.setParent(re);
1879                        re.getCells().add( detailCell );
1880                    }
1881
1882                }
1883
1884                re.setPosition(re.position);
1885                re.trasform(new java.awt.Point JavaDoc(0,0),TransformationType.TRANSFORMATION_RESIZE_SE);
1886                rElement = re;
1887            }
1888
1889
1890            //System.out.println(""+child.getNodeName());
1891
if (rElement != null && !(rElement instanceof FrameReportElement))
1892            {
1893                if (crosstabReportElement != null)
1894                {
1895                    crosstabReportElement.getElements().addElement( rElement );
1896                }
1897                else
1898                {
1899                    getReport().getElements().addElement(rElement);
1900                }
1901            }
1902            rElement = null;
1903        }
1904
1905    }
1906
1907    /**
1908     * Read all the hyperlink related attibutes and parameters
1909     *
1910     */

1911    private void readHyperlink(Node JavaDoc elementNode, HyperLinkableReportElement re)
1912    {
1913        NodeList JavaDoc childsOfChild = elementNode.getChildNodes();
1914
1915        NamedNodeMap JavaDoc nodeAttributes = elementNode.getAttributes();
1916        if (nodeAttributes.getNamedItem("hyperlinkType") != null)
1917            re.setHyperlinkType( ""+nodeAttributes.getNamedItem("hyperlinkType").getNodeValue() );
1918        if (nodeAttributes.getNamedItem("hyperlinkTarget") != null)
1919            re.setHyperlinkTarget( ""+nodeAttributes.getNamedItem("hyperlinkTarget").getNodeValue() );
1920        if (nodeAttributes.getNamedItem("bookmarkLevel") != null)
1921            re.setBookmarkLevel( Integer.parseInt( nodeAttributes.getNamedItem("bookmarkLevel").getNodeValue() ) );
1922
1923        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
1924            Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
1925            NamedNodeMap JavaDoc subNodeAttributes = child_child.getAttributes();
1926            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("hyperlinkParameter")) {
1927                String JavaDoc name = "";
1928                if (subNodeAttributes.getNamedItem("name") != null) {
1929                    name = ""+subNodeAttributes.getNamedItem("name").getNodeValue();
1930                }
1931                // Find expression in childs......
1932
String JavaDoc expression = "";
1933                NodeList JavaDoc childsOfChildOfChild = child_child.getChildNodes();
1934                for (int c_count_2=0; c_count_2< childsOfChildOfChild.getLength(); c_count_2++) {
1935                    Node JavaDoc child_child_child = (Node JavaDoc)childsOfChildOfChild.item(c_count_2);
1936                    if (child_child_child.getNodeType() == Node.ELEMENT_NODE && child_child_child.getNodeName().equals("hyperlinkParameterExpression")) {
1937                        expression = readPCDATA(child_child_child);
1938                        break;
1939                    }
1940                }
1941                re.getLinkParameters().add( new it.businesslogic.ireport.JRLinkParameter( name, expression));
1942            }
1943            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("anchorNameExpression")) {
1944                re.setAnchorNameExpression( readPCDATA(child_child) );
1945            }
1946            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("hyperlinkAnchorExpression")) {
1947                re.setHyperlinkAnchorExpression( readPCDATA(child_child) );
1948            }
1949            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("hyperlinkPageExpression")) {
1950                re.setHyperlinkPageExpression( readPCDATA(child_child) );
1951            }
1952            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("hyperlinkReferenceExpression")) {
1953                re.setHyperlinkReferenceExpression( readPCDATA(child_child) );
1954            }
1955        }
1956    }
1957
1958    private void readCrosstabRowGroup(Node JavaDoc rowGroupXmlNode, CrosstabReportElement re)
1959    {
1960        CrosstabRowGroup group = new CrosstabRowGroup();
1961
1962
1963        NamedNodeMap JavaDoc nodeAttributes = rowGroupXmlNode.getAttributes();
1964
1965        if (nodeAttributes.getNamedItem("name") != null)
1966            group.setName( nodeAttributes.getNamedItem("name").getNodeValue() );
1967
1968        if (nodeAttributes.getNamedItem("width") != null)
1969        {
1970           try { group.setWidth( Integer.parseInt( nodeAttributes.getNamedItem("width").getNodeValue() )); } catch (Exception JavaDoc ex){
1971            System.out.println("Invalid width for crosstab row group " + group.getName());
1972           }
1973        }
1974
1975        if (nodeAttributes.getNamedItem("totalPosition") != null)
1976            group.setTotalPosition( nodeAttributes.getNamedItem("totalPosition").getNodeValue() );
1977        if (nodeAttributes.getNamedItem("headerPosition") != null)
1978            group.setHeaderPosition( nodeAttributes.getNamedItem("headerPosition").getNodeValue() );
1979
1980        re.getRowGroups().add(group);
1981
1982        NodeList JavaDoc list_child = rowGroupXmlNode.getChildNodes();
1983        for (int ck=0; ck< list_child.getLength(); ck++) {
1984            Node JavaDoc child = (Node JavaDoc)list_child.item(ck);
1985            NamedNodeMap JavaDoc subNodeAttributes = child.getAttributes();
1986            if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("bucket")) {
1987
1988                readBucket(child, group);
1989            }
1990            else if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("crosstabRowHeader")) {
1991
1992                it.businesslogic.ireport.crosstab.CrosstabCell cell = new it.businesslogic.ireport.crosstab.CrosstabCell();
1993                cell.setName(group.getName() + " header" );
1994                readCellContents(child, cell, re);
1995                group.setHeaderCell( cell );
1996                cell.setType( cell.HEADER_CELL );
1997                cell.setParent(re);
1998                re.getCells().add( cell );
1999            }
2000            else if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("crosstabTotalRowHeader")) {
2001                it.businesslogic.ireport.crosstab.CrosstabCell cell = new it.businesslogic.ireport.crosstab.CrosstabCell();
2002                cell.setName(group.getName() + " total header" );
2003                readCellContents(child, cell, re);
2004                group.setTotalCell( cell );
2005                cell.setType( cell.HEADER_CELL );
2006                cell.setParent(re);
2007                re.getCells().add( cell );
2008            }
2009        }
2010
2011        if (group.getHeaderCell() == null)
2012        {
2013            it.businesslogic.ireport.crosstab.CrosstabCell cell = new it.businesslogic.ireport.crosstab.CrosstabCell();
2014            cell.setName(group.getName() + " header" );
2015            cell.setType( cell.HEADER_CELL );
2016            cell.setParent(re);
2017            cell.setWidth( group.getWidth() );
2018            re.getCells().add( cell );
2019            group.setHeaderCell( cell );
2020         }
2021
2022        if (group.getTotalCell() == null)
2023        {
2024            it.businesslogic.ireport.crosstab.CrosstabCell cell = new it.businesslogic.ireport.crosstab.CrosstabCell();
2025            cell.setType( cell.HEADER_CELL );
2026            cell.setName(group.getName() + " total header" );
2027            cell.setParent(re);
2028            cell.setWidth( group.getWidth() );
2029            re.getCells().add( cell );
2030            group.setTotalCell( cell );
2031         }
2032
2033
2034    }
2035
2036    private void readCrosstabColumnGroup(Node JavaDoc columnGroupXmlNode, CrosstabReportElement re)
2037    {
2038        CrosstabColumnGroup group = new CrosstabColumnGroup();
2039
2040        NamedNodeMap JavaDoc nodeAttributes = columnGroupXmlNode.getAttributes();
2041
2042        if (nodeAttributes.getNamedItem("name") != null)
2043            group.setName( nodeAttributes.getNamedItem("name").getNodeValue() );
2044
2045        if (nodeAttributes.getNamedItem("height") != null)
2046        {
2047           try { group.setHeight( Integer.parseInt( nodeAttributes.getNamedItem("height").getNodeValue() )); } catch (Exception JavaDoc ex){
2048            System.out.println("Invalid height for crosstab column group " + group.getName());
2049           }
2050        }
2051
2052        if (nodeAttributes.getNamedItem("totalPosition") != null)
2053            group.setTotalPosition( nodeAttributes.getNamedItem("totalPosition").getNodeValue() );
2054        if (nodeAttributes.getNamedItem("headerPosition") != null)
2055            group.setHeaderPosition( nodeAttributes.getNamedItem("headerPosition").getNodeValue() );
2056
2057        re.getColumnGroups().add(group);
2058
2059        NodeList JavaDoc list_child = columnGroupXmlNode.getChildNodes();
2060        for (int ck=0; ck< list_child.getLength(); ck++) {
2061            Node JavaDoc child = (Node JavaDoc)list_child.item(ck);
2062            NamedNodeMap JavaDoc subNodeAttributes = child.getAttributes();
2063            if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("bucket")) {
2064
2065                readBucket(child, group);
2066            }
2067            else if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("crosstabColumnHeader")) {
2068
2069                it.businesslogic.ireport.crosstab.CrosstabCell cell = new it.businesslogic.ireport.crosstab.CrosstabCell();
2070                cell.setName(group.getName() + " header" );
2071                readCellContents(child, cell, re);
2072                group.setHeaderCell( cell );
2073                cell.setType( cell.HEADER_CELL );
2074                cell.setParent(re);
2075                re.getCells().add( cell );
2076            }
2077            else if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("crosstabTotalColumnHeader")) {
2078                it.businesslogic.ireport.crosstab.CrosstabCell cell = new it.businesslogic.ireport.crosstab.CrosstabCell();
2079                cell.setName(group.getName() + " total header" );
2080                readCellContents(child, cell, re);
2081                group.setTotalCell( cell );
2082                cell.setType( cell.HEADER_CELL );
2083                cell.setParent(re);
2084                re.getCells().add( cell );
2085            }
2086
2087        }
2088
2089        if (group.getHeaderCell() == null)
2090        {
2091            it.businesslogic.ireport.crosstab.CrosstabCell cell = new it.businesslogic.ireport.crosstab.CrosstabCell();
2092            cell.setName(group.getName() + " header" );
2093            cell.setType( cell.HEADER_CELL );
2094            cell.setParent(re);
2095            cell.setHeight( group.getHeight() );
2096            re.getCells().add( cell );
2097            group.setHeaderCell( cell );
2098         }
2099
2100        if (group.getTotalCell() == null)
2101        {
2102            it.businesslogic.ireport.crosstab.CrosstabCell cell = new it.businesslogic.ireport.crosstab.CrosstabCell();
2103            cell.setType( cell.HEADER_CELL );
2104            cell.setName(group.getName() + " total header" );
2105            cell.setParent(re);
2106            cell.setHeight( group.getHeight() );
2107            re.getCells().add( cell );
2108            group.setTotalCell( cell );
2109         }
2110    }
2111
2112    private void readCellContents(Node JavaDoc cellConetensNode, it.businesslogic.ireport.crosstab.CrosstabCell cell, CrosstabReportElement re)
2113    {
2114        NamedNodeMap JavaDoc nodeAttributes = cellConetensNode.getAttributes();
2115
2116        if (nodeAttributes.getNamedItem("width") != null)
2117        {
2118           try { cell.setWidth( Integer.parseInt( nodeAttributes.getNamedItem("width").getNodeValue() )); } catch (Exception JavaDoc ex){
2119            System.out.println("Invalid width for crosstab cell");
2120           }
2121        }
2122
2123        if (nodeAttributes.getNamedItem("height") != null)
2124        {
2125           try { cell.setHeight( Integer.parseInt( nodeAttributes.getNamedItem("height").getNodeValue() )); } catch (Exception JavaDoc ex){
2126            System.out.println("Invalid height for crosstab cell");
2127           }
2128        }
2129
2130        if (nodeAttributes.getNamedItem("rowTotalGroup") != null)
2131            cell.setRowTotalGroup(nodeAttributes.getNamedItem("rowTotalGroup").getNodeValue() );
2132
2133        if (nodeAttributes.getNamedItem("columnTotalGroup") != null)
2134            cell.setColumnTotalGroup(nodeAttributes.getNamedItem("columnTotalGroup").getNodeValue() );
2135
2136
2137        // Look for the CellContents node...
2138
Node JavaDoc cellContentsElementNode = null;
2139        NodeList JavaDoc list_child = cellConetensNode.getChildNodes();
2140        for (int ck=0; ck< list_child.getLength(); ck++) {
2141            Node JavaDoc child = (Node JavaDoc)list_child.item(ck);
2142            NamedNodeMap JavaDoc subNodeAttributes = child.getAttributes();
2143            if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("cellContents")) {
2144                cellContentsElementNode = child;
2145
2146                if (subNodeAttributes.getNamedItem("style") != null)
2147                {
2148                   String JavaDoc sname = subNodeAttributes.getNamedItem("style").getNodeValue();
2149                   for (int j=0; j<getReport().getStyles().size(); ++j)
2150                   {
2151                        Style sparent = (Style)getReport().getStyles().elementAt(j);
2152                        if (sparent.getName().equals( sname))
2153                        {
2154                            cell.setStyle( sparent);
2155                            break;
2156                        }
2157                   }
2158                }
2159
2160                if (subNodeAttributes.getNamedItem("backcolor") != null)
2161                        cell.setBackcolor( getReport().decodeColor( subNodeAttributes.getNamedItem("backcolor").getNodeValue() ));
2162
2163                if (subNodeAttributes.getNamedItem("mode") != null)
2164                    cell.setMode( subNodeAttributes.getNamedItem("mode").getNodeValue());
2165            }
2166        }
2167
2168        if (cellContentsElementNode != null)
2169        {
2170            list_child = cellContentsElementNode.getChildNodes();
2171            for (int ck=0; ck< list_child.getLength(); ck++) {
2172                Node JavaDoc child = (Node JavaDoc)list_child.item(ck);
2173                NamedNodeMap JavaDoc subNodeAttributes = child.getAttributes();
2174
2175
2176                if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("box")) {
2177                    readBoxElement(child, cell);
2178                }
2179            }
2180
2181        }
2182        readBandElements("",cellContentsElementNode,null,null,re,cell);
2183
2184    }
2185
2186    private void readBucket(Node JavaDoc bucketXmlNode, CrosstabGroup grp)
2187    {
2188        NamedNodeMap JavaDoc nodeAttributes = bucketXmlNode.getAttributes();
2189
2190        if (nodeAttributes.getNamedItem("order") != null)
2191            grp.setBucketOrder( nodeAttributes.getNamedItem("order").getNodeValue() );
2192
2193        NodeList JavaDoc list_child = bucketXmlNode.getChildNodes();
2194        for (int ck=0; ck< list_child.getLength(); ck++) {
2195            Node JavaDoc child = (Node JavaDoc)list_child.item(ck);
2196            NamedNodeMap JavaDoc subNodeAttributes = child.getAttributes();
2197            if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("bucketExpression")) {
2198
2199                if (subNodeAttributes.getNamedItem("class") != null)
2200                    grp.setBucketExpressionClass( subNodeAttributes.getNamedItem("class").getNodeValue());
2201
2202                grp.setBucketExpression(readPCDATA(child));
2203            }
2204            else if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("comparatorExpression")) {
2205                grp.setBucketComparatorExpression(readPCDATA(child));
2206            }
2207        }
2208    }
2209
2210
2211    private void readChartElement(Node JavaDoc xmlChart, ChartReportElement2 re) {
2212        NamedNodeMap JavaDoc nodeAttributes = xmlChart.getAttributes();
2213
2214        if (nodeAttributes.getNamedItem("isShowLegend") != null)
2215            re.getChart().setShowLegend( nodeAttributes.getNamedItem("isShowLegend").getNodeValue().equals("true") );
2216        if (nodeAttributes.getNamedItem("evaluationTime") != null)
2217            re.setEvaluationTime( nodeAttributes.getNamedItem("evaluationTime").getNodeValue() );
2218        if (nodeAttributes.getNamedItem("evaluationGroup") != null)
2219            re.setEvaluationGroup( nodeAttributes.getNamedItem("evaluationGroup").getNodeValue() );
2220        //if (nodeAttributes.getNamedItem("hyperlinkType") != null)
2221
// re.setHyperlinkType( ""+nodeAttributes.getNamedItem("hyperlinkType").getNodeValue() );
2222
//if (nodeAttributes.getNamedItem("hyperlinkTarget") != null)
2223
// re.setHyperlinkTarget( ""+nodeAttributes.getNamedItem("hyperlinkTarget").getNodeValue() );
2224
//if (nodeAttributes.getNamedItem("bookmarkLevel") != null)
2225
// re.setBookmarkLevel( Integer.parseInt( nodeAttributes.getNamedItem("bookmarkLevel").getNodeValue() ) );
2226
if (nodeAttributes.getNamedItem("customizerClass") != null)
2227            re.getChart().setCustomizerClass( nodeAttributes.getNamedItem("customizerClass").getNodeValue() );
2228
2229        NodeList JavaDoc childsOfChild = xmlChart.getChildNodes();
2230        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
2231            Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
2232            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("printWhenExpression")) {
2233                re.setPrintWhenExpression( readPCDATA(child_child) );
2234            }
2235            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("reportElement")) {
2236                readXMLReportElement(child_child, re);
2237            }
2238            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("box")) {
2239                readBoxElement(child_child, re);
2240            }
2241            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("chartTitle")) {
2242                readChartTitleElement(child_child, re);
2243            }
2244            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("chartSubtitle")) {
2245                readChartSubTitleElement(child_child, re);
2246            }
2247            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("chartLegend")) {
2248                readChartLegendElement(child_child, re);
2249            }
2250            /*
2251            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("anchorNameExpression")) {
2252                re.setAnchorNameExpression( readPCDATA(child_child) );
2253            }
2254            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("hyperlinkAnchorExpression")) {
2255                re.setHyperlinkAnchorExpression( readPCDATA(child_child) );
2256            }
2257            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("hyperlinkPageExpression")) {
2258                re.setHyperlinkPageExpression( readPCDATA(child_child) );
2259            }
2260            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("hyperlinkReferenceExpression")) {
2261                re.setHyperlinkReferenceExpression( readPCDATA(child_child) );
2262            }
2263            */

2264        }
2265        readHyperlink(xmlChart, re);
2266    }
2267
2268    private void readChartTitleElement(Node JavaDoc xmlElement, ChartReportElement2 re) {
2269        NamedNodeMap JavaDoc nodeAttributes = xmlElement.getAttributes();
2270
2271        if (nodeAttributes.getNamedItem("position") != null)
2272            re.getChart().getTitle().setPosition( nodeAttributes.getNamedItem("position").getNodeValue() );
2273        if (nodeAttributes.getNamedItem("color") != null)
2274            re.getChart().getTitle().setColor( decodeColor( ""+nodeAttributes.getNamedItem("color").getNodeValue()) );
2275
2276        NodeList JavaDoc childsOfChild = xmlElement.getChildNodes();
2277        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
2278            Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
2279            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("titleExpression")) {
2280                re.getChart().getTitle().setTitleExpression( readPCDATA(child_child) );
2281            }
2282            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("font")) {
2283                re.getChart().getTitle().setFont( readFontElement(child_child) );
2284            }
2285        }
2286    }
2287
2288    private void readChartLegendElement(Node JavaDoc xmlElement, ChartReportElement2 re) {
2289        NamedNodeMap JavaDoc nodeAttributes = xmlElement.getAttributes();
2290
2291        if (nodeAttributes.getNamedItem("textColor") != null)
2292            re.getChart().getLegend().setTextColor( decodeColor( ""+nodeAttributes.getNamedItem("textColor").getNodeValue()) );
2293
2294        if (nodeAttributes.getNamedItem("backgroundColor") != null)
2295            re.getChart().getLegend().setBackgroundColor( decodeColor( ""+nodeAttributes.getNamedItem("backgroundColor").getNodeValue()) );
2296
2297
2298        NodeList JavaDoc childsOfChild = xmlElement.getChildNodes();
2299        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
2300            Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
2301            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("font")) {
2302                re.getChart().getLegend().setFont( readFontElement(child_child) );
2303            }
2304        }
2305    }
2306
2307     private IReportFont readFontElement(Node JavaDoc xmlElement) {
2308
2309            NamedNodeMap JavaDoc nnm = xmlElement.getAttributes();
2310            IReportFont font = null;
2311
2312            if ( nnm.getNamedItem("reportFont") != null) {
2313
2314                font = getReport().getReportFontByName( nnm.getNamedItem("reportFont").getNodeValue() );
2315                if (font != null)
2316                {
2317                    font = (IReportFont) font.clone();
2318                    font.setReportFont( nnm.getNamedItem("reportFont").getNodeValue());
2319                }
2320            }
2321
2322            if (font == null)
2323            {
2324                if ( getReport().getDefaultFont() != null)
2325                {
2326                    font = (IReportFont)getReport().getDefaultFont().clone();
2327                }
2328                else
2329                {
2330                    font = new IReportFont();
2331                }
2332            }
2333
2334            //System.out.println("Working on: " + xmlReportElement);
2335
for (int kkk=0; kkk<nnm.getLength(); ++kkk)
2336            {
2337                //System.out.println( + " " + );
2338

2339                String JavaDoc propName = nnm.item(kkk).getNodeName();
2340                String JavaDoc propValue = nnm.item(kkk).getNodeValue();
2341                if (propName != null && propValue != null)
2342                {
2343                    if (propName.equals("fontName"))
2344                        font.setFontName(propValue);
2345                    else if (propName.equals("pdfFontName"))
2346                        font.setPDFFontName(propValue);
2347                    else if (propName.equals("size"))
2348                        font.setFontSize( Integer.parseInt(""+propValue) );
2349                    else if (propName.equals("isBold"))
2350                        font.setBold( (new String JavaDoc(""+propValue)).equalsIgnoreCase("true") );
2351                    else if (propName.equals("isItalic"))
2352                        font.setItalic( (new String JavaDoc(""+propValue)).equalsIgnoreCase("true") );
2353                    else if (propName.equals("isUnderline"))
2354                        font.setUnderline( (new String JavaDoc(""+propValue)).equalsIgnoreCase("true") );
2355                    else if (propName.equals("isStrikeThrough"))
2356                        font.setStrikeTrought( (new String JavaDoc(""+propValue)).equalsIgnoreCase("true") );
2357                    else if (propName.equals("isPdfEmbedded"))
2358                        font.setPdfEmbedded((new String JavaDoc(""+propValue)).equalsIgnoreCase("true") );
2359                    else if (propName.equals("pdfEncoding"))
2360                        font.setPdfEncoding( ""+propValue );
2361                }
2362            }
2363
2364
2365            return font;
2366     }
2367
2368    private void readDataset(Node JavaDoc xmlNode, ChartReportElement2 re) {
2369
2370        readDataset(xmlNode, re.getChart().getDataset());
2371    }
2372
2373
2374    private void readDataset(Node JavaDoc xmlNode, Dataset dataset) {
2375        NamedNodeMap JavaDoc nodeAttributes = xmlNode.getAttributes();
2376
2377        if (nodeAttributes.getNamedItem("resetType") != null)
2378            dataset.setResetType( nodeAttributes.getNamedItem("resetType").getNodeValue() );
2379        if (nodeAttributes.getNamedItem("resetGroup") != null)
2380            dataset.setResetGroup( nodeAttributes.getNamedItem("resetGroup").getNodeValue() );
2381        if (nodeAttributes.getNamedItem("incrementType") != null)
2382            dataset.setIncrementType( nodeAttributes.getNamedItem("incrementType").getNodeValue() );
2383        if (nodeAttributes.getNamedItem("incrementGroup") != null)
2384            dataset.setIncrementGroup( nodeAttributes.getNamedItem("incrementGroup").getNodeValue() );
2385
2386        NodeList JavaDoc childsOfChild = xmlNode.getChildNodes();
2387        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
2388            Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
2389
2390            NamedNodeMap JavaDoc subNodeAttributes = child_child.getAttributes();
2391            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("incrementWhenExpression")) {
2392
2393                dataset.setIncrementWhenExpression( readPCDATA(child_child) );
2394            }
2395            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("datasetRun")) {
2396
2397                if (subNodeAttributes.getNamedItem("subDataset") != null)
2398                {
2399                        String JavaDoc name = subNodeAttributes.getNamedItem("subDataset").getNodeValue();
2400                        Enumeration JavaDoc enum_datasets = getReport().getSubDatasets().elements();
2401                        while (enum_datasets.hasMoreElements())
2402                        {
2403                            SubDataset subDataset = (SubDataset)enum_datasets.nextElement();
2404                            if ( subDataset.getName().equals(name))
2405                            {
2406                                dataset.setSubDataset( subDataset );
2407                                break;
2408                            }
2409                        }
2410
2411                        NodeList JavaDoc childsOfchild_child = child_child.getChildNodes();
2412                        for (int c_count2=0; c_count2< childsOfchild_child.getLength(); c_count2++) {
2413                            Node JavaDoc child_child2 = (Node JavaDoc)childsOfchild_child.item(c_count2);
2414
2415                            NamedNodeMap JavaDoc subNodeAttributes2 = child_child2.getAttributes();
2416
2417                            if (child_child2.getNodeType() == Node.ELEMENT_NODE && child_child2.getNodeName().equals("parametersMapExpression")) {
2418                                dataset.setParametersMapExpression( readPCDATA(child_child2) );
2419                            }
2420                            else if (child_child2.getNodeType() == Node.ELEMENT_NODE && child_child2.getNodeName().equals("datasetParameter")) {
2421                                name = "";
2422                                if (subNodeAttributes2.getNamedItem("name") != null) {
2423                                    name = ""+subNodeAttributes2.getNamedItem("name").getNodeValue();
2424                                }
2425                                // Find expression in childs......
2426
String JavaDoc expression = "";
2427                                NodeList JavaDoc childsOfChildOfChild = child_child2.getChildNodes();
2428                                for (int c_count_2=0; c_count_2< childsOfChildOfChild.getLength(); c_count_2++) {
2429                                    Node JavaDoc child_child_child = (Node JavaDoc)childsOfChildOfChild.item(c_count_2);
2430                                    if (child_child_child.getNodeType() == Node.ELEMENT_NODE && child_child_child.getNodeName().equals("datasetParameterExpression")) {
2431                                        expression = readPCDATA(child_child_child);
2432                                        break;
2433                                    }
2434                                }
2435                                dataset.getSubreportParameters().addElement( new it.businesslogic.ireport.JRSubreportParameter( name, expression));
2436                            }
2437                            else if (child_child2.getNodeType() == Node.ELEMENT_NODE && child_child2.getNodeName().equals("connectionExpression")) {
2438                                dataset.setConnectionExpression( readPCDATA(child_child2));
2439                                dataset.setUseConnection(true);
2440                            }
2441                            else if (child_child2.getNodeType() == Node.ELEMENT_NODE && child_child2.getNodeName().equals("dataSourceExpression")) {
2442                                dataset.setDataSourceExpression(readPCDATA(child_child2));
2443                                dataset.setUseConnection(false);
2444                            }
2445                        }
2446                }
2447            }
2448        }
2449    }
2450
2451    private void readSectionItemHyperlink(Node JavaDoc elementNode, SectionItemHyperlink sih) {
2452
2453        NodeList JavaDoc childsOfChild = elementNode.getChildNodes();
2454
2455        NamedNodeMap JavaDoc nodeAttributes = elementNode.getAttributes();
2456        if (nodeAttributes.getNamedItem("hyperlinkType") != null)
2457            sih.setHyperlinkType( ""+nodeAttributes.getNamedItem("hyperlinkType").getNodeValue() );
2458        if (nodeAttributes.getNamedItem("hyperlinkTarget") != null)
2459            sih.setHyperlinkTarget( ""+nodeAttributes.getNamedItem("hyperlinkTarget").getNodeValue() );
2460
2461        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
2462            Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
2463            NamedNodeMap JavaDoc subNodeAttributes = child_child.getAttributes();
2464            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("hyperlinkParameter")) {
2465                String JavaDoc name = "";
2466                if (subNodeAttributes.getNamedItem("name") != null) {
2467                    name = ""+subNodeAttributes.getNamedItem("name").getNodeValue();
2468                }
2469                // Find expression in childs......
2470
String JavaDoc expression = "";
2471                NodeList JavaDoc childsOfChildOfChild = child_child.getChildNodes();
2472                for (int c_count_2=0; c_count_2< childsOfChildOfChild.getLength(); c_count_2++) {
2473                    Node JavaDoc child_child_child = (Node JavaDoc)childsOfChildOfChild.item(c_count_2);
2474                    if (child_child_child.getNodeType() == Node.ELEMENT_NODE && child_child_child.getNodeName().equals("hyperlinkParameterExpression")) {
2475                        expression = readPCDATA(child_child_child);
2476                        break;
2477                    }
2478                }
2479                sih.getHyperlinkParameters().add( new it.businesslogic.ireport.JRLinkParameter( name, expression));
2480            }
2481            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("hyperlinkAnchorExpression")) {
2482                sih.setHyperlinkAnchorExpression( readPCDATA(child_child) );
2483            }
2484            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("hyperlinkPageExpression")) {
2485                sih.setHyperlinkPageExpression( readPCDATA(child_child) );
2486            }
2487            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("hyperlinkReferenceExpression")) {
2488                sih.setHyperlinkReferenceExpression( readPCDATA(child_child) );
2489            }
2490            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("hyperlinkTooltipExpression")) {
2491                sih.setHyperlinkTooltipExpression( readPCDATA(child_child) );
2492            }
2493        }
2494
2495    }
2496
2497    private void readPieDataset(Node JavaDoc xmlNode, ChartReportElement2 re) {
2498
2499        NodeList JavaDoc childsOfChild = xmlNode.getChildNodes();
2500        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
2501            Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
2502            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("dataset")) {
2503                readDataset(child_child, re);
2504            }
2505            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("keyExpression")) {
2506                 ((it.businesslogic.ireport.chart.PieDataset)re.getChart().getDataset()).setKeyExpression( readPCDATA(child_child) );
2507            }
2508            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("valueExpression")) {
2509                 ((it.businesslogic.ireport.chart.PieDataset)re.getChart().getDataset()).setValueExpression( readPCDATA(child_child) );
2510            }
2511            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("labelExpression")) {
2512                 ((it.businesslogic.ireport.chart.PieDataset)re.getChart().getDataset()).setLabelExpression( readPCDATA(child_child) );
2513            }
2514            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("sectionHyperlink")) {
2515                 readSectionItemHyperlink(child_child, ((PieDataset)re.getChart().getDataset()).getSectionHyperLink() );
2516            }
2517        }
2518    }
2519
2520
2521
2522    private void readCategoryDataset(Node JavaDoc xmlNode, ChartReportElement2 re) {
2523
2524        NodeList JavaDoc childsOfChild = xmlNode.getChildNodes();
2525
2526        CategoryDataset cd = new CategoryDataset();
2527        re.getChart().setDataset(cd);
2528
2529        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
2530            Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
2531            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("dataset")) {
2532                readDataset(child_child, re);
2533            }
2534            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("categorySeries")) {
2535                CategorySeries cs = readCategorySeries(child_child);
2536                cd.getCategorySeries().add(cs);
2537            }
2538        }
2539    }
2540
2541    private void readTimePeriodDataset(Node JavaDoc xmlNode, ChartReportElement2 re) {
2542
2543        NodeList JavaDoc childsOfChild = xmlNode.getChildNodes();
2544
2545        TimePeriodDataset cd = new TimePeriodDataset();
2546        re.getChart().setDataset(cd);
2547
2548        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
2549            Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
2550            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("dataset")) {
2551                readDataset(child_child, re);
2552            }
2553            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("timePeriodSeries")) {
2554                TimePeriodSeries cs = readTimePeriodSeries(child_child);
2555                cd.getTimePeriodSeries().add(cs);
2556            }
2557        }
2558    }
2559
2560    private void readXYDataset(Node JavaDoc xmlNode, ChartReportElement2 re) {
2561
2562        NodeList JavaDoc childsOfChild = xmlNode.getChildNodes();
2563
2564        XYDataset cd = new XYDataset();
2565        re.getChart().setDataset(cd);
2566
2567        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
2568            Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
2569            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("dataset")) {
2570                readDataset(child_child, re);
2571            }
2572            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("xySeries")) {
2573                XYSeries cs = readXYSeries(child_child);
2574                cd.getXYSeries().add(cs);
2575            }
2576        }
2577    }
2578
2579    private void readXYZDataset(Node JavaDoc xmlNode, ChartReportElement2 re) {
2580
2581        NodeList JavaDoc childsOfChild = xmlNode.getChildNodes();
2582
2583        XYZDataset cd = new XYZDataset();
2584        re.getChart().setDataset(cd);
2585
2586        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
2587            Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
2588            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("dataset")) {
2589                readDataset(child_child, re);
2590            }
2591            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("xyzSeries")) {
2592                XYZSeries cs = readXYZSeries(child_child);
2593                cd.getXYZSeries().add(cs);
2594            }
2595        }
2596    }
2597
2598    private void readTimeSeriesDataset(Node JavaDoc xmlNode, ChartReportElement2 re) {
2599
2600        NamedNodeMap JavaDoc nodeAttributes = xmlNode.getAttributes();
2601        NodeList JavaDoc childsOfChild = xmlNode.getChildNodes();
2602
2603        TimeSeriesDataset cd = new TimeSeriesDataset();
2604        re.getChart().setDataset(cd);
2605
2606        if (nodeAttributes.getNamedItem("timePeriod") != null)
2607            cd.setTimePeriod( nodeAttributes.getNamedItem("timePeriod").getNodeValue() );
2608
2609        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
2610            Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
2611            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("dataset")) {
2612                readDataset(child_child, re);
2613            }
2614            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("timeSeries")) {
2615                TimeSeries cs = readTimeSeries(child_child);
2616                cd.getTimeSeries().add(cs);
2617            }
2618        }
2619    }
2620
2621    private void readHighLowDataset(Node JavaDoc xmlNode, ChartReportElement2 re) {
2622
2623        NodeList JavaDoc childsOfChild = xmlNode.getChildNodes();
2624
2625        HighLowDataset cd = new HighLowDataset();
2626        re.getChart().setDataset(cd);
2627
2628        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
2629            Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
2630            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("dataset")) {
2631                readDataset(child_child, re);
2632            }
2633            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("seriesExpression")) {
2634                 cd.setSeriesExpression( readPCDATA(child_child) );
2635            }
2636            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("dateExpression")) {
2637                 cd.setDateExpression( readPCDATA(child_child) );
2638            }
2639            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("highExpression")) {
2640                 cd.setHighExpression( readPCDATA(child_child) );
2641            }
2642            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("lowExpression")) {
2643                 cd.setLowExpression( readPCDATA(child_child) );
2644            }
2645            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("openExpression")) {
2646                 cd.setOpenExpression( readPCDATA(child_child) );
2647            }
2648            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("closeExpression")) {
2649                 cd.setCloseExpression( readPCDATA(child_child) );
2650            }
2651            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("volumeExpression")) {
2652                 cd.setVolumeExpression( readPCDATA(child_child) );
2653            }
2654            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("sectionHyperlink")) {
2655                 readSectionItemHyperlink(child_child, cd.getItemHyperLink());
2656            }
2657
2658        }
2659    }
2660
2661    private void readValueDataset(Node JavaDoc xmlNode, ChartReportElement2 re) {
2662
2663        NodeList JavaDoc childsOfChild = xmlNode.getChildNodes();
2664
2665        ValueDataset cd = new ValueDataset();
2666        re.getChart().setDataset(cd);
2667
2668        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
2669            Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
2670            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("dataset")) {
2671                readDataset(child_child, re);
2672            }
2673            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("valueExpression")) {
2674                 cd.setValueExpression( readPCDATA(child_child) );
2675            }
2676
2677
2678        }
2679    }
2680
2681    private CategorySeries readCategorySeries(Node JavaDoc xmlNode) {
2682
2683        NodeList JavaDoc childsOfChild = xmlNode.getChildNodes();
2684
2685        CategorySeries cs = new CategorySeries();
2686
2687        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
2688            Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
2689            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("seriesExpression")) {
2690                cs.setSeriesExpression( readPCDATA(child_child) );
2691            }
2692            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("categoryExpression")) {
2693                cs.setCategoryExpression( readPCDATA(child_child) );
2694            }
2695            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("valueExpression")) {
2696                cs.setValueExpression( readPCDATA(child_child) );
2697            }
2698            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("labelExpression")) {
2699                cs.setLabelExpression( readPCDATA(child_child) );
2700            }
2701            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("sectionHyperlink")) {
2702                 readSectionItemHyperlink(child_child, cs.getSectionItemHyperlink() );
2703            }
2704        }
2705
2706        return cs;
2707    }
2708
2709    private TimePeriodSeries readTimePeriodSeries(Node JavaDoc xmlNode) {
2710
2711        NodeList JavaDoc childsOfChild = xmlNode.getChildNodes();
2712
2713        TimePeriodSeries cs = new TimePeriodSeries();
2714
2715        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
2716            Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
2717            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("seriesExpression")) {
2718                cs.setSeriesExpression( readPCDATA(child_child) );
2719            }
2720            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("startDateExpression")) {
2721                cs.setStartDateExpression( readPCDATA(child_child) );
2722            }
2723            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("endDateExpression")) {
2724                cs.setEndDateExpression( readPCDATA(child_child) );
2725            }
2726            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("valueExpression")) {
2727                cs.setValueExpression( readPCDATA(child_child) );
2728            }
2729            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("labelExpression")) {
2730                cs.setLabelExpression( readPCDATA(child_child) );
2731            }
2732            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("sectionHyperlink")) {
2733                 readSectionItemHyperlink(child_child, cs.getSectionItemHyperlink() );
2734            }
2735        }
2736
2737        return cs;
2738    }
2739
2740    private TimeSeries readTimeSeries(Node JavaDoc xmlNode) {
2741
2742        NodeList JavaDoc childsOfChild = xmlNode.getChildNodes();
2743
2744        TimeSeries cs = new TimeSeries();
2745
2746        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
2747            Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
2748            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("seriesExpression")) {
2749                cs.setSeriesExpression( readPCDATA(child_child) );
2750            }
2751            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("timePeriodExpression")) {
2752                cs.setTimePeriodExpression( readPCDATA(child_child) );
2753            }
2754            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("valueExpression")) {
2755                cs.setValueExpression( readPCDATA(child_child) );
2756            }
2757            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("labelExpression")) {
2758                cs.setLabelExpression( readPCDATA(child_child) );
2759            }
2760            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("sectionHyperlink")) {
2761                 readSectionItemHyperlink(child_child, cs.getSectionItemHyperlink() );
2762            }
2763        }
2764
2765        return cs;
2766    }
2767
2768    private XYSeries readXYSeries(Node JavaDoc xmlNode) {
2769
2770        NodeList JavaDoc childsOfChild = xmlNode.getChildNodes();
2771
2772        XYSeries cs = new XYSeries();
2773
2774        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
2775            Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
2776            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("seriesExpression")) {
2777                cs.setSeriesExpression( readPCDATA(child_child) );
2778            }
2779            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("xValueExpression")) {
2780                cs.setXValueExpression( readPCDATA(child_child) );
2781            }
2782            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("yValueExpression")) {
2783                cs.setYValueExpression( readPCDATA(child_child) );
2784            }
2785            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("labelExpression")) {
2786                cs.setLabelExpression( readPCDATA(child_child) );
2787            }
2788            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("sectionHyperlink")) {
2789                 readSectionItemHyperlink(child_child, cs.getSectionItemHyperlink() );
2790            }
2791        }
2792
2793        return cs;
2794    }
2795
2796    private XYZSeries readXYZSeries(Node JavaDoc xmlNode) {
2797
2798        NodeList JavaDoc childsOfChild = xmlNode.getChildNodes();
2799
2800        XYZSeries cs = new XYZSeries();
2801
2802        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
2803            Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
2804            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("seriesExpression")) {
2805                cs.setSeriesExpression( readPCDATA(child_child) );
2806            }
2807            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("xValueExpression")) {
2808                cs.setXValueExpression( readPCDATA(child_child) );
2809            }
2810            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("yValueExpression")) {
2811                cs.setYValueExpression( readPCDATA(child_child) );
2812            }
2813            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("zValueExpression")) {
2814                cs.setZValueExpression( readPCDATA(child_child) );
2815            }
2816            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("sectionHyperlink")) {
2817                 readSectionItemHyperlink(child_child, cs.getSectionItemHyperlink() );
2818            }
2819        }
2820
2821        return cs;
2822    }
2823
2824    private void readPiePlot(Node JavaDoc xmlNode, PiePlot plot) {
2825       readPlot(xmlNode, plot);
2826    }
2827
2828    private void readPie3DPlot(Node JavaDoc xmlNode, Pie3DPlot plot) {
2829        NamedNodeMap JavaDoc nodeAttributes = xmlNode.getAttributes();
2830
2831        if (nodeAttributes.getNamedItem("depthFactor") != null)
2832            plot.setDepthFactor( Double.parseDouble( nodeAttributes.getNamedItem("depthFactor").getNodeValue() ) );
2833
2834        readPlot(xmlNode, plot);
2835    }
2836
2837    private void readBarPlot(Node JavaDoc xmlNode, BarPlot plot) {
2838        NamedNodeMap JavaDoc nodeAttributes = xmlNode.getAttributes();
2839
2840        readPlot(xmlNode, plot);
2841
2842        if (nodeAttributes.getNamedItem("isShowLabels") != null)
2843                plot.setShowLabels( nodeAttributes.getNamedItem("isShowLabels").getNodeValue().equals("true") );
2844        if (nodeAttributes.getNamedItem("isShowTickMarks") != null)
2845                plot.setShowTickMarks( nodeAttributes.getNamedItem("isShowTickMarks").getNodeValue().equals("true") );
2846        if (nodeAttributes.getNamedItem("isShowTickLabels") != null)
2847                plot.setShowTickLabels( nodeAttributes.getNamedItem("isShowTickLabels").getNodeValue().equals("true") );
2848
2849        NodeList JavaDoc childsOfChild = xmlNode.getChildNodes();
2850        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
2851            Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
2852            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("categoryAxisLabelExpression")) {
2853                plot.setCategoryAxisLabelExpression( readPCDATA(child_child) );
2854            }
2855            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("valueAxisLabelExpression")) {
2856                plot.setValueAxisLabelExpression( readPCDATA(child_child) );
2857            }
2858            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("categoryAxisFormat")) {
2859                plot.setCategoryAxisFormat(readAxisFormat( findChild(child_child, "axisFormat") ));
2860            }
2861            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("valueAxisFormat")) {
2862                plot.setValueAxisFormat( readAxisFormat(findChild(child_child, "axisFormat") ));
2863            }
2864        }
2865    }
2866
2867    private void readBar3DPlot(Node JavaDoc xmlNode, Bar3DPlot plot) {
2868        NamedNodeMap JavaDoc nodeAttributes = xmlNode.getAttributes();
2869
2870        readPlot(xmlNode, plot);
2871
2872        if (nodeAttributes.getNamedItem("isShowLabels") != null)
2873                plot.setShowLabels( nodeAttributes.getNamedItem("isShowLabels").getNodeValue().equals("true") );
2874        if (nodeAttributes.getNamedItem("xOffset") != null)
2875                plot.setXOffset( Double.parseDouble( nodeAttributes.getNamedItem("xOffset").getNodeValue() ) );
2876        if (nodeAttributes.getNamedItem("yOffset") != null)
2877                plot.setYOffset( Double.parseDouble( nodeAttributes.getNamedItem("yOffset").getNodeValue() ) );
2878
2879        NodeList JavaDoc childsOfChild = xmlNode.getChildNodes();
2880        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
2881            Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
2882            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("categoryAxisLabelExpression")) {
2883                plot.setCategoryAxisLabelExpression( readPCDATA(child_child) );
2884            }
2885            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("valueAxisLabelExpression")) {
2886                plot.setValueAxisLabelExpression( readPCDATA(child_child) );
2887            }
2888            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("categoryAxisFormat")) {
2889                plot.setCategoryAxisFormat(readAxisFormat( findChild(child_child, "axisFormat") ));
2890            }
2891            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("valueAxisFormat")) {
2892                plot.setValueAxisFormat( readAxisFormat(findChild(child_child, "axisFormat") ));
2893            }
2894        }
2895    }
2896
2897    private void readLinePlot(Node JavaDoc xmlNode, LinePlot plot) {
2898        NamedNodeMap JavaDoc nodeAttributes = xmlNode.getAttributes();
2899
2900        readPlot(xmlNode, plot);
2901
2902        if (nodeAttributes.getNamedItem("isShowLines") != null)
2903                plot.setShowLines( nodeAttributes.getNamedItem("isShowLines").getNodeValue().equals("true") );
2904        if (nodeAttributes.getNamedItem("isShowShapes") != null)
2905                plot.setShowShapes( nodeAttributes.getNamedItem("isShowShapes").getNodeValue().equals("true") );
2906
2907        NodeList JavaDoc childsOfChild = xmlNode.getChildNodes();
2908        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
2909            Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
2910            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("categoryAxisLabelExpression")) {
2911                plot.setCategoryAxisLabelExpression( readPCDATA(child_child) );
2912            }
2913            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("valueAxisLabelExpression")) {
2914                plot.setValueAxisLabelExpression( readPCDATA(child_child) );
2915            }
2916            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("categoryAxisFormat")) {
2917                plot.setCategoryAxisFormat(readAxisFormat( findChild(child_child, "axisFormat") ));
2918            }
2919            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("valueAxisFormat")) {
2920                plot.setValueAxisFormat( readAxisFormat(findChild(child_child, "axisFormat") ));
2921            }
2922        }
2923    }
2924
2925
2926    private AxisFormat readAxisFormat(Node JavaDoc xmlNode) {
2927
2928        AxisFormat axisFormat = new AxisFormat();
2929
2930        NamedNodeMap JavaDoc nodeAttributes = xmlNode.getAttributes();
2931
2932        if (nodeAttributes.getNamedItem("labelColor") != null)
2933                axisFormat.setLabelColor( decodeColor( ""+nodeAttributes.getNamedItem("labelColor").getNodeValue()) );
2934
2935        if (nodeAttributes.getNamedItem("tickLabelColor") != null)
2936                axisFormat.setTickLabelColor( decodeColor( ""+nodeAttributes.getNamedItem("tickLabelColor").getNodeValue()) );
2937
2938        if (nodeAttributes.getNamedItem("axisLineColor") != null)
2939                axisFormat.setAxisLineColor( decodeColor( ""+nodeAttributes.getNamedItem("axisLineColor").getNodeValue()) );
2940
2941        if (nodeAttributes.getNamedItem("tickLabelMask") != null)
2942                axisFormat.setTickLabelMask( ""+nodeAttributes.getNamedItem("tickLabelMask").getNodeValue() );
2943
2944        NodeList JavaDoc childsOfChild = xmlNode.getChildNodes();
2945        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
2946            Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
2947            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("labelFont")) {
2948                Node JavaDoc fontNode = findChild(child_child, "font");
2949                if (fontNode != null)
2950                axisFormat.setLabelFont( readFontElement(fontNode) );
2951            }
2952            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("tickLabelFont")) {
2953                Node JavaDoc fontNode = findChild(child_child, "font");
2954                if (fontNode != null)
2955                axisFormat.setTickLabelFont( readFontElement(fontNode) );
2956            }
2957        }
2958
2959        return axisFormat;
2960    }
2961
2962    private void readAreaPlot(Node JavaDoc xmlNode, AreaPlot plot) {
2963        NamedNodeMap JavaDoc nodeAttributes = xmlNode.getAttributes();
2964
2965        readPlot(xmlNode, plot);
2966
2967        NodeList JavaDoc childsOfChild = xmlNode.getChildNodes();
2968        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
2969            Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
2970            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("categoryAxisLabelExpression")) {
2971                plot.setCategoryAxisLabelExpression( readPCDATA(child_child) );
2972            }
2973            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("valueAxisLabelExpression")) {
2974                plot.setValueAxisLabelExpression( readPCDATA(child_child) );
2975            }
2976            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("categoryAxisFormat")) {
2977                plot.setCategoryAxisFormat(readAxisFormat( findChild(child_child, "axisFormat") ));
2978            }
2979            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("valueAxisFormat")) {
2980                plot.setValueAxisFormat( readAxisFormat(findChild(child_child, "axisFormat") ));
2981            }
2982        }
2983    }
2984
2985    private void readScatterPlot(Node JavaDoc xmlNode, ScatterPlot plot) {
2986        NamedNodeMap JavaDoc nodeAttributes = xmlNode.getAttributes();
2987
2988        readPlot(xmlNode, plot);
2989
2990        if (nodeAttributes.getNamedItem("isShowLines") != null)
2991                plot.setShowLines( nodeAttributes.getNamedItem("isShowLines").getNodeValue().equals("true") );
2992        if (nodeAttributes.getNamedItem("isShowShapes") != null)
2993                plot.setShowShapes( nodeAttributes.getNamedItem("isShowShapes").getNodeValue().equals("true") );
2994
2995        NodeList JavaDoc childsOfChild = xmlNode.getChildNodes();
2996        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
2997            Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
2998            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("xAxisLabelExpression")) {
2999                plot.setXAxisLabelExpression( readPCDATA(child_child) );
3000            }
3001            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("yAxisLabelExpression")) {
3002                plot.setYAxisLabelExpression( readPCDATA(child_child) );
3003            }
3004            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("xAxisFormat")) {
3005                plot.setXAxisFormat(readAxisFormat( findChild(child_child, "axisFormat") ));
3006            }
3007            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("yAxisFormat")) {
3008                plot.setYAxisFormat( readAxisFormat(findChild(child_child, "axisFormat") ));
3009            }
3010        }
3011    }
3012
3013    private void readBubblePlot(Node JavaDoc xmlNode, BubblePlot plot) {
3014        NamedNodeMap JavaDoc nodeAttributes = xmlNode.getAttributes();
3015
3016        readPlot(xmlNode, plot);
3017
3018        if (nodeAttributes.getNamedItem("scaleType") != null)
3019                plot.setScaleType( nodeAttributes.getNamedItem("scaleType").getNodeValue() );
3020
3021        NodeList JavaDoc childsOfChild = xmlNode.getChildNodes();
3022        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
3023            Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
3024            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("xAxisLabelExpression")) {
3025                plot.setXAxisLabelExpression( readPCDATA(child_child) );
3026            }
3027            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("yAxisLabelExpression")) {
3028                plot.setYAxisLabelExpression( readPCDATA(child_child) );
3029            }
3030            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("xAxisFormat")) {
3031                plot.setXAxisFormat(readAxisFormat( findChild(child_child, "axisFormat") ));
3032            }
3033            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("yAxisFormat")) {
3034                plot.setYAxisFormat( readAxisFormat(findChild(child_child, "axisFormat") ));
3035            }
3036        }
3037    }
3038
3039    private void readTimeSeriesPlot(Node JavaDoc xmlNode, TimeSeriesPlot plot) {
3040        NamedNodeMap JavaDoc nodeAttributes = xmlNode.getAttributes();
3041
3042        readPlot(xmlNode, plot);
3043
3044        if (nodeAttributes.getNamedItem("isShowLines") != null)
3045                plot.setShowLines( nodeAttributes.getNamedItem("isShowLines").getNodeValue().equals("true") );
3046        if (nodeAttributes.getNamedItem("isShowShapes") != null)
3047                plot.setShowShapes( nodeAttributes.getNamedItem("isShowShapes").getNodeValue().equals("true") );
3048
3049        NodeList JavaDoc childsOfChild = xmlNode.getChildNodes();
3050        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
3051            Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
3052            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("timeAxisLabelExpression")) {
3053                plot.setTimeAxisLabelExpression( readPCDATA(child_child) );
3054            }
3055            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("valueAxisLabelExpression")) {
3056                plot.setValueAxisLabelExpression( readPCDATA(child_child) );
3057            }
3058            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("timeAxisFormat")) {
3059                plot.setTimeAxisFormat(readAxisFormat( findChild(child_child, "axisFormat") ));
3060            }
3061            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("valueAxisFormat")) {
3062                plot.setValueAxisFormat( readAxisFormat(findChild(child_child, "axisFormat") ));
3063            }
3064        }
3065    }
3066
3067    private void readHighLowPlot(Node JavaDoc xmlNode, HighLowPlot plot) {
3068        NamedNodeMap JavaDoc nodeAttributes = xmlNode.getAttributes();
3069
3070        readPlot(xmlNode, plot);
3071
3072        if (nodeAttributes.getNamedItem("isShowCloseTicks") != null)
3073                plot.setShowCloseTicks( nodeAttributes.getNamedItem("isShowCloseTicks").getNodeValue().equals("true") );
3074        if (nodeAttributes.getNamedItem("isShowOpenTicks") != null)
3075                plot.setShowOpenTicks( nodeAttributes.getNamedItem("isShowOpenTicks").getNodeValue().equals("true") );
3076
3077        NodeList JavaDoc childsOfChild = xmlNode.getChildNodes();
3078        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
3079            Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
3080            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("timeAxisLabelExpression")) {
3081                plot.setTimeAxisLabelExpression( readPCDATA(child_child) );
3082            }
3083            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("valueAxisLabelExpression")) {
3084                plot.setValueAxisLabelExpression( readPCDATA(child_child) );
3085            }
3086            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("timeAxisFormat")) {
3087                plot.setTimeAxisFormat(readAxisFormat( findChild(child_child, "axisFormat") ));
3088            }
3089            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("valueAxisFormat")) {
3090                plot.setValueAxisFormat( readAxisFormat(findChild(child_child, "axisFormat") ));
3091            }
3092        }
3093    }
3094
3095    private void readCandlestickPlot(Node JavaDoc xmlNode, CandlestickPlot plot) {
3096        NamedNodeMap JavaDoc nodeAttributes = xmlNode.getAttributes();
3097
3098        readPlot(xmlNode, plot);
3099
3100        if (nodeAttributes.getNamedItem("isShowVolume") != null)
3101                plot.setShowVolume( nodeAttributes.getNamedItem("isShowVolume").getNodeValue().equals("true") );
3102
3103        NodeList JavaDoc childsOfChild = xmlNode.getChildNodes();
3104        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
3105            Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
3106            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("timeAxisLabelExpression")) {
3107                plot.setTimeAxisLabelExpression( readPCDATA(child_child) );
3108            }
3109            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("valueAxisLabelExpression")) {
3110                plot.setValueAxisLabelExpression( readPCDATA(child_child) );
3111            }
3112            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("timeAxisFormat")) {
3113                plot.setTimeAxisFormat(readAxisFormat( findChild(child_child, "axisFormat") ));
3114            }
3115            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("valueAxisFormat")) {
3116                plot.setValueAxisFormat( readAxisFormat(findChild(child_child, "axisFormat") ));
3117            }
3118        }
3119    }
3120
3121    private void readMeterPlot(Node JavaDoc xmlNode, MeterPlot plot) {
3122        NamedNodeMap JavaDoc nodeAttributes = xmlNode.getAttributes();
3123
3124        readPlot(xmlNode, plot);
3125
3126        if (nodeAttributes.getNamedItem("shape") != null)
3127                plot.setShape( nodeAttributes.getNamedItem("shape").getNodeValue() );
3128
3129        if (nodeAttributes.getNamedItem("angle") != null)
3130        {
3131            try {
3132                            plot.setAngle( Integer.parseInt(nodeAttributes.getNamedItem("angle").getNodeValue()+"") );
3133            } catch (Exception JavaDoc ex)
3134            {
3135                it.businesslogic.ireport.gui.MainFrame.getMainInstance().logOnConsole(
3136                        I18n.getString("reportReader.notValidAngle","Not valid angle value for the MeterPlot tag.") );
3137            }
3138        }
3139        if (nodeAttributes.getNamedItem("units") != null)
3140                plot.setUnits( nodeAttributes.getNamedItem("units").getNodeValue() );
3141
3142        if (nodeAttributes.getNamedItem("tickInterval") != null)
3143        {
3144            try {
3145                            plot.setTickInterval( Double.parseDouble(nodeAttributes.getNamedItem("tickInterval").getNodeValue()+"") );
3146            } catch (Exception JavaDoc ex)
3147            {
3148                it.businesslogic.ireport.gui.MainFrame.getMainInstance().logOnConsole(
3149                        I18n.getString("reportReader.notValidTickInterval","Not valid tickInterval value for the MeterPlot tag.")
3150                        );
3151            }
3152        }
3153
3154        if (nodeAttributes.getNamedItem("meterColor") != null)
3155                plot.setMeterColor( decodeColor( ""+nodeAttributes.getNamedItem("meterColor").getNodeValue()) );
3156
3157        if (nodeAttributes.getNamedItem("needleColor") != null)
3158                plot.setNeedleColor( decodeColor( ""+nodeAttributes.getNamedItem("needleColor").getNodeValue()) );
3159
3160        if (nodeAttributes.getNamedItem("tickColor") != null)
3161                plot.setTickColor( decodeColor( ""+nodeAttributes.getNamedItem("tickColor").getNodeValue()) );
3162
3163        NodeList JavaDoc childsOfChild = xmlNode.getChildNodes();
3164        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
3165            Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
3166            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("valueDisplay")) {
3167                plot.setValueDisplay( readValueDisplay(child_child) );
3168            }
3169            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("dataRange")) {
3170                plot.setDataRange( readDataRange(child_child) );
3171            }
3172            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("meterInterval")) {
3173                plot.getMeterIntervals().add(readMeterInterval(child_child));
3174            }
3175
3176        }
3177    }
3178
3179
3180    private void readThermometerPlot(Node JavaDoc xmlNode, ThermometerPlot plot) {
3181        NamedNodeMap JavaDoc nodeAttributes = xmlNode.getAttributes();
3182
3183        readPlot(xmlNode, plot);
3184
3185        if (nodeAttributes.getNamedItem("valueLocation") != null)
3186                plot.setValueLocation( nodeAttributes.getNamedItem("valueLocation").getNodeValue() );
3187
3188        if (nodeAttributes.getNamedItem("isShowValueLines") != null)
3189                plot.setShowValueLines( nodeAttributes.getNamedItem("isShowValueLines").getNodeValue().equals("true") );
3190
3191        if (nodeAttributes.getNamedItem("mercuryColor") != null)
3192                plot.setMercuryColor( decodeColor( ""+nodeAttributes.getNamedItem("mercuryColor").getNodeValue()) );
3193
3194        NodeList JavaDoc childsOfChild = xmlNode.getChildNodes();
3195        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
3196            Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
3197            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("valueDisplay")) {
3198                plot.setValueDisplay( readValueDisplay(child_child) );
3199            }
3200            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("dataRange")) {
3201                plot.setDataRange( readDataRange(child_child) );
3202            }
3203            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("lowRange")) {
3204                plot.setLowRange( readDataRange( findChild(child_child, "dataRange") ));
3205            }
3206            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("mediumRange")) {
3207                plot.setMediumRange( readDataRange( findChild(child_child, "dataRange") ));
3208            }
3209            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("highRange")) {
3210                plot.setHighRange( readDataRange( findChild(child_child, "dataRange") ));
3211            }
3212
3213        }
3214    }
3215
3216    private ValueDisplay readValueDisplay(Node JavaDoc xmlNode) {
3217
3218        ValueDisplay valueDisplay = new ValueDisplay();
3219
3220        NamedNodeMap JavaDoc nodeAttributes = xmlNode.getAttributes();
3221
3222        if (nodeAttributes.getNamedItem("color") != null)
3223                valueDisplay.setColor( decodeColor( ""+nodeAttributes.getNamedItem("color").getNodeValue()) );
3224
3225        if (nodeAttributes.getNamedItem("mask") != null)
3226                valueDisplay.setMask( ""+nodeAttributes.getNamedItem("mask").getNodeValue() );
3227
3228        NodeList JavaDoc childsOfChild = xmlNode.getChildNodes();
3229        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
3230            Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
3231            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("font")) {
3232                valueDisplay.setFont( readFontElement(child_child) );
3233            }
3234        }
3235
3236        return valueDisplay;
3237    }
3238
3239    private DataRange readDataRange(Node JavaDoc xmlNode) {
3240
3241        DataRange dataRange = new DataRange();
3242
3243        NodeList JavaDoc childsOfChild = xmlNode.getChildNodes();
3244        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
3245            Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
3246            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("lowExpression")) {
3247                dataRange.setLowExpression( readPCDATA(child_child) );
3248            }
3249            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("highExpression")) {
3250                dataRange.setHighExpression( readPCDATA(child_child) );
3251            }
3252        }
3253
3254        return dataRange;
3255    }
3256
3257    private MeterInterval readMeterInterval(Node JavaDoc xmlNode) {
3258
3259        MeterInterval meterInterval = new MeterInterval();
3260
3261        NamedNodeMap JavaDoc nodeAttributes = xmlNode.getAttributes();
3262
3263        if (nodeAttributes.getNamedItem("label") != null)
3264                meterInterval.setLabel( ""+nodeAttributes.getNamedItem("label").getNodeValue() );
3265
3266        if (nodeAttributes.getNamedItem("color") != null)
3267                meterInterval.setColor( decodeColor( ""+nodeAttributes.getNamedItem("color").getNodeValue()) );
3268
3269
3270        if (nodeAttributes.getNamedItem("alpha") != null)
3271        {
3272            try {
3273                            meterInterval.setAlpha( Double.parseDouble(nodeAttributes.getNamedItem("alpha").getNodeValue()+"") );
3274            } catch (Exception JavaDoc ex)
3275            {
3276                it.businesslogic.ireport.gui.MainFrame.getMainInstance().logOnConsole(
3277                        I18n.getString("reportReader.notValidApha","Not valid alpha value for the MeterPlot -> MeterInterval tag.")
3278                        );
3279            }
3280        }
3281
3282
3283        NodeList JavaDoc childsOfChild = xmlNode.getChildNodes();
3284        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
3285            Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
3286            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("dataRange")) {
3287                meterInterval.setDataRange( readDataRange(child_child) );
3288            }
3289        }
3290
3291        return meterInterval;
3292    }
3293
3294    private void readPlot(Node JavaDoc xmlNodeParent, Plot plot) {
3295        NodeList JavaDoc childsOfChild = xmlNodeParent.getChildNodes();
3296        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
3297            Node JavaDoc xmlNode = (Node JavaDoc)childsOfChild.item(c_count);
3298            if (xmlNode.getNodeType() == Node.ELEMENT_NODE && xmlNode.getNodeName().equals("plot")) {
3299
3300                NamedNodeMap JavaDoc nodeAttributes = xmlNode.getAttributes();
3301
3302                if (nodeAttributes.getNamedItem("backcolor") != null)
3303                    plot.setBackcolor( decodeColor( ""+nodeAttributes.getNamedItem("backcolor").getNodeValue()) );
3304
3305                if (nodeAttributes.getNamedItem("orientation") != null)
3306                    plot.setOrientation(""+nodeAttributes.getNamedItem("orientation").getNodeValue());
3307
3308                if (nodeAttributes.getNamedItem("backgroundAlpha") != null)
3309                    plot.setBackgroundAlpha( Double.parseDouble(nodeAttributes.getNamedItem("backgroundAlpha").getNodeValue()) );
3310
3311                if (nodeAttributes.getNamedItem("foregroundAlpha") != null)
3312                    plot.setForegroundAlpha( Double.parseDouble(nodeAttributes.getNamedItem("foregroundAlpha").getNodeValue()) );
3313
3314                if (nodeAttributes.getNamedItem("labelRotation") != null)
3315                    plot.setLabelRotation( Double.parseDouble(nodeAttributes.getNamedItem("labelRotation").getNodeValue()) );
3316
3317
3318                NodeList JavaDoc childsOfChildPlot = xmlNode.getChildNodes();
3319                for (int c_plot_count=0; c_plot_count< childsOfChildPlot.getLength(); c_plot_count++) {
3320                    Node JavaDoc child_child_plot = (Node JavaDoc)childsOfChildPlot.item(c_plot_count);
3321                    if (child_child_plot.getNodeType() == Node.ELEMENT_NODE && child_child_plot.getNodeName().equals("seriesColor")) {
3322
3323                        NamedNodeMap JavaDoc nodeAttributes2 = child_child_plot.getAttributes();
3324
3325                        java.awt.Color JavaDoc c = java.awt.Color.red;
3326                        int seriesOrder = 0;
3327
3328                        if (nodeAttributes2.getNamedItem("color") != null)
3329                            c = decodeColor( ""+nodeAttributes2.getNamedItem("color").getNodeValue() );
3330
3331                        if (nodeAttributes2.getNamedItem("seriesOrder") != null)
3332                        {
3333                            try {
3334                            seriesOrder = Integer.parseInt(""+nodeAttributes2.getNamedItem("seriesOrder").getNodeValue() );
3335                            } catch (Exception JavaDoc ex)
3336                            {
3337                            }
3338                        }
3339
3340                        SeriesColor sc = new SeriesColor();
3341                        sc.setSeriesOrder(seriesOrder);
3342                        sc.setColor( c );
3343
3344                        plot.getSeriesColors().add(sc);
3345                    }
3346              }
3347              // Sort seriescolor....
3348
Object JavaDoc[] objs = plot.getSeriesColors().toArray();
3349              java.util.Arrays.sort( objs );
3350              plot.getSeriesColors().clear();
3351              for (int i=0; i<objs.length; ++i)
3352              {
3353                  plot.getSeriesColors().add( objs[i] );
3354              }
3355           }
3356        }
3357    }
3358
3359    private void readChartSubTitleElement(Node JavaDoc xmlElement, ChartReportElement2 re) {
3360        NamedNodeMap JavaDoc nodeAttributes = xmlElement.getAttributes();
3361
3362        if (nodeAttributes.getNamedItem("color") != null)
3363            re.getChart().getSubTitle().setColor( decodeColor( ""+nodeAttributes.getNamedItem("color").getNodeValue()) );
3364
3365        NodeList JavaDoc childsOfChild = xmlElement.getChildNodes();
3366        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
3367            Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
3368            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("subtitleExpression")) {
3369                re.getChart().getSubTitle().setTitleExpression( readPCDATA(child_child) );
3370            }
3371            else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("font")) {
3372                 re.getChart().getSubTitle().setFont( readFontElement(child_child) );
3373            }
3374        }
3375    }
3376
3377    private void readXMLReportElement(Node JavaDoc xmlReportElement, ReportElement re) {
3378        NamedNodeMap JavaDoc nodeAttributes = xmlReportElement.getAttributes();
3379
3380        if (nodeAttributes.getNamedItem("style") != null)
3381        {
3382           String JavaDoc sname = nodeAttributes.getNamedItem("style").getNodeValue();
3383           for (int j=0; j<getReport().getStyles().size(); ++j)
3384           {
3385                Style sparent = (Style)getReport().getStyles().elementAt(j);
3386                if (sparent.getName().equals( sname))
3387                {
3388                    re.setStyle( sparent);
3389                    break;
3390                }
3391           }
3392        }
3393        //if ( bandAttributes.getNamedItem("height") != null) b.setHeight( Integer.parseInt(bandAttributes.getNamedItem("height").getNodeValue()) );
3394
if (nodeAttributes.getNamedItem("x") != null)
3395        {
3396            re.getPosition().x = Integer.parseInt(""+nodeAttributes.getNamedItem("x").getNodeValue());
3397            re.getRelativePosition().x = re.getPosition().x;
3398        }
3399        if (nodeAttributes.getNamedItem("y") != null)
3400        {
3401            re.getPosition().y = Integer.parseInt(""+nodeAttributes.getNamedItem("y").getNodeValue());
3402            re.getRelativePosition().y = re.getPosition().y;
3403        }
3404        if (nodeAttributes.getNamedItem("width") != null)
3405            re.setWidth( Integer.parseInt(""+nodeAttributes.getNamedItem("width").getNodeValue()) );
3406        if (nodeAttributes.getNamedItem("height") != null)
3407            re.setHeight( Integer.parseInt(""+nodeAttributes.getNamedItem("height").getNodeValue()) );
3408        if (nodeAttributes.getNamedItem("key") != null)
3409            re.setKey( ""+nodeAttributes.getNamedItem("key").getNodeValue() );
3410
3411        if (nodeAttributes.getNamedItem("stretchType") != null)
3412            re.setStretchType( ""+nodeAttributes.getNamedItem("stretchType").getNodeValue() );
3413
3414        if (nodeAttributes.getNamedItem("isPrintRepeatedValues") != null)
3415            re.setIsPrintRepeatedValues( (""+nodeAttributes.getNamedItem("isPrintRepeatedValues").getNodeValue()).equalsIgnoreCase("true") );
3416
3417        if (nodeAttributes.getNamedItem("positionType") != null)
3418            re.setPositionType( ""+nodeAttributes.getNamedItem("positionType").getNodeValue() );
3419        else
3420            re.setPositionType( "FixRelativeToTop" );
3421
3422        if (nodeAttributes.getNamedItem("isPrintRepeatedValues") != null)
3423            re.setIsPrintRepeatedValues( (""+nodeAttributes.getNamedItem("isPrintRepeatedValues").getNodeValue()).equalsIgnoreCase("true") );
3424
3425        if (nodeAttributes.getNamedItem("isRemoveLineWhenBlank") != null)
3426        {
3427            re.setIsRemoveLineWhenBlank( (""+nodeAttributes.getNamedItem("isRemoveLineWhenBlank").getNodeValue()).equalsIgnoreCase("true") ) ;
3428        }
3429
3430        if (nodeAttributes.getNamedItem("isPrintInFirstWholeBand") != null)
3431            re.setIsPrintInFirstWholeBand( (""+nodeAttributes.getNamedItem("isPrintInFirstWholeBand").getNodeValue()).equalsIgnoreCase("true") );
3432
3433        if (nodeAttributes.getNamedItem("isPrintWhenDetailOverflows") != null)
3434            re.setIsPrintWhenDetailOverflows( (""+nodeAttributes.getNamedItem("isPrintWhenDetailOverflows").getNodeValue()).equalsIgnoreCase("true") );
3435
3436        if (nodeAttributes.getNamedItem("printWhenGroupChanges") != null)
3437            re.setPrintWhenGroupChanges( ""+nodeAttributes.getNamedItem("printWhenGroupChanges").getNodeValue() );
3438
3439
3440        if (nodeAttributes.getNamedItem("forecolor") != null) {
3441            String JavaDoc color = ""+nodeAttributes.getNamedItem("forecolor").getNodeValue();
3442            re.setFgcolor(decodeColor(color) );
3443        }
3444        if (nodeAttributes.getNamedItem("backcolor") != null) {
3445            String JavaDoc color = ""+nodeAttributes.getNamedItem("backcolor").getNodeValue();
3446            re.setBgcolor(decodeColor(color) );
3447
3448        }
3449        if (nodeAttributes.getNamedItem("mode") != null) {
3450            re.setTransparent(""+nodeAttributes.getNamedItem("mode").getNodeValue());
3451        }
3452
3453        NodeList JavaDoc childsOfChild = xmlReportElement.getChildNodes();
3454        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
3455            Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
3456            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("printWhenExpression")) {
3457                re.setPrintWhenExpression( readPCDATA(child_child) );
3458            }
3459        }
3460    }
3461
3462     private void readBoxElement(Node JavaDoc xmlReportElement, BoxElement re) {
3463        NamedNodeMap JavaDoc nodeAttributes = xmlReportElement.getAttributes();
3464
3465        Box box = new Box();
3466        // ------- defaults --------
3467
if (nodeAttributes.getNamedItem("border") != null)
3468        {
3469            box.setBorder(""+nodeAttributes.getNamedItem("border").getNodeValue() );
3470            box.setLeftBorder(""+nodeAttributes.getNamedItem("border").getNodeValue() );
3471            box.setRightBorder(""+nodeAttributes.getNamedItem("border").getNodeValue() );
3472            box.setTopBorder(""+nodeAttributes.getNamedItem("border").getNodeValue() );
3473            box.setBottomBorder(""+nodeAttributes.getNamedItem("border").getNodeValue() );
3474        }
3475
3476        if (nodeAttributes.getNamedItem("padding") != null)
3477        {
3478            box.setPadding(Integer.parseInt(""+nodeAttributes.getNamedItem("padding").getNodeValue() ));
3479            box.setLeftPadding(Integer.parseInt(""+nodeAttributes.getNamedItem("padding").getNodeValue() ));
3480            box.setRightPadding(Integer.parseInt(""+nodeAttributes.getNamedItem("padding").getNodeValue() ));
3481            box.setTopPadding(Integer.parseInt(""+nodeAttributes.getNamedItem("padding").getNodeValue() ));
3482            box.setBottomPadding(Integer.parseInt(""+nodeAttributes.getNamedItem("padding").getNodeValue() ));
3483        }
3484
3485        if (nodeAttributes.getNamedItem("borderColor") != null)
3486        {
3487            String JavaDoc color = ""+nodeAttributes.getNamedItem("borderColor").getNodeValue();
3488            java.awt.Color JavaDoc colorObj = decodeColor(color);
3489
3490            box.setBorderColor(new java.awt.Color JavaDoc(colorObj.getRGB()));
3491            box.setLeftBorderColor(new java.awt.Color JavaDoc(colorObj.getRGB()));
3492            box.setRightBorderColor(new java.awt.Color JavaDoc(colorObj.getRGB()));
3493            box.setTopBorderColor(new java.awt.Color JavaDoc(colorObj.getRGB()));
3494            box.setBottomBorderColor(new java.awt.Color JavaDoc(colorObj.getRGB()));
3495
3496        }
3497        // ------- top --------
3498
if (nodeAttributes.getNamedItem("topBorder") != null)
3499        {
3500            box.setTopBorder(""+nodeAttributes.getNamedItem("topBorder").getNodeValue() );
3501        }
3502
3503         if (nodeAttributes.getNamedItem("topPadding") != null)
3504        {
3505            box.setTopPadding(Integer.parseInt(""+nodeAttributes.getNamedItem("topPadding").getNodeValue() ));
3506        }
3507
3508        if (nodeAttributes.getNamedItem("topBorderColor") != null)
3509        {
3510            String JavaDoc color = ""+nodeAttributes.getNamedItem("topBorderColor").getNodeValue();
3511            box.setTopBorderColor(decodeColor(color));
3512        }
3513
3514        // ------- left --------
3515
if (nodeAttributes.getNamedItem("leftBorder") != null)
3516        {
3517            box.setLeftBorder(""+nodeAttributes.getNamedItem("leftBorder").getNodeValue() );
3518        }
3519
3520         if (nodeAttributes.getNamedItem("leftPadding") != null)
3521        {
3522            box.setLeftPadding(Integer.parseInt(""+nodeAttributes.getNamedItem("leftPadding").getNodeValue() ));
3523        }
3524
3525        if (nodeAttributes.getNamedItem("leftBorderColor") != null)
3526        {
3527            String JavaDoc color = ""+nodeAttributes.getNamedItem("leftBorderColor").getNodeValue();
3528            box.setLeftBorderColor(decodeColor(color));
3529        }
3530
3531        // ------- right --------
3532
if (nodeAttributes.getNamedItem("rightBorder") != null)
3533        {
3534            box.setRightBorder(""+nodeAttributes.getNamedItem("rightBorder").getNodeValue() );
3535        }
3536
3537         if (nodeAttributes.getNamedItem("rightPadding") != null)
3538        {
3539            box.setRightPadding(Integer.parseInt(""+nodeAttributes.getNamedItem("rightPadding").getNodeValue() ));
3540        }
3541
3542        if (nodeAttributes.getNamedItem("rightBorderColor") != null)
3543        {
3544            String JavaDoc color = ""+nodeAttributes.getNamedItem("rightBorderColor").getNodeValue();
3545            box.setRightBorderColor(decodeColor(color));
3546        }
3547
3548        // ------- bottom --------
3549
if (nodeAttributes.getNamedItem("bottomBorder") != null)
3550        {
3551            box.setBottomBorder(""+nodeAttributes.getNamedItem("bottomBorder").getNodeValue() );
3552        }
3553
3554         if (nodeAttributes.getNamedItem("bottomPadding") != null)
3555        {
3556            box.setBottomPadding(Integer.parseInt(""+nodeAttributes.getNamedItem("bottomPadding").getNodeValue() ));
3557        }
3558
3559        if (nodeAttributes.getNamedItem("bottomBorderColor") != null)
3560        {
3561            String JavaDoc color = ""+nodeAttributes.getNamedItem("bottomBorderColor").getNodeValue();
3562            box.setBottomBorderColor(decodeColor(color));
3563        }
3564
3565        if (re instanceof BoxElement) ((BoxElement)re).setBox(box);
3566
3567    }
3568
3569
3570
3571
3572    static java.awt.Color JavaDoc decodeColor(String JavaDoc colorString)
3573    {
3574        java.awt.Color JavaDoc color = null;
3575        char firstChar = colorString.charAt(0);
3576        if (firstChar == '#')
3577        {
3578               color = new java.awt.Color JavaDoc(Integer.parseInt(colorString.substring(1), 16));
3579        }
3580        else if ('0' <= firstChar && firstChar <= '9')
3581        {
3582               color = new java.awt.Color JavaDoc(Integer.parseInt(colorString));
3583        }
3584        else
3585        {
3586                if (net.sf.jasperreports.engine.xml.JRXmlConstants.getColorMap().containsKey(colorString))
3587                {
3588                        color = (java.awt.Color JavaDoc)net.sf.jasperreports.engine.xml.JRXmlConstants.getColorMap().get(colorString);
3589                }
3590                else
3591                {
3592                        color = java.awt.Color.black;
3593                }
3594        }
3595        return color;
3596
3597    }
3598
3599
3600    static public String JavaDoc readPCDATA(Node JavaDoc textNode) {
3601        return readPCDATA(textNode,true);
3602    }
3603
3604    static public String JavaDoc readPCDATA(Node JavaDoc textNode, boolean trim) {
3605        NodeList JavaDoc list_child = textNode.getChildNodes();
3606        for (int ck=0; ck< list_child.getLength(); ck++) {
3607            Node JavaDoc child_child = (Node JavaDoc)list_child.item(ck);
3608
3609            // --- start solution: if there is another node this should be the PCDATA-node
3610
Node JavaDoc ns = child_child.getNextSibling();
3611            if (ns != null)
3612            child_child = ns;
3613            // --- end solution
3614

3615            final short nt = child_child.getNodeType();
3616            if ((nt == Node.CDATA_SECTION_NODE) || (nt == Node.TEXT_NODE)) {
3617               if (trim) return ((String JavaDoc)child_child.getNodeValue()).trim();
3618                return (String JavaDoc)child_child.getNodeValue();
3619            }
3620        }
3621        return "";
3622    }
3623
3624
3625    private void readXMLTextElement(Node JavaDoc xmlReportElement, TextReportElement re) {
3626        NamedNodeMap JavaDoc nodeAttributes = xmlReportElement.getAttributes();
3627        if (nodeAttributes.getNamedItem("textAlignment") != null)
3628            re.setAlign(""+nodeAttributes.getNamedItem("textAlignment").getNodeValue());
3629
3630        if (nodeAttributes.getNamedItem("verticalAlignment") != null)
3631            re.setVerticalAlign(""+nodeAttributes.getNamedItem("verticalAlignment").getNodeValue());
3632
3633        if (nodeAttributes.getNamedItem("lineSpacing") != null)
3634            re.setLineSpacing( ""+nodeAttributes.getNamedItem("lineSpacing").getNodeValue());
3635
3636        if (nodeAttributes.getNamedItem("rotation") != null)
3637            re.setRotate(""+nodeAttributes.getNamedItem("rotation").getNodeValue());
3638
3639        if (nodeAttributes.getNamedItem("isStyledText") != null)
3640            re.setIsStyledText( (""+nodeAttributes.getNamedItem("isStyledText").getNodeValue()).equals("true") );
3641
3642
3643        // Check for Font sub_element...
3644
NodeList JavaDoc childsOfChild = xmlReportElement.getChildNodes();
3645        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
3646            Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
3647            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("font")) {
3648                NamedNodeMap JavaDoc subNodeAttributes = child_child.getAttributes();
3649                if (subNodeAttributes.getNamedItem("reportFont") != null) {
3650
3651                    IReportFont baseFont = null;
3652                    re.setReportFont(subNodeAttributes.getNamedItem("reportFont").getNodeValue());
3653                    for (int fn =0; fn < getReport().getFonts().size(); ++fn) {
3654                        baseFont = (IReportFont)getReport().getFonts().elementAt(fn);
3655                        if (baseFont != null && baseFont.getReportFont().equals(re.getReportFont())) {
3656                            break;
3657                        }
3658                        else
3659                            baseFont = null;
3660                    }
3661                    if (baseFont != null) {
3662                        //re.setFontSize(baseFont.getFontSize());
3663
//re.setFontName(baseFont.getFontName());
3664
//re.setPDFFontName( baseFont.getPDFFontName());
3665
//re.setPdfEncoding( baseFont.getPdfEncoding());
3666
//re.setPdfEmbedded( baseFont.isPdfEmbedded());
3667
//re.setBold(baseFont.isBold()) ;
3668
//re.setItalic( baseFont.isItalic());
3669
//re.setStrikeTrought(baseFont.isStrikeTrought());
3670
//re.setUnderline(baseFont.isUnderline());
3671
}else{
3672
3673                        //using default font
3674
//re.setFontSize(defaultFont.getFontSize());
3675
//re.setFontName(defaultFont.getFontName());
3676
//re.setPDFFontName( defaultFont.getPDFFontName());
3677
//re.setPdfEncoding( defaultFont.getPdfEncoding());
3678
//re.setPdfEmbedded( defaultFont.isPdfEmbedded());
3679
//re.setBold(defaultFont.isBold()) ;
3680
//re.setItalic(defaultFont.isItalic());
3681
//re.setStrikeTrought(defaultFont.isStrikeTrought());
3682
//re.setUnderline(defaultFont.isUnderline());
3683
}
3684
3685                }
3686
3687                //System.out.println("Working on: " + xmlReportElement);
3688
for (int kkk=0; kkk<subNodeAttributes.getLength(); ++kkk)
3689                {
3690                    //System.out.println( + " " + );
3691

3692                    String JavaDoc propName = subNodeAttributes.item(kkk).getNodeName();
3693                    String JavaDoc propValue = subNodeAttributes.item(kkk).getNodeValue();
3694                    if (propName != null && propValue != null)
3695                    {
3696                        if (propName.equals("fontName"))
3697                            re.setFontName(propValue);
3698                        else if (propName.equals("pdfFontName"))
3699                            re.setPDFFontName(propValue);
3700                        else if (propName.equals("size"))
3701                            re.setFontSize( Integer.parseInt(""+propValue) );
3702                        else if (propName.equals("isBold"))
3703                            re.setBold( (new String JavaDoc(""+propValue)).equalsIgnoreCase("true") );
3704                        else if (propName.equals("isItalic"))
3705                            re.setItalic( (new String JavaDoc(""+propValue)).equalsIgnoreCase("true") );
3706                        else if (propName.equals("isUnderline"))
3707                            re.setUnderline( (new String JavaDoc(""+propValue)).equalsIgnoreCase("true") );
3708                        else if (propName.equals("isStrikeThrough"))
3709                            re.setStrikeTrought( (new String JavaDoc(""+propValue)).equalsIgnoreCase("true") );
3710                        else if (propName.equals("isPdfEmbedded"))
3711                            re.setPdfEmbedded((new String JavaDoc(""+propValue)).equalsIgnoreCase("true") );
3712                        else if (propName.equals("pdfEncoding"))
3713                            re.setPdfEncoding( ""+propValue );
3714                    }
3715                }
3716                re.setFont(null);
3717            }
3718        }
3719    }
3720
3721    private Node JavaDoc findNextNode(Node JavaDoc node) {
3722        int type = node.getNodeType();
3723        if (type == Node.ELEMENT_NODE){
3724            return node;
3725        }
3726        NodeList JavaDoc children = node.getChildNodes();
3727        if (children != null) {
3728            for (int i=0; i< children.getLength(); i++) {
3729                return findNextNode (children.item(i));
3730            }
3731        }
3732        return null;
3733    }
3734
3735
3736    /**
3737     * Find a node named childName inside parent
3738     *
3739     */

3740    private Node JavaDoc findChild(Node JavaDoc parent, String JavaDoc childName) {
3741
3742        if (parent == null) return null;
3743
3744        NodeList JavaDoc children = parent.getChildNodes();
3745
3746        if (children != null) {
3747            for (int i=0; i< children.getLength(); i++) {
3748
3749                Node JavaDoc node = (Node JavaDoc)children.item(i);
3750                if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals(childName)){
3751                    return node;
3752                }
3753            }
3754            Node JavaDoc foundNode = null;
3755            for (int i=0; foundNode == null && i< children.getLength(); i++) {
3756
3757                Node JavaDoc node = (Node JavaDoc)children.item(i);
3758                if (node.getNodeType() == Node.ELEMENT_NODE){
3759                    foundNode = findChild( node, childName);
3760                }
3761            }
3762            return foundNode;
3763        }
3764        return null;
3765    }
3766
3767    private void readChartReportElement(Node JavaDoc child, ChartReportElement2 re) {
3768
3769                if ( child.getNodeName().equals("pieChart") ) { re.setChart( new it.businesslogic.ireport.chart.PieChart()); }
3770                else if ( child.getNodeName().equals("pie3DChart") ) { re.setChart( new it.businesslogic.ireport.chart.Pie3DChart()); }
3771                else if ( child.getNodeName().equals("barChart") ) { re.setChart( new it.businesslogic.ireport.chart.BarChart()); }
3772                else if ( child.getNodeName().equals("bar3DChart") ) { re.setChart( new it.businesslogic.ireport.chart.Bar3DChart()); }
3773                else if ( child.getNodeName().equals("xyBarChart") ) { re.setChart( new it.businesslogic.ireport.chart.XYBarChart()); }
3774                else if ( child.getNodeName().equals("stackedBarChart") ) { re.setChart( new it.businesslogic.ireport.chart.StackedBarChart()); }
3775                else if ( child.getNodeName().equals("stackedBar3DChart") ) { re.setChart( new it.businesslogic.ireport.chart.StackedBar3DChart()); }
3776                else if ( child.getNodeName().equals("lineChart") ) { re.setChart( new it.businesslogic.ireport.chart.LineChart()); }
3777                else if ( child.getNodeName().equals("xyLineChart") ) { re.setChart( new it.businesslogic.ireport.chart.XYLineChart()); }
3778                else if ( child.getNodeName().equals("areaChart") ) { re.setChart( new it.businesslogic.ireport.chart.AreaChart()); }
3779                else if ( child.getNodeName().equals("xyAreaChart") ) { re.setChart( new it.businesslogic.ireport.chart.XYAreaChart()); }
3780                else if ( child.getNodeName().equals("scatterChart") ) { re.setChart( new it.businesslogic.ireport.chart.ScatterChart()); }
3781                else if ( child.getNodeName().equals("bubbleChart") ) { re.setChart( new it.businesslogic.ireport.chart.BubbleChart()); }
3782                else if ( child.getNodeName().equals("timeSeriesChart") ) { re.setChart( new it.businesslogic.ireport.chart.TimeSeriesChart()); }
3783                else if ( child.getNodeName().equals("highLowChart") ) { re.setChart( new it.businesslogic.ireport.chart.HighLowChart()); }
3784                else if ( child.getNodeName().equals("candlestickChart") ) { re.setChart( new it.businesslogic.ireport.chart.CandlestickChart()); }
3785                else if ( child.getNodeName().equals("meterChart") ) { re.setChart( new it.businesslogic.ireport.chart.MeterChart()); }
3786                else if ( child.getNodeName().equals("thermometerChart") ) { re.setChart( new it.businesslogic.ireport.chart.ThermometerChart()); }
3787                else if ( child.getNodeName().equals("multiAxisChart") ) { re.setChart( new it.businesslogic.ireport.chart.MultiAxisChart()); }
3788
3789                // Element properties...
3790
NodeList JavaDoc childsOfChild = child.getChildNodes();
3791                for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
3792                    Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
3793                    NamedNodeMap JavaDoc subNodeAttributes = child_child.getAttributes();
3794                    if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("chart")) {
3795                        readChartElement(child_child,re);
3796                    }
3797                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("pieDataset")) {
3798                        readPieDataset(child_child,re);
3799                    }
3800                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("categoryDataset")) {
3801                        readCategoryDataset(child_child,re);
3802                    }
3803                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("timePeriodDataset")) {
3804                        readTimePeriodDataset(child_child,re);
3805                    }
3806                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("timeSeriesDataset")) {
3807                        readTimeSeriesDataset(child_child,re);
3808                    }
3809                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("xyDataset")) {
3810                        readXYDataset(child_child,re);
3811                    }
3812                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("xyzDataset")) {
3813                        readXYZDataset(child_child,re);
3814                    }
3815                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("highLowDataset")) {
3816                        readHighLowDataset(child_child,re);
3817                    }
3818                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("valueDataset")) {
3819                        readValueDataset(child_child,re);
3820                    }
3821                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("piePlot")) {
3822                        readPiePlot(child_child, (PiePlot)re.getChart().getPlot());
3823                    }
3824                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("pie3DPlot")) {
3825                        readPie3DPlot(child_child, (Pie3DPlot)re.getChart().getPlot());
3826                    }
3827                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("barPlot")) {
3828                        readBarPlot(child_child, (BarPlot)re.getChart().getPlot());
3829                    }
3830                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("bar3DPlot")) {
3831                        readBar3DPlot(child_child, (Bar3DPlot)re.getChart().getPlot());
3832                    }
3833                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("linePlot")) {
3834                        readLinePlot(child_child, (LinePlot)re.getChart().getPlot());
3835                    }
3836                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("areaPlot")) {
3837                        readAreaPlot(child_child, (AreaPlot)re.getChart().getPlot());
3838                    }
3839                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("scatterPlot")) {
3840                        readScatterPlot(child_child, (ScatterPlot)re.getChart().getPlot());
3841                    }
3842                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("bubblePlot")) {
3843                        readBubblePlot(child_child, (BubblePlot)re.getChart().getPlot());
3844                    }
3845                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("timeSeriesPlot")) {
3846                        readTimeSeriesPlot(child_child, (TimeSeriesPlot)re.getChart().getPlot());
3847                    }
3848                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("highLowPlot")) {
3849                        readHighLowPlot(child_child, (HighLowPlot)re.getChart().getPlot());
3850                    }
3851                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("candlestickPlot")) {
3852                        readCandlestickPlot(child_child, (CandlestickPlot)re.getChart().getPlot());
3853                    }
3854                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("meterPlot")) {
3855                        readMeterPlot(child_child, (MeterPlot)re.getChart().getPlot());
3856                    }
3857                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("thermometerPlot")) {
3858                        readThermometerPlot(child_child, (ThermometerPlot)re.getChart().getPlot());
3859                    }
3860                    else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("multiAxisPlot")) {
3861                        readMultiAxisPlot(child_child, (MultiAxisPlot)re.getChart().getPlot());
3862                    }
3863                }
3864    }
3865
3866    private void readMultiAxisPlot(Node JavaDoc xmlNode, MultiAxisPlot plot) {
3867
3868        NamedNodeMap JavaDoc nodeAttributes = xmlNode.getAttributes();
3869
3870        readPlot(xmlNode, plot);
3871
3872
3873        NodeList JavaDoc childsOfChild = xmlNode.getChildNodes();
3874        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
3875            Node JavaDoc child_child = (Node JavaDoc)childsOfChild.item(c_count);
3876            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("axis")) {
3877                plot.getAxis().add( readAxis(child_child) );
3878            }
3879        }
3880    }
3881
3882    private Axis readAxis(Node JavaDoc xmlNode) {
3883
3884        Axis axis = new Axis();
3885
3886        NamedNodeMap JavaDoc nodeAttributes = xmlNode.getAttributes();
3887
3888        if (nodeAttributes.getNamedItem("position") != null)
3889                axis.setPosition( ""+nodeAttributes.getNamedItem("position").getNodeValue() );
3890
3891        NodeList JavaDoc childsOfChild = xmlNode.getChildNodes();
3892        for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) {
3893            Node JavaDoc child = (Node JavaDoc)childsOfChild.item(c_count);
3894            if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("pieChart") ||
3895                     child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("pie3DChart") ||
3896                     child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("barChart") ||
3897                     child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("bar3DChart") ||
3898                     child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("xyBarChart") ||
3899                     child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("stackedBarChart") ||
3900                     child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("stackedBar3DChart") ||
3901                     child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("lineChart") ||
3902                     child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("xyLineChart") ||
3903                     child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("areaChart") ||
3904                     child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("xyAreaChart") ||
3905                     child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("scatterChart") ||
3906                     child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("bubbleChart") ||
3907                     child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("timeSeriesChart") ||
3908                     child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("highLowChart") ||
3909                     child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("candlestickChart") ||
3910                     child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("meterChart") ||
3911                     child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("thermometerChart") ||
3912                     child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("multiAxisChart")) {
3913                ChartReportElement2 re = new ChartReportElement2(0,0,0,0);
3914                readChartReportElement(child, re);
3915                axis.setChartReportElement(re);
3916            }
3917        }
3918
3919        return axis;
3920    }
3921
3922
3923}
3924
Popular Tags