1 33 34 package it.businesslogic.ireport; 35 36 import it.businesslogic.ireport.chart.SectionItemHyperlink; 38 import it.businesslogic.ireport.crosstab.CrosstabParameter; 39 import it.businesslogic.ireport.gui.event.ReportDocumentStatusChangedEvent; 40 import it.businesslogic.ireport.gui.event.ReportSubDatasetChangedEvent; 41 import it.businesslogic.ireport.chart.Axis; 42 import it.businesslogic.ireport.util.I18n; 43 import java.io.ByteArrayInputStream ; 44 import java.util.Vector ; 45 import java.util.Iterator ; 46 import java.util.Properties ; 47 import java.util.Enumeration ; 48 49 import it.businesslogic.ireport.util.Misc; 51 import it.businesslogic.ireport.util.PageSize; 52 import it.businesslogic.ireport.gui.JReportFrame; 53 import it.businesslogic.ireport.chart.*; 54 import it.businesslogic.ireport.crosstab.CrosstabCell; 55 import it.businesslogic.ireport.crosstab.CrosstabColumnGroup; 56 import it.businesslogic.ireport.crosstab.CrosstabGroup; 57 import it.businesslogic.ireport.crosstab.CrosstabRowGroup; 58 import it.businesslogic.ireport.crosstab.Measure; 59 import it.businesslogic.ireport.gui.event.StyleChangedEvent; 60 import it.businesslogic.ireport.gui.event.SubDatasetObjectChangedListener; 61 62 63 import org.apache.xerces.parsers.DOMParser; 64 65 import org.w3c.dom.Document ; 67 import org.w3c.dom.NamedNodeMap ; 68 import org.w3c.dom.Node ; 69 import org.w3c.dom.NodeList ; 70 71 import org.xml.sax.SAXException ; 72 73 import java.io.IOException ; 74 import java.io.File ; 75 import java.io.PrintWriter ; 76 77 81 public class ReportWriter { 82 83 private Report report = null; 84 85 public ReportWriter(Report report) 86 { 87 this.setReport(report); 88 } 89 90 public void saveXMLFile( String aFilename ) { 91 92 93 String scriptletFileName = getReport().getScriptletFileName(aFilename); 94 95 String className = ""; 96 java.io.File classFile = new java.io.File (scriptletFileName); 97 98 className = classFile.getName().substring(0, classFile.getName().length()-5); 99 100 if (getReport().getScriptletHandling() == getReport().SCRIPTLET_IREPORT_INTERNAL_HANDLING) { 101 getReport().setScriptletClass( className ); 102 } 103 104 for (int pk= 0; pk < getReport().getJRproperties().size(); ++pk) { 105 JRProperty prop = (JRProperty)getReport().getJRproperties().elementAt( pk ); 106 if (prop.getName().equals("ireport.scriptlethandling") || 107 prop.getName().equals("ireport.encoding")) { 108 getReport().getJRproperties().remove( prop ); 109 pk--; 110 } 111 } 112 113 JRProperty prop = new JRProperty(); 114 prop.setName( "ireport.scriptlethandling" ); 115 prop.setValue( ""+ getReport().getScriptletHandling() ); 116 getReport().getJRproperties().add( prop ); 117 118 prop = new JRProperty(); 119 prop.setName( "ireport.encoding" ); 120 prop.setValue( ""+ getReport().getEncoding() ); 121 getReport().getJRproperties().add( prop ); 122 123 try { 124 125 String fileencoding = "UTF-8"; 127 if (getReport().getEncoding() != null && !getReport().getEncoding().trim().equals("")) { 128 fileencoding = getReport().getEncoding(); 129 if (fileencoding.equalsIgnoreCase("UTF-8")){ 130 fileencoding = "UTF8"; } 132 } else{ 133 getReport().setEncoding("UTF-8"); } 135 136 writeToOutputStream(new java.io.FileOutputStream ( aFilename ), fileencoding); 138 if (getReport().getScriptletHandling() == getReport().SCRIPTLET_IREPORT_INTERNAL_HANDLING) { 140 try { 141 142 String allcode = new String (getReport().getScripletCode().getAll() +""); 143 144 allcode = Misc.string_replace(className,"<ScriptletClassName>", allcode); 145 java.io.FileOutputStream fos = new java.io.FileOutputStream (scriptletFileName); 146 fos.write( allcode.getBytes() ); 147 fos.close(); 148 149 } catch (Exception ex) { 150 java.io.StringWriter s = new java.io.StringWriter (); 151 ex.printStackTrace(new java.io.PrintWriter (s)); 152 javax.swing.JOptionPane.showMessageDialog(getReport().getReportFrame().getMainFrame(),ex.getMessage()+" "+s,I18n.getString("message.title.exception","Exception"),javax.swing.JOptionPane.ERROR_MESSAGE); 153 } 154 } 155 156 if (aFilename != null) { 161 } 162 } catch (Exception ex) { 163 166 java.io.StringWriter s = new java.io.StringWriter (); 167 ex.printStackTrace(new java.io.PrintWriter (s)); 168 javax.swing.JOptionPane.showMessageDialog(getReport().getReportFrame().getMainFrame(),ex.getMessage()+" "+s,I18n.getString("message.title.exception","Exception"),javax.swing.JOptionPane.ERROR_MESSAGE); 169 } 170 } 171 172 182 public void writeToOutputStream(java.io.OutputStream outputStream) { 183 writeToOutputStream(outputStream, "UTF-8"); 184 } 185 186 196 public void writeToOutputStream(java.io.OutputStream outputStream, String fileencoding) { 197 try { 198 PrintWriter pw = new PrintWriter ( new java.io.OutputStreamWriter ( outputStream, fileencoding )); 202 pw.print("<?xml version=\"1.0\""); 203 if (getReport().getEncoding() != null && getReport().getEncoding().length()>0) { 204 pw.print(" encoding=\""+ getReport().getEncoding() +"\" "); 205 } 206 pw.println(" ?>"); 207 pw.println("<!-- Created with iReport - A designer for JasperReports -->"); 208 pw.println("<!DOCTYPE jasperReport PUBLIC \"//JasperReports//DTD Report Design//EN\" \"http://jasperreports.sourceforge.net/dtds/jasperreport.dtd\">"); 209 pw.println("<jasperReport"); 212 pw.println("\t\t name=\""+ getReport().getName() +"\""); 213 214 if ( CompatibilitySupport.version >= CompatibilitySupport.JR066 && getReport().getLanguage() != null && 215 !getReport().getLanguage().trim().equals("") && !getReport().getLanguage().equals("java") ) 216 { 217 pw.print("\n\t\t language=\"" + getReport().getLanguage().trim() + "\""); 218 } 219 220 pw.println("\t\t columnCount=\""+ getReport().getColumnCount() +"\""); 221 pw.println("\t\t printOrder=\""+ getReport().getPrintOrder() +"\""); 222 pw.println("\t\t orientation=\""+ getReport().getOrientation() +"\""); 223 pw.println("\t\t pageWidth=\""+ getReport().getWidth() +"\""); 224 pw.println("\t\t pageHeight=\""+ getReport().getHeight() +"\""); 225 pw.println("\t\t columnWidth=\""+ getReport().getColumnWidth() +"\""); 226 pw.println("\t\t columnSpacing=\""+ getReport().getColumnSpacing() +"\""); 227 pw.println("\t\t leftMargin=\""+ getReport().getLeftMargin() +"\""); 228 pw.println("\t\t rightMargin=\""+ getReport().getRightMargin() +"\""); 229 pw.println("\t\t topMargin=\""+ getReport().getTopMargin() +"\""); 230 pw.println("\t\t bottomMargin=\""+ getReport().getBottomMargin() +"\""); 231 pw.println("\t\t whenNoDataType=\""+ getReport().getWhenNoDataType() +"\""); 232 233 if ( CompatibilitySupport.version >= CompatibilitySupport.JR063 && getReport().isFloatColumnFooter() ) 234 { 235 pw.println("\t\t isFloatColumnFooter=\"true\""); 236 } 237 238 if (getReport().getScriptletClass() != null && getReport().getScriptletClass().length()>0){ 239 pw.println("\t\t scriptletClass=\""+ getReport().getScriptletClass() +"\""); 240 } 241 242 pw.println("\t\t isTitleNewPage=\""+ getReport().isIsTitleNewPage() +"\""); 243 pw.print("\t\t isSummaryNewPage=\""+ getReport().isIsSummaryNewPage() +"\""); 244 if ( CompatibilitySupport.version >= CompatibilitySupport.JR062 && getReport().getResourceBundleBaseName()!=null 245 && !getReport().getResourceBundleBaseName().trim().equals("")) 246 { 247 pw.print("\n\t\t resourceBundle=\"" + getReport().getResourceBundleBaseName().trim() + "\""); 248 } 249 250 if ( CompatibilitySupport.version >= CompatibilitySupport.JR100 && getReport().getWhenResourceMissingType()!=null 251 && !getReport().getWhenResourceMissingType().trim().equals("Null")) 252 { 253 pw.print("\n\t\t whenResourceMissingType=\"" + getReport().getWhenResourceMissingType().trim() + "\""); 254 } 255 256 if ( CompatibilitySupport.version >= CompatibilitySupport.JR111 && getReport().isIgnorePagination() ) 257 { 258 pw.print("\n\t\t isIgnorePagination=\"true\""); 259 } 260 261 if ( CompatibilitySupport.version >= CompatibilitySupport.JR128 && 262 getReport().getFormatFactoryClass() != null && 263 getReport().getFormatFactoryClass().trim().length() > 0) 264 { 265 pw.print("\n\t\t formatFactoryClass=\"" + 266 Misc.xmlEscape(getReport().getFormatFactoryClass().trim()) + "\""); 267 } 268 269 270 pw.println(">"); 271 272 Enumeration e = null; 274 275 e = getReport().getJRproperties().elements(); 276 while (e.hasMoreElements()) { 277 JRProperty property = (JRProperty)e.nextElement(); 278 if (!property.getName().startsWith("chart.")) 279 { 280 pw.print("\t<property name=\""+ Misc.xmlEscape(property.getName()) + "\" "); 281 pw.println("value=\""+ Misc.xmlEscape(property.getValue()) + "\" />"); 282 } 283 284 } 285 Enumeration enum_chartElements = getReport().getElements().elements(); 287 while (enum_chartElements.hasMoreElements()) 288 { 289 ReportElement re = (ReportElement)enum_chartElements.nextElement(); 290 if (re instanceof ChartReportElement) 291 { 292 Properties props = ((ChartReportElement)re).getProps(); 293 String name = re.getName(); 294 295 Iterator keys = props.keySet().iterator(); 296 int i=0; 297 while (keys.hasNext()) 298 { 299 String key = ""+keys.next(); 300 String val = props.getProperty(key); 301 pw.print("\t<property name=\""+ "chart." + name + "."+key + "\" "); 302 pw.println("value=\""+ Misc.xmlEscape( val) + "\" />"); 303 } 304 } 305 } 306 307 if ( CompatibilitySupport.version >= CompatibilitySupport.JR062 ) 309 { 310 e = getReport().getImports().elements(); 311 while (e.hasMoreElements()) { 312 String _import = (String )e.nextElement(); 313 pw.print("\t<import "); 314 pw.println("value=\""+ _import + "\" />"); 315 } 316 } 317 318 e = getReport().getFonts().elements(); 319 320 while (e.hasMoreElements()) { 321 IReportFont font = (IReportFont)e.nextElement(); 322 pw.print("\t<reportFont name=\""+ font.getReportFont() + "\" "); 323 pw.print("isDefault=\""+ font.isDefaultFont() + "\" "); 324 pw.print("fontName=\""+ font.getFontName() + "\" "); 325 pw.print("size=\""+ font.getFontSize() + "\" "); 326 pw.print("isBold=\""+ font.isBold() + "\" "); 327 pw.print("isItalic=\""+ font.isItalic() + "\" "); 328 pw.print("isUnderline=\""+ font.isUnderline() + "\" "); 329 pw.print("isStrikeThrough=\""+ font.isStrikeTrought() + "\" "); 330 if (Misc.nvl(font.getPDFFontName(), "").indexOf("TTF") > 0) 331 pw.print("pdfFontName=\""+ font.getTTFFont() + "\" "); 334 else 335 pw.print("pdfFontName=\""+ font.getPDFFontName() + "\" "); 336 pw.print("pdfEncoding=\""+ font.getPdfEncoding() + "\" "); 337 pw.println("isPdfEmbedded=\""+ font.isPdfEmbedded() + "\"/>"); 338 } 339 340 if ( CompatibilitySupport.version >= CompatibilitySupport.JR111 ) 342 { 343 writeXMLStyles(getReport().getStyles(), pw, "\t"); 344 } 345 346 if ( CompatibilitySupport.version >= CompatibilitySupport.JR110) 348 { 349 writeXMLSubDatasets(getReport().getSubDatasets(), pw, "\t"); 350 } 351 352 writeXMLParameters(getReport().getParameters(), pw, "\t"); 354 355 if (getReport().getQuery() != null && getReport().getQuery().trim().length() >0 ) { 357 358 pw.print("\t<queryString"); 359 360 if ( CompatibilitySupport.version >= CompatibilitySupport.JR120 && 361 !getReport().getQueryLanguage().equals("sql")) 362 { 363 pw.print(" language=\"" + getReport().getQueryLanguage() + "\""); 364 } 365 pw.println(">"+ getCDATAString(getReport().getQuery(),1) + "</queryString>"); 366 } 367 368 writeXMLFields(getReport().getFields(), pw, "\t"); 370 371 372 if ( CompatibilitySupport.version >= CompatibilitySupport.JR128) 373 { 374 writeXMLSortFields(getReport().getSortFields(), pw, "\t"); 375 } 376 377 writeXMLVariables(getReport().getVariables(), pw, "\t"); 379 380 if ( CompatibilitySupport.version >= CompatibilitySupport.JR125 && 381 getReport().getFilterExpression() != null && 382 getReport().getFilterExpression().trim().length() >0 ) { 383 384 pw.println("\t<filterExpression>"+ getCDATAString(getReport().getFilterExpression(),1) + "</filterExpression>"); 385 } 386 387 writeXMLGroups(getReport().getGroups(), pw,true,2); 389 390 { 392 writeXMLSection("background", pw); 393 } 394 395 writeXMLSection("title", pw); 396 writeXMLSection("pageHeader", pw); 397 writeXMLSection("columnHeader", pw); 398 writeXMLSection("detail", pw); 399 writeXMLSection("columnFooter", pw); 400 writeXMLSection("pageFooter", pw); 401 if ( CompatibilitySupport.version >= CompatibilitySupport.JR061 ) 402 { 403 writeXMLSection("lastPageFooter", pw); 404 } 405 writeXMLSection("summary", pw); 406 407 pw.println("</jasperReport>"); 408 pw.close(); 409 410 } catch (Exception ex) { 411 414 java.io.StringWriter s = new java.io.StringWriter (); 415 ex.printStackTrace(new java.io.PrintWriter (s)); 416 javax.swing.JOptionPane.showMessageDialog(getReport().getReportFrame().getMainFrame(),ex.getMessage()+" "+s,I18n.getString("message.title.exception","Exception"),javax.swing.JOptionPane.ERROR_MESSAGE); 417 } 418 getReport().setLoadTime( Misc.getLastWriteTime( getReport().getFilename() )); 420 421 getReport().setReportChanges(0); 422 } 423 424 void writeXMLSection(String section, PrintWriter pw) { 425 Band band = null; 427 428 for (Iterator i = getReport().getBands().iterator(); i.hasNext(); ) { 429 band = (Band) i.next(); 430 if (band.getName().equalsIgnoreCase(section)) { 431 break; 432 } 433 } 434 if (band == null) { 435 return; 436 } 437 438 if (section.equals("lastPageFooter") 439 && band.getHeight() == 0) return; 440 441 pw.println("\t\t<"+ section +">"); 442 writeXMLBand(band, pw); 443 pw.println("\t\t</"+ section +">"); 444 } 445 446 void writeXMLSubDatasets(Vector subDatasets, PrintWriter pw, String tabs) { 447 Enumeration e = subDatasets.elements(); 448 449 while (e.hasMoreElements()) { 450 451 pw.println(""); 452 453 it.businesslogic.ireport.SubDataset subDataset = (it.businesslogic.ireport.SubDataset)e.nextElement(); 454 455 pw.print(tabs + "<subDataset name=\""+ subDataset.getName() +"\" "); 456 if (subDataset.getScriptletClass() != null && subDataset.getScriptletClass().length()>0){ 457 pw.println( tabs + "\t scriptletClass=\""+ subDataset.getScriptletClass() +"\""); 458 } 459 460 if (subDataset.getResourceBundleBaseName()!=null && !subDataset.getResourceBundleBaseName().trim().equals("")) 461 { 462 pw.print("\n" + tabs +"\t resourceBundle=\"" + getReport().getResourceBundleBaseName().trim() + "\""); 463 } 464 465 if ( subDataset.getWhenResourceMissingType()!=null && !subDataset.getWhenResourceMissingType().trim().equals("Null")) 466 { 467 pw.print("\n" + tabs + "\t whenResourceMissingType=\"" + getReport().getWhenResourceMissingType().trim() + "\""); 468 } 469 pw.println(">"); 470 471 if ( CompatibilitySupport.version >= CompatibilitySupport.JR120 ) 472 { 473 Enumeration eProperties = subDataset.getJRproperties().elements(); 475 while (eProperties.hasMoreElements()) { 476 JRProperty property = (JRProperty)eProperties.nextElement(); 477 pw.print(tabs + "\t<property name=\""+ Misc.xmlEscape(property.getName()) + "\" "); 478 pw.println("value=\""+ Misc.xmlEscape(property.getValue()) + "\" />"); 479 } 480 } 481 482 writeXMLParameters(subDataset.getParameters(), pw, "\t\t"); 484 485 if (subDataset.getQuery() != null && subDataset.getQuery().trim().length() >0 ) { 487 pw.print(tabs+ "\t<queryString"); 488 489 if ( CompatibilitySupport.version >= CompatibilitySupport.JR120 && 490 !subDataset.getQueryLanguage().equals("sql")) 491 { 492 pw.print(" language=\"" + subDataset.getQueryLanguage() + "\""); 493 } 494 pw.println(">"+ getCDATAString(subDataset.getQuery(),1) + "</queryString>"); 495 } 496 497 499 if ( CompatibilitySupport.version >= CompatibilitySupport.JR110) 500 { 501 writeXMLFields(subDataset.getFields(), pw, "\t\t"); 502 } 503 504 writeXMLSortFields(subDataset.getSortFields(), pw, "\t\t"); 505 writeXMLVariables(subDataset.getVariables(), pw, "\t\t"); 507 508 509 if ( CompatibilitySupport.version >= CompatibilitySupport.JR125 && 510 subDataset.getFilterExpression() != null && 511 subDataset.getFilterExpression().trim().length() >0 ) { 512 513 pw.println("\t\t<filterExpression>"+ getCDATAString(subDataset.getFilterExpression(),2) + "</filterExpression>"); 514 } 515 516 writeXMLGroups(subDataset.getGroups(), pw,false,2); 518 pw.println(tabs + "</subDataset>"); 519 } 520 } 521 522 void writeXMLParameters(Vector parameters, PrintWriter pw, String tabs) { 523 Enumeration e = parameters.elements(); 524 if (parameters.size() > 0) pw.println(""); 525 while (e.hasMoreElements()) { 526 it.businesslogic.ireport.JRParameter p = (it.businesslogic.ireport.JRParameter)e.nextElement(); 527 if (p.isBuiltin()) continue; 528 529 pw.print(tabs + "<parameter name=\""+ p.getName() +"\" "); 530 if (p.getClassType() == null ) p.setClassType("java.lang.String"); 531 pw.print("isForPrompting=\""+ p.isIsForPrompting() +"\" "); 532 pw.print("class=\""+ p.getClassType() +"\""); 533 534 if (p.getDefaultValueExpression().trim().length()> 0 || 535 p.getDescription().trim().length()>0) { 536 pw.println(">"); 537 if (p.getDescription().trim().length()> 0) 538 pw.println(tabs + "\t<parameterDescription>"+ getCDATAString(p.getDescription(),2) +"</parameterDescription>"); 539 if (p.getDefaultValueExpression().trim().length()> 0) { 540 pw.print(tabs + "\t<defaultValueExpression "); 541 546 pw.println(">" + getCDATAString(p.getDefaultValueExpression(),2 ) +"</defaultValueExpression>"); 547 } 548 pw.println(tabs + "</parameter>"); 549 } 550 else 551 pw.println("/>"); 552 553 } 554 555 557 } 558 559 void writeXMLFields(Vector fields, PrintWriter pw, String tabs) 560 { 561 Enumeration e = fields.elements(); 562 if (fields.size() > 0) pw.println(""); 563 while (e.hasMoreElements()) { 564 it.businesslogic.ireport.JRField f = (it.businesslogic.ireport.JRField)e.nextElement(); 565 pw.print(tabs + "<field name=\""+ f.getName() +"\" "); 566 if (f.getClassType() == null ) f.setClassType("java.lang.String"); 567 pw.print("class=\""+ f.getClassType() +"\""); 568 569 if (f.getDescription() != null && f.getDescription().trim().length()>0) { 570 pw.println(">"); 571 if (f.getDescription().trim().length()> 0) 572 pw.println(tabs + "\t<fieldDescription>"+ getCDATAString(f.getDescription(),2) +"</fieldDescription>"); 573 pw.println(tabs + "</field>"); 574 } 575 else 576 pw.println("/>"); 577 } 578 } 579 580 void writeXMLSortFields(Vector fields, PrintWriter pw, String tabs) 581 { 582 Enumeration e = fields.elements(); 583 if (fields.size() > 0) pw.println(""); 584 while (e.hasMoreElements()) { 585 SortField f = (SortField)e.nextElement(); 586 pw.print(tabs + "<sortField name=\""+ Misc.xmlEscape( f.getFieldName() ) +"\" "); 587 if (f.isDesc()) 588 { 589 pw.print("order=\"Descending\" "); 590 } 591 pw.println("/>"); 592 } 593 } 594 595 void writeXMLVariables(Vector variables, PrintWriter pw, String tabs) 596 { 597 Enumeration e = variables.elements(); 598 if (variables.size() > 0) pw.println(""); 599 while (e.hasMoreElements()) { 600 it.businesslogic.ireport.JRVariable f = (it.businesslogic.ireport.JRVariable)e.nextElement(); 601 if (f.isBuiltin()) continue; 602 pw.print(tabs + "<variable name=\""+ f.getName() +"\" "); 603 if (f.getClassType() == null ) f.setClassType("java.lang.String"); 604 pw.print("class=\""+ f.getClassType() +"\" "); 605 pw.print("resetType=\""+ f.getResetType() +"\" "); 606 607 if (f.getIncrementerFactoryClass() != null && 609 f.getIncrementerFactoryClass().trim().length() > 0) { 610 pw.print("incrementerFactoryClass=\""+ f.getIncrementerFactoryClass() +"\" "); 611 } 612 613 if ( CompatibilitySupport.version >= CompatibilitySupport.JR066 && f.getIncrementType() !=null 614 && !f.getIncrementType().trim().equals("None")) 615 { 616 pw.print("incrementType=\"" + f.getIncrementType().trim() + "\" "); 617 if (f.getIncrementType().equals("Group")) 618 { 619 pw.print("incrementGroup=\"" + f.getIncrementGroup().trim() + "\" "); 620 } 621 } 622 623 if (f.getResetGroup().length() >0 ) pw.print("resetGroup=\""+ f.getResetGroup() +"\" "); 624 pw.println("calculation=\""+ f.getCalculation() +"\">"); 625 if (f.getExpression().length()>0) { 626 pw.print(tabs + "\t<variableExpression"); 627 632 pw.println(">"+ getCDATAString(f.getExpression(),2) + "</variableExpression>"); 633 } 634 if (f.getInitialValueExpression().length()>0) { 635 pw.print(tabs + "\t<initialValueExpression"); 636 641 pw.println(">"+getCDATAString(f.getInitialValueExpression(),2) +"</initialValueExpression>"); 642 } 643 pw.println(tabs + "</variable>"); 644 } 645 } 646 647 void writeXMLMeasures(Vector measures, PrintWriter pw, String tabs) 648 { 649 Enumeration e = measures.elements(); 650 if (measures.size() > 0) pw.println(""); 651 while (e.hasMoreElements()) { 652 it.businesslogic.ireport.crosstab.Measure f = (it.businesslogic.ireport.crosstab.Measure)e.nextElement(); 653 654 pw.print(tabs + "<measure name=\""+ f.getName() +"\""); 655 if (f.getClassType() == null ) f.setClassType("java.lang.String"); 656 pw.print(" class=\""+ f.getClassType() +"\""); 657 if (!f.getCalculation().equals("Nothing")) pw.print(" calculation=\""+ f.getCalculation() +"\""); 658 if (f.getIncrementerFactoryClass().trim().length() > 0) pw.print(" incrementerFactoryClass=\""+ f.getIncrementerFactoryClass() +"\""); 659 if (!f.getPercentageOf().equals("None")) pw.print(" percentageOf=\""+ f.getPercentageOf() +"\""); 660 if (f.getPercentageCalculatorClass().trim().length() > 0) pw.print(" percentageCalculatorClass=\""+ f.getPercentageCalculatorClass() +"\""); 661 pw.println(">"); 662 663 if (f.getExpression().length()>0) { 664 pw.print(tabs + "\t<measureExpression>"); 665 pw.println(getCDATAString(f.getExpression(),2) + "</measureExpression>"); 666 } 667 668 pw.println(tabs + "</measure>"); 669 } 670 } 671 672 void writeXMLCrosstabParameters(Vector parameters, PrintWriter pw, String tabs) 673 { 674 Enumeration e = parameters.elements(); 675 if (parameters.size() > 0) pw.println(""); 676 while (e.hasMoreElements()) { 677 it.businesslogic.ireport.crosstab.CrosstabParameter f = (it.businesslogic.ireport.crosstab.CrosstabParameter)e.nextElement(); 678 679 pw.print(tabs + "<crosstabParameter name=\""+ f.getName() +"\" "); 680 if (f.getClassType() == null ) f.setClassType("java.lang.String"); 681 pw.print("class=\""+ f.getClassType() +"\" "); 682 pw.print(">"); 683 684 if (f.getParameterValueExpression().length()>0) { 685 pw.print(tabs + "\t<parameterValueExpression>"); 686 pw.println(""+ getCDATAString(f.getParameterValueExpression(), tabs.length()+1 ) + "</parameterValueExpression>"); 687 } 688 689 pw.println(tabs + "</crosstabParameter>"); 690 } 691 } 692 693 void writeXMLHyperlinkParameters(java.util.List parameters, PrintWriter pw, String tabs) 694 { 695 Iterator e = parameters.iterator(); 696 if (parameters.size() > 0) pw.println(""); 697 while (e.hasNext()) { 698 it.businesslogic.ireport.JRLinkParameter f = (it.businesslogic.ireport.JRLinkParameter)e.next(); 699 700 pw.println(tabs + "<hyperlinkParameter name=\""+ f.getName() +"\">"); 701 pw.print(tabs + "\t<hyperlinkParameterExpression>"); 702 pw.println(""+ getCDATAString(f.getExpression(), tabs.length()+1 ) + "</hyperlinkParameterExpression>"); 703 pw.println(tabs + "</hyperlinkParameter>"); 704 } 705 } 706 707 708 void writeXMLGroups(Vector groups, java.io.PrintWriter pw, boolean writeAll, int tabCount) { 709 if (groups.size() > 0) pw.println(""); 711 for (int i=0; i< groups.size(); i++) { 712 Group grp = (Group)groups.elementAt(i); 713 for (int t=0; t<tabCount; ++t) pw.print("\t"); 714 pw.print("<group "); 715 pw.print(" name=\""+grp.getName() +"\""); 716 if (grp.isIsStartNewColumn()) pw.print(" isStartNewColumn=\""+grp.isIsStartNewColumn() +"\""); 717 if (grp.isIsStartNewPage()) pw.print(" isStartNewPage=\""+grp.isIsStartNewPage() +"\""); 718 if (grp.isIsResetPageNumber()) pw.print(" isResetPageNumber=\""+grp.isIsResetPageNumber() +"\""); 719 if (grp.isIsReprintHeaderOnEachPage()) pw.print(" isReprintHeaderOnEachPage=\""+grp.isIsReprintHeaderOnEachPage() +"\""); 720 if (grp.getMinHeightToStartNewPage() != 0) pw.print(" minHeightToStartNewPage=\""+grp.getMinHeightToStartNewPage() +"\""); 721 pw.println(" >"); 722 pw.print("\t\t\t<groupExpression"); 723 728 pw.println(">" + getCDATAString(grp.getGroupExpression() ,tabCount + 1) +"</groupExpression>"); 729 if (writeAll) 730 { 731 pw.println("\t\t\t<groupHeader>"); 732 writeXMLBand(grp.getGroupHeader(), pw); 733 pw.println("\t\t\t</groupHeader>"); 734 pw.println("\t\t\t<groupFooter>"); 735 writeXMLBand(grp.getGroupFooter(), pw); 736 pw.println("\t\t\t</groupFooter>"); 737 } 738 for (int t=0; t<tabCount; ++t) pw.print("\t"); 739 pw.println("</group>"); 740 } 741 } 742 743 void writeXMLStyles(Vector styles, java.io.PrintWriter pw, String tabs) 744 { 745 746 Enumeration e = styles.elements(); 747 if (styles.size() > 0) pw.println(""); 748 while (e.hasMoreElements()) { 749 it.businesslogic.ireport.Style style = (it.businesslogic.ireport.Style)e.nextElement(); 750 751 String tabs2 = tabs; 752 if ( CompatibilitySupport.version >= CompatibilitySupport.JR120 ) 753 { 754 if (style instanceof ConditionedStyle) 755 { 756 pw.println(tabs2 + "<conditionalStyle>"); 757 tabs += "\t"; 758 pw.print(tabs + "<conditionExpression"); 759 pw.println(">" + getCDATAString(((ConditionedStyle)style).getCondition() ,tabs2.length()+1) +"</conditionExpression>"); 760 } 761 762 } 763 764 pw.println(tabs + "<style "); 765 for (int i=0; i<Style.JRXMLStyleAttributes.length; ++i) 766 { 767 if ( style.getAttributes().containsKey(Style.JRXMLStyleAttributes[i]) && 768 style.getAttributes().get( Style.JRXMLStyleAttributes[i] ) != null) { 769 Object obj = style.getAttributes().get(Style.JRXMLStyleAttributes[i]); 770 String value = ""+obj; 771 if (obj instanceof java.awt.Color ) 772 { 773 value = writeEncodedColor( (java.awt.Color )obj); 774 } 775 if (Style.JRXMLStyleAttributes[i].toLowerCase().endsWith("color") && value.startsWith("[")) 776 { 777 try { 779 value = writeEncodedColor(it.businesslogic.ireport.gui.sheet.ColorSelectorPanel.parseColorString(value)); 780 } catch (Exception ex) 781 { 782 value="black"; 783 } 784 } 785 if (Style.JRXMLStyleAttributes[i].equals("style")) 786 { 787 if (value == null || value.trim().length() == 0) continue; 788 } 789 pw.println(tabs + "\t" + Style.JRXMLStyleAttributes[i] + "=\"" + value +"\""); 790 } 791 } 792 793 if (CompatibilitySupport.version < CompatibilitySupport.JR120 || style.getConditionedStyles().size() == 0) 794 { 795 pw.println(tabs + "/>"); 796 } 797 else 798 { 799 pw.println(tabs + ">"); 800 writeXMLStyles(style.getConditionedStyles(), pw, tabs+"\t"); 801 pw.println(tabs + "</style>"); 802 } 803 if ( CompatibilitySupport.version >= CompatibilitySupport.JR120 ) 804 { 805 if (style instanceof ConditionedStyle) 806 { 807 pw.println(tabs2 + "</conditionalStyle>"); 808 } 809 } 810 } 811 } 812 813 void writeXMLBand(Band band, PrintWriter pw) { 814 pw.print("\t\t\t<band height=\""+ band.getHeight() + "\" "); 815 816 { 818 pw.print(" isSplitAllowed=\"" + band.isSplitAllowed() + "\" "); 819 } 820 pw.println(">"); 821 822 if (band.getPrintWhenExpression().trim().length() > 0) { 823 pw.print("\t\t\t\t<printWhenExpression"); 824 829 pw.println(">" + getCDATAString(band.getPrintWhenExpression(),4) + "</printWhenExpression>"); 830 } 831 832 writeBandElements(pw, band, null); 833 pw.println("\t\t\t</band>"); 834 } 835 836 837 public void writeBandElements(PrintWriter pw, Band band, ReportElement parent) 838 { 839 String actualElementGroup = ""; 840 for (Iterator i = getReport().getElements().iterator(); i.hasNext(); ) { 841 ReportElement re = (ReportElement) i.next(); 842 if (re.band == band && re.getParentElement() == parent) { 843 actualElementGroup = writeOpenCloseGroup(pw,re.getElementGroup(), actualElementGroup); 844 writeXMLReportElement(re,pw); 845 } 846 } 847 writeOpenCloseGroup(pw, "", actualElementGroup); 848 } 849 850 public String writeOpenCloseGroup(PrintWriter pw, String newGroup, String oldGroup) 851 { 852 if (oldGroup.equals(newGroup)) return newGroup; 853 while (!newGroup.startsWith( oldGroup) && oldGroup.length() > 0) 854 { 855 pw.println("\t\t\t\t</elementGroup><!-- End " + oldGroup + " !-->"); 856 if (oldGroup.lastIndexOf(".") >= 0) 857 { 858 oldGroup = oldGroup.substring(0, oldGroup.lastIndexOf(".")); 859 } 860 else 861 { 862 oldGroup=""; 863 } 864 } 865 866 String remainNewGroup = newGroup; 867 if (oldGroup.length() > 0 && newGroup.startsWith(oldGroup)) 868 { 869 remainNewGroup = newGroup.substring(oldGroup.length()+1); 870 } 871 872 String groupName = remainNewGroup; 873 while (remainNewGroup.length() > 0) 874 { 875 pw.print("\t\t\t\t<elementGroup>"); 876 877 if (remainNewGroup.indexOf(".") >= 0) 878 { 879 groupName = ((oldGroup.length() > 0) ? oldGroup + "." : "") + remainNewGroup.substring(0,remainNewGroup.indexOf(".")); 880 oldGroup = remainNewGroup.substring(0,remainNewGroup.indexOf(".")); 881 remainNewGroup = remainNewGroup.substring(remainNewGroup.indexOf(".")+1); 882 } 883 else 884 { 885 groupName = ((oldGroup.length() > 0) ? oldGroup + "." : "") + remainNewGroup; 886 remainNewGroup=""; 887 } 888 pw.println("<!-- Start: " + groupName + " !-->"); 889 } 890 891 return newGroup; 892 } 893 894 void writeXMLReportElement(ReportElement re, PrintWriter pw) { 895 if (re instanceof StaticTextReportElement) { 896 pw.println("\t\t\t\t<staticText>"); 897 898 writeXMLReportElementElement(re, pw); 899 writeXMLBox( ((TextReportElement)re).getBox(), pw ); 900 writeXMLTextElementElement((TextReportElement)re, pw); 901 pw.println("\t\t\t\t<text>"+getCDATAString(((StaticTextReportElement)re).getText(), 4)+"</text>"); 902 pw.println("\t\t\t\t</staticText>"); 903 904 } 905 else if (re instanceof FrameReportElement) 906 { 907 FrameReportElement fre = (FrameReportElement)re; 908 pw.print("\t\t\t\t<frame>"); 909 writeXMLReportElementElement(fre, pw); 910 writeXMLBox( ((BoxElement)fre).getBox(), pw ); 911 if (re instanceof FrameReportElement) 912 { 913 writeBandElements(pw, re.getBand(), re); 914 } 915 pw.print("\t\t\t\t</frame>"); 916 } 917 else if (re instanceof TextFieldReportElement) { 918 TextFieldReportElement tfre = (TextFieldReportElement)re; 919 pw.print("\t\t\t\t<textField"); 920 pw.print(" isStretchWithOverflow=\""+ tfre.isStretchWithOverflow() +"\""); 921 922 if (tfre.getPropertyValue(tfre.PATTERN) != null) 923 { 924 pw.print(" pattern=\"" + tfre.getPattern() + "\""); 925 } 926 927 pw.print(" isBlankWhenNull=\"" + tfre.isBlankWhenNull() +"\""); 928 pw.print(" evaluationTime=\""+ tfre.getEvaluationTime() +"\""); 929 if (tfre.getEvaluationTime().equals("Group")) { 930 pw.print(" evaluationGroup=\"" + tfre.getGroup() +"\" "); 931 } 932 pw.print(" hyperlinkType=\"" + tfre.getHyperlinkType() +"\" "); 933 934 if ( CompatibilitySupport.version >= CompatibilitySupport.JR062 ) 935 { 936 pw.print(" hyperlinkTarget=\"" + tfre.getHyperlinkTarget() +"\" "); 937 } 938 939 if ( CompatibilitySupport.version >= CompatibilitySupport.JR100 ) 940 { 941 if (tfre.getBookmarkLevel() != 0 ) pw.print(" bookmarkLevel=\"" + tfre.getBookmarkLevel() +"\" "); 942 } 943 944 pw.println(">"); 945 946 writeXMLReportElementElement(tfre, pw); 947 writeXMLBox(((TextReportElement)re).getBox(), pw); 948 writeXMLTextElementElement(tfre, pw); 949 pw.print("\t\t\t\t<textFieldExpression "); 950 if (tfre.getClassExpression().length() > 0) { 951 pw.print(" class=\""+ tfre.getClassExpression()+"\""); 952 } 953 958 pw.println(">"+getCDATAString(((TextFieldReportElement)re).getText(),4)+"</textFieldExpression>"); 959 960 writeHyperLinkExpressions(tfre, pw); 961 962 pw.println("\t\t\t\t</textField>"); 963 } 964 else if (re instanceof ImageReportElement) { 965 ImageReportElement ire = (ImageReportElement)re; 966 pw.print("\t\t\t\t<image "); 967 968 if (ire.getPropertyValue( ire.SCALE) != null) 970 { 971 pw.print(" scaleImage=\""+ ire.getScaleImage() +"\""); 972 } 973 974 if (ire.getPropertyValue( ire.VERTICAL_ALIGN) != null) 976 { 977 pw.print(" vAlign=\""+ ire.getVerticalAlignment() +"\""); 978 } 979 if (ire.getPropertyValue( ire.HORIZONTAL_ALIGN) != null) 981 { 982 pw.print(" hAlign=\""+ ire.getHorizontalAlignment() +"\""); 983 } 984 985 if ( CompatibilitySupport.version >= CompatibilitySupport.JR065 && ire.isIsLazy() == true) 986 { 987 pw.print(" isLazy=\""+ ire.isIsLazy() +"\""); 988 } 989 990 if ( CompatibilitySupport.version >= CompatibilitySupport.JR103 && !ire.getOnErrorType().equals("Error")) 991 { 992 pw.print(" onErrorType=\""+ ire.getOnErrorType() +"\""); 993 } 994 995 if (ire.getPropertyValue( ire.USING_CACHE) != null) 996 { 997 pw.print(" isUsingCache=\""+ ire.isIsUsingCache() +"\""); 998 } 999 1000 pw.print(" evaluationTime=\""+ ire.getEvaluationTime() + "\""); 1001 1002 if (((ImageReportElement)re).getEvaluationTime().equals("Group")) { 1003 pw.print(" evaluationGroup=\"" + ire.getEvaluationGroup() +"\" "); 1004 } 1005 1006 pw.print(" hyperlinkType=\"" + ire.getHyperlinkType()+"\" "); 1007 1008 if ( CompatibilitySupport.version >= CompatibilitySupport.JR062 ) 1009 { 1010 pw.print(" hyperlinkTarget=\"" + ire.getHyperlinkTarget() +"\" "); 1011 } 1012 1013 if ( CompatibilitySupport.version >= CompatibilitySupport.JR100 ) 1014 { 1015 if (ire.getBookmarkLevel() != 0 ) pw.print(" bookmarkLevel=\"" + ire.getBookmarkLevel() +"\" "); 1016 } 1017 1018 pw.println(">"); 1019 1020 1021 writeXMLReportElementElement(re, pw); 1022 writeXMLBox( ((ImageReportElement)re).getBox(), pw); 1023 writeXMLGraphicElement(ire,pw); 1024 1025 if (re instanceof ChartReportElement) { 1026 pw.print("\t\t\t\t\t<imageExpression class=\"java.awt.Image\""); 1027 1032 pw.print(">" 1033 + getCDATAString( 1035 writeChartExpression( (ChartReportElement)re) 1036 , 5) + "</imageExpression>\n" ); 1037 } 1038 else { 1039 pw.print("\t\t\t\t\t<imageExpression class=\""+ ire.getImageClass() + "\""); 1040 1045 pw.println(">" 1046 + getCDATAString( ire.getImageExpression(), 5) + "</imageExpression>" ); 1048 } 1049 1050 writeHyperLinkExpressions(ire, pw); 1051 pw.println("\t\t\t\t</image>"); 1052 1053 } else if (re instanceof LineReportElement) { 1054 LineReportElement lre = (LineReportElement)re; 1055 pw.println("\t\t\t\t<line direction=\""+ lre.getDirection() +"\">"); 1056 writeXMLReportElementElement(re, pw); 1057 writeXMLGraphicElement(lre,pw); 1058 pw.println("\t\t\t\t</line>"); 1059 1060 } else if (re instanceof BreakReportElement) { 1061 1062 if ( CompatibilitySupport.version >= CompatibilitySupport.JR129) 1063 { 1064 BreakReportElement lre = (BreakReportElement)re; 1065 pw.print("\t\t\t\t<break"); 1066 if (!lre.getType().equals("Page")) 1067 { 1068 pw.print(" type=\""+ lre.getType() +"\""); 1069 } 1070 pw.println(">"); 1071 writeXMLReportElementElement(re, pw); 1072 pw.println("\t\t\t\t</break>"); 1073 } 1074 1075 } else if (re instanceof RectangleReportElement) { 1076 RectangleReportElement rre = (RectangleReportElement)re; 1077 pw.print("\t\t\t\t<rectangle"); 1078 if (rre.getPropertyValue( rre.RADIUS) != null) 1080 { 1081 pw.print(" radius=\""+ rre.getRadius() + "\" "); 1082 } 1083 pw.println(">"); 1084 writeXMLReportElementElement(re, pw); 1085 writeXMLGraphicElement(rre,pw); 1086 pw.println("\t\t\t\t</rectangle>"); 1087 1088 } else if (re instanceof EllipseReportElement ) { 1089 { 1091 EllipseReportElement ere = (EllipseReportElement)re; 1092 pw.println("\t\t\t\t<ellipse>"); 1093 writeXMLReportElementElement(ere, pw); 1094 writeXMLGraphicElement(ere,pw); 1095 pw.println("\t\t\t\t</ellipse>"); 1096 } 1097 } 1098 else if (re instanceof SubReportElement) { 1099 SubReportElement sre = (SubReportElement)re; 1100 pw.println("\t\t\t\t<subreport isUsingCache=\""+ sre.isIsUsingCache() +"\">"); 1101 writeXMLReportElementElement(re, pw); 1102 if (sre.getParametersMapExpression() != null && 1103 sre.getParametersMapExpression().trim().length() > 0) { 1104 pw.print("\t\t\t\t\t<parametersMapExpression"); 1105 1110 pw.println(">"+getCDATAString(sre.getParametersMapExpression(),5)+"</parametersMapExpression>"); 1111 } 1112 1113 Enumeration e = sre.getSubreportParameters().elements(); 1114 while (e.hasMoreElements()) { 1115 JRSubreportParameter je = (JRSubreportParameter)e.nextElement(); 1116 pw.println("\t\t\t\t\t<subreportParameter name=\""+ je.getName() +"\">"); 1117 pw.print("\t\t\t\t\t\t<subreportParameterExpression"); 1118 1123 pw.println(">"+getCDATAString(je.getExpression(),6)+"</subreportParameterExpression>"); 1124 pw.println("\t\t\t\t\t</subreportParameter>"); 1125 } 1126 if (sre.isUseConnection() && sre.getConnectionExpression().trim().length() > 0 ) { 1127 pw.print("\t\t\t\t\t<connectionExpression"); 1128 1133 pw.println(">"+getCDATAString(sre.getConnectionExpression(),5 )+ "</connectionExpression>"); 1134 } 1135 else if (!sre.isUseConnection() && sre.getDataSourceExpression().length() > 0) { 1136 pw.print("\t\t\t\t\t<dataSourceExpression"); 1137 1142 pw.println(">"+getCDATAString(sre.getDataSourceExpression(),5 )+"</dataSourceExpression>"); 1143 } 1144 1145 if ( CompatibilitySupport.version >= CompatibilitySupport.JR100) 1146 { 1147 Enumeration e_sr = sre.getReturnValues().elements(); 1148 while (e_sr.hasMoreElements()) { 1149 it.businesslogic.ireport.JRSubreportReturnValue jerv = (it.businesslogic.ireport.JRSubreportReturnValue)e_sr.nextElement(); 1150 pw.print("\t\t\t\t\t<returnValue"); 1151 if (jerv.getSubreportVariable()!= null && jerv.getSubreportVariable().length()>0) pw.print(" subreportVariable=\""+ jerv.getSubreportVariable() +"\""); 1152 if (jerv.getToVariable()!= null && jerv.getToVariable().length()>0) pw.print(" toVariable=\""+ jerv.getToVariable() +"\""); 1153 if (jerv.getCalculation() != null && !jerv.getCalculation().equals("Nothing")) pw.print(" calculation=\""+ jerv.getCalculation() +"\""); 1154 if (jerv.getIncrementFactoryClass()!= null && jerv.getIncrementFactoryClass().length()>0) pw.print(" incrementerFactoryClass=\""+ jerv.getIncrementFactoryClass() +"\""); 1155 pw.println("/>"); 1156 } 1157 } 1158 1159 if (sre.getSubreportExpression() != null && 1160 sre.getSubreportExpression().trim().length() > 0) { 1161 pw.print("\t\t\t\t\t<subreportExpression class=\""+ sre.getSubreportExpressionClass() +"\""); 1162 1167 pw.println(">" + 1168 getCDATAString(sre.getSubreportExpression(),5) + "</subreportExpression>"); 1169 } 1170 1171 pw.println("\t\t\t\t</subreport>"); 1172 } else if (re instanceof ChartReportElement2 ) { 1173 writeChartElement((ChartReportElement2)re, pw); 1174 } else if (re instanceof CrosstabReportElement) { 1175 CrosstabReportElement cre = (CrosstabReportElement)re; 1176 if ( CompatibilitySupport.version >= CompatibilitySupport.JR111 ) 1177 { 1178 pw.print("\t\t\t\t<crosstab "); 1179 if (!cre.isRepeatColumnHeaders()) pw.print("isRepeatColumnHeaders=\""+ cre.isRepeatColumnHeaders() +"\" "); 1180 if (!cre.isRepeatRowHeaders()) pw.print("isRepeatRowHeaders=\""+ cre.isRepeatRowHeaders() +"\" "); 1181 if (cre.getColumnBreakOffset() != 10) pw.print("columnBreakOffset=\""+ cre.getColumnBreakOffset() +"\" "); 1182 pw.println(">"); 1183 writeXMLReportElementElement(re, pw); 1184 writeXMLCrosstabParameters(cre.getCrosstabParameters(),pw,"\t\t\t\t\t"); 1185 1186 if (cre.getParametersMapExpression() != null && cre.getParametersMapExpression().trim().length() > 0) { 1187 pw.print("\t\t\t\t\t<parametersMapExpression>"); 1188 pw.println(getCDATAString(cre.getParametersMapExpression(),5)+"</parametersMapExpression>"); 1189 } 1190 1191 if (cre.isUseDataset() ) { 1192 pw.print("\t\t\t\t\t<crosstabDataset"); 1193 if (cre.isPreSorted()) pw.print(" isDataPreSorted=\""+ cre.isPreSorted() +"\" "); 1194 pw.println(">"); 1195 if (cre.getDataset() != null) 1196 { 1197 writeDatasetDataset( cre.getDataset(), pw ); 1198 } 1199 pw.println("\t\t\t\t\t</crosstabDataset>"); 1200 } 1201 1202 if ( CompatibilitySupport.version >= CompatibilitySupport.JR120 ) 1203 { 1204 for (int i=0; i<cre.getCells().size(); ++i) 1205 { 1206 CrosstabCell cell = (CrosstabCell)cre.getCells().elementAt(i); 1207 if (cell.getType() == cell.CT_HEADER_CELL) 1208 { 1209 pw.print("\t\t\t\t\t<crosstabHeaderCell>"); 1210 writeXMLCrosstabCellcontents( cell, cre.getElements(), pw, "\t\t\t\t\t\t"); 1211 pw.print("\t\t\t\t\t</crosstabHeaderCell>"); 1212 } 1213 } 1214 } 1215 1216 writeXMLCrosstabRowGroups(cre.getRowGroups(), cre.getElements(), pw); 1217 writeXMLCrosstabColumnGroups(cre.getColumnGroups(), cre.getElements(), pw); 1218 writeXMLMeasures(cre.getMeasures(), pw, "\t\t\t\t\t"); 1219 writeXMLCrosstabCells(cre.getCells(), cre.getElements(), pw, "\t\t\t\t\t"); 1220 1221 for (int i=0; i<cre.getCells().size(); ++i) 1222 { 1223 CrosstabCell cell = (CrosstabCell)cre.getCells().elementAt(i); 1224 if (cell.getType() == cell.NODATA_CELL) 1225 { 1226 pw.print("\t\t\t\t\t<whenNoDataCell>"); 1227 writeXMLCrosstabCellcontents( cell, cre.getElements(), pw, "\t\t\t\t\t\t"); 1228 pw.print("\t\t\t\t\t</whenNoDataCell>"); 1229 } 1230 } 1231 1232 1233 1234 pw.println("\t\t\t\t\t</crosstab>"); 1235 } 1236 } 1237 1238 } 1239 1240 void writeXMLBox(Box box, PrintWriter pw) { 1241 1242 if ( CompatibilitySupport.version >= CompatibilitySupport.JR063 ) 1243 { 1244 if (box == null) return; 1245 pw.print("\t\t\t\t\t<box"); 1246 if (box.getTopBorder() != null) pw.print(" topBorder=\"" + box.getTopBorder() + "\""); 1247 if (box.getTopBorderColor() != null) pw.print(" topBorderColor=\"" + writeEncodedColor( box.getTopBorderColor() ) + "\""); 1248 if (box.getTopPadding() > 0) pw.print(" topPadding=\"" + box.getTopPadding() + "\""); 1249 1250 if (box.getLeftBorder() != null) pw.print(" leftBorder=\"" + box.getLeftBorder() + "\""); 1251 if (box.getLeftBorderColor() != null) pw.print(" leftBorderColor=\"" + writeEncodedColor( box.getLeftBorderColor() ) + "\""); 1252 if (box.getLeftPadding() > 0) pw.print(" leftPadding=\"" + box.getLeftPadding() + "\""); 1253 1254 if (box.getRightBorder() != null) pw.print(" rightBorder=\"" + box.getRightBorder() + "\""); 1255 if (box.getRightBorderColor() != null) pw.print(" rightBorderColor=\"" + writeEncodedColor( box.getRightBorderColor() ) + "\""); 1256 if (box.getRightPadding() > 0) pw.print(" rightPadding=\"" + box.getRightPadding() + "\""); 1257 1258 if (box.getBottomBorder() != null) pw.print(" bottomBorder=\"" + box.getBottomBorder() + "\""); 1259 if (box.getBottomBorderColor() != null) pw.print(" bottomBorderColor=\"" + writeEncodedColor( box.getBottomBorderColor() ) + "\""); 1260 if (box.getBottomPadding() > 0) pw.print(" bottomPadding=\"" + box.getBottomPadding() + "\""); 1261 pw.println("/>"); 1262 } 1263 } 1264 1265 void writeFontElement(IReportFont font, PrintWriter pw) { 1266 1267 if (font == null) return; 1268 pw.print("\t\t\t\t\t<font"); 1269 1270 IReportFont base = getReport().getReportFontByName( font.getReportFont() ); 1271 1272 if (font.getReportFont() != null && font.getReportFont().length() > 0) pw.print(" reportFont=\"" + font.getReportFont() + "\""); 1273 1274 if (base != null && base.getFontName().equals( font.getFontName())) { } 1275 else if (font.getFontName() != null && font.getFontName().length() > 0) pw.print(" fontName=\"" + font.getFontName() + "\""); 1276 1277 if ( base != null && base.getPDFFontName().equals( font.getPDFFontName())) { } 1278 else if (font.getPDFFontName() != null && font.getPDFFontName().length() > 0) pw.print(" pdfFontName=\"" + font.getPDFFontName() + "\""); 1279 1280 if ( base != null && base.getFontSize() == font.getFontSize() ) { } 1281 else pw.print(" size=\"" + font.getFontSize() + "\""); 1282 1283 if ( base != null && base.isBold() == font.isBold() ) { } 1284 else pw.print(" isBold=\"" + ((font.isBold()) ? "true" : "false") + "\""); 1285 1286 if ( base != null && base.isItalic() == font.isItalic() ) { } 1287 else pw.print(" isItalic=\"" + ((font.isItalic()) ? "true" : "false") + "\""); 1288 1289 if ( base != null && base.isUnderline() == font.isUnderline() ) { } 1290 else pw.print(" isUnderline=\"" + ((font.isUnderline()) ? "true" : "false") + "\""); 1291 1292 if ( base != null && base.isStrikeTrought() == font.isStrikeTrought() ) { } 1293 else pw.print(" isStrikeThrough=\"" + ((font.isStrikeTrought()) ? "true" : "false") + "\""); 1294 1295 if ( base != null && base.isPdfEmbedded() == font.isPdfEmbedded() ) { } 1296 else pw.print(" isPdfEmbedded=\"" + ((font.isPdfEmbedded()) ? "true" : "false") + "\""); 1297 1298 if ( base != null && base.getPdfEncoding().equals(font.getPdfEncoding()) ) { } 1299 else if (font.getPdfEncoding() != null && font.getPdfEncoding().length() > 0) pw.print(" pdfEncoding=\"" + font.getPdfEncoding() + "\""); 1300 1301 pw.println("/>"); 1302 } 1303 1304 1305 void writeXMLReportElementElement(ReportElement re, PrintWriter pw) { 1306 pw.print("\t\t\t\t\t<reportElement"); 1307 1308 if ( CompatibilitySupport.version >= CompatibilitySupport.JR111 ) 1309 { 1310 if ( re.getStyle() != null) 1311 pw.print("\n\t\t\t\t\t\tstyle=\""+ re.getStyle() + "\""); 1312 } 1313 1314 { 1316 if (re.getPropertyValue(re.MODE) != null) 1317 { 1318 pw.print("\n\t\t\t\t\t\tmode=\""+ re.getTransparent() + "\""); 1319 } 1320 } 1321 1322 int position_x = re.getPosition().x; 1323 1324 if (re.getParentElement() != null) position_x -= re.getParentElement().getPosition().x; 1325 else if (re.getCell() != null) position_x = position_x - re.getCell().getLeft()- 10; 1326 else position_x = position_x - getReport().getLeftMargin() - 10; 1327 1328 pw.print("\n\t\t\t\t\t\tx=\""+ position_x + "\""); 1329 1330 int position_y = re.getPosition().y; 1331 if (re.getParentElement() != null) position_y -= re.getParentElement().getPosition().y; 1332 else if (re.getCell() != null) position_y = position_y - re.getCell().getTop()- 10; 1333 else position_y = position_y - 10 - getReport().getBandYLocation(re.getBand()); 1334 1335 pw.print("\n\t\t\t\t\t\ty=\""+ position_y +"\""); 1336 1337 pw.print("\n\t\t\t\t\t\twidth=\""+ re.getWidth() + "\""); 1338 pw.print("\n\t\t\t\t\t\theight=\""+ re.getHeight() + "\""); 1339 1340 1341 { 1343 if (re.getColorValue(re.FGCOLOR, null) != null) 1344 { 1345 pw.print("\n\t\t\t\t\t\tforecolor=\""+ writeEncodedColor(re.getColorValue(re.FGCOLOR, null)) +"\""); 1346 } 1347 } 1348 1349 { 1351 if (re.getColorValue(re.BGCOLOR, null) != null) 1352 { 1353 pw.print("\n\t\t\t\t\t\tbackcolor=\""+ writeEncodedColor(re.getColorValue(re.BGCOLOR, null)) +"\""); 1354 } 1355 } 1356 1357 if (!re.getKey().equals("")) 1359 { 1360 pw.print("\n\t\t\t\t\t\tkey=\""+ re.getKey() +"\""); 1361 } 1362 1363 if (!re.getStretchType().equals("NoStretch")) 1364 { 1365 pw.print("\n\t\t\t\t\t\tstretchType=\""+ re.getStretchType() +"\""); 1366 } 1367 1368 if (!re.getPositionType().equals("FixRelativeToTop")) 1369 { 1370 pw.print("\n\t\t\t\t\t\tpositionType=\""+ re.getPositionType() +"\""); 1371 } 1372 1373 if (re.isIsPrintRepeatedValues() != true) 1374 { 1375 pw.print("\n\t\t\t\t\t\tisPrintRepeatedValues=\""+ re.isIsPrintRepeatedValues() +"\""); 1376 } 1377 if (re.isIsRemoveLineWhenBlank() != false) 1378 { 1379 pw.print("\n\t\t\t\t\t\tisRemoveLineWhenBlank=\""+ re.isIsRemoveLineWhenBlank() +"\""); 1380 } 1381 if (re.isIsPrintInFirstWholeBand() != false) 1382 { 1383 pw.print("\n\t\t\t\t\t\tisPrintInFirstWholeBand=\""+ re.isIsPrintInFirstWholeBand() +"\""); 1384 } 1385 1386 if (re.getPrintWhenGroupChanges() != null && re.getPrintWhenGroupChanges().trim().length()>0) 1387 pw.print("\n\t\t\t\t\t\tprintWhenGroupChanges=\""+ re.getPrintWhenGroupChanges() +"\""); 1388 1389 if (re.isIsPrintWhenDetailOverflows() != false) 1390 { 1391 pw.print("\n\t\t\t\t\t\tisPrintWhenDetailOverflows=\""+ re.isIsPrintWhenDetailOverflows() +"\""); 1392 } 1393 1394 if (re.getPrintWhenExpression().length()>0) { 1395 pw.println(">"); 1396 pw.print("\t\t\t\t\t\t\t<printWhenExpression"); 1397 1402 pw.println(">"+getCDATAString(re.getPrintWhenExpression(),7) + "</printWhenExpression>"); 1403 pw.println("\t\t\t\t\t\t</reportElement>"); 1404 } 1405 else{ 1406 pw.println("/>"); 1407 } 1408 1409 } 1410 1411 public static String getCDATAString( String string, int tabCount ) { 1412 String CRLF = System.getProperty("line.separator"); 1415 String tab = ""; 1416 for ( int i = 0; i < tabCount; i++ ) { 1417 tab += "\t"; 1418 } 1419 return "<![CDATA[" + string + "]]>"; } 1421 1422 void writeXMLGraphicElement(GraphicReportElement re, PrintWriter pw) { 1423 pw.print("\t\t\t\t\t<graphicElement"); 1424 1425 pw.print(" stretchType=\"" + re.getStretchType() + "\""); 1426 if (re.getPropertyValue(re.PEN) != null) 1428 { 1429 pw.print(" pen=\""+ re.getGraphicElementPen() + "\""); 1430 } 1431 1432 1434 if (re.getPropertyValue(GraphicReportElement.FILL) != null) 1435 { 1436 pw.print(" fill=\"" + re.getFill() + "\" "); 1437 } 1438 1439 pw.println("/>"); 1440 } 1441 1442 void writeXMLCrosstabRowGroups(Vector crosstabRowGroups, Vector crosstabElements, PrintWriter pw) { 1443 1444 for (int i=0; i<crosstabRowGroups.size(); ++i) 1445 { 1446 CrosstabRowGroup group = (CrosstabRowGroup)crosstabRowGroups.elementAt(i); 1447 1448 pw.print("\t\t\t\t\t<rowGroup"); 1449 pw.print(" name=\"" + group.getName() + "\""); 1450 pw.print(" width=\""+ group.getWidth() + "\""); 1451 if (!group.getTotalPosition().equals("None")) pw.print(" totalPosition=\""+ group.getTotalPosition() + "\""); 1452 if (!group.getHeaderPosition().equals("Top")) pw.print(" headerPosition=\""+ group.getHeaderPosition() + "\""); 1453 pw.println(">"); 1454 1455 writeXMLBucket(group, pw); 1457 1458 if (group.getHeaderCell().getHeight() > 0 && group.getHeaderCell().getWidth() > 0) 1459 { 1460 pw.println("\t\t\t\t\t\t<crosstabRowHeader>"); 1461 writeXMLCrosstabCellcontents(group.getHeaderCell(), crosstabElements, pw, "\t\t\t\t\t\t\t"); 1462 pw.println("\t\t\t\t\t\t</crosstabRowHeader>"); 1463 } 1464 1465 if (group.getTotalCell().getHeight() > 0 && group.getTotalCell().getWidth() > 0) 1466 { 1467 pw.println("\t\t\t\t\t\t<crosstabTotalRowHeader>"); 1468 writeXMLCrosstabCellcontents(group.getTotalCell(), crosstabElements, pw, "\t\t\t\t\t\t\t"); 1469 pw.println("\t\t\t\t\t\t</crosstabTotalRowHeader>"); 1470 } 1471 1472 pw.println("\t\t\t\t\t</rowGroup>"); 1473 } 1474 1475 } 1476 1477 void writeXMLCrosstabColumnGroups(Vector crosstabColumnGroups, Vector crosstabElements, PrintWriter pw) { 1478 1479 for (int i=0; i<crosstabColumnGroups.size(); ++i) 1480 { 1481 CrosstabColumnGroup group = (CrosstabColumnGroup)crosstabColumnGroups.elementAt(i); 1482 1483 pw.print("\t\t\t\t\t<columnGroup"); 1484 pw.print(" name=\"" + group.getName() + "\""); 1485 pw.print(" height=\""+ group.getHeight() + "\""); 1486 if (!group.getTotalPosition().equals("None")) pw.print(" totalPosition=\""+ group.getTotalPosition() + "\""); 1487 if (!group.getHeaderPosition().equals("Left")) pw.print(" headerPosition=\""+ group.getHeaderPosition() + "\""); 1488 pw.println(">"); 1489 1490 writeXMLBucket(group, pw); 1492 1493 if (group.getHeaderCell().getHeight() > 0 && group.getHeaderCell().getWidth() > 0) 1494 { 1495 pw.println("\t\t\t\t\t\t<crosstabColumnHeader>"); 1496 writeXMLCrosstabCellcontents(group.getHeaderCell(), crosstabElements, pw, "\t\t\t\t\t\t\t"); 1497 pw.println("\t\t\t\t\t\t</crosstabColumnHeader>"); 1498 } 1499 1500 if (group.getTotalCell().getHeight() > 0 && group.getTotalCell().getWidth() > 0) 1501 { 1502 pw.println("\t\t\t\t\t\t<crosstabTotalColumnHeader>"); 1503 writeXMLCrosstabCellcontents(group.getTotalCell(), crosstabElements, pw, "\t\t\t\t\t\t\t"); 1504 pw.println("\t\t\t\t\t\t</crosstabTotalColumnHeader>"); 1505 } 1506 1507 pw.println("\t\t\t\t\t</columnGroup>"); 1508 } 1509 1510 } 1511 1512 void writeXMLCrosstabCellcontents(CrosstabCell cell, Vector elements, PrintWriter pw, String tabs) { 1513 1514 pw.print("\t\t\t\t\t\t<cellContents"); 1515 if (cell.getBackcolor() != null) pw.print(" backcolor=\""+ writeEncodedColor( cell.getBackcolor() ) + "\""); 1516 if ( CompatibilitySupport.version >= CompatibilitySupport.JR120) 1517 { 1518 pw.print(" mode=\""+ cell.getMode() + "\""); 1519 } 1520 1521 if ( CompatibilitySupport.version >= CompatibilitySupport.JR120 && cell.getStyle() != null ) 1522 { 1523 pw.print(" style=\""+ cell.getStyle() + "\""); 1524 } 1525 1526 pw.println(">"); 1527 1528 if (cell.getBox() != null) 1529 { 1530 writeXMLBox(cell.getBox(), pw); 1531 } 1532 1533 for (int i=0; i<elements.size(); ++i) 1534 { 1535 ReportElement re = (ReportElement)elements.elementAt(i); 1536 if (re.getCell() == cell) 1537 { 1538 writeXMLReportElement(re, pw); 1539 } 1540 } 1541 pw.println("\t\t\t\t\t\t</cellContents>"); 1542 } 1543 1544 void writeXMLCrosstabCells(Vector cells, Vector elements, PrintWriter pw, String tabs) { 1545 1546 for (int i=0; i<cells.size(); ++i) 1547 { 1548 CrosstabCell cell = (CrosstabCell)cells.elementAt(i); 1549 if (cell.getType() == cell.DETAIL_CELL) 1553 { 1556 pw.print(tabs + "<crosstabCell"); 1557 pw.print(" width=\"" + cell.getWidth()+"\""); 1558 pw.print(" height=\"" + cell.getHeight()+"\""); 1559 if (cell.getRowTotalGroup().trim().length() > 0) pw.print(" rowTotalGroup=\""+ cell.getRowTotalGroup() + "\""); 1560 if (cell.getColumnTotalGroup().trim().length() > 0) pw.print(" columnTotalGroup=\""+ cell.getColumnTotalGroup() + "\""); 1561 pw.println(">"); 1562 writeXMLCrosstabCellcontents(cell, elements, pw, tabs+"\t"); 1563 1564 pw.println(tabs + "</crosstabCell>"); 1565 } 1566 } 1567 } 1568 1569 void writeXMLBucket(CrosstabGroup group, PrintWriter pw) { 1570 1571 pw.print("\t\t\t\t\t\t<bucket"); 1572 if (!group.getBucketOrder().equals("Ascending")) pw.print(" order=\""+ group.getBucketOrder() + "\""); 1573 pw.println(">"); 1574 pw.print("\t\t\t\t\t\t\t<bucketExpression"); 1575 pw.print(" class=\""+ group.getBucketExpressionClass() + "\""); 1576 pw.print(">"); 1577 pw.print(getCDATAString(group.getBucketExpression(),8)); 1578 pw.println("</bucketExpression>"); 1579 1580 if (group.getBucketComparatorExpression().trim().length() > 0) 1581 { 1582 pw.print("\t\t\t\t\t\t\t<comparatorExpression>"); 1583 pw.print(getCDATAString(group.getBucketComparatorExpression(),8)); 1584 pw.println("</comparatorExpression>"); 1585 } 1586 pw.println("\t\t\t\t\t\t</bucket>"); 1587 } 1588 1589 void writeXMLTextElementElement(TextReportElement re, PrintWriter pw) { 1590 java.text.NumberFormat nf = java.text.NumberFormat.getInstance(); 1591 nf.setGroupingUsed(false); 1592 nf.setMaximumFractionDigits(0); 1593 1594 1595 pw.print("\t\t\t\t\t<textElement"); 1596 1597 if (re.getPropertyValue( re.ALIGN) != null) 1599 { 1600 pw.print(" textAlignment=\""+ re.getAlign() +"\""); 1601 } 1602 1603 if (re.getPropertyValue( re.VERTICAL_ALIGN) != null) 1605 { 1606 pw.print(" verticalAlignment=\""+ re.getVerticalAlign() +"\""); 1607 } 1608 1609 if (re.getPropertyValue( re.ROTATE) != null) 1611 { 1612 pw.print(" rotation=\""+ re.getRotate() +"\""); 1613 } 1614 1615 if (re.getPropertyValue( re.IS_STYLED_TEXT) != null) 1618 { 1619 if (re.isIsStyledText()) { 1620 pw.print(" isStyledText=\"true\""); 1621 } 1622 } 1623 1624 if (re.getPropertyValue( re.LINE_SPACING) != null) 1626 { 1627 pw.print(" lineSpacing=\""+ re.getLineSpacing() +"\""); 1628 } 1629 1632 pw.println(">"); 1633 pw.print("\t\t\t\t\t\t<font"); 1634 1635 IReportFont font = null; 1636 if (re.getReportFont() != null && re.getReportFont().length()>0) { 1637 for (int fn =0; fn < getReport().getFonts().size(); ++fn) { 1639 font = (IReportFont)getReport().getFonts().elementAt(fn); 1640 if (font != null && font.getReportFont().equals(re.getReportFont())) { 1641 break; 1642 } 1643 else{ 1644 font = null; 1645 } 1646 } 1647 pw.print(" reportFont=\""+ re.getReportFont() +"\""); 1648 } 1649 1650 if (font == null || !font.getFontName().equals(re.getFontName() )) 1651 { 1652 if (re.getIReportFont().getPropertyValue( IReportFont.FONT_NAME) != null) 1654 { 1655 pw.print(" fontName=\"" + re.getFontName() +"\""); 1656 } 1657 } 1658 1659 1660 if (font == null || !font.getPDFFontName().equalsIgnoreCase(re.getPDFFontName())) 1661 { 1662 if (re.getIReportFont().getPropertyValue( IReportFont.PDF_FONT_NAME ) != null) 1664 { 1665 pw.print(" pdfFontName=\"" + re.getPDFFontName() +"\""); 1666 } 1667 } 1668 1669 if (font == null || font.getFontSize() != re.getFontSize()) 1671 { 1672 if (re.getIReportFont().getPropertyValue( IReportFont.FONT_SIZE) != null) 1674 { 1675 pw.print(" size=\"" + re.getFontSize() +"\""); 1676 } 1677 } 1678 1679 if (font == null || font.isBold() != re.isBold()) { 1680 1681 if (re.getIReportFont().getPropertyValue( IReportFont.IS_BOLD) != null) 1683 { 1684 pw.print(" isBold=\"" + ((re.isBold()) ? "true" : "false")+"\""); 1685 } 1686 } 1687 1688 if (font == null || font.isItalic() != re.isItalic()) { 1689 if (re.getIReportFont().getPropertyValue( IReportFont.IS_ITALIC) != null) 1691 { 1692 pw.print(" isItalic=\"" + ((re.isItalic()) ? "true" : "false")+"\""); 1693 } 1694 } 1695 1696 if (font == null || font.isUnderline() != re.isUnderline()){ 1697 if (re.getIReportFont().getPropertyValue( IReportFont.IS_UNDERLINE) != null) 1699 { 1700 pw.print(" isUnderline=\"" + ((re.isUnderline() ) ? "true" : "false")+"\""); 1701 } 1702 } 1703 1704 if (font == null || font.isPdfEmbedded() != re.isPdfEmbedded()){ 1705 if (re.getIReportFont().getPropertyValue( IReportFont.IS_PDF_EMBEDDED) != null) 1707 { 1708 pw.print(" isPdfEmbedded =\"" + ((re.isPdfEmbedded() ) ? "true" : "false")+"\""); 1709 } 1710 } 1711 1712 if (font == null || font.getPdfEncoding() == null || font.getPdfEncoding().length() == 0) { 1713 if (re.getIReportFont().getPropertyValue( IReportFont.PDF_ENCODING) != null && 1716 re.getPdfEncoding().length() > 0) 1717 { 1718 pw.print(" pdfEncoding =\"" + re.getPdfEncoding() +"\""); 1719 } 1720 } 1722 if (font == null || font.isStrikeTrought() != re.isStrikeTrought()){ 1723 if (re.getIReportFont().getPropertyValue( IReportFont.IS_STRIKETROUGHT) != null) 1725 { 1726 pw.print(" isStrikeThrough=\"" + ((re.isStrikeTrought() ) ? "true" : "false")+"\" "); 1727 } 1728 } 1729 1730 pw.println("/>"); 1731 pw.println("\t\t\t\t\t</textElement>"); 1732 } 1733 1734 public static String writeEncodedColor(java.awt.Color c) { 1735 String nums = "0123456789ABCDEF"; 1736 String s = "#"; 1737 s += nums.charAt( c.getRed()/16 ); 1738 s += nums.charAt( c.getRed()%16 ); 1739 s += nums.charAt( c.getGreen()/16 ); 1740 s += nums.charAt( c.getGreen()%16 ); 1741 s += nums.charAt( c.getBlue()/16 ); 1742 s += nums.charAt( c.getBlue()%16 ); 1743 return s; 1744 } 1745 1746 private String writeChartExpression(ChartReportElement chartElement) { 1747 String expression = ""; 1748 1749 expression = "(java.awt.Image)it.businesslogic.ireport.chart.DefaultChartFactory.drawChart(new String[]{"; 1750 1751 Properties props = chartElement.getProps(); 1752 Iterator keys = props.keySet().iterator(); 1753 int i=0; 1754 while (keys.hasNext()) 1755 { 1756 String key = ""+keys.next(); 1757 String val = props.getProperty(key); 1758 if (i>0) expression +=","; 1759 val = Misc.string_replace("\\\"", "\"", val ); 1760 expression += "\"" + key + "=" + val +"\""; 1761 i++; 1762 } 1763 expression += "}, (it.businesslogic.ireport.IReportScriptlet)$P{REPORT_SCRIPTLET})"; 1764 1765 return expression; 1766 } 1767 1768 private void writeChartElement(ChartReportElement2 chartElement, PrintWriter pw) { 1769 1770 if ( CompatibilitySupport.version >= CompatibilitySupport.JR100 ) 1771 { 1772 String chartType = ""; 1773 if (chartElement.getChart() instanceof it.businesslogic.ireport.chart.PieChart) chartType = "pieChart"; 1774 else if (chartElement.getChart() instanceof it.businesslogic.ireport.chart.Pie3DChart) chartType = "pie3DChart"; 1775 else if (chartElement.getChart() instanceof it.businesslogic.ireport.chart.BarChart) chartType = "barChart"; 1776 else if (chartElement.getChart() instanceof it.businesslogic.ireport.chart.Bar3DChart) chartType = "bar3DChart"; 1777 else if (chartElement.getChart() instanceof it.businesslogic.ireport.chart.XYBarChart) chartType = "xyBarChart"; 1778 else if (chartElement.getChart() instanceof it.businesslogic.ireport.chart.StackedBarChart) chartType = "stackedBarChart"; 1779 else if (chartElement.getChart() instanceof it.businesslogic.ireport.chart.StackedBar3DChart) chartType = "stackedBar3DChart"; 1780 else if (chartElement.getChart() instanceof it.businesslogic.ireport.chart.LineChart) chartType = "lineChart"; 1781 else if (chartElement.getChart() instanceof it.businesslogic.ireport.chart.XYLineChart) chartType = "xyLineChart"; 1782 else if (chartElement.getChart() instanceof it.businesslogic.ireport.chart.AreaChart) chartType = "areaChart"; 1783 else if (chartElement.getChart() instanceof it.businesslogic.ireport.chart.XYAreaChart) chartType = "xyAreaChart"; 1784 else if (chartElement.getChart() instanceof it.businesslogic.ireport.chart.ScatterChart) chartType = "scatterChart"; 1785 else if (chartElement.getChart() instanceof it.businesslogic.ireport.chart.BubbleChart) chartType = "bubbleChart"; 1786 else if (chartElement.getChart() instanceof it.businesslogic.ireport.chart.TimeSeriesChart) chartType = "timeSeriesChart"; 1787 else if (chartElement.getChart() instanceof it.businesslogic.ireport.chart.HighLowChart) chartType = "highLowChart"; 1788 else if (chartElement.getChart() instanceof it.businesslogic.ireport.chart.CandlestickChart) chartType = "candlestickChart"; 1789 else if (chartElement.getChart() instanceof it.businesslogic.ireport.chart.MeterChart) chartType = "meterChart"; 1790 else if (chartElement.getChart() instanceof it.businesslogic.ireport.chart.ThermometerChart) chartType = "thermometerChart"; 1791 else if (chartElement.getChart() instanceof it.businesslogic.ireport.chart.MultiAxisChart) chartType = "multiAxisChart"; 1792 1793 pw.println("\t\t\t\t<" + chartType + ">"); 1794 writeChartNode(chartElement, pw); 1795 writeDataset(chartElement, pw ); 1796 writePlot(chartElement, pw ); 1797 pw.println("\t\t\t\t</" + chartType + ">"); 1798 } 1799 } 1800 1801 1802 private void writeChartNode(ChartReportElement2 chartElement, PrintWriter pw) 1803 { 1804 pw.print("\t\t\t\t\t<chart "); 1805 if (!chartElement.getChart().isShowLegend()) pw.print("isShowLegend=\"false\" "); 1806 if (!chartElement.getEvaluationTime().equals("Now")) pw.print("evaluationTime=\"" + chartElement.getEvaluationTime() + "\" "); 1807 if (!chartElement.getEvaluationGroup().equals("")) pw.print("evaluationGroup=\"" + chartElement.getEvaluationGroup() + "\" "); 1808 if (!chartElement.getChart().getHyperlinkType().equals("None")) pw.print(" hyperlinkType=\"" + chartElement.getChart().getHyperlinkType() +"\" "); 1809 if (!chartElement.getChart().getHyperlinkTarget().equals("None")) pw.print(" hyperlinkTarget=\"" + chartElement.getChart().getHyperlinkTarget() +"\" "); 1810 if (chartElement.getChart().getBookmarkLevel() != 0) pw.print(" bookmarkLevel=\"" + chartElement.getChart().getBookmarkLevel() +"\" "); 1811 if (chartElement.getChart().getCustomizerClass().length() != 0) pw.print(" customizerClass=\"" + chartElement.getChart().getCustomizerClass() +"\" "); 1812 pw.println(">"); 1813 writeXMLReportElementElement(chartElement, pw); 1814 writeXMLBox(chartElement.getBox(), pw); 1815 writeChartTitleNode(chartElement, pw); 1816 writeChartSubTitleNode(chartElement, pw); 1817 1818 if ( CompatibilitySupport.version >= CompatibilitySupport.JR127 ) 1820 { 1821 writeChartLegendNode(chartElement, pw); 1822 } 1823 1824 writeHyperLinkExpressions(chartElement.getChart(), pw); 1825 pw.println("\t\t\t\t\t</chart>"); 1826 } 1827 1828 private void writeSectionItemHyperLinkExpressions(SectionItemHyperlink hlink, boolean isItem, PrintWriter pw) 1829 { 1830 String tag = "sectionHyperlink"; 1831 if (isItem) tag = "itemHyperlink"; 1832 1833 if ( CompatibilitySupport.version >= CompatibilitySupport.JR126 ) 1834 { 1835 pw.print("\t\t\t\t<" + tag +" "); 1836 if (hlink.getHyperlinkType() != null && 1837 !hlink.getHyperlinkType().equals("None") && 1838 hlink.getHyperlinkType().length() > 0) { 1839 pw.print(" hyperlinkType=\""+ hlink.getHyperlinkType() +"\""); 1840 } 1841 if (hlink.getHyperlinkTarget() != null && 1842 !hlink.getHyperlinkTarget().equals("Self")) { 1843 pw.print(" hyperlinkTarget=\""+ hlink.getHyperlinkTarget() +"\""); 1844 } 1845 pw.println(">"); 1846 1847 if (hlink.getHyperlinkType() != null && hlink.getHyperlinkType().length() > 0) { 1848 if ( hlink.getHyperlinkReferenceExpression().length() > 0 ) { 1849 pw.println("\t\t\t\t\t\t<hyperlinkReferenceExpression>"+getCDATAString(hlink.getHyperlinkReferenceExpression(),6) +"</hyperlinkReferenceExpression>"); 1850 } 1851 1852 if ( hlink.getHyperlinkAnchorExpression().length() > 0 ) { 1853 pw.println("\t\t\t\t\t\t<hyperlinkAnchorExpression>"+getCDATAString(hlink.getHyperlinkAnchorExpression(),6)+"</hyperlinkAnchorExpression>"); 1854 } 1855 1856 if ( hlink.getHyperlinkPageExpression().length() > 0 ) { 1857 pw.println("\t\t\t\t\t\t<hyperlinkPageExpression>"+getCDATAString(hlink.getHyperlinkPageExpression(),6) +"</hyperlinkPageExpression>"); 1858 } 1859 1860 if ( hlink.getHyperlinkTooltipExpression().length() > 0 ) { 1861 pw.println("\t\t\t\t\t\t<hyperlinkTooltipExpression>"+getCDATAString(hlink.getHyperlinkTooltipExpression(),6) +"</hyperlinkTooltipExpression>"); 1862 } 1863 1864 writeXMLHyperlinkParameters( hlink.getHyperlinkParameters(), pw, "\t\t\t\t\t\t"); 1865 } 1866 1867 pw.println("\t\t\t\t</" + tag +">"); 1868 } 1869 } 1870 1871 private void writeHyperLinkExpressions(HyperLinkableReportElement hlink, PrintWriter pw) 1872 { 1873 if (hlink.getAnchorNameExpression() != null && hlink.getAnchorNameExpression().length() > 0) { 1874 pw.println("\t\t\t\t\t\t<anchorNameExpression>"+getCDATAString(hlink.getAnchorNameExpression(),6)+"</anchorNameExpression>"); 1875 } 1876 if (hlink.getHyperlinkType() != null && hlink.getHyperlinkType().length() > 0) { 1877 1878 if ( hlink.getHyperlinkReferenceExpression().length() > 0 ) { 1879 pw.println("\t\t\t\t\t\t<hyperlinkReferenceExpression>"+getCDATAString(hlink.getHyperlinkReferenceExpression(),6) +"</hyperlinkReferenceExpression>"); 1880 } 1881 1882 if ( hlink.getHyperlinkAnchorExpression().length() > 0 ) { 1883 pw.println("\t\t\t\t\t\t<hyperlinkAnchorExpression>"+getCDATAString(hlink.getHyperlinkAnchorExpression(),6)+"</hyperlinkAnchorExpression>"); 1884 } 1885 1886 if ( hlink.getHyperlinkPageExpression().length() > 0 ) { 1887 pw.println("\t\t\t\t\t\t<hyperlinkPageExpression>"+getCDATAString(hlink.getHyperlinkPageExpression(),6) +"</hyperlinkPageExpression>"); 1888 } 1889 1890 1891 if ( CompatibilitySupport.version >= CompatibilitySupport.JR126 ) 1892 { 1893 writeXMLHyperlinkParameters( hlink.getLinkParameters(), pw, "\t\t\t\t\t\t"); 1894 } 1895 } 1896 } 1897 1898 private void writeChartTitleNode(ChartReportElement2 chartElement, PrintWriter pw) 1899 { 1900 if (chartElement.getChart().getTitle().getTitleExpression().trim().length() > 0) 1901 { 1902 pw.print("\t\t\t\t\t\t<chartTitle "); 1903 if (!chartElement.getChart().getTitle().getPosition().equals("Top")) pw.print("position=\"" + chartElement.getChart().getTitle().getPosition() + "\" "); 1904 if (chartElement.getChart().getTitle().getColor() != null) pw.print("color=\"" + writeEncodedColor(chartElement.getChart().getTitle().getColor() ) + "\" "); 1905 pw.println(">"); 1906 writeFontElement(chartElement.getChart().getTitle().getFont(), pw ); 1907 pw.println("\t\t\t\t\t\t\t\t<titleExpression>" + getCDATAString(chartElement.getChart().getTitle().getTitleExpression(),8 ) + "</titleExpression>"); 1908 pw.println("\t\t\t\t\t</chartTitle>"); 1909 } 1910 } 1911 1912 1913 private void writeChartSubTitleNode(ChartReportElement2 chartElement, PrintWriter pw) 1914 { 1915 if (chartElement.getChart().getSubTitle().getTitleExpression().trim().length() > 0) 1916 { 1917 pw.print("\t\t\t\t\t\t<chartSubtitle "); 1918 if (chartElement.getChart().getSubTitle().getColor() != null) pw.print("color=\"" + writeEncodedColor(chartElement.getChart().getSubTitle().getColor() ) + "\" "); 1919 pw.println(">"); 1920 writeFontElement(chartElement.getChart().getSubTitle().getFont(), pw ); 1921 pw.println("\t\t\t\t\t\t\t\t<subtitleExpression>" + getCDATAString(chartElement.getChart().getSubTitle().getTitleExpression(),8 ) + "</subtitleExpression>"); 1922 pw.println("\t\t\t\t\t</chartSubtitle>"); 1923 } 1924 } 1925 1926 private void writeChartLegendNode(ChartReportElement2 chartElement, PrintWriter pw) 1927 { 1928 if (chartElement.getChart().isShowLegend()) 1929 { 1930 pw.print("\t\t\t\t\t\t<chartLegend "); 1931 if (chartElement.getChart().getLegend().getTextColor() != null) pw.print("textColor=\"" + writeEncodedColor(chartElement.getChart().getLegend().getTextColor() ) + "\" "); 1932 if (chartElement.getChart().getLegend().getBackgroundColor() != null) pw.print("backgroundColor=\"" + writeEncodedColor(chartElement.getChart().getLegend().getBackgroundColor() ) + "\" "); 1933 pw.println(">"); 1934 writeFontElement(chartElement.getChart().getLegend().getFont(), pw ); 1935 pw.println("\t\t\t\t\t</chartLegend>"); 1936 } 1937 } 1938 1939 private void writeDataset(ChartReportElement2 chartElement, PrintWriter pw) 1940 { 1941 if (chartElement.getChart().getDataset() instanceof it.businesslogic.ireport.chart.PieDataset) 1942 { 1943 it.businesslogic.ireport.chart.PieDataset pdataset = (it.businesslogic.ireport.chart.PieDataset)chartElement.getChart().getDataset(); 1944 pw.println("\t\t\t\t\t<pieDataset>"); 1945 writeDatasetDataset( chartElement.getChart().getDataset(), pw); 1946 pw.println("\t\t\t\t\t\t<keyExpression>" + getCDATAString(pdataset.getKeyExpression() ,6 ) + "</keyExpression>"); 1947 pw.println("\t\t\t\t\t\t<valueExpression>" + getCDATAString(pdataset.getValueExpression() ,6 ) + "</valueExpression>"); 1948 if (pdataset.getLabelExpression().trim().length() > 0) 1949 { 1950 pw.println("\t\t\t\t\t\t<labelExpression>" + getCDATAString(pdataset.getLabelExpression() ,6 ) + "</labelExpression>"); 1951 } 1952 writeSectionItemHyperLinkExpressions(pdataset.getSectionHyperLink(), false, pw); 1953 pw.println("\t\t\t\t\t</pieDataset>"); 1954 } 1955 else if (chartElement.getChart().getDataset() instanceof it.businesslogic.ireport.chart.CategoryDataset) 1956 { 1957 it.businesslogic.ireport.chart.CategoryDataset pdataset = (it.businesslogic.ireport.chart.CategoryDataset)chartElement.getChart().getDataset(); 1958 pw.println("\t\t\t\t\t<categoryDataset>"); 1959 writeDatasetDataset( chartElement.getChart().getDataset(), pw); 1960 for (int i=0; i<pdataset.getCategorySeries().size(); ++i) 1961 { 1962 writeCategorySeries( (CategorySeries)pdataset.getCategorySeries().elementAt(i) , pw); 1963 } 1964 pw.println("\t\t\t\t\t</categoryDataset>"); 1965 } 1966 else if (chartElement.getChart().getDataset() instanceof it.businesslogic.ireport.chart.TimePeriodDataset) 1967 { 1968 it.businesslogic.ireport.chart.TimePeriodDataset pdataset = (it.businesslogic.ireport.chart.TimePeriodDataset)chartElement.getChart().getDataset(); 1969 pw.println("\t\t\t\t\t<timePeriodDataset>"); 1970 writeDatasetDataset( chartElement.getChart().getDataset(), pw); 1971 for (int i=0; i<pdataset.getTimePeriodSeries().size(); ++i) 1972 { 1973 writeTimePeriodSeries( (TimePeriodSeries)pdataset.getTimePeriodSeries().elementAt(i) , pw); 1974 } 1975 pw.println("\t\t\t\t\t</timePeriodDataset>"); 1976 } 1977 else if (chartElement.getChart().getDataset() instanceof it.businesslogic.ireport.chart.TimeSeriesDataset) 1978 { 1979 it.businesslogic.ireport.chart.TimeSeriesDataset pdataset = (it.businesslogic.ireport.chart.TimeSeriesDataset)chartElement.getChart().getDataset(); 1980 pw.print("\t\t\t\t\t<timeSeriesDataset"); 1981 if (!pdataset.getTimePeriod().equals("Day")) pw.println(" timePeriod=\"" + pdataset.getTimePeriod() + "\""); 1982 pw.println(">"); 1983 writeDatasetDataset( chartElement.getChart().getDataset(), pw); 1984 for (int i=0; i<pdataset.getTimeSeries().size(); ++i) 1985 { 1986 writeTimeSeries((TimeSeries)pdataset.getTimeSeries().elementAt(i) , pw); 1987 } 1988 pw.println("\t\t\t\t\t</timeSeriesDataset>"); 1989 } 1990 else if (chartElement.getChart().getDataset() instanceof it.businesslogic.ireport.chart.XYDataset) 1991 { 1992 it.businesslogic.ireport.chart.XYDataset pdataset = (it.businesslogic.ireport.chart.XYDataset)chartElement.getChart().getDataset(); 1993 pw.println("\t\t\t\t\t<xyDataset>"); 1994 writeDatasetDataset( chartElement.getChart().getDataset(), pw); 1995 for (int i=0; i<pdataset.getXYSeries().size(); ++i) 1996 { 1997 writeXYSeries((XYSeries)pdataset.getXYSeries().elementAt(i) , pw); 1998 } 1999 pw.println("\t\t\t\t\t</xyDataset>"); 2000 } 2001 else if (chartElement.getChart().getDataset() instanceof it.businesslogic.ireport.chart.XYZDataset) 2002 { 2003 it.businesslogic.ireport.chart.XYZDataset pdataset = (it.businesslogic.ireport.chart.XYZDataset)chartElement.getChart().getDataset(); 2004 pw.println("\t\t\t\t\t<xyzDataset>"); 2005 writeDatasetDataset( chartElement.getChart().getDataset(), pw); 2006 for (int i=0; i<pdataset.getXYZSeries().size(); ++i) 2007 { 2008 writeXYZSeries((XYZSeries)pdataset.getXYZSeries().elementAt(i) , pw); 2009 } 2010 pw.println("\t\t\t\t\t</xyzDataset>"); 2011 } 2012 else if (chartElement.getChart().getDataset() instanceof it.businesslogic.ireport.chart.HighLowDataset) 2013 { 2014 it.businesslogic.ireport.chart.HighLowDataset pdataset = (it.businesslogic.ireport.chart.HighLowDataset)chartElement.getChart().getDataset(); 2015 pw.println("\t\t\t\t\t<highLowDataset>"); 2016 writeDatasetDataset( chartElement.getChart().getDataset(), pw); 2017 pw.println("\t\t\t\t\t\t<seriesExpression>" + getCDATAString(pdataset.getSeriesExpression() ,6 ) + "</seriesExpression>"); 2018 pw.println("\t\t\t\t\t\t<dateExpression>" + getCDATAString(pdataset.getDateExpression() ,6 ) + "</dateExpression>"); 2019 pw.println("\t\t\t\t\t\t<highExpression>" + getCDATAString(pdataset.getHighExpression() ,6 ) + "</highExpression>"); 2020 pw.println("\t\t\t\t\t\t<lowExpression>" + getCDATAString(pdataset.getLowExpression() ,6 ) + "</lowExpression>"); 2021 pw.println("\t\t\t\t\t\t<openExpression>" + getCDATAString(pdataset.getOpenExpression() ,6 ) + "</openExpression>"); 2022 pw.println("\t\t\t\t\t\t<closeExpression>" + getCDATAString(pdataset.getCloseExpression() ,6 ) + "</closeExpression>"); 2023 pw.println("\t\t\t\t\t\t<volumeExpression>" + getCDATAString(pdataset.getVolumeExpression() ,6 ) + "</volumeExpression>"); 2024 writeSectionItemHyperLinkExpressions(pdataset.getItemHyperLink(), true, pw); 2025 pw.println("\t\t\t\t\t</highLowDataset>"); 2026 } 2027 else if (chartElement.getChart().getDataset() instanceof it.businesslogic.ireport.chart.ValueDataset) 2028 { 2029 it.businesslogic.ireport.chart.ValueDataset pdataset = (it.businesslogic.ireport.chart.ValueDataset)chartElement.getChart().getDataset(); 2030 pw.println("\t\t\t\t\t<valueDataset>"); 2031 writeDatasetDataset( chartElement.getChart().getDataset(), pw); 2032 pw.println("\t\t\t\t\t\t<valueExpression>" + getCDATAString(pdataset.getValueExpression() ,6 ) + "</valueExpression>"); 2033 pw.println("\t\t\t\t\t</valueDataset>"); 2034 } 2035 } 2036 2037 private void writeCategorySeries(CategorySeries cs, PrintWriter pw) 2038 { 2039 pw.println("\t\t\t\t\t\t<categorySeries>"); 2040 pw.println("\t\t\t\t\t\t\t<seriesExpression>" + getCDATAString( cs.getSeriesExpression() ,7 ) + "</seriesExpression>"); 2041 pw.println("\t\t\t\t\t\t\t<categoryExpression>" + getCDATAString( cs.getCategoryExpression() ,7 ) + "</categoryExpression>"); 2042 pw.println("\t\t\t\t\t\t\t<valueExpression>" + getCDATAString( cs.getValueExpression() ,7 ) + "</valueExpression>"); 2043 if (cs.getLabelExpression().trim().length() != 0) 2044 pw.println("\t\t\t\t\t\t\t<labelExpression>" + getCDATAString( cs.getLabelExpression() ,7 ) + "</labelExpression>"); 2045 writeSectionItemHyperLinkExpressions(cs.getSectionItemHyperlink(), true, pw); 2046 pw.println("\t\t\t\t\t\t</categorySeries>"); 2047 } 2048 2049 private void writeXYSeries(XYSeries cs, PrintWriter pw) 2050 { 2051 pw.println("\t\t\t\t\t\t<xySeries>"); 2052 pw.println("\t\t\t\t\t\t\t<seriesExpression>" + getCDATAString( cs.getSeriesExpression() ,7 ) + "</seriesExpression>"); 2053 pw.println("\t\t\t\t\t\t\t<xValueExpression>" + getCDATAString( cs.getXValueExpression() ,7 ) + "</xValueExpression>"); 2054 pw.println("\t\t\t\t\t\t\t<yValueExpression>" + getCDATAString( cs.getYValueExpression() ,7 ) + "</yValueExpression>"); 2055 if (cs.getLabelExpression().trim().length() != 0) 2056 pw.println("\t\t\t\t\t\t\t<labelExpression>" + getCDATAString( cs.getLabelExpression() ,7 ) + "</labelExpression>"); 2057 writeSectionItemHyperLinkExpressions(cs.getSectionItemHyperlink(), true, pw); 2058 pw.println("\t\t\t\t\t\t</xySeries>"); 2059 } 2060 2061 private void writeXYZSeries(XYZSeries cs, PrintWriter pw) 2062 { 2063 pw.println("\t\t\t\t\t\t<xyzSeries>"); 2064 pw.println("\t\t\t\t\t\t\t<seriesExpression>" + getCDATAString( cs.getSeriesExpression() ,7 ) + "</seriesExpression>"); 2065 pw.println("\t\t\t\t\t\t\t<xValueExpression>" + getCDATAString( cs.getXValueExpression() ,7 ) + "</xValueExpression>"); 2066 pw.println("\t\t\t\t\t\t\t<yValueExpression>" + getCDATAString( cs.getYValueExpression() ,7 ) + "</yValueExpression>"); 2067 if (cs.getZValueExpression().trim().length() != 0) 2068 pw.println("\t\t\t\t\t\t\t<zValueExpression>" + getCDATAString( cs.getZValueExpression() ,7 ) + "</zValueExpression>"); 2069 writeSectionItemHyperLinkExpressions(cs.getSectionItemHyperlink(), true, pw); 2070 pw.println("\t\t\t\t\t\t</xyzSeries>"); 2071 } 2072 2073 private void writeTimePeriodSeries(TimePeriodSeries cs, PrintWriter pw) 2074 { 2075 pw.println("\t\t\t\t\t\t<timePeriodSeries>"); 2076 pw.println("\t\t\t\t\t\t\t<seriesExpression>" + getCDATAString( cs.getSeriesExpression() ,7 ) + "</seriesExpression>"); 2077 pw.println("\t\t\t\t\t\t\t<startDateExpression>" + getCDATAString( cs.getStartDateExpression() ,7 ) + "</startDateExpression>"); 2078 pw.println("\t\t\t\t\t\t\t<endDateExpression>" + getCDATAString( cs.getStartDateExpression() ,7 ) + "</endDateExpression>"); 2079 pw.println("\t\t\t\t\t\t\t<valueExpression>" + getCDATAString( cs.getValueExpression() ,7 ) + "</valueExpression>"); 2080 if (cs.getLabelExpression().trim().length() != 0) 2081 pw.println("\t\t\t\t\t\t\t<labelExpression>" + getCDATAString( cs.getLabelExpression() ,7 ) + "</labelExpression>"); 2082 writeSectionItemHyperLinkExpressions(cs.getSectionItemHyperlink(), true, pw); 2083 pw.println("\t\t\t\t\t\t</timePeriodSeries>"); 2084 } 2085 2086 private void writeTimeSeries(TimeSeries cs, PrintWriter pw) 2087 { 2088 pw.println("\t\t\t\t\t\t<timeSeries>"); 2089 pw.println("\t\t\t\t\t\t\t<seriesExpression>" + getCDATAString( cs.getSeriesExpression() ,7 ) + "</seriesExpression>"); 2090 pw.println("\t\t\t\t\t\t\t<timePeriodExpression>" + getCDATAString( cs.getTimePeriodExpression() ,7 ) + "</timePeriodExpression>"); 2091 pw.println("\t\t\t\t\t\t\t<valueExpression>" + getCDATAString( cs.getValueExpression() ,7 ) + "</valueExpression>"); 2092 if (cs.getLabelExpression().trim().length() != 0) 2093 pw.println("\t\t\t\t\t\t\t<labelExpression>" + getCDATAString( cs.getLabelExpression() ,7 ) + "</labelExpression>"); 2094 writeSectionItemHyperLinkExpressions(cs.getSectionItemHyperlink(), true, pw); 2095 pw.println("\t\t\t\t\t\t</timeSeries>"); 2096 } 2097 2098 2099 2100 private void writeDatasetDataset(Dataset dataset, PrintWriter pw) 2101 { 2102 pw.print("\t\t\t\t\t\t<dataset "); 2103 if (!dataset.getResetType().equals("Report")) pw.print("resetType=\"" + dataset.getResetType() + "\" "); 2104 if (!dataset.getResetGroup().equals("")) pw.print("resetGroup=\"" + dataset.getResetGroup() + "\" "); 2105 if (!dataset.getIncrementType().equals("None")) pw.print("incrementType=\"" + dataset.getIncrementType() + "\" "); 2106 if (!dataset.getIncrementGroup().equals("")) pw.print("incrementGroup=\"" + dataset.getIncrementGroup() + "\" "); 2107 pw.println(">"); 2108 2109 if ( CompatibilitySupport.version >= CompatibilitySupport.JR125 && dataset.getIncrementWhenExpression().length() > 0) 2110 { 2111 pw.println("\t\t\t\t\t\t\t<incrementWhenExpression>" + getCDATAString(dataset.getIncrementWhenExpression().trim(), 9 ) + "</incrementWhenExpression>"); 2112 2113 } 2114 if ( CompatibilitySupport.version >= CompatibilitySupport.JR110 ) 2115 { 2116 if (dataset.getSubDataset() != null) 2117 { 2118 pw.println("\t\t\t\t\t\t\t<datasetRun subDataset=\"" + dataset.getSubDataset().getName() +"\">"); 2119 if (dataset.getParametersMapExpression() != null && 2120 dataset.getParametersMapExpression().trim().length() > 0) 2121 { 2122 pw.println("\t\t\t\t\t\t\t\t<parametersMapExpression>" + getCDATAString(dataset.getParametersMapExpression().trim(), 9 ) + "</parametersMapExpression>"); 2123 } 2124 2125 2126 Enumeration e = dataset.getSubreportParameters().elements(); 2127 while (e.hasMoreElements()) { 2128 JRSubreportParameter je = (JRSubreportParameter)e.nextElement(); 2129 pw.println("\t\t\t\t\t\t\t\t<datasetParameter name=\""+ je.getName() +"\">"); 2130 pw.print("\t\t\t\t\t\t\t\t\t<datasetParameterExpression"); 2131 pw.println(">"+getCDATAString(je.getExpression(),9)+"</datasetParameterExpression>"); 2132 pw.println("\t\t\t\t\t\t\t\t</datasetParameter>"); 2133 } 2134 2135 if (dataset.isUseConnection() && dataset.getConnectionExpression().trim().length() > 0 ) { 2136 pw.print("\t\t\t\t\t\t\t\t<connectionExpression"); 2137 pw.println(">"+getCDATAString(dataset.getConnectionExpression(),8 )+ "</connectionExpression>"); 2138 } 2139 else if (!dataset.isUseConnection() && dataset.getDataSourceExpression().length() > 0) { 2140 pw.print("\t\t\t\t\t<dataSourceExpression"); 2141 pw.println(">"+getCDATAString(dataset.getDataSourceExpression(),8 )+"</dataSourceExpression>"); 2142 } 2143 2144 pw.println("\t\t\t\t\t\t\t</datasetRun>"); 2145 } 2146 } 2147 2148 pw.println("\t\t\t\t\t\t</dataset>"); 2149 } 2150 2151 private void writePlot(ChartReportElement2 chartElement, PrintWriter pw) 2152 { 2153 if (chartElement.getChart().getPlot() instanceof it.businesslogic.ireport.chart.PiePlot) 2154 { 2155 it.businesslogic.ireport.chart.PiePlot plot = (it.businesslogic.ireport.chart.PiePlot)chartElement.getChart().getPlot(); 2156 pw.println("\t\t\t\t\t<piePlot>"); 2157 writePlotPlot( chartElement, pw); 2158 pw.println("\t\t\t\t\t</piePlot>"); 2159 } 2160 else if (chartElement.getChart().getPlot() instanceof it.businesslogic.ireport.chart.Pie3DPlot) 2161 { 2162 it.businesslogic.ireport.chart.Pie3DPlot plot = (it.businesslogic.ireport.chart.Pie3DPlot)chartElement.getChart().getPlot(); 2163 pw.print("\t\t\t\t\t<pie3DPlot "); 2164 if (plot.getDepthFactor() != 0.2) pw.print("depthFactor=\"" + plot.getDepthFactor() + "\" "); 2165 pw.println(">"); 2166 writePlotPlot( chartElement, pw); 2167 pw.println("\t\t\t\t\t</pie3DPlot>"); 2168 } 2169 else if (chartElement.getChart().getPlot() instanceof it.businesslogic.ireport.chart.BarPlot) 2170 { 2171 it.businesslogic.ireport.chart.BarPlot plot = (it.businesslogic.ireport.chart.BarPlot)chartElement.getChart().getPlot(); 2172 pw.print("\t\t\t\t\t<barPlot "); 2173 if (plot.isShowLabels()) pw.print("isShowLabels=\"" + plot.isShowLabels() + "\" "); 2174 if (!plot.isShowTickMarks()) pw.print("isShowTickMarks=\"" + plot.isShowTickMarks() + "\" "); 2175 if (!plot.isShowTickLabels()) pw.print("isShowTickLabels=\"" + plot.isShowTickLabels() + "\" "); 2176 pw.println(">"); 2177 2178 writePlotPlot( chartElement, pw); 2179 2180 if (plot.getCategoryAxisLabelExpression().trim().length() != 0) 2181 pw.println("\t\t\t\t\t<categoryAxisLabelExpression>" + getCDATAString(plot.getCategoryAxisLabelExpression() ,6 ) + "</categoryAxisLabelExpression>"); 2182 2183 if ( CompatibilitySupport.version >= CompatibilitySupport.JR127 ) 2184 { 2185 writeAxisFormat("categoryAxisFormat", plot.getCategoryAxisFormat() ,pw); 2186 } 2187 2188 if (plot.getValueAxisLabelExpression().trim().length() != 0) 2189 pw.println("\t\t\t\t\t<valueAxisLabelExpression>" + getCDATAString(plot.getValueAxisLabelExpression() ,6 ) + "</valueAxisLabelExpression>"); 2190 2191 if ( CompatibilitySupport.version >= CompatibilitySupport.JR127 ) 2192 { 2193 writeAxisFormat("valueAxisFormat", plot.getValueAxisFormat() ,pw); 2194 } 2195 2196 pw.println("\t\t\t\t\t</barPlot>"); 2197 } 2198 else if (chartElement.getChart().getPlot() instanceof it.businesslogic.ireport.chart.Bar3DPlot) 2199 { 2200 it.businesslogic.ireport.chart.Bar3DPlot plot = (it.businesslogic.ireport.chart.Bar3DPlot)chartElement.getChart().getPlot(); 2201 pw.print("\t\t\t\t\t<bar3DPlot "); 2202 if (plot.isShowLabels()) pw.print("isShowLabels=\"" + plot.isShowLabels() + "\" "); 2203 if (plot.getXOffset() != org.jfree.chart.renderer.category.BarRenderer3D.DEFAULT_X_OFFSET) pw.print("xOffset=\"" + plot.getXOffset() + "\" "); 2204 if (plot.getYOffset() != org.jfree.chart.renderer.category.BarRenderer3D.DEFAULT_Y_OFFSET) pw.print("yOffset=\"" + plot.getYOffset() + "\" "); 2205 pw.println(">"); 2206 2207 writePlotPlot( chartElement, pw); 2208 2209 if (plot.getCategoryAxisLabelExpression().trim().length() != 0) 2210 pw.println("\t\t\t\t\t<categoryAxisLabelExpression>" + getCDATAString(plot.getCategoryAxisLabelExpression() ,6 ) + "</categoryAxisLabelExpression>"); 2211 2212 if ( CompatibilitySupport.version >= CompatibilitySupport.JR127 ) 2213 { 2214 writeAxisFormat("categoryAxisFormat", plot.getCategoryAxisFormat() ,pw); 2215 } 2216 2217 if (plot.getValueAxisLabelExpression().trim().length() != 0) 2218 pw.println("\t\t\t\t\t<valueAxisLabelExpression>" + getCDATAString(plot.getValueAxisLabelExpression() ,6 ) + "</valueAxisLabelExpression>"); 2219 2220 2221 if ( CompatibilitySupport.version >= CompatibilitySupport.JR127 ) 2222 { 2223 writeAxisFormat("valueAxisFormat", plot.getValueAxisFormat() ,pw); 2224 } 2225 2226 pw.println("\t\t\t\t\t</bar3DPlot>"); 2227 } 2228 else if (chartElement.getChart().getPlot() instanceof it.businesslogic.ireport.chart.LinePlot) 2229 { 2230 it.businesslogic.ireport.chart.LinePlot plot = (it.businesslogic.ireport.chart.LinePlot)chartElement.getChart().getPlot(); 2231 pw.print("\t\t\t\t\t<linePlot "); 2232 if (!plot.isShowLines()) pw.print("isShowLines=\"" + plot.isShowLines() + "\" "); 2233 if (!plot.isShowShapes()) pw.print("isShowShapes=\"" + plot.isShowShapes() + "\" "); 2234 pw.println(">"); 2235 2236 writePlotPlot( chartElement, pw); 2237 2238 if (plot.getCategoryAxisLabelExpression().trim().length() != 0) 2239 pw.println("\t\t\t\t\t<categoryAxisLabelExpression>" + getCDATAString(plot.getCategoryAxisLabelExpression() ,6 ) + "</categoryAxisLabelExpression>"); 2240 2241 if ( CompatibilitySupport.version >= CompatibilitySupport.JR127 ) 2242 { 2243 writeAxisFormat("categoryAxisFormat", plot.getCategoryAxisFormat() ,pw); 2244 } 2245 2246 if (plot.getValueAxisLabelExpression().trim().length() != 0) 2247 pw.println("\t\t\t\t\t<valueAxisLabelExpression>" + getCDATAString(plot.getValueAxisLabelExpression() ,6 ) + "</valueAxisLabelExpression>"); 2248 2249 if ( CompatibilitySupport.version >= CompatibilitySupport.JR127 ) 2250 { 2251 writeAxisFormat("valueAxisFormat", plot.getValueAxisFormat() ,pw); 2252 } 2253 2254 pw.println("\t\t\t\t\t</linePlot>"); 2255 } 2256 else if (chartElement.getChart().getPlot() instanceof it.businesslogic.ireport.chart.AreaPlot) 2257 { 2258 it.businesslogic.ireport.chart.AreaPlot plot = (it.businesslogic.ireport.chart.AreaPlot)chartElement.getChart().getPlot(); 2259 pw.print("\t\t\t\t\t<areaPlot>"); 2260 2261 writePlotPlot( chartElement, pw); 2262 2263 if (plot.getCategoryAxisLabelExpression().trim().length() != 0) 2264 pw.println("\t\t\t\t\t<categoryAxisLabelExpression>" + getCDATAString(plot.getCategoryAxisLabelExpression() ,6 ) + "</categoryAxisLabelExpression>"); 2265 2266 if ( CompatibilitySupport.version >= CompatibilitySupport.JR127 ) 2267 { 2268 writeAxisFormat("categoryAxisFormat", plot.getCategoryAxisFormat() ,pw); 2269 } 2270 2271 2272 if (plot.getValueAxisLabelExpression().trim().length() != 0) 2273 pw.println("\t\t\t\t\t<valueAxisLabelExpression>" + getCDATAString(plot.getValueAxisLabelExpression() ,6 ) + "</valueAxisLabelExpression>"); 2274 2275 if ( CompatibilitySupport.version >= CompatibilitySupport.JR127 ) 2276 { 2277 writeAxisFormat("valueAxisFormat", plot.getValueAxisFormat() ,pw); 2278 } 2279 2280 pw.println("\t\t\t\t\t</areaPlot>"); 2281 } 2282 else if (chartElement.getChart().getPlot() instanceof it.businesslogic.ireport.chart.ScatterPlot) 2283 { 2284 it.businesslogic.ireport.chart.ScatterPlot plot = (it.businesslogic.ireport.chart.ScatterPlot)chartElement.getChart().getPlot(); 2285 pw.print("\t\t\t\t\t<scatterPlot "); 2286 if (!plot.isShowLines()) pw.print("isShowLines=\"" + plot.isShowLines() + "\" "); 2287 if (!plot.isShowShapes()) pw.print("isShowShapes=\"" + plot.isShowShapes() + "\" "); 2288 pw.println(">"); 2289 2290 writePlotPlot( chartElement, pw); 2291 2292 if (plot.getXAxisLabelExpression().trim().length() != 0) 2293 pw.println("\t\t\t\t\t<xAxisLabelExpression>" + getCDATAString(plot.getXAxisLabelExpression() ,6 ) + "</xAxisLabelExpression>"); 2294 2295 if ( CompatibilitySupport.version >= CompatibilitySupport.JR127 ) 2296 { 2297 writeAxisFormat("xAxisFormat", plot.getXAxisFormat() ,pw); 2298 } 2299 2300 if (plot.getYAxisLabelExpression().trim().length() != 0) 2301 pw.println("\t\t\t\t\t<yAxisLabelExpression>" + getCDATAString(plot.getYAxisLabelExpression() ,6 ) + "</yAxisLabelExpression>"); 2302 2303 if ( CompatibilitySupport.version >= CompatibilitySupport.JR127 ) 2304 { 2305 writeAxisFormat("yAxisFormat", plot.getYAxisFormat() ,pw); 2306 } 2307 2308 pw.println("\t\t\t\t\t</scatterPlot>"); 2309 } 2310 else if (chartElement.getChart().getPlot() instanceof it.businesslogic.ireport.chart.BubblePlot) 2311 { 2312 it.businesslogic.ireport.chart.BubblePlot plot = (it.businesslogic.ireport.chart.BubblePlot)chartElement.getChart().getPlot(); 2313 pw.print("\t\t\t\t\t<bubblePlot "); 2314 if (!plot.getScaleType().equals("RangeAxis") ) pw.print("scaleType=\"" + plot.getScaleType() + "\" "); 2315 pw.println(">"); 2316 2317 writePlotPlot( chartElement, pw); 2318 2319 if (plot.getXAxisLabelExpression().trim().length() != 0) 2320 pw.println("\t\t\t\t\t<xAxisLabelExpression>" + getCDATAString(plot.getXAxisLabelExpression() ,6 ) + "</xAxisLabelExpression>"); 2321 2322 if ( CompatibilitySupport.version >= CompatibilitySupport.JR127 ) 2323 { 2324 writeAxisFormat("xAxisFormat", plot.getXAxisFormat() ,pw); 2325 } 2326 2327 2328 if (plot.getYAxisLabelExpression().trim().length() != 0) 2329 pw.println("\t\t\t\t\t<yAxisLabelExpression>" + getCDATAString(plot.getYAxisLabelExpression() ,6 ) + "</yAxisLabelExpression>"); 2330 2331 if ( CompatibilitySupport.version >= CompatibilitySupport.JR127 ) 2332 { 2333 writeAxisFormat("yAxisFormat", plot.getYAxisFormat() ,pw); 2334 } 2335 2336 pw.println("\t\t\t\t\t</bubblePlot>"); 2337 } 2338 else if (chartElement.getChart().getPlot() instanceof it.businesslogic.ireport.chart.TimeSeriesPlot) 2339 { 2340 it.businesslogic.ireport.chart.TimeSeriesPlot plot = (it.businesslogic.ireport.chart.TimeSeriesPlot)chartElement.getChart().getPlot(); 2341 pw.print("\t\t\t\t\t<timeSeriesPlot "); 2342 if (!plot.isShowLines()) pw.print("isShowLines=\"" + plot.isShowLines() + "\" "); 2343 if (!plot.isShowShapes()) pw.print("isShowShapes=\"" + plot.isShowShapes() + "\" "); 2344 pw.println(">"); 2345 2346 writePlotPlot( chartElement, pw); 2347 2348 if (plot.getTimeAxisLabelExpression().trim().length() != 0) 2349 pw.println("\t\t\t\t\t<timeAxisLabelExpression>" + getCDATAString(plot.getTimeAxisLabelExpression() ,6 ) + "</timeAxisLabelExpression>"); 2350 2351 if ( CompatibilitySupport.version >= CompatibilitySupport.JR127 ) 2352 { 2353 writeAxisFormat("timeAxisFormat", plot.getTimeAxisFormat() ,pw); 2354 } 2355 2356 if (plot.getValueAxisLabelExpression().trim().length() != 0) 2357 pw.println("\t\t\t\t\t<valueAxisLabelExpression>" + getCDATAString(plot.getValueAxisLabelExpression() ,6 ) + "</valueAxisLabelExpression>"); 2358 2359 if ( CompatibilitySupport.version >= CompatibilitySupport.JR127 ) 2360 { 2361 writeAxisFormat("valueAxisFormat", plot.getValueAxisFormat() ,pw); 2362 } 2363 2364 pw.println("\t\t\t\t\t</timeSeriesPlot>"); 2365 } 2366 else if (chartElement.getChart().getPlot() instanceof it.businesslogic.ireport.chart.HighLowPlot) 2367 { 2368 it.businesslogic.ireport.chart.HighLowPlot plot = (it.businesslogic.ireport.chart.HighLowPlot)chartElement.getChart().getPlot(); 2369 pw.print("\t\t\t\t\t<highLowPlot "); 2370 if (!plot.isShowCloseTicks()) pw.print("isShowCloseTicks=\"" + plot.isShowCloseTicks() + "\" "); 2371 if (!plot.isShowOpenTicks()) pw.print("isShowOpenTicks=\"" + plot.isShowOpenTicks() + "\" "); 2372 pw.println(">"); 2373 2374 writePlotPlot( chartElement, pw); 2375 2376 if (plot.getTimeAxisLabelExpression().trim().length() != 0) 2377 pw.println("\t\t\t\t\t<timeAxisLabelExpression>" + getCDATAString(plot.getTimeAxisLabelExpression() ,6 ) + "</timeAxisLabelExpression>"); 2378 2379 if ( CompatibilitySupport.version >= CompatibilitySupport.JR127 ) 2380 { 2381 writeAxisFormat("timeAxisFormat", plot.getTimeAxisFormat() ,pw); 2382 } 2383 2384 if (plot.getValueAxisLabelExpression().trim().length() != 0) 2385 pw.println("\t\t\t\t\t<valueAxisLabelExpression>" + getCDATAString(plot.getValueAxisLabelExpression() ,6 ) + "</valueAxisLabelExpression>"); 2386 2387 if ( CompatibilitySupport.version >= CompatibilitySupport.JR127 ) 2388 { 2389 writeAxisFormat("valueAxisFormat", plot.getValueAxisFormat() ,pw); 2390 } 2391 2392 pw.println("\t\t\t\t\t</highLowPlot>"); 2393 } 2394 else if (chartElement.getChart().getPlot() instanceof it.businesslogic.ireport.chart.CandlestickPlot) 2395 { 2396 it.businesslogic.ireport.chart.CandlestickPlot plot = (it.businesslogic.ireport.chart.CandlestickPlot)chartElement.getChart().getPlot(); 2397 pw.print("\t\t\t\t\t<candlestickPlot "); 2398 if (!plot.isShowVolume()) pw.print("isShowVolume=\"" + plot.isShowVolume() + "\" "); 2399 pw.println(">"); 2400 2401 writePlotPlot( chartElement, pw); 2402 2403 if (plot.getTimeAxisLabelExpression().trim().length() != 0) 2404 pw.println("\t\t\t\t\t<timeAxisLabelExpression>" + getCDATAString(plot.getTimeAxisLabelExpression() ,6 ) + "</timeAxisLabelExpression>"); 2405 2406 if ( CompatibilitySupport.version >= CompatibilitySupport.JR127 ) 2407 { 2408 writeAxisFormat("timeAxisFormat", plot.getTimeAxisFormat() ,pw); 2409 } 2410 2411 if (plot.getValueAxisLabelExpression().trim().length() != 0) 2412 pw.println("\t\t\t\t\t<valueAxisLabelExpression>" + getCDATAString(plot.getValueAxisLabelExpression() ,6 ) + "</valueAxisLabelExpression>"); 2413 2414 if ( CompatibilitySupport.version >= CompatibilitySupport.JR127 ) 2415 { 2416 writeAxisFormat("valueAxisFormat", plot.getValueAxisFormat() ,pw); 2417 } 2418 pw.println("\t\t\t\t\t</candlestickPlot>"); 2419 } 2420 else if (chartElement.getChart().getPlot() instanceof it.businesslogic.ireport.chart.MeterPlot 2421 && CompatibilitySupport.version >= CompatibilitySupport.JR127) 2422 { 2423 it.businesslogic.ireport.chart.MeterPlot plot = (it.businesslogic.ireport.chart.MeterPlot)chartElement.getChart().getPlot(); 2424 pw.print("\t\t\t\t\t<meterPlot "); 2425 2426 if (plot.getShape() != null && !plot.getShape().equals("pie")) pw.print("shape=\"" + plot.getShape() + "\" "); 2427 if (plot.getAngle() != 180) pw.print("angle=\"" + plot.getAngle() + "\" "); 2428 if (plot.getUnits() != null && plot.getUnits().trim().length() > 0) pw.print("units=\"" + Misc.xmlEscape( plot.getUnits() ) + "\" "); 2429 if (plot.getTickInterval() != 10) pw.print("tickInterval=\"" + plot.getTickInterval() + "\" "); 2430 if (plot.getMeterColor() != null) pw.print("meterColor=\"" + writeEncodedColor(plot.getMeterColor() ) + "\" "); 2431 if (plot.getNeedleColor() != null) pw.print("needleColor=\"" + writeEncodedColor(plot.getNeedleColor() ) + "\" "); 2432 if (plot.getTickColor() != null) pw.print("tickColor=\"" + writeEncodedColor(plot.getTickColor() ) + "\" "); 2433 pw.println(">"); 2434 2435 writePlotPlot( chartElement, pw); 2436 writeValueDisplay( plot.getValueDisplay(), pw); 2437 writeDataRange( plot.getDataRange(), pw); 2438 2439 for (int interval_c = 0; interval_c < plot.getMeterIntervals().size(); ++interval_c) 2440 { 2441 writeMeterInterval( (MeterInterval) plot.getMeterIntervals().get(interval_c), pw); 2442 } 2443 2444 pw.println("\t\t\t\t\t</meterPlot>"); 2445 } 2446 else if (chartElement.getChart().getPlot() instanceof it.businesslogic.ireport.chart.ThermometerPlot 2447 && CompatibilitySupport.version >= CompatibilitySupport.JR127) 2448 { 2449 it.businesslogic.ireport.chart.ThermometerPlot plot = (it.businesslogic.ireport.chart.ThermometerPlot)chartElement.getChart().getPlot(); 2450 pw.print("\t\t\t\t\t<thermometerPlot "); 2451 2452 if (plot.getValueLocation() != null && !plot.getValueLocation().equals("bulb")) pw.print("valueLocation=\"" + plot.getValueLocation() + "\" "); 2453 if (plot.isShowValueLines() != false) pw.print("isShowValueLines=\"" + plot.isShowValueLines() + "\" "); 2454 if (plot.getMercuryColor() != null) pw.print("mercuryColor=\"" + writeEncodedColor(plot.getMercuryColor() ) + "\" "); 2455 pw.println(">"); 2456 2457 writePlotPlot( chartElement, pw); 2458 writeValueDisplay( plot.getValueDisplay(), pw); 2459 writeDataRange( plot.getDataRange(), pw); 2460 writeDataRange("lowRange", plot.getLowRange(), pw); 2461 writeDataRange("mediumRange", plot.getMediumRange(), pw); 2462 writeDataRange("highRange", plot.getHighRange(), pw); 2463 2464 pw.println("\t\t\t\t\t</thermometerPlot>"); 2465 } 2466 else if (chartElement.getChart().getPlot() instanceof it.businesslogic.ireport.chart.MultiAxisPlot 2467 && CompatibilitySupport.version >= CompatibilitySupport.JR127) 2468 { 2469 it.businesslogic.ireport.chart.MultiAxisPlot plot = (it.businesslogic.ireport.chart.MultiAxisPlot)chartElement.getChart().getPlot(); 2470 pw.println("\t\t\t\t\t<multiAxisPlot>"); 2471 2472 writePlotPlot( chartElement, pw); 2473 2474 for (int axis_c = 0; axis_c < plot.getAxis().size(); ++axis_c) 2475 { 2476 writeAxis( (Axis) plot.getAxis().get(axis_c), pw); 2477 } 2478 2479 2480 pw.println("\t\t\t\t\t</multiAxisPlot>"); 2481 } 2482 } 2483 2484 2485 2486 private void writePlotPlot(ChartReportElement2 chartElement, PrintWriter pw) 2487 { 2488 pw.print("\t\t\t\t\t\t<plot "); 2489 if (chartElement.getChart().getPlot().getBackcolor() != null) pw.print("backcolor=\"" + writeEncodedColor(chartElement.getChart().getPlot().getBackcolor() ) + "\" "); 2490 if (!chartElement.getChart().getPlot().getOrientation().equals("Vertical")) pw.print("orientation=\"" + chartElement.getChart().getPlot().getOrientation() + "\" "); 2491 if (chartElement.getChart().getPlot().getBackgroundAlpha() != 1.0) pw.print("backgroundAlpha=\"" + chartElement.getChart().getPlot().getBackgroundAlpha() + "\" "); 2492 if (chartElement.getChart().getPlot().getBackgroundAlpha() != 1.0) pw.print("foregroundAlpha=\"" + chartElement.getChart().getPlot().getForegroundAlpha() + "\" "); 2493 if (chartElement.getChart().getPlot().getLabelRotation() != 0 && CompatibilitySupport.version >= CompatibilitySupport.JR127) 2494 { 2495 pw.print("labelRotation=\"" + chartElement.getChart().getPlot().getLabelRotation() + "\" "); 2496 } 2497 2498 if (chartElement.getChart().getPlot().getSeriesColors().size() > 0 && CompatibilitySupport.version >= CompatibilitySupport.JR127) 2499 { 2500 pw.println(">"); 2501 2502 for (int i=0; i<chartElement.getChart().getPlot().getSeriesColors().size(); ++i) 2503 { 2504 SeriesColor sc = (SeriesColor)chartElement.getChart().getPlot().getSeriesColors().get(i); 2505 pw.println("\t\t\t\t\t\t\t<seriesColor seriesOrder=\"" + sc.getSeriesOrder() + "\" color=\"" + writeEncodedColor(sc.getColor() ) +"\"/>"); 2506 2507 } 2508 2509 2510 pw.println("</plot>"); 2511 } 2512 else 2513 { 2514 2515 pw.println("/>"); 2516 } 2517 } 2518 2519 private void writeAxisFormat(String axisName, AxisFormat axisFormat, PrintWriter pw) { 2520 2521 if (axisFormat == null) return; 2522 pw.println("\t\t\t\t\t\t<" + axisName + ">"); 2523 pw.print("\t\t\t\t\t\t\t<axisFormat "); 2524 if (axisFormat.getLabelColor() != null) pw.print("labelColor=\"" + writeEncodedColor(axisFormat.getLabelColor() ) + "\" "); 2525 if (axisFormat.getTickLabelColor() != null) pw.print("tickLabelColor=\"" + writeEncodedColor(axisFormat.getTickLabelColor() ) + "\" "); 2526 if (axisFormat.getTickLabelMask().trim().length() > 0) pw.print("tickLabelMask=\"" + Misc.xmlEscape( axisFormat.getTickLabelMask()) + "\" "); 2527 if (axisFormat.getAxisLineColor() != null) pw.print("axisLineColor=\"" + writeEncodedColor(axisFormat.getAxisLineColor() ) + "\" "); 2528 pw.println(">"); 2529 2530 if (axisFormat.getLabelFont() != null) 2531 { 2532 pw.println("\t\t\t\t\t\t\t\t<labelFont>"); 2533 writeFontElement(axisFormat.getLabelFont(), pw ); 2534 pw.println("\t\t\t\t\t\t\t\t</labelFont>"); 2535 } 2536 if (axisFormat.getLabelFont() != null) 2537 { 2538 pw.println("\t\t\t\t\t\t\t\t<tickLabelFont>"); 2539 writeFontElement(axisFormat.getTickLabelFont(), pw ); 2540 pw.println("\t\t\t\t\t\t\t\t</tickLabelFont>"); 2541 } 2542 2543 pw.println("\t\t\t\t\t\t\t</axisFormat>"); 2544 pw.println("\t\t\t\t\t\t</" + axisName + ">"); 2545 } 2546 2547 private void writeValueDisplay(ValueDisplay valueDisplay, PrintWriter pw) { 2548 2549 if (valueDisplay == null) return; 2550 2551 pw.print("\t\t\t\t\t\t\t<valueDisplay "); 2552 if (valueDisplay.getColor() != null) pw.print("color=\"" + writeEncodedColor(valueDisplay.getColor() ) + "\" "); 2553 if (valueDisplay.getMask().trim().length() > 0) pw.print("mask=\"" + Misc.xmlEscape( valueDisplay.getMask()) + "\" "); 2554 pw.println(">"); 2555 writeFontElement(valueDisplay.getFont(), pw ); 2556 pw.println("\t\t\t\t\t\t\t</valueDisplay>"); 2557 } 2558 2559 private void writeDataRange(DataRange dataRange, PrintWriter pw) { 2560 writeDataRange(null, dataRange, pw); 2561 } 2562 2563 private void writeDataRange(String outTagName, DataRange dataRange, PrintWriter pw) { 2564 2565 if (dataRange == null) return; 2566 2567 if (outTagName != null) pw.println("\t\t\t\t\t\t<" + outTagName + ">"); 2568 2569 pw.println("\t\t\t\t\t\t\t<dataRange>"); 2570 pw.println("\t\t\t\t\t\t\t\t<lowExpression>" + getCDATAString(dataRange.getLowExpression() ,8 ) + "</lowExpression>"); 2571 pw.println("\t\t\t\t\t\t\t\t<highExpression>" + getCDATAString(dataRange.getHighExpression() ,8 ) + "</highExpression>"); 2572 pw.println("\t\t\t\t\t\t\t</dataRange>"); 2573 2574 if (outTagName != null) pw.println("\t\t\t\t\t\t</" + outTagName + ">"); 2575 } 2576 2577 private void writeMeterInterval(MeterInterval meterInterval, PrintWriter pw) { 2578 2579 if (meterInterval == null) return; 2580 2581 pw.print("\t\t\t\t\t\t\t<meterInterval "); 2582 2583 if (meterInterval.getLabel().trim().length() > 0) pw.print("label=\"" + Misc.xmlEscape( meterInterval.getLabel()) + "\" "); 2584 if (meterInterval.getColor() != null) pw.print("color=\"" + writeEncodedColor(meterInterval.getColor() ) + "\" "); 2585 if (meterInterval.getAlpha() != 1) pw.print("alpha=\"" + meterInterval.getAlpha() + "\" "); 2586 2587 pw.println(">"); 2588 2589 writeDataRange(meterInterval.getDataRange(), pw ); 2590 2591 pw.println("\t\t\t\t\t\t\t</meterInterval>"); 2592 } 2593 2594 private void writeAxis(Axis axis, PrintWriter pw) 2595 { 2596 2597 if (axis == null) return; 2598 2599 pw.print("\t\t\t\t\t\t\t<axis "); 2600 if (!axis.getPosition().equals("leftOrTop")) pw.print("position=\"" + Misc.xmlEscape( axis.getPosition()) + "\" "); 2601 pw.println(">"); 2602 2603 writeChartElement(axis.getChartReportElement(), pw ); 2604 2605 pw.println("\t\t\t\t\t\t\t</axis>"); 2606 } 2607 2608 public Report getReport() { 2609 return report; 2610 } 2611 2612 public void setReport(Report report) { 2613 this.report = report; 2614 } 2615 2616} 2617 | Popular Tags |