0001: /*
0002: * ============================================================================
0003: * GNU Lesser General Public License
0004: * ============================================================================
0005: *
0006: * JasperReports - Free Java report-generating library.
0007: * Copyright (C) 2001-2006 JasperSoft Corporation http://www.jaspersoft.com
0008: *
0009: * This library is free software; you can redistribute it and/or
0010: * modify it under the terms of the GNU Lesser General Public
0011: * License as published by the Free Software Foundation; either
0012: * version 2.1 of the License, or (at your option) any later version.
0013: *
0014: * This library is distributed in the hope that it will be useful,
0015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
0016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0017: * Lesser General Public License for more details.
0018: *
0019: * You should have received a copy of the GNU Lesser General Public
0020: * License along with this library; if not, write to the Free Software
0021: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
0022: *
0023: * JasperSoft Corporation
0024: * 303 Second Street, Suite 450 North
0025: * San Francisco, CA 94107
0026: * http://www.jaspersoft.com
0027: */
0028: package net.sf.jasperreports.engine.xml;
0029:
0030: import java.awt.Color;
0031: import java.io.FileOutputStream;
0032: import java.io.IOException;
0033: import java.io.OutputStream;
0034: import java.io.OutputStreamWriter;
0035: import java.io.StringWriter;
0036: import java.io.Writer;
0037: import java.util.HashMap;
0038: import java.util.HashSet;
0039: import java.util.Iterator;
0040: import java.util.List;
0041: import java.util.Map;
0042: import java.util.Set;
0043: import java.util.SortedSet;
0044:
0045: import net.sf.jasperreports.charts.JRAreaPlot;
0046: import net.sf.jasperreports.charts.JRBar3DPlot;
0047: import net.sf.jasperreports.charts.JRBarPlot;
0048: import net.sf.jasperreports.charts.JRBubblePlot;
0049: import net.sf.jasperreports.charts.JRCandlestickPlot;
0050: import net.sf.jasperreports.charts.JRCategoryDataset;
0051: import net.sf.jasperreports.charts.JRCategorySeries;
0052: import net.sf.jasperreports.charts.JRChartAxis;
0053: import net.sf.jasperreports.charts.JRDataRange;
0054: import net.sf.jasperreports.charts.JRHighLowDataset;
0055: import net.sf.jasperreports.charts.JRHighLowPlot;
0056: import net.sf.jasperreports.charts.JRLinePlot;
0057: import net.sf.jasperreports.charts.JRMeterPlot;
0058: import net.sf.jasperreports.charts.JRMultiAxisPlot;
0059: import net.sf.jasperreports.charts.JRPie3DPlot;
0060: import net.sf.jasperreports.charts.JRPieDataset;
0061: import net.sf.jasperreports.charts.JRPiePlot;
0062: import net.sf.jasperreports.charts.JRScatterPlot;
0063: import net.sf.jasperreports.charts.JRThermometerPlot;
0064: import net.sf.jasperreports.charts.JRTimePeriodDataset;
0065: import net.sf.jasperreports.charts.JRTimePeriodSeries;
0066: import net.sf.jasperreports.charts.JRTimeSeries;
0067: import net.sf.jasperreports.charts.JRTimeSeriesDataset;
0068: import net.sf.jasperreports.charts.JRTimeSeriesPlot;
0069: import net.sf.jasperreports.charts.JRValueDataset;
0070: import net.sf.jasperreports.charts.JRValueDisplay;
0071: import net.sf.jasperreports.charts.JRXyDataset;
0072: import net.sf.jasperreports.charts.JRXySeries;
0073: import net.sf.jasperreports.charts.JRXyzDataset;
0074: import net.sf.jasperreports.charts.JRXyzSeries;
0075: import net.sf.jasperreports.charts.util.JRMeterInterval;
0076: import net.sf.jasperreports.charts.xml.JRChartAxisFactory;
0077: import net.sf.jasperreports.charts.xml.JRMeterPlotFactory;
0078: import net.sf.jasperreports.charts.xml.JRThermometerPlotFactory;
0079: import net.sf.jasperreports.crosstabs.JRCellContents;
0080: import net.sf.jasperreports.crosstabs.JRCrosstab;
0081: import net.sf.jasperreports.crosstabs.JRCrosstabBucket;
0082: import net.sf.jasperreports.crosstabs.JRCrosstabCell;
0083: import net.sf.jasperreports.crosstabs.JRCrosstabColumnGroup;
0084: import net.sf.jasperreports.crosstabs.JRCrosstabDataset;
0085: import net.sf.jasperreports.crosstabs.JRCrosstabMeasure;
0086: import net.sf.jasperreports.crosstabs.JRCrosstabParameter;
0087: import net.sf.jasperreports.crosstabs.JRCrosstabRowGroup;
0088: import net.sf.jasperreports.crosstabs.design.JRDesignCrosstab;
0089: import net.sf.jasperreports.crosstabs.fill.calculation.BucketDefinition;
0090: import net.sf.jasperreports.crosstabs.xml.JRCellContentsFactory;
0091: import net.sf.jasperreports.crosstabs.xml.JRCrosstabBucketFactory;
0092: import net.sf.jasperreports.crosstabs.xml.JRCrosstabCellFactory;
0093: import net.sf.jasperreports.crosstabs.xml.JRCrosstabColumnGroupFactory;
0094: import net.sf.jasperreports.crosstabs.xml.JRCrosstabDatasetFactory;
0095: import net.sf.jasperreports.crosstabs.xml.JRCrosstabFactory;
0096: import net.sf.jasperreports.crosstabs.xml.JRCrosstabGroupFactory;
0097: import net.sf.jasperreports.crosstabs.xml.JRCrosstabMeasureFactory;
0098: import net.sf.jasperreports.crosstabs.xml.JRCrosstabParameterFactory;
0099: import net.sf.jasperreports.crosstabs.xml.JRCrosstabRowGroupFactory;
0100: import net.sf.jasperreports.engine.JRAnchor;
0101: import net.sf.jasperreports.engine.JRBand;
0102: import net.sf.jasperreports.engine.JRBox;
0103: import net.sf.jasperreports.engine.JRBreak;
0104: import net.sf.jasperreports.engine.JRChart;
0105: import net.sf.jasperreports.engine.JRChartDataset;
0106: import net.sf.jasperreports.engine.JRChartPlot;
0107: import net.sf.jasperreports.engine.JRChild;
0108: import net.sf.jasperreports.engine.JRDataset;
0109: import net.sf.jasperreports.engine.JRDatasetParameter;
0110: import net.sf.jasperreports.engine.JRDatasetRun;
0111: import net.sf.jasperreports.engine.JRElement;
0112: import net.sf.jasperreports.engine.JRElementDataset;
0113: import net.sf.jasperreports.engine.JRElementGroup;
0114: import net.sf.jasperreports.engine.JREllipse;
0115: import net.sf.jasperreports.engine.JRException;
0116: import net.sf.jasperreports.engine.JRExpression;
0117: import net.sf.jasperreports.engine.JRField;
0118: import net.sf.jasperreports.engine.JRFont;
0119: import net.sf.jasperreports.engine.JRFrame;
0120: import net.sf.jasperreports.engine.JRGraphicElement;
0121: import net.sf.jasperreports.engine.JRGroup;
0122: import net.sf.jasperreports.engine.JRHyperlink;
0123: import net.sf.jasperreports.engine.JRHyperlinkParameter;
0124: import net.sf.jasperreports.engine.JRImage;
0125: import net.sf.jasperreports.engine.JRLine;
0126: import net.sf.jasperreports.engine.JRParameter;
0127: import net.sf.jasperreports.engine.JRPropertiesHolder;
0128: import net.sf.jasperreports.engine.JRPropertiesMap;
0129: import net.sf.jasperreports.engine.JRQuery;
0130: import net.sf.jasperreports.engine.JRRectangle;
0131: import net.sf.jasperreports.engine.JRReport;
0132: import net.sf.jasperreports.engine.JRReportFont;
0133: import net.sf.jasperreports.engine.JRReportTemplate;
0134: import net.sf.jasperreports.engine.JRRuntimeException;
0135: import net.sf.jasperreports.engine.JRSortField;
0136: import net.sf.jasperreports.engine.JRStaticText;
0137: import net.sf.jasperreports.engine.JRStyle;
0138: import net.sf.jasperreports.engine.JRSubreport;
0139: import net.sf.jasperreports.engine.JRSubreportParameter;
0140: import net.sf.jasperreports.engine.JRSubreportReturnValue;
0141: import net.sf.jasperreports.engine.JRTextElement;
0142: import net.sf.jasperreports.engine.JRTextField;
0143: import net.sf.jasperreports.engine.JRVariable;
0144: import net.sf.jasperreports.engine.JRChartPlot.JRSeriesColor;
0145: import net.sf.jasperreports.engine.query.JRJdbcQueryExecuterFactory;
0146: import net.sf.jasperreports.engine.util.JRXmlWriteHelper;
0147:
0148: import org.jfree.chart.plot.PlotOrientation;
0149: import org.jfree.chart.renderer.category.BarRenderer3D;
0150: import org.jfree.data.time.Day;
0151:
0152: /**
0153: * @author Teodor Danciu (teodord@users.sourceforge.net)
0154: * @author Minor enhancements by Barry Klawans (bklawans@users.sourceforge.net)
0155: * @version $Id: JRXmlWriter.java 1798 2007-07-30 09:47:58Z teodord $
0156: */
0157: public class JRXmlWriter extends JRXmlBaseWriter {
0158:
0159: /**
0160: *
0161: */
0162: private JRReport report = null;
0163: private String encoding = null;
0164:
0165: /**
0166: *
0167: */
0168: private Map fontsMap = new HashMap();
0169:
0170: /**
0171: *
0172: */
0173: protected JRXmlWriter(JRReport report, String encoding) {
0174: this .report = report;
0175: this .encoding = encoding;
0176: }
0177:
0178: /**
0179: *
0180: */
0181: public static String writeReport(JRReport report, String encoding) {
0182: JRXmlWriter writer = new JRXmlWriter(report, encoding);
0183: StringWriter buffer = new StringWriter();
0184: try {
0185: writer.writeReport(buffer);
0186: } catch (IOException e) {
0187: // doesn't actually happen
0188: throw new JRRuntimeException(
0189: "Error writing report design.", e);
0190: }
0191: return buffer.toString();
0192: }
0193:
0194: /**
0195: *
0196: */
0197: public static void writeReport(JRReport report,
0198: String destFileName, String encoding) throws JRException {
0199: FileOutputStream fos = null;
0200:
0201: try {
0202: fos = new FileOutputStream(destFileName);
0203: Writer out = new OutputStreamWriter(fos, encoding);
0204: JRXmlWriter writer = new JRXmlWriter(report, encoding);
0205: writer.writeReport(out);
0206: } catch (IOException e) {
0207: throw new JRException("Error writing to file : "
0208: + destFileName, e);
0209: } finally {
0210: if (fos != null) {
0211: try {
0212: fos.close();
0213: } catch (IOException e) {
0214: }
0215: }
0216: }
0217: }
0218:
0219: /**
0220: *
0221: */
0222: public static void writeReport(JRReport report,
0223: OutputStream outputStream, String encoding)
0224: throws JRException {
0225: try {
0226: Writer out = new OutputStreamWriter(outputStream, encoding);
0227: JRXmlWriter writer = new JRXmlWriter(report, encoding);
0228: writer.writeReport(out);
0229: } catch (Exception e) {
0230: throw new JRException("Error writing to OutputStream : "
0231: + report.getName(), e);
0232: }
0233: }
0234:
0235: /**
0236: *
0237: */
0238: protected void writeReport(Writer out) throws IOException {
0239: useWriter(new JRXmlWriteHelper(out));
0240:
0241: writer.writeProlog(encoding);
0242: writer.writePublicDoctype(JRXmlConstants.ELEMENT_jasperReport,
0243: JRXmlConstants.JASPERREPORT_PUBLIC_ID,
0244: JRXmlConstants.JASPERREPORT_SYSTEM_ID);
0245:
0246: writer.startElement(JRXmlConstants.ELEMENT_jasperReport);
0247: writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_name,
0248: report.getName());
0249: writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_language,
0250: report.getLanguage(), JRReport.LANGUAGE_JAVA);
0251: writer.addAttribute(JRXmlConstants.ATTRIBUTE_columnCount,
0252: report.getColumnCount(), 1);
0253: writer.addAttribute(JRXmlConstants.ATTRIBUTE_printOrder, report
0254: .getPrintOrder(), JRXmlConstants.getPrintOrderMap(),
0255: JRReport.PRINT_ORDER_VERTICAL);
0256: writer.addAttribute(JRXmlConstants.ATTRIBUTE_pageWidth, report
0257: .getPageWidth());
0258: writer.addAttribute(JRXmlConstants.ATTRIBUTE_pageHeight, report
0259: .getPageHeight());
0260: writer.addAttribute(JRXmlConstants.ATTRIBUTE_orientation,
0261: report.getOrientation(), JRXmlConstants
0262: .getOrientationMap(),
0263: JRReport.ORIENTATION_PORTRAIT);
0264: writer.addAttribute(JRXmlConstants.ATTRIBUTE_whenNoDataType,
0265: report.getWhenNoDataType(), JRXmlConstants
0266: .getWhenNoDataTypeMap(),
0267: JRReport.WHEN_NO_DATA_TYPE_NO_PAGES);
0268: writer.addAttribute(JRXmlConstants.ATTRIBUTE_columnWidth,
0269: report.getColumnWidth());
0270: writer.addAttribute(JRXmlConstants.ATTRIBUTE_columnSpacing,
0271: report.getColumnSpacing(), 0);
0272: writer.addAttribute(JRXmlConstants.ATTRIBUTE_leftMargin, report
0273: .getLeftMargin());
0274: writer.addAttribute(JRXmlConstants.ATTRIBUTE_rightMargin,
0275: report.getRightMargin());
0276: writer.addAttribute(JRXmlConstants.ATTRIBUTE_topMargin, report
0277: .getTopMargin());
0278: writer.addAttribute(JRXmlConstants.ATTRIBUTE_bottomMargin,
0279: report.getBottomMargin());
0280: writer.addAttribute(JRXmlConstants.ATTRIBUTE_isTitleNewPage,
0281: report.isTitleNewPage(), false);
0282: writer.addAttribute(JRXmlConstants.ATTRIBUTE_isSummaryNewPage,
0283: report.isSummaryNewPage(), false);
0284: writer.addAttribute(
0285: JRXmlConstants.ATTRIBUTE_isFloatColumnFooter, report
0286: .isFloatColumnFooter(), false);
0287: writer.addAttribute(JRXmlConstants.ATTRIBUTE_scriptletClass,
0288: report.getScriptletClass());
0289: writer.addAttribute(
0290: JRXmlConstants.ATTRIBUTE_formatFactoryClass, report
0291: .getFormatFactoryClass());
0292: writer.addEncodedAttribute(
0293: JRXmlConstants.ATTRIBUTE_resourceBundle, report
0294: .getResourceBundle());
0295: writer.addAttribute(
0296: JRXmlConstants.ATTRIBUTE_whenResourceMissingType,
0297: report.getWhenResourceMissingType(), JRXmlConstants
0298: .getWhenResourceMissingTypeMap(),
0299: JRReport.WHEN_RESOURCE_MISSING_TYPE_NULL);
0300: writer.addAttribute(
0301: JRXmlConstants.ATTRIBUTE_isIgnorePagination, report
0302: .isIgnorePagination(), false);
0303:
0304: writeProperties(report);
0305:
0306: /* */
0307: String[] imports = report.getImports();
0308: if (imports != null && imports.length > 0) {
0309: for (int i = 0; i < imports.length; i++) {
0310: String value = imports[i];
0311: if (value != null) {
0312: writer.startElement(JRXmlConstants.ELEMENT_import);
0313: writer.addEncodedAttribute(
0314: JRXmlConstants.ATTRIBUTE_value, value);
0315: writer.closeElement();
0316: }
0317: }
0318: }
0319:
0320: writeTemplates();
0321:
0322: /* */
0323: JRReportFont[] fonts = report.getFonts();
0324: if (fonts != null && fonts.length > 0) {
0325: for (int i = 0; i < fonts.length; i++) {
0326: fontsMap.put(fonts[i].getName(), fonts[i]);
0327: writeReportFont(fonts[i]);
0328: }
0329: }
0330:
0331: /* */
0332: JRStyle[] styles = report.getStyles();
0333: if (styles != null && styles.length > 0) {
0334: for (int i = 0; i < styles.length; i++) {
0335: writeStyle(styles[i]);
0336: }
0337: }
0338:
0339: JRDataset[] datasets = report.getDatasets();
0340: if (datasets != null && datasets.length > 0) {
0341: for (int i = 0; i < datasets.length; ++i) {
0342: writeDataset(datasets[i]);
0343: }
0344: }
0345:
0346: writeDatasetContents(report.getMainDataset());
0347:
0348: if (report.getBackground() != null) {
0349: writer.startElement(JRXmlConstants.ELEMENT_background);
0350: writeBand(report.getBackground());
0351: writer.closeElement();
0352: }
0353:
0354: if (report.getTitle() != null) {
0355: writer.startElement(JRXmlConstants.ELEMENT_title);
0356: writeBand(report.getTitle());
0357: writer.closeElement();
0358: }
0359:
0360: if (report.getPageHeader() != null) {
0361: writer.startElement(JRXmlConstants.ELEMENT_pageHeader);
0362: writeBand(report.getPageHeader());
0363: writer.closeElement();
0364: }
0365:
0366: if (report.getColumnHeader() != null) {
0367: writer.startElement(JRXmlConstants.ELEMENT_columnHeader);
0368: writeBand(report.getColumnHeader());
0369: writer.closeElement();
0370: }
0371:
0372: if (report.getDetail() != null) {
0373: writer.startElement(JRXmlConstants.ELEMENT_detail);
0374: writeBand(report.getDetail());
0375: writer.closeElement();
0376: }
0377:
0378: if (report.getColumnFooter() != null) {
0379: writer.startElement(JRXmlConstants.ELEMENT_columnFooter);
0380: writeBand(report.getColumnFooter());
0381: writer.closeElement();
0382: }
0383:
0384: if (report.getPageFooter() != null) {
0385: writer.startElement(JRXmlConstants.ELEMENT_pageFooter);
0386: writeBand(report.getPageFooter());
0387: writer.closeElement();
0388: }
0389:
0390: if (report.getLastPageFooter() != null) {
0391: writer.startElement(JRXmlConstants.ELEMENT_lastPageFooter);
0392: writeBand(report.getLastPageFooter());
0393: writer.closeElement();
0394: }
0395:
0396: if (report.getSummary() != null) {
0397: writer.startElement(JRXmlConstants.ELEMENT_summary);
0398: writeBand(report.getSummary());
0399: writer.closeElement();
0400: }
0401:
0402: if (report.getNoData() != null) {
0403: writer.startElement(JRXmlConstants.ELEMENT_noData);
0404: writeBand(report.getNoData());
0405: writer.closeElement();
0406: }
0407:
0408: writer.closeElement();
0409:
0410: out.flush();
0411: }
0412:
0413: private void writeProperties(JRPropertiesHolder propertiesHolder)
0414: throws IOException {
0415: JRPropertiesMap propertiesMap = propertiesHolder
0416: .getPropertiesMap();
0417: if (propertiesMap != null) {
0418: String[] propertyNames = propertiesMap.getPropertyNames();
0419: if (propertyNames != null && propertyNames.length > 0) {
0420: for (int i = 0; i < propertyNames.length; i++) {
0421: String value = propertiesMap
0422: .getProperty(propertyNames[i]);
0423: if (value != null) {
0424: writer
0425: .startElement(JRXmlConstants.ELEMENT_property);
0426: writer.addEncodedAttribute(
0427: JRXmlConstants.ATTRIBUTE_name,
0428: propertyNames[i]);
0429: writer.addEncodedAttribute(
0430: JRXmlConstants.ATTRIBUTE_value, value);
0431: writer.closeElement();
0432: }
0433: }
0434: }
0435: }
0436: }
0437:
0438: protected void writeTemplates() throws IOException {
0439: JRReportTemplate[] templates = report.getTemplates();
0440: if (templates != null) {
0441: for (int i = 0; i < templates.length; i++) {
0442: JRReportTemplate template = templates[i];
0443: writeTemplate(template);
0444: }
0445: }
0446: }
0447:
0448: protected void writeTemplate(JRReportTemplate template)
0449: throws IOException {
0450: writer.writeExpression(JRXmlConstants.ELEMENT_template,
0451: template.getSourceExpression(), true, String.class
0452: .getName());
0453: }
0454:
0455: /**
0456: *
0457: */
0458: private void writeReportFont(JRReportFont font) throws IOException {
0459: writer.startElement(JRXmlConstants.ELEMENT_reportFont);
0460: writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_name, font
0461: .getName());
0462: writer.addAttribute(JRXmlConstants.ATTRIBUTE_isDefault, font
0463: .isDefault());
0464: writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_fontName,
0465: font.getFontName());
0466: writer.addAttribute(JRXmlConstants.ATTRIBUTE_size, font
0467: .getFontSize());
0468: writer.addAttribute(JRXmlConstants.ATTRIBUTE_isBold, font
0469: .isBold());
0470: writer.addAttribute(JRXmlConstants.ATTRIBUTE_isItalic, font
0471: .isItalic());
0472: writer.addAttribute(JRXmlConstants.ATTRIBUTE_isUnderline, font
0473: .isUnderline());
0474: writer.addAttribute(JRXmlConstants.ATTRIBUTE_isStrikeThrough,
0475: font.isStrikeThrough());
0476: writer.addEncodedAttribute(
0477: JRXmlConstants.ATTRIBUTE_pdfFontName, font
0478: .getPdfFontName());
0479: writer.addEncodedAttribute(
0480: JRXmlConstants.ATTRIBUTE_pdfEncoding, font
0481: .getPdfEncoding());
0482: writer.addAttribute(JRXmlConstants.ATTRIBUTE_isPdfEmbedded,
0483: font.isPdfEmbedded());
0484: writer.closeElement();
0485: }
0486:
0487: /**
0488: *
0489: */
0490: private void writeParameter(JRParameter parameter)
0491: throws IOException {
0492: writer.startElement(JRXmlConstants.ELEMENT_parameter);
0493: writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_name,
0494: parameter.getName());
0495: writer.addAttribute(JRXmlConstants.ATTRIBUTE_class, parameter
0496: .getValueClassName());
0497: writer.addAttribute(JRXmlConstants.ATTRIBUTE_isForPrompting,
0498: parameter.isForPrompting(), true);
0499:
0500: writeProperties(parameter);
0501:
0502: writer.writeCDATAElement(
0503: JRXmlConstants.ELEMENT_parameterDescription, parameter
0504: .getDescription());
0505: writer.writeExpression(
0506: JRXmlConstants.ELEMENT_defaultValueExpression,
0507: parameter.getDefaultValueExpression(), false);
0508:
0509: writer.closeElement();
0510: }
0511:
0512: /**
0513: *
0514: */
0515: private void writeQuery(JRQuery query) throws IOException {
0516: writer.startElement(JRXmlConstants.ELEMENT_queryString);
0517: writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_language,
0518: query.getLanguage(),
0519: JRJdbcQueryExecuterFactory.QUERY_LANGUAGE_SQL);
0520: writer.writeCDATA(query.getText());
0521: writer.closeElement();
0522: }
0523:
0524: /**
0525: *
0526: */
0527: private void writeField(JRField field) throws IOException {
0528: writer.startElement(JRXmlConstants.ELEMENT_field);
0529: writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_name, field
0530: .getName());
0531: writer.addAttribute(JRXmlConstants.ATTRIBUTE_class, field
0532: .getValueClassName());
0533:
0534: writeProperties(field);
0535:
0536: writer.writeCDATAElement(
0537: JRXmlConstants.ELEMENT_fieldDescription, field
0538: .getDescription());
0539:
0540: writer.closeElement();
0541: }
0542:
0543: /**
0544: *
0545: */
0546: private void writeSortField(JRSortField sortField)
0547: throws IOException {
0548: writer.startElement(JRXmlConstants.ELEMENT_sortField);
0549: writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_name,
0550: sortField.getName());
0551: writer.addAttribute(JRXmlConstants.ATTRIBUTE_order, sortField
0552: .getOrder(), JRXmlConstants.getSortOrderMap(),
0553: JRSortField.SORT_ORDER_ASCENDING);
0554: writer.closeElement();
0555: }
0556:
0557: /**
0558: *
0559: */
0560: private void writeVariable(JRVariable variable) throws IOException {
0561: writer.startElement(JRXmlConstants.ELEMENT_variable);
0562: writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_name,
0563: variable.getName());
0564: writer.addAttribute(JRXmlConstants.ATTRIBUTE_class, variable
0565: .getValueClassName());
0566: writer.addAttribute(JRXmlConstants.ATTRIBUTE_resetType,
0567: variable.getResetType(), JRXmlConstants
0568: .getResetTypeMap(),
0569: JRVariable.RESET_TYPE_REPORT);
0570: if (variable.getResetGroup() != null) {
0571: writer.addEncodedAttribute(
0572: JRXmlConstants.ATTRIBUTE_resetGroup, variable
0573: .getResetGroup().getName());
0574: }
0575: writer.addAttribute(JRXmlConstants.ATTRIBUTE_incrementType,
0576: variable.getIncrementType(), JRXmlConstants
0577: .getResetTypeMap(), JRVariable.RESET_TYPE_NONE);
0578: if (variable.getIncrementGroup() != null) {
0579: writer.addEncodedAttribute(
0580: JRXmlConstants.ATTRIBUTE_incrementGroup, variable
0581: .getIncrementGroup().getName());
0582: }
0583: writer.addAttribute(JRXmlConstants.ATTRIBUTE_calculation,
0584: variable.getCalculation(), JRXmlConstants
0585: .getCalculationMap(),
0586: JRVariable.CALCULATION_NOTHING);
0587: writer.addAttribute(
0588: JRXmlConstants.ATTRIBUTE_incrementerFactoryClass,
0589: variable.getIncrementerFactoryClassName());
0590:
0591: writer.writeExpression(
0592: JRXmlConstants.ELEMENT_variableExpression, variable
0593: .getExpression(), false);
0594: writer.writeExpression(
0595: JRXmlConstants.ELEMENT_initialValueExpression, variable
0596: .getInitialValueExpression(), false);
0597:
0598: writer.closeElement();
0599: }
0600:
0601: /**
0602: *
0603: */
0604: private void writeGroup(JRGroup group) throws IOException {
0605: writer.startElement(JRXmlConstants.ELEMENT_group);
0606: writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_name, group
0607: .getName());
0608: writer.addAttribute(JRXmlConstants.ATTRIBUTE_isStartNewColumn,
0609: group.isStartNewColumn(), false);
0610: writer.addAttribute(JRXmlConstants.ATTRIBUTE_isStartNewPage,
0611: group.isStartNewPage(), false);
0612: writer.addAttribute(JRXmlConstants.ATTRIBUTE_isResetPageNumber,
0613: group.isResetPageNumber(), false);
0614: writer.addAttribute(
0615: JRXmlConstants.ATTRIBUTE_isReprintHeaderOnEachPage,
0616: group.isReprintHeaderOnEachPage(), false);
0617: writer.addAttributePositive(
0618: JRXmlConstants.ATTRIBUTE_minHeightToStartNewPage, group
0619: .getMinHeightToStartNewPage());
0620:
0621: writer.writeExpression(JRXmlConstants.ELEMENT_groupExpression,
0622: group.getExpression(), false);
0623:
0624: if (group.getGroupHeader() != null) {
0625: writer.startElement(JRXmlConstants.ELEMENT_groupHeader);
0626: writeBand(group.getGroupHeader());
0627: writer.closeElement();
0628: }
0629:
0630: if (group.getGroupFooter() != null) {
0631: writer.startElement(JRXmlConstants.ELEMENT_groupFooter);
0632: writeBand(group.getGroupFooter());
0633: writer.closeElement();
0634: }
0635:
0636: writer.closeElement();
0637: }
0638:
0639: /**
0640: *
0641: */
0642: private void writeBand(JRBand band) throws IOException {
0643: writer.startElement(JRXmlConstants.ELEMENT_band);
0644: writer.addAttributePositive(JRXmlConstants.ATTRIBUTE_height,
0645: band.getHeight());
0646: writer.addAttribute(JRXmlConstants.ATTRIBUTE_isSplitAllowed,
0647: band.isSplitAllowed(), true);
0648:
0649: writer.writeExpression(
0650: JRXmlConstants.ELEMENT_printWhenExpression, band
0651: .getPrintWhenExpression(), false);
0652:
0653: /* */
0654: List children = band.getChildren();
0655: if (children != null && children.size() > 0) {
0656: for (int i = 0; i < children.size(); i++) {
0657: ((JRChild) children.get(i)).writeXml(this );
0658: }
0659: }
0660:
0661: writer.closeElement();
0662: }
0663:
0664: /**
0665: *
0666: */
0667: public void writeElementGroup(JRElementGroup elementGroup)
0668: throws IOException {
0669: writer.startElement(JRXmlConstants.ELEMENT_elementGroup);
0670:
0671: /* */
0672: List children = elementGroup.getChildren();
0673: if (children != null && children.size() > 0) {
0674: for (int i = 0; i < children.size(); i++) {
0675: JRChild child = (JRChild) children.get(i);
0676: child.writeXml(this );
0677: }
0678: }
0679:
0680: writer.closeElement();
0681: }
0682:
0683: /**
0684: *
0685: */
0686: public void writeBreak(JRBreak breakElement) throws IOException {
0687: writer.startElement(JRXmlConstants.ELEMENT_break);
0688: writer.addAttribute(JRXmlConstants.ATTRIBUTE_type, breakElement
0689: .getType(), JRXmlConstants.getBreakTypeMap(),
0690: JRBreak.TYPE_PAGE);
0691:
0692: writeReportElement(breakElement);
0693:
0694: writer.closeElement();
0695: }
0696:
0697: /**
0698: *
0699: */
0700: public void writeLine(JRLine line) throws IOException {
0701: writer.startElement(JRXmlConstants.ELEMENT_line);
0702: writer.addAttribute(JRXmlConstants.ATTRIBUTE_direction, line
0703: .getDirection(), JRXmlConstants.getDirectionMap(),
0704: JRLine.DIRECTION_TOP_DOWN);
0705:
0706: writeReportElement(line);
0707: writeGraphicElement(line);
0708:
0709: writer.closeElement();
0710: }
0711:
0712: /**
0713: *
0714: */
0715: private void writeReportElement(JRElement element)
0716: throws IOException {
0717: writer.startElement(JRXmlConstants.ELEMENT_reportElement);
0718: writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_key,
0719: element.getKey());
0720: JRStyle style = element.getStyle();
0721: if (style != null) {
0722: writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_style,
0723: style.getName());
0724: }
0725: writer.addAttribute(JRXmlConstants.ATTRIBUTE_positionType,
0726: element.getPositionType(), JRXmlConstants
0727: .getPositionTypeMap(),
0728: JRElement.POSITION_TYPE_FIX_RELATIVE_TO_TOP);
0729: writer.addAttribute(JRXmlConstants.ATTRIBUTE_stretchType,
0730: element.getStretchType(), JRXmlConstants
0731: .getStretchTypeMap(),
0732: JRElement.STRETCH_TYPE_NO_STRETCH);
0733: writer.addAttribute(
0734: JRXmlConstants.ATTRIBUTE_isPrintRepeatedValues, element
0735: .isPrintRepeatedValues(), true);
0736: writer.addAttribute(JRXmlConstants.ATTRIBUTE_mode, element
0737: .getOwnMode(), JRXmlConstants.getModeMap());
0738:
0739: writer.addAttribute(JRXmlConstants.ATTRIBUTE_x, element.getX());
0740: writer.addAttribute(JRXmlConstants.ATTRIBUTE_y, element.getY());
0741: writer.addAttribute(JRXmlConstants.ATTRIBUTE_width, element
0742: .getWidth());
0743: writer.addAttribute(JRXmlConstants.ATTRIBUTE_height, element
0744: .getHeight());
0745: writer.addAttribute(
0746: JRXmlConstants.ATTRIBUTE_isRemoveLineWhenBlank, element
0747: .isRemoveLineWhenBlank(), false);
0748: writer.addAttribute(
0749: JRXmlConstants.ATTRIBUTE_isPrintInFirstWholeBand,
0750: element.isPrintInFirstWholeBand(), false);
0751: writer.addAttribute(
0752: JRXmlConstants.ATTRIBUTE_isPrintWhenDetailOverflows,
0753: element.isPrintWhenDetailOverflows(), false);
0754:
0755: if (element.getPrintWhenGroupChanges() != null) {
0756: writer.addEncodedAttribute(
0757: JRXmlConstants.ATTRIBUTE_printWhenGroupChanges,
0758: element.getPrintWhenGroupChanges().getName());
0759: }
0760:
0761: writer.addAttribute(JRXmlConstants.ATTRIBUTE_forecolor, element
0762: .getOwnForecolor());
0763: writer.addAttribute(JRXmlConstants.ATTRIBUTE_backcolor, element
0764: .getOwnBackcolor());
0765:
0766: writer.writeExpression(
0767: JRXmlConstants.ELEMENT_printWhenExpression, element
0768: .getPrintWhenExpression(), false);
0769: writer.closeElement();
0770: }
0771:
0772: /**
0773: *
0774: */
0775: private void writeGraphicElement(JRGraphicElement element)
0776: throws IOException {
0777: writer.startElement(JRXmlConstants.ELEMENT_graphicElement);
0778: writer.addAttribute(JRXmlConstants.ATTRIBUTE_pen, element
0779: .getOwnPen(), JRXmlConstants.getPenMap());
0780: writer.addAttribute(JRXmlConstants.ATTRIBUTE_fill, element
0781: .getOwnFill(), JRXmlConstants.getFillMap());
0782: writer.closeElement();
0783: }
0784:
0785: /**
0786: *
0787: */
0788: public void writeRectangle(JRRectangle rectangle)
0789: throws IOException {
0790: writer.startElement(JRXmlConstants.ELEMENT_rectangle);
0791: writer.addAttribute(JRXmlConstants.ATTRIBUTE_radius, rectangle
0792: .getOwnRadius());
0793:
0794: writeReportElement(rectangle);
0795: writeGraphicElement(rectangle);
0796:
0797: writer.closeElement();
0798: }
0799:
0800: /**
0801: *
0802: */
0803: public void writeEllipse(JREllipse ellipse) throws IOException {
0804: writer.startElement(JRXmlConstants.ELEMENT_ellipse);
0805:
0806: writeReportElement(ellipse);
0807: writeGraphicElement(ellipse);
0808:
0809: writer.closeElement();
0810: }
0811:
0812: /**
0813: *
0814: */
0815: public void writeImage(JRImage image) throws IOException {
0816: writer.startElement(JRXmlConstants.ELEMENT_image);
0817: writer.addAttribute(JRXmlConstants.ATTRIBUTE_scaleImage, image
0818: .getOwnScaleImage(), JRXmlConstants.getScaleImageMap());
0819: writer.addAttribute(JRXmlConstants.ATTRIBUTE_hAlign, image
0820: .getOwnHorizontalAlignment(), JRXmlConstants
0821: .getHorizontalAlignMap());
0822: writer.addAttribute(JRXmlConstants.ATTRIBUTE_vAlign, image
0823: .getOwnVerticalAlignment(), JRXmlConstants
0824: .getVerticalAlignMap());
0825: writer.addAttribute(JRXmlConstants.ATTRIBUTE_isUsingCache,
0826: image.isOwnUsingCache());
0827: writer.addAttribute(JRXmlConstants.ATTRIBUTE_isLazy, image
0828: .isLazy(), false);
0829: writer.addAttribute(JRXmlConstants.ATTRIBUTE_onErrorType, image
0830: .getOnErrorType(), JRXmlConstants.getOnErrorTypeMap(),
0831: JRImage.ON_ERROR_TYPE_ERROR);
0832: writer.addAttribute(JRXmlConstants.ATTRIBUTE_evaluationTime,
0833: image.getEvaluationTime(), JRXmlConstants
0834: .getEvaluationTimeMap(),
0835: JRExpression.EVALUATION_TIME_NOW);
0836:
0837: if (image.getEvaluationGroup() != null) {
0838: writer.addEncodedAttribute(
0839: JRXmlConstants.ATTRIBUTE_evaluationGroup, image
0840: .getEvaluationGroup().getName());
0841: }
0842:
0843: writer.addEncodedAttribute(
0844: JRXmlConstants.ATTRIBUTE_hyperlinkType, image
0845: .getLinkType());
0846: writer.addAttribute(JRXmlConstants.ATTRIBUTE_hyperlinkTarget,
0847: image.getHyperlinkTarget(), JRXmlConstants
0848: .getHyperlinkTargetMap(),
0849: JRHyperlink.HYPERLINK_TARGET_SELF);
0850: writer.addAttribute(JRXmlConstants.ATTRIBUTE_bookmarkLevel,
0851: image.getBookmarkLevel(), JRAnchor.NO_BOOKMARK);
0852:
0853: writeReportElement(image);
0854: writeBox(image);
0855: writeGraphicElement(image);
0856:
0857: //FIXME class is mandatory in verifier
0858:
0859: writer.writeExpression(JRXmlConstants.ELEMENT_imageExpression,
0860: image.getExpression(), true);
0861: writer.writeExpression(
0862: JRXmlConstants.ELEMENT_anchorNameExpression, image
0863: .getAnchorNameExpression(), false);
0864: writer.writeExpression(
0865: JRXmlConstants.ELEMENT_hyperlinkReferenceExpression,
0866: image.getHyperlinkReferenceExpression(), false);
0867: writer.writeExpression(
0868: JRXmlConstants.ELEMENT_hyperlinkAnchorExpression, image
0869: .getHyperlinkAnchorExpression(), false);
0870: writer.writeExpression(
0871: JRXmlConstants.ELEMENT_hyperlinkPageExpression, image
0872: .getHyperlinkPageExpression(), false);
0873: writer.writeExpression(
0874: JRXmlConstants.ELEMENT_hyperlinkTooltipExpression,
0875: image.getHyperlinkTooltipExpression(), false);
0876: writeHyperlinkParameters(image.getHyperlinkParameters());
0877:
0878: writer.closeElement();
0879: }
0880:
0881: /**
0882: *
0883: */
0884: private void writeBox(JRBox box) throws IOException {
0885: if (box != null) {
0886: writer.startElement(JRXmlConstants.ELEMENT_box);
0887: writer.addAttribute(JRXmlConstants.ATTRIBUTE_border, box
0888: .getOwnBorder(), JRXmlConstants.getPenMap());
0889: writer.addAttribute(JRXmlConstants.ATTRIBUTE_borderColor,
0890: box.getOwnBorderColor());
0891: writer.addAttribute(JRXmlConstants.ATTRIBUTE_padding, box
0892: .getOwnPadding());
0893:
0894: writer.addAttribute(JRXmlConstants.ATTRIBUTE_topBorder, box
0895: .getOwnTopBorder(), JRXmlConstants.getPenMap());
0896: writer.addAttribute(
0897: JRXmlConstants.ATTRIBUTE_topBorderColor, box
0898: .getOwnTopBorderColor());
0899: writer.addAttribute(JRXmlConstants.ATTRIBUTE_topPadding,
0900: box.getOwnTopPadding());
0901:
0902: writer.addAttribute(JRXmlConstants.ATTRIBUTE_leftBorder,
0903: box.getOwnLeftBorder(), JRXmlConstants.getPenMap());
0904: writer.addAttribute(
0905: JRXmlConstants.ATTRIBUTE_leftBorderColor, box
0906: .getOwnLeftBorderColor());
0907: writer.addAttribute(JRXmlConstants.ATTRIBUTE_leftPadding,
0908: box.getOwnLeftPadding());
0909:
0910: writer.addAttribute(JRXmlConstants.ATTRIBUTE_bottomBorder,
0911: box.getOwnBottomBorder(), JRXmlConstants
0912: .getPenMap());
0913: writer.addAttribute(
0914: JRXmlConstants.ATTRIBUTE_bottomBorderColor, box
0915: .getOwnBottomBorderColor());
0916: writer.addAttribute(JRXmlConstants.ATTRIBUTE_bottomPadding,
0917: box.getOwnBottomPadding());
0918:
0919: writer
0920: .addAttribute(JRXmlConstants.ATTRIBUTE_rightBorder,
0921: box.getOwnRightBorder(), JRXmlConstants
0922: .getPenMap());
0923: writer.addAttribute(
0924: JRXmlConstants.ATTRIBUTE_rightBorderColor, box
0925: .getOwnRightBorderColor());
0926: writer.addAttribute(JRXmlConstants.ATTRIBUTE_rightPadding,
0927: box.getOwnRightPadding());
0928:
0929: writer.closeElement(true);
0930: }
0931: }
0932:
0933: /**
0934: *
0935: */
0936: public void writeStaticText(JRStaticText staticText)
0937: throws IOException {
0938: writer.startElement(JRXmlConstants.ELEMENT_staticText);
0939:
0940: writeReportElement(staticText);
0941: writeBox(staticText);
0942: writeTextElement(staticText);
0943:
0944: writer.writeCDATAElement(JRXmlConstants.ELEMENT_text,
0945: staticText.getText());
0946:
0947: writer.closeElement();
0948: }
0949:
0950: /**
0951: *
0952: */
0953: private void writeTextElement(JRTextElement textElement)
0954: throws IOException {
0955: writer.startElement(JRXmlConstants.ELEMENT_textElement);
0956: writer.addAttribute(JRXmlConstants.ATTRIBUTE_textAlignment,
0957: textElement.getOwnHorizontalAlignment(), JRXmlConstants
0958: .getHorizontalAlignMap());
0959: writer.addAttribute(JRXmlConstants.ATTRIBUTE_verticalAlignment,
0960: textElement.getOwnVerticalAlignment(), JRXmlConstants
0961: .getVerticalAlignMap());
0962: writer.addAttribute(JRXmlConstants.ATTRIBUTE_rotation,
0963: textElement.getOwnRotation(), JRXmlConstants
0964: .getRotationMap());
0965: writer.addAttribute(JRXmlConstants.ATTRIBUTE_lineSpacing,
0966: textElement.getOwnLineSpacing(), JRXmlConstants
0967: .getLineSpacingMap());
0968: writer.addAttribute(JRXmlConstants.ATTRIBUTE_isStyledText,
0969: textElement.isOwnStyledText());
0970:
0971: writeFont(textElement);
0972:
0973: writer.closeElement();
0974: }
0975:
0976: /**
0977: *
0978: */
0979: private void writeFont(JRFont font) throws IOException {
0980: if (font != null) {
0981: writer.startElement(JRXmlConstants.ELEMENT_font);
0982: if (font.getReportFont() != null) {
0983: JRFont baseFont = (JRFont) fontsMap.get(font
0984: .getReportFont().getName());
0985: if (baseFont != null) {
0986: writer.addEncodedAttribute(
0987: JRXmlConstants.ATTRIBUTE_reportFont, font
0988: .getReportFont().getName());
0989: } else {
0990: throw new JRRuntimeException(
0991: "Referenced report font not found : "
0992: + font.getReportFont().getName());
0993: }
0994: }
0995:
0996: writer.addEncodedAttribute(
0997: JRXmlConstants.ATTRIBUTE_fontName, font
0998: .getOwnFontName());
0999: writer.addAttribute(JRXmlConstants.ATTRIBUTE_size, font
1000: .getOwnFontSize());
1001: writer.addAttribute(JRXmlConstants.ATTRIBUTE_isBold, font
1002: .isOwnBold());
1003: writer.addAttribute(JRXmlConstants.ATTRIBUTE_isItalic, font
1004: .isOwnItalic());
1005: writer.addAttribute(JRXmlConstants.ATTRIBUTE_isUnderline,
1006: font.isOwnUnderline());
1007: writer.addAttribute(
1008: JRXmlConstants.ATTRIBUTE_isStrikeThrough, font
1009: .isOwnStrikeThrough());
1010: writer.addEncodedAttribute(
1011: JRXmlConstants.ATTRIBUTE_pdfFontName, font
1012: .getOwnPdfFontName());
1013: writer.addEncodedAttribute(
1014: JRXmlConstants.ATTRIBUTE_pdfEncoding, font
1015: .getOwnPdfEncoding());
1016: writer.addAttribute(JRXmlConstants.ATTRIBUTE_isPdfEmbedded,
1017: font.isOwnPdfEmbedded());
1018: writer.closeElement(true);
1019: }
1020: }
1021:
1022: /**
1023: *
1024: */
1025: public void writeTextField(JRTextField textField)
1026: throws IOException {
1027: writer.startElement(JRXmlConstants.ELEMENT_textField);
1028: writer.addAttribute(
1029: JRXmlConstants.ATTRIBUTE_isStretchWithOverflow,
1030: textField.isStretchWithOverflow(), false);
1031: writer.addAttribute(JRXmlConstants.ATTRIBUTE_evaluationTime,
1032: textField.getEvaluationTime(), JRXmlConstants
1033: .getEvaluationTimeMap(),
1034: JRExpression.EVALUATION_TIME_NOW);
1035:
1036: if (textField.getEvaluationGroup() != null) {
1037: writer.addEncodedAttribute(
1038: JRXmlConstants.ATTRIBUTE_evaluationGroup, textField
1039: .getEvaluationGroup().getName());
1040: }
1041:
1042: writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_pattern,
1043: textField.getOwnPattern());
1044: writer.addAttribute(JRXmlConstants.ATTRIBUTE_isBlankWhenNull,
1045: textField.isOwnBlankWhenNull());
1046:
1047: writer.addEncodedAttribute(
1048: JRXmlConstants.ATTRIBUTE_hyperlinkType, textField
1049: .getLinkType());
1050: writer.addAttribute(JRXmlConstants.ATTRIBUTE_hyperlinkTarget,
1051: textField.getHyperlinkTarget(), JRXmlConstants
1052: .getHyperlinkTargetMap(),
1053: JRHyperlink.HYPERLINK_TARGET_SELF);
1054: writer.addAttribute(JRXmlConstants.ATTRIBUTE_bookmarkLevel,
1055: textField.getBookmarkLevel(), JRAnchor.NO_BOOKMARK);
1056:
1057: writeReportElement(textField);
1058: writeBox(textField);
1059: writeTextElement(textField);
1060:
1061: writer.writeExpression(
1062: JRXmlConstants.ELEMENT_textFieldExpression, textField
1063: .getExpression(), true);
1064:
1065: writer.writeExpression(
1066: JRXmlConstants.ELEMENT_anchorNameExpression, textField
1067: .getAnchorNameExpression(), false);
1068: writer.writeExpression(
1069: JRXmlConstants.ELEMENT_hyperlinkReferenceExpression,
1070: textField.getHyperlinkReferenceExpression(), false);
1071: writer.writeExpression(
1072: JRXmlConstants.ELEMENT_hyperlinkAnchorExpression,
1073: textField.getHyperlinkAnchorExpression(), false);
1074: writer.writeExpression(
1075: JRXmlConstants.ELEMENT_hyperlinkPageExpression,
1076: textField.getHyperlinkPageExpression(), false);
1077: writer.writeExpression(
1078: JRXmlConstants.ELEMENT_hyperlinkTooltipExpression,
1079: textField.getHyperlinkTooltipExpression(), false);
1080: writeHyperlinkParameters(textField.getHyperlinkParameters());
1081:
1082: writer.closeElement();
1083: }
1084:
1085: /**
1086: *
1087: */
1088: public void writeSubreport(JRSubreport subreport)
1089: throws IOException {
1090: writer.startElement(JRXmlConstants.ELEMENT_subreport);
1091: writer.addAttribute(JRXmlConstants.ATTRIBUTE_isUsingCache,
1092: subreport.isOwnUsingCache());
1093:
1094: writeReportElement(subreport);
1095:
1096: writer.writeExpression(
1097: JRXmlConstants.ELEMENT_parametersMapExpression,
1098: subreport.getParametersMapExpression(), false);
1099:
1100: /* */
1101: JRSubreportParameter[] parameters = subreport.getParameters();
1102: if (parameters != null && parameters.length > 0) {
1103: for (int i = 0; i < parameters.length; i++) {
1104: writeSubreportParameter(parameters[i]);
1105: }
1106: }
1107:
1108: writer.writeExpression(
1109: JRXmlConstants.ELEMENT_connectionExpression, subreport
1110: .getConnectionExpression(), false);
1111: writer.writeExpression(
1112: JRXmlConstants.ELEMENT_dataSourceExpression, subreport
1113: .getDataSourceExpression(), false);
1114:
1115: JRSubreportReturnValue[] returnValues = subreport
1116: .getReturnValues();
1117: if (returnValues != null && returnValues.length > 0) {
1118: for (int i = 0; i < returnValues.length; i++) {
1119: writeSubreportReturnValue(returnValues[i]);
1120: }
1121: }
1122:
1123: writer.writeExpression(
1124: JRXmlConstants.ELEMENT_subreportExpression, subreport
1125: .getExpression(), true);
1126:
1127: writer.closeElement();
1128: }
1129:
1130: /**
1131: *
1132: */
1133: private void writeSubreportParameter(
1134: JRSubreportParameter subreportParameter) throws IOException {
1135: writer.startElement(JRXmlConstants.ELEMENT_subreportParameter);
1136: writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_name,
1137: subreportParameter.getName());
1138:
1139: writer.writeExpression(
1140: JRXmlConstants.ELEMENT_subreportParameterExpression,
1141: subreportParameter.getExpression(), false);
1142:
1143: writer.closeElement();
1144: }
1145:
1146: private void writeDatasetParameter(
1147: JRDatasetParameter datasetParameter) throws IOException {
1148: writer.startElement(JRXmlConstants.ELEMENT_datasetParameter);
1149: writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_name,
1150: datasetParameter.getName());
1151:
1152: writer.writeExpression(
1153: JRXmlConstants.ELEMENT_datasetParameterExpression,
1154: datasetParameter.getExpression(), false);
1155:
1156: writer.closeElement();
1157: }
1158:
1159: /**
1160: *
1161: */
1162: private void writeChart(JRChart chart) throws IOException {
1163: writer.startElement(JRXmlConstants.ELEMENT_chart);
1164: writer.addAttribute(JRXmlConstants.ATTRIBUTE_isShowLegend,
1165: chart.isShowLegend(), true);
1166: writer.addAttribute(JRXmlConstants.ATTRIBUTE_evaluationTime,
1167: chart.getEvaluationTime(), JRXmlConstants
1168: .getEvaluationTimeMap(),
1169: JRExpression.EVALUATION_TIME_NOW);
1170:
1171: if (chart.getEvaluationTime() == JRExpression.EVALUATION_TIME_GROUP) {
1172: writer.addEncodedAttribute(
1173: JRXmlConstants.ATTRIBUTE_evaluationGroup, chart
1174: .getEvaluationGroup().getName());
1175: }
1176:
1177: writer.addEncodedAttribute(
1178: JRXmlConstants.ATTRIBUTE_hyperlinkType, chart
1179: .getLinkType());
1180: writer.addAttribute(JRXmlConstants.ATTRIBUTE_hyperlinkTarget,
1181: chart.getHyperlinkTarget(), JRXmlConstants
1182: .getHyperlinkTargetMap(),
1183: JRHyperlink.HYPERLINK_TARGET_SELF);
1184: writer.addAttribute(JRXmlConstants.ATTRIBUTE_bookmarkLevel,
1185: chart.getBookmarkLevel(), JRAnchor.NO_BOOKMARK);
1186: writer.addAttribute(JRXmlConstants.ATTRIBUTE_customizerClass,
1187: chart.getCustomizerClass());
1188:
1189: writeReportElement(chart);
1190: writeBox(chart);
1191:
1192: // write title
1193: writer.startElement(JRXmlConstants.ELEMENT_chartTitle);
1194: writer
1195: .addAttribute(JRXmlConstants.ATTRIBUTE_position, chart
1196: .getTitlePosition(), JRXmlConstants
1197: .getChartTitlePositionMap(),
1198: JRChart.TITLE_POSITION_TOP);
1199: writer.addAttribute(JRXmlConstants.ATTRIBUTE_color, chart
1200: .getOwnTitleColor());
1201: writeFont(chart.getTitleFont());
1202: if (chart.getTitleExpression() != null) {
1203: writer.writeExpression(
1204: JRXmlConstants.ELEMENT_titleExpression, chart
1205: .getTitleExpression(), false);
1206: }
1207: writer.closeElement();
1208:
1209: // write subtitle
1210: writer.startElement(JRXmlConstants.ELEMENT_chartSubtitle);
1211: writer.addAttribute(JRXmlConstants.ATTRIBUTE_color, chart
1212: .getOwnSubtitleColor());
1213: writeFont(chart.getSubtitleFont());
1214: if (chart.getSubtitleExpression() != null) {
1215: writer.writeExpression(
1216: JRXmlConstants.ELEMENT_subtitleExpression, chart
1217: .getSubtitleExpression(), false);
1218: }
1219: writer.closeElement();
1220:
1221: // write chartLegend
1222: writer.startElement(JRXmlConstants.ELEMENT_chartLegend);
1223: if (chart.getOwnLegendColor() != null)
1224: writer.addAttribute(JRXmlConstants.ATTRIBUTE_textColor,
1225: chart.getOwnLegendColor());
1226: if (chart.getOwnLegendBackgroundColor() != null)
1227: writer.addAttribute(
1228: JRXmlConstants.ATTRIBUTE_backgroundColor, chart
1229: .getOwnLegendBackgroundColor());
1230: writeFont(chart.getLegendFont());
1231: writer.closeElement();
1232:
1233: writer.writeExpression(
1234: JRXmlConstants.ELEMENT_anchorNameExpression, chart
1235: .getAnchorNameExpression(), false);
1236: writer.writeExpression(
1237: JRXmlConstants.ELEMENT_hyperlinkReferenceExpression,
1238: chart.getHyperlinkReferenceExpression(), false);
1239: writer.writeExpression(
1240: JRXmlConstants.ELEMENT_hyperlinkAnchorExpression, chart
1241: .getHyperlinkAnchorExpression(), false);
1242: writer.writeExpression(
1243: JRXmlConstants.ELEMENT_hyperlinkPageExpression, chart
1244: .getHyperlinkPageExpression(), false);
1245: writer.writeExpression(
1246: JRXmlConstants.ELEMENT_hyperlinkTooltipExpression,
1247: chart.getHyperlinkTooltipExpression(), false);
1248: writeHyperlinkParameters(chart.getHyperlinkParameters());
1249:
1250: writer.closeElement();
1251: }
1252:
1253: /**
1254: *
1255: */
1256: private void writeElementDataset(JRElementDataset dataset)
1257: throws IOException {
1258: writer.startElement(JRXmlConstants.ELEMENT_dataset);
1259: writer.addAttribute(JRXmlConstants.ATTRIBUTE_resetType, dataset
1260: .getResetType(), JRXmlConstants.getResetTypeMap(),
1261: JRVariable.RESET_TYPE_REPORT);
1262:
1263: if (dataset.getResetType() == JRVariable.RESET_TYPE_GROUP) {
1264: writer.addEncodedAttribute(
1265: JRXmlConstants.ATTRIBUTE_resetGroup, dataset
1266: .getResetGroup().getName());
1267: }
1268: writer.addAttribute(JRXmlConstants.ATTRIBUTE_incrementType,
1269: dataset.getIncrementType(), JRXmlConstants
1270: .getResetTypeMap(), JRVariable.RESET_TYPE_NONE);
1271:
1272: if (dataset.getIncrementType() == JRVariable.RESET_TYPE_GROUP) {
1273: writer.addEncodedAttribute(
1274: JRXmlConstants.ATTRIBUTE_incrementGroup, dataset
1275: .getIncrementGroup().getName());
1276: }
1277:
1278: writer.writeExpression(
1279: JRXmlConstants.ELEMENT_incrementWhenExpression, dataset
1280: .getIncrementWhenExpression(), false);
1281:
1282: JRDatasetRun datasetRun = dataset.getDatasetRun();
1283: if (datasetRun != null) {
1284: writeDatasetRun(datasetRun);
1285: }
1286:
1287: writer.closeElement(true);
1288: }
1289:
1290: /**
1291: *
1292: */
1293: private void writeCategoryDataSet(JRCategoryDataset dataset)
1294: throws IOException {
1295: writer.startElement(JRXmlConstants.ELEMENT_categoryDataset);
1296:
1297: writeElementDataset(dataset);
1298:
1299: /* */
1300: JRCategorySeries[] categorySeries = dataset.getSeries();
1301: if (categorySeries != null && categorySeries.length > 0) {
1302: for (int i = 0; i < categorySeries.length; i++) {
1303: writeCategorySeries(categorySeries[i]);
1304: }
1305: }
1306:
1307: writer.closeElement();
1308: }
1309:
1310: private void writeTimeSeriesDataset(JRTimeSeriesDataset dataset)
1311: throws IOException {
1312: writer.startElement(JRXmlConstants.ELEMENT_timeSeriesDataset);
1313: if (dataset.getTimePeriod() != null
1314: && !Day.class.getName().equals(
1315: dataset.getTimePeriod().getName())) {
1316: writer.addAttribute(JRXmlConstants.ATTRIBUTE_timePeriod,
1317: JRXmlConstants.getTimePeriodName(dataset
1318: .getTimePeriod()));
1319: }
1320:
1321: writeElementDataset(dataset);
1322:
1323: JRTimeSeries[] timeSeries = dataset.getSeries();
1324: if (timeSeries != null && timeSeries.length > 0) {
1325: for (int i = 0; i < timeSeries.length; i++) {
1326: writeTimeSeries(timeSeries[i]);
1327: }
1328: }
1329:
1330: writer.closeElement();
1331: }
1332:
1333: private void writeTimePeriodDataset(JRTimePeriodDataset dataset)
1334: throws IOException {
1335: writer.startElement(JRXmlConstants.ELEMENT_timePeriodDataset);
1336: writeElementDataset(dataset);
1337:
1338: JRTimePeriodSeries[] timePeriodSeries = dataset.getSeries();
1339: if (timePeriodSeries != null && timePeriodSeries.length > 0) {
1340: for (int i = 0; i < timePeriodSeries.length; i++) {
1341: writeTimePeriodSeries(timePeriodSeries[i]);
1342: }
1343: }
1344: writer.closeElement();
1345: }
1346:
1347: /**
1348: *
1349: */
1350: private void writeCategorySeries(JRCategorySeries categorySeries)
1351: throws IOException {
1352: writer.startElement(JRXmlConstants.ELEMENT_categorySeries);
1353:
1354: writer.writeExpression(JRXmlConstants.ELEMENT_seriesExpression,
1355: categorySeries.getSeriesExpression(), false);
1356: writer.writeExpression(
1357: JRXmlConstants.ELEMENT_categoryExpression,
1358: categorySeries.getCategoryExpression(), false);
1359: writer.writeExpression(JRXmlConstants.ELEMENT_valueExpression,
1360: categorySeries.getValueExpression(), false);
1361: writer.writeExpression(JRXmlConstants.ELEMENT_labelExpression,
1362: categorySeries.getLabelExpression(), false);
1363: writeHyperlink(JRXmlConstants.ELEMENT_itemHyperlink,
1364: categorySeries.getItemHyperlink());
1365:
1366: writer.closeElement();
1367: }
1368:
1369: /**
1370: *
1371: */
1372: private void writeXyzDataset(JRXyzDataset dataset)
1373: throws IOException {
1374: writer.startElement(JRXmlConstants.ELEMENT_xyzDataset);
1375: writeElementDataset(dataset);
1376:
1377: JRXyzSeries[] series = dataset.getSeries();
1378: if (series != null && series.length > 0) {
1379: for (int i = 0; i < series.length; i++) {
1380: writeXyzSeries(series[i]);
1381: }
1382: }
1383:
1384: writer.closeElement();
1385: }
1386:
1387: /**
1388: *
1389: */
1390: private void writeXyzSeries(JRXyzSeries series) throws IOException {
1391: writer.startElement(JRXmlConstants.ELEMENT_xyzSeries);
1392:
1393: writer.writeExpression(JRXmlConstants.ELEMENT_seriesExpression,
1394: series.getSeriesExpression(), false);
1395: writer.writeExpression(JRXmlConstants.ELEMENT_xValueExpression,
1396: series.getXValueExpression(), false);
1397: writer.writeExpression(JRXmlConstants.ELEMENT_yValueExpression,
1398: series.getYValueExpression(), false);
1399: writer.writeExpression(JRXmlConstants.ELEMENT_zValueExpression,
1400: series.getZValueExpression(), false);
1401: writeHyperlink(JRXmlConstants.ELEMENT_itemHyperlink, series
1402: .getItemHyperlink());
1403:
1404: writer.closeElement();
1405: }
1406:
1407: /**
1408: *
1409: */
1410: private void writeXySeries(JRXySeries xySeries) throws IOException {
1411: writer.startElement(JRXmlConstants.ELEMENT_xySeries);
1412:
1413: writer.writeExpression(JRXmlConstants.ELEMENT_seriesExpression,
1414: xySeries.getSeriesExpression(), false);
1415: writer.writeExpression(JRXmlConstants.ELEMENT_xValueExpression,
1416: xySeries.getXValueExpression(), false);
1417: writer.writeExpression(JRXmlConstants.ELEMENT_yValueExpression,
1418: xySeries.getYValueExpression(), false);
1419: writer.writeExpression(JRXmlConstants.ELEMENT_labelExpression,
1420: xySeries.getLabelExpression(), false);
1421: writeHyperlink(JRXmlConstants.ELEMENT_itemHyperlink, xySeries
1422: .getItemHyperlink());
1423:
1424: writer.closeElement();
1425: }
1426:
1427: /**
1428: *
1429: */
1430: private void writeXyDataset(JRXyDataset dataset) throws IOException {
1431: writer.startElement(JRXmlConstants.ELEMENT_xyDataset);
1432:
1433: writeElementDataset(dataset);
1434:
1435: /* */
1436: JRXySeries[] xySeries = dataset.getSeries();
1437: if (xySeries != null && xySeries.length > 0) {
1438: for (int i = 0; i < xySeries.length; i++) {
1439: writeXySeries(xySeries[i]);
1440: }
1441: }
1442:
1443: writer.closeElement();
1444: }
1445:
1446: /**
1447: *
1448: */
1449: private void writeTimeSeries(JRTimeSeries timeSeries)
1450: throws IOException {
1451: writer.startElement(JRXmlConstants.ELEMENT_timeSeries);
1452:
1453: writer.writeExpression(JRXmlConstants.ELEMENT_seriesExpression,
1454: timeSeries.getSeriesExpression(), false);
1455: writer.writeExpression(
1456: JRXmlConstants.ELEMENT_timePeriodExpression, timeSeries
1457: .getTimePeriodExpression(), false);
1458: writer.writeExpression(JRXmlConstants.ELEMENT_valueExpression,
1459: timeSeries.getValueExpression(), false);
1460: writer.writeExpression(JRXmlConstants.ELEMENT_labelExpression,
1461: timeSeries.getLabelExpression(), false);
1462: writeHyperlink(JRXmlConstants.ELEMENT_itemHyperlink, timeSeries
1463: .getItemHyperlink());
1464:
1465: writer.closeElement();
1466: }
1467:
1468: private void writeTimePeriodSeries(
1469: JRTimePeriodSeries timePeriodSeries) throws IOException {
1470: writer.startElement(JRXmlConstants.ELEMENT_timePeriodSeries);
1471:
1472: writer.writeExpression(JRXmlConstants.ELEMENT_seriesExpression,
1473: timePeriodSeries.getSeriesExpression(), false);
1474: writer.writeExpression(
1475: JRXmlConstants.ELEMENT_startDateExpression,
1476: timePeriodSeries.getStartDateExpression(), false);
1477: writer.writeExpression(
1478: JRXmlConstants.ELEMENT_endDateExpression,
1479: timePeriodSeries.getEndDateExpression(), false);
1480: writer.writeExpression(JRXmlConstants.ELEMENT_valueExpression,
1481: timePeriodSeries.getValueExpression(), false);
1482: writer.writeExpression(JRXmlConstants.ELEMENT_labelExpression,
1483: timePeriodSeries.getLabelExpression(), false);
1484: writeHyperlink(JRXmlConstants.ELEMENT_itemHyperlink,
1485: timePeriodSeries.getItemHyperlink());
1486:
1487: writer.closeElement();
1488: }
1489:
1490: /**
1491: *
1492: */
1493: public void writePieDataset(JRPieDataset dataset)
1494: throws IOException {
1495: writer.startElement(JRXmlConstants.ELEMENT_pieDataset);
1496:
1497: writeElementDataset(dataset);
1498:
1499: writer.writeExpression(JRXmlConstants.ELEMENT_keyExpression,
1500: dataset.getKeyExpression(), false);
1501: writer.writeExpression(JRXmlConstants.ELEMENT_valueExpression,
1502: dataset.getValueExpression(), false);
1503: writer.writeExpression(JRXmlConstants.ELEMENT_labelExpression,
1504: dataset.getLabelExpression(), false);
1505: writeHyperlink(JRXmlConstants.ELEMENT_sectionHyperlink, dataset
1506: .getSectionHyperlink());
1507:
1508: writer.closeElement();
1509: }
1510:
1511: /**
1512: * Writes the description of a value dataset to the output stream.
1513: * @param dataset the value dataset to persist
1514: */
1515: public void writeValueDataset(JRValueDataset dataset)
1516: throws IOException {
1517: writer.startElement(JRXmlConstants.ELEMENT_valueDataset);
1518:
1519: writeElementDataset(dataset);
1520:
1521: writer.writeExpression(JRXmlConstants.ELEMENT_valueExpression,
1522: dataset.getValueExpression(), false);
1523:
1524: writer.closeElement();
1525: }
1526:
1527: /**
1528: * Writes the description of how to display a value in a valueDataset.
1529: *
1530: * @param valueDisplay the description to save
1531: */
1532: public void writeValueDisplay(JRValueDisplay valueDisplay)
1533: throws IOException {
1534: writer.startElement(JRXmlConstants.ELEMENT_valueDisplay);
1535:
1536: writer.addAttribute(JRXmlConstants.ATTRIBUTE_color,
1537: valueDisplay.getColor());
1538: writer.addAttribute(JRXmlConstants.ATTRIBUTE_mask, valueDisplay
1539: .getMask());
1540:
1541: writeFont(valueDisplay.getFont());
1542:
1543: writer.closeElement();
1544: }
1545:
1546: /**
1547: * Writes a data range block to the output stream.
1548: *
1549: * @param dataRange the range to write
1550: */
1551: public void writeDataRange(JRDataRange dataRange)
1552: throws IOException {
1553: writer.startElement(JRXmlConstants.ELEMENT_dataRange);
1554:
1555: writer.writeExpression(JRXmlConstants.ELEMENT_lowExpression,
1556: dataRange.getLowExpression(), false);
1557: writer.writeExpression(JRXmlConstants.ELEMENT_highExpression,
1558: dataRange.getHighExpression(), false);
1559:
1560: writer.closeElement();
1561: }
1562:
1563: /**
1564: * Writes a meter interval description to the output stream.
1565: *
1566: * @param interval the interval to write
1567: */
1568: private void writeMeterInterval(JRMeterInterval interval)
1569: throws IOException {
1570: writer.startElement(JRXmlConstants.ELEMENT_meterInterval);
1571:
1572: writer.addAttribute(JRXmlConstants.ATTRIBUTE_label, interval
1573: .getLabel());
1574: writer.addAttribute(JRXmlConstants.ATTRIBUTE_color, interval
1575: .getBackgroundColor());
1576: writer.addAttribute(JRXmlConstants.ATTRIBUTE_alpha, interval
1577: .getAlpha());
1578:
1579: writeDataRange(interval.getDataRange());
1580:
1581: writer.closeElement();
1582: }
1583:
1584: /**
1585: * Writes out the contents of a series colors block for a chart. Assumes the caller
1586: * has already written the <code><seriesColors></code> tag.
1587: *
1588: * @param seriesColors the colors to write
1589: */
1590: private void writeSeriesColors(SortedSet seriesColors)
1591: throws IOException {
1592: if (seriesColors == null || seriesColors.size() == 0)
1593: return;
1594:
1595: JRSeriesColor[] colors = (JRSeriesColor[]) seriesColors
1596: .toArray(new JRSeriesColor[0]);
1597: for (int i = 0; i < colors.length; i++) {
1598: writer.startElement(JRXmlConstants.ELEMENT_seriesColor);
1599: writer.addAttribute(JRXmlConstants.ATTRIBUTE_seriesOrder,
1600: colors[i].getSeriesOrder());
1601: writer.addAttribute(JRXmlConstants.ATTRIBUTE_color,
1602: colors[i].getColor());
1603: writer.closeElement();
1604: }
1605: }
1606:
1607: /**
1608: * Write the information about a the data and layout that make up one range axis in
1609: * a multiple axis chart.
1610: *
1611: * @param chartAxis the axis being written
1612: */
1613: private void writeChartAxis(JRChartAxis chartAxis)
1614: throws IOException {
1615: writer.startElement(JRChartAxisFactory.ELEMENT_axis);
1616: writer.addAttribute(JRChartAxisFactory.ATTRIBUTE_position,
1617: chartAxis.getPosition(), JRXmlConstants
1618: .getAxisPositionMap(),
1619: JRChartAxis.POSITION_LEFT_OR_TOP);
1620:
1621: // Let the nested chart describe itself
1622: writeChartTag(chartAxis.getChart());
1623: writer.closeElement();
1624: }
1625:
1626: /**
1627: *
1628: *
1629: */
1630: private void writePlot(JRChartPlot plot) throws IOException {
1631: writer.startElement(JRXmlConstants.ELEMENT_plot);
1632: writer.addAttribute(JRXmlConstants.ATTRIBUTE_backcolor, plot
1633: .getOwnBackcolor());
1634: writer.addAttribute(JRXmlConstants.ATTRIBUTE_orientation, plot
1635: .getOrientation(), JRXmlConstants
1636: .getPlotOrientationMap(), PlotOrientation.VERTICAL);
1637: writer.addAttribute(JRXmlConstants.ATTRIBUTE_backgroundAlpha,
1638: plot.getBackgroundAlpha(), 1.0f);
1639: writer.addAttribute(JRXmlConstants.ATTRIBUTE_foregroundAlpha,
1640: plot.getForegroundAlpha(), 1.0f);
1641: writer.addAttribute(JRXmlConstants.ATTRIBUTE_labelRotation,
1642: plot.getLabelRotation(), 0.0);
1643: writeSeriesColors(plot.getSeriesColors());
1644:
1645: writer.closeElement();
1646: }
1647:
1648: /**
1649: *
1650: */
1651: public void writePieChart(JRChart chart) throws IOException {
1652: writer.startElement(JRXmlConstants.ELEMENT_pieChart);
1653: writeChart(chart);
1654: writePieDataset((JRPieDataset) chart.getDataset());
1655:
1656: // write plot
1657: JRPiePlot plot = (JRPiePlot) chart.getPlot();
1658: writer.startElement(JRXmlConstants.ELEMENT_piePlot);
1659: writer.addAttribute(JRXmlConstants.ATTRIBUTE_isCircular, plot
1660: .isCircular(), false);
1661: writePlot(chart.getPlot());
1662: writer.closeElement();
1663:
1664: writer.closeElement();
1665: }
1666:
1667: /**
1668: *
1669: */
1670: public void writePie3DChart(JRChart chart) throws IOException {
1671: writer.startElement(JRXmlConstants.ELEMENT_pie3DChart);
1672: writeChart(chart);
1673: writePieDataset((JRPieDataset) chart.getDataset());
1674:
1675: // write plot
1676: JRPie3DPlot plot = (JRPie3DPlot) chart.getPlot();
1677: writer.startElement(JRXmlConstants.ELEMENT_pie3DPlot);
1678: writer.addAttribute(JRXmlConstants.ATTRIBUTE_depthFactor, plot
1679: .getDepthFactor(), JRPie3DPlot.DEPTH_FACTOR_DEFAULT);
1680: writer.addAttribute(JRXmlConstants.ATTRIBUTE_isCircular, plot
1681: .isCircular(), false);
1682: writePlot(chart.getPlot());
1683: writer.closeElement();
1684:
1685: writer.closeElement();
1686: }
1687:
1688: /**
1689: * Writes out the axis format block for a chart axis.
1690: *
1691: * @param axisFormatElementName the name of the axis format element being written
1692: * @param axisLabelFont font to use for the axis label
1693: * @param axisLabelColor color to use for the axis label
1694: * @param axisTickLabelFont font to use for the label of each tick mark
1695: * @param axisTickLabelColor color to use for the label of each tick mark
1696: * @param axisTickLabelMask formatting mask to use for the label of each tick mark
1697: * @param axisLineColor the color to use for the axis line and any tick marks
1698: *
1699: */
1700: public void writeAxisFormat(String axisFormatElementName,
1701: JRFont axisLabelFont, Color axisLabelColor,
1702: JRFont axisTickLabelFont, Color axisTickLabelColor,
1703: String axisTickLabelMask, Color axisLineColor)
1704: throws IOException {
1705: if (axisLabelFont == null && axisLabelColor == null
1706: && axisTickLabelFont == null
1707: && axisTickLabelColor == null && axisLineColor == null)
1708: return;
1709:
1710: writer.startElement(axisFormatElementName);
1711: writer.startElement(JRXmlConstants.ELEMENT_axisFormat);
1712: writer.addAttribute(JRXmlConstants.ATTRIBUTE_labelColor,
1713: axisLabelColor);
1714: writer.addAttribute(JRXmlConstants.ATTRIBUTE_tickLabelColor,
1715: axisTickLabelColor);
1716: writer.addAttribute(JRXmlConstants.ATTRIBUTE_tickLabelMask,
1717: axisTickLabelMask);
1718: writer.addAttribute(JRXmlConstants.ATTRIBUTE_axisLineColor,
1719: axisLineColor);
1720:
1721: if (axisLabelFont != null) {
1722: writer.startElement(JRXmlConstants.ELEMENT_labelFont);
1723: writeFont(axisLabelFont);
1724: writer.closeElement();
1725: }
1726:
1727: if (axisTickLabelFont != null) {
1728: writer.startElement(JRXmlConstants.ELEMENT_tickLabelFont);
1729: writeFont(axisTickLabelFont);
1730: writer.closeElement();
1731: }
1732:
1733: writer.closeElement();
1734: writer.closeElement();
1735: }
1736:
1737: /**
1738: *
1739: */
1740: private void writeBarPlot(JRBarPlot plot) throws IOException {
1741: writer.startElement(JRXmlConstants.ELEMENT_barPlot);
1742: writer.addAttribute(JRXmlConstants.ATTRIBUTE_isShowLabels, plot
1743: .isShowLabels(), false);
1744: writer.addAttribute(JRXmlConstants.ATTRIBUTE_isShowTickLabels,
1745: plot.isShowTickLabels(), true);
1746: writer.addAttribute(JRXmlConstants.ATTRIBUTE_isShowTickMarks,
1747: plot.isShowTickMarks(), true);
1748: writePlot(plot);
1749:
1750: writer.writeExpression(
1751: JRXmlConstants.ELEMENT_categoryAxisLabelExpression,
1752: plot.getCategoryAxisLabelExpression(), false);
1753: writeAxisFormat(JRXmlConstants.ELEMENT_categoryAxisFormat, plot
1754: .getCategoryAxisLabelFont(), plot
1755: .getOwnCategoryAxisLabelColor(), plot
1756: .getCategoryAxisTickLabelFont(), plot
1757: .getOwnCategoryAxisTickLabelColor(), plot
1758: .getCategoryAxisTickLabelMask(), plot
1759: .getOwnCategoryAxisLineColor());
1760: writer.writeExpression(
1761: JRXmlConstants.ELEMENT_valueAxisLabelExpression, plot
1762: .getValueAxisLabelExpression(), false);
1763: writeAxisFormat(JRXmlConstants.ELEMENT_valueAxisFormat, plot
1764: .getValueAxisLabelFont(), plot
1765: .getOwnValueAxisLabelColor(), plot
1766: .getValueAxisTickLabelFont(), plot
1767: .getOwnValueAxisTickLabelColor(), plot
1768: .getValueAxisTickLabelMask(), plot
1769: .getOwnValueAxisLineColor());
1770:
1771: writer.closeElement();
1772: }
1773:
1774: /**
1775: *
1776: */
1777: private void writeBubblePlot(JRBubblePlot plot) throws IOException {
1778: writer.startElement(JRXmlConstants.ELEMENT_bubblePlot);
1779: writer.addAttribute(JRXmlConstants.ATTRIBUTE_scaleType, plot
1780: .getScaleType(), JRXmlConstants.getScaleTypeMap());
1781: writePlot(plot);
1782:
1783: writer.writeExpression(
1784: JRXmlConstants.ELEMENT_xAxisLabelExpression, plot
1785: .getXAxisLabelExpression(), false);
1786: writeAxisFormat(JRXmlConstants.ELEMENT_xAxisFormat, plot
1787: .getXAxisLabelFont(), plot.getOwnXAxisLabelColor(),
1788: plot.getXAxisTickLabelFont(), plot
1789: .getOwnXAxisTickLabelColor(), plot
1790: .getXAxisTickLabelMask(), plot
1791: .getOwnXAxisLineColor());
1792: writer.writeExpression(
1793: JRXmlConstants.ELEMENT_yAxisLabelExpression, plot
1794: .getYAxisLabelExpression(), false);
1795: writeAxisFormat(JRXmlConstants.ELEMENT_yAxisFormat, plot
1796: .getYAxisLabelFont(), plot.getOwnYAxisLabelColor(),
1797: plot.getYAxisTickLabelFont(), plot
1798: .getOwnYAxisTickLabelColor(), plot
1799: .getYAxisTickLabelMask(), plot
1800: .getOwnYAxisLineColor());
1801:
1802: writer.closeElement();
1803: }
1804:
1805: /**
1806: *
1807: */
1808: private void writeLinePlot(JRLinePlot plot) throws IOException {
1809: writer.startElement(JRXmlConstants.ELEMENT_linePlot);
1810: writer.addAttribute(JRXmlConstants.ATTRIBUTE_isShowLines, plot
1811: .isShowLines(), true);
1812: writer.addAttribute(JRXmlConstants.ATTRIBUTE_isShowShapes, plot
1813: .isShowShapes(), true);
1814:
1815: writePlot(plot);
1816:
1817: writer.writeExpression(
1818: JRXmlConstants.ELEMENT_categoryAxisLabelExpression,
1819: plot.getCategoryAxisLabelExpression(), false);
1820: writeAxisFormat(JRXmlConstants.ELEMENT_categoryAxisFormat, plot
1821: .getCategoryAxisLabelFont(), plot
1822: .getOwnCategoryAxisLabelColor(), plot
1823: .getCategoryAxisTickLabelFont(), plot
1824: .getOwnCategoryAxisTickLabelColor(), plot
1825: .getCategoryAxisTickLabelMask(), plot
1826: .getOwnCategoryAxisLineColor());
1827: writer.writeExpression(
1828: JRXmlConstants.ELEMENT_valueAxisLabelExpression, plot
1829: .getValueAxisLabelExpression(), false);
1830: writeAxisFormat(JRXmlConstants.ELEMENT_valueAxisFormat, plot
1831: .getValueAxisLabelFont(), plot
1832: .getOwnValueAxisLabelColor(), plot
1833: .getValueAxisTickLabelFont(), plot
1834: .getOwnValueAxisTickLabelColor(), plot
1835: .getValueAxisTickLabelMask(), plot
1836: .getOwnValueAxisLineColor());
1837:
1838: writer.closeElement();
1839: }
1840:
1841: private void writeTimeSeriesPlot(JRTimeSeriesPlot plot)
1842: throws IOException {
1843: writer.startElement(JRXmlConstants.ELEMENT_timeSeriesPlot);
1844: writer.addAttribute(JRXmlConstants.ATTRIBUTE_isShowLines, plot
1845: .isShowLines(), true);
1846: writer.addAttribute(JRXmlConstants.ATTRIBUTE_isShowShapes, plot
1847: .isShowShapes(), true);
1848:
1849: writePlot(plot);
1850:
1851: writer.writeExpression(
1852: JRXmlConstants.ELEMENT_timeAxisLabelExpression, plot
1853: .getTimeAxisLabelExpression(), false);
1854: writeAxisFormat(JRXmlConstants.ELEMENT_timeAxisFormat, plot
1855: .getTimeAxisLabelFont(), plot
1856: .getOwnTimeAxisLabelColor(), plot
1857: .getTimeAxisTickLabelFont(), plot
1858: .getOwnTimeAxisTickLabelColor(), plot
1859: .getTimeAxisTickLabelMask(), plot
1860: .getOwnTimeAxisLineColor());
1861: writer.writeExpression(
1862: JRXmlConstants.ELEMENT_valueAxisLabelExpression, plot
1863: .getValueAxisLabelExpression(), false);
1864: writeAxisFormat(JRXmlConstants.ELEMENT_valueAxisFormat, plot
1865: .getValueAxisLabelFont(), plot
1866: .getOwnValueAxisLabelColor(), plot
1867: .getValueAxisTickLabelFont(), plot
1868: .getOwnValueAxisTickLabelColor(), plot
1869: .getValueAxisTickLabelMask(), plot
1870: .getOwnValueAxisLineColor());
1871:
1872: writer.closeElement();
1873: }
1874:
1875: /**
1876: *
1877: */
1878: public void writeBar3DPlot(JRBar3DPlot plot) throws IOException {
1879: writer.startElement(JRXmlConstants.ELEMENT_bar3DPlot);
1880: writer.addAttribute(JRXmlConstants.ATTRIBUTE_isShowLabels, plot
1881: .isShowLabels(), false);
1882: writer.addAttribute(JRXmlConstants.ATTRIBUTE_xOffset, plot
1883: .getXOffset(), BarRenderer3D.DEFAULT_X_OFFSET);
1884: writer.addAttribute(JRXmlConstants.ATTRIBUTE_yOffset, plot
1885: .getYOffset(), BarRenderer3D.DEFAULT_Y_OFFSET);
1886:
1887: writePlot(plot);
1888:
1889: writer.writeExpression(
1890: JRXmlConstants.ELEMENT_categoryAxisLabelExpression,
1891: plot.getCategoryAxisLabelExpression(), false);
1892: writeAxisFormat(JRXmlConstants.ELEMENT_categoryAxisFormat, plot
1893: .getCategoryAxisLabelFont(), plot
1894: .getOwnCategoryAxisLabelColor(), plot
1895: .getCategoryAxisTickLabelFont(), plot
1896: .getOwnCategoryAxisTickLabelColor(), plot
1897: .getCategoryAxisTickLabelMask(), plot
1898: .getOwnCategoryAxisLineColor());
1899: writer.writeExpression(
1900: JRXmlConstants.ELEMENT_valueAxisLabelExpression, plot
1901: .getValueAxisLabelExpression(), false);
1902: writeAxisFormat(JRXmlConstants.ELEMENT_valueAxisFormat, plot
1903: .getValueAxisLabelFont(), plot
1904: .getOwnValueAxisLabelColor(), plot
1905: .getValueAxisTickLabelFont(), plot
1906: .getOwnValueAxisTickLabelColor(), plot
1907: .getValueAxisTickLabelMask(), plot
1908: .getOwnValueAxisLineColor());
1909:
1910: writer.closeElement();
1911: }
1912:
1913: /**
1914: *
1915: */
1916: public void writeBarChart(JRChart chart) throws IOException {
1917: writer.startElement(JRXmlConstants.ELEMENT_barChart);
1918:
1919: writeChart(chart);
1920: writeCategoryDataSet((JRCategoryDataset) chart.getDataset());
1921: writeBarPlot((JRBarPlot) chart.getPlot());
1922:
1923: writer.closeElement();
1924: }
1925:
1926: /**
1927: *
1928: */
1929: public void writeBar3DChart(JRChart chart) throws IOException {
1930: writer.startElement(JRXmlConstants.ELEMENT_bar3DChart);
1931:
1932: writeChart(chart);
1933: writeCategoryDataSet((JRCategoryDataset) chart.getDataset());
1934: writeBar3DPlot((JRBar3DPlot) chart.getPlot());
1935:
1936: writer.closeElement();
1937: }
1938:
1939: /**
1940: *
1941: */
1942: public void writeBubbleChart(JRChart chart) throws IOException {
1943: writer.startElement(JRXmlConstants.ELEMENT_bubbleChart);
1944: writeChart(chart);
1945: writeXyzDataset((JRXyzDataset) chart.getDataset());
1946: writeBubblePlot((JRBubblePlot) chart.getPlot());
1947: writer.closeElement();
1948: }
1949:
1950: /**
1951: *
1952: */
1953: public void writeStackedBarChart(JRChart chart) throws IOException {
1954: writer.startElement(JRXmlConstants.ELEMENT_stackedBarChart);
1955:
1956: writeChart(chart);
1957: writeCategoryDataSet((JRCategoryDataset) chart.getDataset());
1958: writeBarPlot((JRBarPlot) chart.getPlot());
1959:
1960: writer.closeElement();
1961: }
1962:
1963: /**
1964: *
1965: */
1966: public void writeStackedBar3DChart(JRChart chart)
1967: throws IOException {
1968: writer.startElement(JRXmlConstants.ELEMENT_stackedBar3DChart);
1969:
1970: writeChart(chart);
1971: writeCategoryDataSet((JRCategoryDataset) chart.getDataset());
1972: writeBar3DPlot((JRBar3DPlot) chart.getPlot());
1973: writer.closeElement();
1974: }
1975:
1976: /**
1977: *
1978: */
1979: public void writeLineChart(JRChart chart) throws IOException {
1980: writer.startElement(JRXmlConstants.ELEMENT_lineChart);
1981:
1982: writeChart(chart);
1983: writeCategoryDataSet((JRCategoryDataset) chart.getDataset());
1984: writeLinePlot((JRLinePlot) chart.getPlot());
1985: writer.closeElement();
1986: }
1987:
1988: public void writeTimeSeriesChart(JRChart chart) throws IOException {
1989: writer.startElement(JRXmlConstants.ELEMENT_timeSeriesChart);
1990: writeChart(chart);
1991: writeTimeSeriesDataset((JRTimeSeriesDataset) chart.getDataset());
1992: writeTimeSeriesPlot((JRTimeSeriesPlot) chart.getPlot());
1993: writer.closeElement();
1994: }
1995:
1996: public void writeHighLowDataset(JRHighLowDataset dataset)
1997: throws IOException {
1998: writer.startElement(JRXmlConstants.ELEMENT_highLowDataset);
1999:
2000: writeElementDataset(dataset);
2001:
2002: writer.writeExpression(JRXmlConstants.ELEMENT_seriesExpression,
2003: dataset.getSeriesExpression(), false);
2004: writer.writeExpression(JRXmlConstants.ELEMENT_dateExpression,
2005: dataset.getDateExpression(), false);
2006: writer.writeExpression(JRXmlConstants.ELEMENT_highExpression,
2007: dataset.getHighExpression(), false);
2008: writer.writeExpression(JRXmlConstants.ELEMENT_lowExpression,
2009: dataset.getLowExpression(), false);
2010: writer.writeExpression(JRXmlConstants.ELEMENT_openExpression,
2011: dataset.getOpenExpression(), false);
2012: writer.writeExpression(JRXmlConstants.ELEMENT_closeExpression,
2013: dataset.getCloseExpression(), false);
2014: writer.writeExpression(JRXmlConstants.ELEMENT_volumeExpression,
2015: dataset.getVolumeExpression(), false);
2016: writeHyperlink(JRXmlConstants.ELEMENT_itemHyperlink, dataset
2017: .getItemHyperlink());
2018:
2019: writer.closeElement();
2020: }
2021:
2022: public void writeHighLowChart(JRChart chart) throws IOException {
2023: writer.startElement(JRXmlConstants.ELEMENT_highLowChart);
2024:
2025: writeChart(chart);
2026: writeHighLowDataset((JRHighLowDataset) chart.getDataset());
2027:
2028: JRHighLowPlot plot = (JRHighLowPlot) chart.getPlot();
2029: writer.startElement(JRXmlConstants.ELEMENT_highLowPlot);
2030: writer.addAttribute(JRXmlConstants.ATTRIBUTE_isShowOpenTicks,
2031: plot.isShowOpenTicks(), true);
2032: writer.addAttribute(JRXmlConstants.ATTRIBUTE_isShowCloseTicks,
2033: plot.isShowCloseTicks(), true);
2034:
2035: writePlot(plot);
2036:
2037: writer.writeExpression(
2038: JRXmlConstants.ELEMENT_timeAxisLabelExpression, plot
2039: .getTimeAxisLabelExpression(), false);
2040: writeAxisFormat(JRXmlConstants.ELEMENT_timeAxisFormat, plot
2041: .getTimeAxisLabelFont(), plot
2042: .getOwnTimeAxisLabelColor(), plot
2043: .getTimeAxisTickLabelFont(), plot
2044: .getOwnTimeAxisTickLabelColor(), plot
2045: .getTimeAxisTickLabelMask(), plot
2046: .getOwnTimeAxisLineColor());
2047: writer.writeExpression(
2048: JRXmlConstants.ELEMENT_valueAxisLabelExpression, plot
2049: .getValueAxisLabelExpression(), false);
2050: writeAxisFormat(JRXmlConstants.ELEMENT_valueAxisFormat, plot
2051: .getValueAxisLabelFont(), plot
2052: .getOwnValueAxisLabelColor(), plot
2053: .getValueAxisTickLabelFont(), plot
2054: .getOwnValueAxisTickLabelColor(), plot
2055: .getValueAxisTickLabelMask(), plot
2056: .getOwnValueAxisLineColor());
2057:
2058: writer.closeElement();
2059: writer.closeElement();
2060: }
2061:
2062: public void writeCandlestickChart(JRChart chart) throws IOException {
2063: writer.startElement(JRXmlConstants.ELEMENT_candlestickChart);
2064:
2065: writeChart(chart);
2066: writeHighLowDataset((JRHighLowDataset) chart.getDataset());
2067:
2068: JRCandlestickPlot plot = (JRCandlestickPlot) chart.getPlot();
2069: writer.startElement(JRXmlConstants.ELEMENT_candlestickPlot);
2070: writer.addAttribute(JRXmlConstants.ATTRIBUTE_isShowVolume, plot
2071: .isShowVolume(), true);
2072:
2073: writePlot(plot);
2074:
2075: writer.writeExpression(
2076: JRXmlConstants.ELEMENT_timeAxisLabelExpression, plot
2077: .getTimeAxisLabelExpression(), false);
2078: writeAxisFormat(JRXmlConstants.ELEMENT_timeAxisFormat, plot
2079: .getTimeAxisLabelFont(), plot
2080: .getOwnTimeAxisLabelColor(), plot
2081: .getTimeAxisTickLabelFont(), plot
2082: .getOwnTimeAxisTickLabelColor(), plot
2083: .getTimeAxisTickLabelMask(), plot
2084: .getOwnTimeAxisLineColor());
2085: writer.writeExpression(
2086: JRXmlConstants.ELEMENT_valueAxisLabelExpression, plot
2087: .getValueAxisLabelExpression(), false);
2088: writeAxisFormat(JRXmlConstants.ELEMENT_valueAxisFormat, plot
2089: .getValueAxisLabelFont(), plot
2090: .getOwnValueAxisLabelColor(), plot
2091: .getValueAxisTickLabelFont(), plot
2092: .getOwnValueAxisTickLabelColor(), plot
2093: .getValueAxisTickLabelMask(), plot
2094: .getOwnValueAxisLineColor());
2095:
2096: writer.closeElement();
2097: writer.closeElement();
2098: }
2099:
2100: /**
2101: *
2102: */
2103: private void writeAreaPlot(JRAreaPlot plot) throws IOException {
2104: writer.startElement(JRXmlConstants.ELEMENT_areaPlot);
2105: writePlot(plot);
2106:
2107: writer.writeExpression(
2108: JRXmlConstants.ELEMENT_categoryAxisLabelExpression,
2109: plot.getCategoryAxisLabelExpression(), false);
2110: writeAxisFormat(JRXmlConstants.ELEMENT_categoryAxisFormat, plot
2111: .getCategoryAxisLabelFont(), plot
2112: .getOwnCategoryAxisLabelColor(), plot
2113: .getCategoryAxisTickLabelFont(), plot
2114: .getOwnCategoryAxisTickLabelColor(), plot
2115: .getCategoryAxisTickLabelMask(), plot
2116: .getOwnCategoryAxisLineColor());
2117: writer.writeExpression(
2118: JRXmlConstants.ELEMENT_valueAxisLabelExpression, plot
2119: .getValueAxisLabelExpression(), false);
2120: writeAxisFormat(JRXmlConstants.ELEMENT_valueAxisFormat, plot
2121: .getValueAxisLabelFont(), plot
2122: .getOwnValueAxisLabelColor(), plot
2123: .getValueAxisTickLabelFont(), plot
2124: .getOwnValueAxisTickLabelColor(), plot
2125: .getValueAxisTickLabelMask(), plot
2126: .getOwnValueAxisLineColor());
2127:
2128: writer.closeElement();
2129: }
2130:
2131: /**
2132: *
2133: */
2134: public void writeAreaChart(JRChart chart) throws IOException {
2135: writer.startElement(JRXmlConstants.ELEMENT_areaChart);
2136:
2137: writeChart(chart);
2138: writeCategoryDataSet((JRCategoryDataset) chart.getDataset());
2139: writeAreaPlot((JRAreaPlot) chart.getPlot());
2140:
2141: writer.closeElement();
2142: }
2143:
2144: /**
2145: *
2146: */
2147: private void writeScatterPlot(JRScatterPlot plot)
2148: throws IOException {
2149: writer.startElement(JRXmlConstants.ELEMENT_scatterPlot);
2150: writer.addAttribute(JRXmlConstants.ATTRIBUTE_isShowLines, plot
2151: .isShowLines(), true);
2152: writer.addAttribute(JRXmlConstants.ATTRIBUTE_isShowShapes, plot
2153: .isShowShapes(), true);
2154:
2155: writePlot(plot);
2156:
2157: writer.writeExpression(
2158: JRXmlConstants.ELEMENT_xAxisLabelExpression, plot
2159: .getXAxisLabelExpression(), false);
2160: writeAxisFormat(JRXmlConstants.ELEMENT_xAxisFormat, plot
2161: .getXAxisLabelFont(), plot.getOwnXAxisLabelColor(),
2162: plot.getXAxisTickLabelFont(), plot
2163: .getOwnXAxisTickLabelColor(), plot
2164: .getXAxisTickLabelMask(), plot
2165: .getOwnXAxisLineColor());
2166: writer.writeExpression(
2167: JRXmlConstants.ELEMENT_yAxisLabelExpression, plot
2168: .getYAxisLabelExpression(), false);
2169: writeAxisFormat(JRXmlConstants.ELEMENT_yAxisFormat, plot
2170: .getYAxisLabelFont(), plot.getOwnYAxisLabelColor(),
2171: plot.getYAxisTickLabelFont(), plot
2172: .getOwnYAxisTickLabelColor(), plot
2173: .getYAxisTickLabelMask(), plot
2174: .getOwnYAxisLineColor());
2175:
2176: writer.closeElement();
2177: }
2178:
2179: /**
2180: *
2181: */
2182: public void writeScatterChart(JRChart chart) throws IOException {
2183: writer.startElement(JRXmlConstants.ELEMENT_scatterChart);
2184:
2185: writeChart(chart);
2186: writeXyDataset((JRXyDataset) chart.getDataset());
2187: writeScatterPlot((JRScatterPlot) chart.getPlot());
2188:
2189: writer.closeElement();
2190: }
2191:
2192: /**
2193: *
2194: */
2195: public void writeXyAreaChart(JRChart chart) throws IOException {
2196: writer.startElement(JRXmlConstants.ELEMENT_xyAreaChart);
2197:
2198: writeChart(chart);
2199: writeXyDataset((JRXyDataset) chart.getDataset());
2200: writeAreaPlot((JRAreaPlot) chart.getPlot());
2201:
2202: writer.closeElement();
2203: }
2204:
2205: /**
2206: *
2207: */
2208: public void writeXyBarChart(JRChart chart) throws IOException {
2209: writer.startElement(JRXmlConstants.ELEMENT_xyBarChart);
2210:
2211: writeChart(chart);
2212: JRChartDataset dataset = chart.getDataset();
2213:
2214: if (dataset.getDatasetType() == JRChartDataset.TIMESERIES_DATASET) {
2215: writeTimeSeriesDataset((JRTimeSeriesDataset) dataset);
2216: } else if (dataset.getDatasetType() == JRChartDataset.TIMEPERIOD_DATASET) {
2217: writeTimePeriodDataset((JRTimePeriodDataset) dataset);
2218: } else if (dataset.getDatasetType() == JRChartDataset.XY_DATASET) {
2219: writeXyDataset((JRXyDataset) dataset);
2220: }
2221:
2222: writeBarPlot((JRBarPlot) chart.getPlot());
2223:
2224: writer.closeElement();
2225: }
2226:
2227: /**
2228: *
2229: */
2230: public void writeXyLineChart(JRChart chart) throws IOException {
2231: writer.startElement(JRXmlConstants.ELEMENT_xyLineChart);
2232:
2233: writeChart(chart);
2234: writeXyDataset((JRXyDataset) chart.getDataset());
2235: writeLinePlot((JRLinePlot) chart.getPlot());
2236:
2237: writer.closeElement();
2238: }
2239:
2240: /**
2241: * Writes the definition of a meter chart to the output stream.
2242: *
2243: * @param chart the meter chart to write
2244: */
2245: public void writeMeterChart(JRChart chart) throws IOException {
2246: writer.startElement(JRXmlConstants.ELEMENT_meterChart);
2247:
2248: writeChart(chart);
2249: writeValueDataset((JRValueDataset) chart.getDataset());
2250:
2251: // write plot
2252: JRMeterPlot plot = (JRMeterPlot) chart.getPlot();
2253: writer.startElement(JRMeterPlotFactory.ELEMENT_meterPlot);
2254: writer.addAttribute(JRMeterPlotFactory.ATTRIBUTE_shape, plot
2255: .getShape(), JRXmlConstants.getMeterShapeMap(),
2256: JRMeterPlot.SHAPE_PIE);
2257: writer.addAttribute(JRMeterPlotFactory.ATTRIBUTE_angle, plot
2258: .getMeterAngle());
2259: writer.addAttribute(JRMeterPlotFactory.ATTRIBUTE_units, plot
2260: .getUnits());
2261: writer.addAttribute(JRMeterPlotFactory.ATTRIBUTE_tickInterval,
2262: plot.getTickInterval());
2263: writer.addAttribute(JRMeterPlotFactory.ATTRIBUTE_meterColor,
2264: plot.getMeterBackgroundColor());
2265: writer.addAttribute(JRMeterPlotFactory.ATTRIBUTE_needleColor,
2266: plot.getNeedleColor());
2267: writer.addAttribute(JRMeterPlotFactory.ATTRIBUTE_tickColor,
2268: plot.getTickColor());
2269:
2270: writePlot(chart.getPlot());
2271: writeValueDisplay(plot.getValueDisplay());
2272: writeDataRange(plot.getDataRange());
2273:
2274: List intervals = plot.getIntervals();
2275: if (intervals != null) {
2276: Iterator iter = intervals.iterator();
2277: while (iter.hasNext()) {
2278: JRMeterInterval meterInterval = (JRMeterInterval) iter
2279: .next();
2280: writeMeterInterval(meterInterval);
2281: }
2282: }
2283: writer.closeElement();
2284:
2285: writer.closeElement();
2286: }
2287:
2288: /**
2289: * Writes the description of a thermometer chart to the output stream.
2290: *
2291: * @param chart the thermometer chart to write
2292: */
2293: public void writeThermometerChart(JRChart chart) throws IOException {
2294: writer.startElement(JRXmlConstants.ELEMENT_thermometerChart);
2295:
2296: writeChart(chart);
2297: writeValueDataset((JRValueDataset) chart.getDataset());
2298:
2299: // write plot
2300: JRThermometerPlot plot = (JRThermometerPlot) chart.getPlot();
2301:
2302: writer.startElement(JRThermometerPlotFactory.ELEMENT_meterPlot);
2303:
2304: writer.addAttribute(
2305: JRThermometerPlotFactory.ATTRIBUTE_valueLocation, plot
2306: .getValueLocation(), JRXmlConstants
2307: .getThermometerValueLocationMap(),
2308: JRThermometerPlot.LOCATION_BULB);
2309: writer.addAttribute(
2310: JRThermometerPlotFactory.ATTRIBUTE_showValueLines, plot
2311: .isShowValueLines());
2312: writer.addAttribute(
2313: JRThermometerPlotFactory.ATTRIBUTE_mercuryColor, plot
2314: .getMercuryColor());
2315:
2316: writePlot(chart.getPlot());
2317:
2318: writeValueDisplay(plot.getValueDisplay());
2319: writeDataRange(plot.getDataRange());
2320:
2321: if (plot.getLowRange() != null) {
2322: writer
2323: .startElement(JRThermometerPlotFactory.ELEMENT_lowRange);
2324: writeDataRange(plot.getLowRange());
2325: writer.closeElement();
2326: }
2327:
2328: if (plot.getMediumRange() != null) {
2329: writer
2330: .startElement(JRThermometerPlotFactory.ELEMENT_mediumRange);
2331: writeDataRange(plot.getMediumRange());
2332: writer.closeElement();
2333: }
2334:
2335: if (plot.getHighRange() != null) {
2336: writer
2337: .startElement(JRThermometerPlotFactory.ELEMENT_highRange);
2338: writeDataRange(plot.getHighRange());
2339: writer.closeElement();
2340: }
2341:
2342: writer.closeElement();
2343:
2344: writer.closeElement();
2345: }
2346:
2347: /**
2348: * Writes the definition of a multiple axis chart to the output stream.
2349: *
2350: * @param chart the multiple axis chart to write
2351: */
2352: public void writeMultiAxisChart(JRChart chart) throws IOException {
2353: writer.startElement(JRXmlConstants.ELEMENT_multiAxisChart);
2354:
2355: writeChart(chart);
2356:
2357: // write plot
2358: JRMultiAxisPlot plot = (JRMultiAxisPlot) chart.getPlot();
2359: writer.startElement(JRXmlConstants.ELEMENT_multiAxisPlot);
2360:
2361: writePlot(chart.getPlot());
2362:
2363: List axes = plot.getAxes();
2364: if (axes != null) {
2365: Iterator iter = axes.iterator();
2366: while (iter.hasNext()) {
2367: JRChartAxis chartAxis = (JRChartAxis) iter.next();
2368: writeChartAxis(chartAxis);
2369: }
2370: }
2371: writer.closeElement();
2372:
2373: writer.closeElement();
2374: }
2375:
2376: /**
2377: *
2378: */
2379: public void writeStackedAreaChart(JRChart chart) throws IOException {
2380: writer.startElement(JRXmlConstants.ELEMENT_stackedAreaChart);
2381:
2382: writeChart(chart);
2383: writeCategoryDataSet((JRCategoryDataset) chart.getDataset());
2384: writeAreaPlot((JRAreaPlot) chart.getPlot());
2385:
2386: writer.closeElement();
2387: }
2388:
2389: public void writeChartTag(JRChart chart) throws IOException {
2390: switch (chart.getChartType()) {
2391: case JRChart.CHART_TYPE_AREA:
2392: writeAreaChart(chart);
2393: break;
2394: case JRChart.CHART_TYPE_BAR:
2395: writeBarChart(chart);
2396: break;
2397: case JRChart.CHART_TYPE_BAR3D:
2398: writeBar3DChart(chart);
2399: break;
2400: case JRChart.CHART_TYPE_BUBBLE:
2401: writeBubbleChart(chart);
2402: break;
2403: case JRChart.CHART_TYPE_CANDLESTICK:
2404: writeCandlestickChart(chart);
2405: break;
2406: case JRChart.CHART_TYPE_HIGHLOW:
2407: writeHighLowChart(chart);
2408: break;
2409: case JRChart.CHART_TYPE_LINE:
2410: writeLineChart(chart);
2411: break;
2412: case JRChart.CHART_TYPE_METER:
2413: writeMeterChart(chart);
2414: break;
2415: case JRChart.CHART_TYPE_MULTI_AXIS:
2416: writeMultiAxisChart(chart);
2417: break;
2418: case JRChart.CHART_TYPE_PIE:
2419: writePieChart(chart);
2420: break;
2421: case JRChart.CHART_TYPE_PIE3D:
2422: writePie3DChart(chart);
2423: break;
2424: case JRChart.CHART_TYPE_SCATTER:
2425: writeScatterChart(chart);
2426: break;
2427: case JRChart.CHART_TYPE_STACKEDBAR:
2428: writeStackedBarChart(chart);
2429: break;
2430: case JRChart.CHART_TYPE_STACKEDBAR3D:
2431: writeStackedBar3DChart(chart);
2432: break;
2433: case JRChart.CHART_TYPE_THERMOMETER:
2434: writeThermometerChart(chart);
2435: break;
2436: case JRChart.CHART_TYPE_TIMESERIES:
2437: writeTimeSeriesChart(chart);
2438: break;
2439: case JRChart.CHART_TYPE_XYAREA:
2440: writeXyAreaChart(chart);
2441: break;
2442: case JRChart.CHART_TYPE_XYBAR:
2443: writeXyBarChart(chart);
2444: break;
2445: case JRChart.CHART_TYPE_XYLINE:
2446: writeXyLineChart(chart);
2447: break;
2448: case JRChart.CHART_TYPE_STACKEDAREA:
2449: writeStackedAreaChart(chart);
2450: break;
2451: default:
2452: throw new JRRuntimeException("Chart type not supported.");
2453: }
2454: }
2455:
2456: private void writeSubreportReturnValue(
2457: JRSubreportReturnValue returnValue) throws IOException {
2458: writer.startElement(JRXmlConstants.ELEMENT_returnValue);
2459: writer.addEncodedAttribute(
2460: JRXmlConstants.ATTRIBUTE_subreportVariable, returnValue
2461: .getSubreportVariable());
2462: writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_toVariable,
2463: returnValue.getToVariable());
2464: writer.addAttribute(JRXmlConstants.ATTRIBUTE_calculation,
2465: returnValue.getCalculation(), JRXmlConstants
2466: .getCalculationMap(),
2467: JRVariable.CALCULATION_NOTHING);
2468: writer.addAttribute(
2469: JRXmlConstants.ATTRIBUTE_incrementerFactoryClass,
2470: returnValue.getIncrementerFactoryClassName());
2471: writer.closeElement();
2472: }
2473:
2474: public void writeCrosstab(JRCrosstab crosstab) throws IOException {
2475: writer.startElement(JRCrosstabFactory.ELEMENT_crosstab);
2476: writer.addAttribute(
2477: JRCrosstabFactory.ATTRIBUTE_isRepeatColumnHeaders,
2478: crosstab.isRepeatColumnHeaders(), true);
2479: writer.addAttribute(
2480: JRCrosstabFactory.ATTRIBUTE_isRepeatRowHeaders,
2481: crosstab.isRepeatRowHeaders(), true);
2482: writer.addAttribute(
2483: JRCrosstabFactory.ATTRIBUTE_columnBreakOffset, crosstab
2484: .getColumnBreakOffset(),
2485: JRCrosstab.DEFAULT_COLUMN_BREAK_OFFSET);
2486: writer.addAttribute(JRXmlConstants.ATTRIBUTE_runDirection,
2487: crosstab.getRunDirection(), JRXmlConstants
2488: .getRunDirectionMap(),
2489: JRCrosstab.RUN_DIRECTION_LTR);
2490:
2491: writeReportElement(crosstab);
2492:
2493: JRCrosstabParameter[] parameters = crosstab.getParameters();
2494: if (parameters != null) {
2495: for (int i = 0; i < parameters.length; i++) {
2496: if (!parameters[i].isSystemDefined()) {
2497: writeCrosstabParameter(parameters[i]);
2498: }
2499: }
2500: }
2501:
2502: writer.writeExpression(
2503: JRCrosstabFactory.ELEMENT_parametersMapExpression,
2504: crosstab.getParametersMapExpression(), false);
2505:
2506: writeCrosstabDataset(crosstab);
2507:
2508: writeCrosstabHeaderCell(crosstab);
2509:
2510: JRCrosstabRowGroup[] rowGroups = crosstab.getRowGroups();
2511: for (int i = 0; i < rowGroups.length; i++) {
2512: writeCrosstabRowGroup(rowGroups[i]);
2513: }
2514:
2515: JRCrosstabColumnGroup[] columnGroups = crosstab
2516: .getColumnGroups();
2517: for (int i = 0; i < columnGroups.length; i++) {
2518: writeCrosstabColumnGroup(columnGroups[i]);
2519: }
2520:
2521: JRCrosstabMeasure[] measures = crosstab.getMeasures();
2522: for (int i = 0; i < measures.length; i++) {
2523: writeCrosstabMeasure(measures[i]);
2524: }
2525:
2526: if (crosstab instanceof JRDesignCrosstab) {
2527: List cellsList = ((JRDesignCrosstab) crosstab)
2528: .getCellsList();
2529: for (Iterator it = cellsList.iterator(); it.hasNext();) {
2530: JRCrosstabCell cell = (JRCrosstabCell) it.next();
2531: writeCrosstabCell(cell);
2532: }
2533: } else {
2534: JRCrosstabCell[][] cells = crosstab.getCells();
2535: Set cellsSet = new HashSet();
2536: for (int i = cells.length - 1; i >= 0; --i) {
2537: for (int j = cells[i].length - 1; j >= 0; --j) {
2538: JRCrosstabCell cell = cells[i][j];
2539: if (cell != null && cellsSet.add(cell)) {
2540: writeCrosstabCell(cell);
2541: }
2542: }
2543: }
2544: }
2545:
2546: writeCrosstabWhenNoDataCell(crosstab);
2547:
2548: writer.closeElement();
2549: }
2550:
2551: private void writeCrosstabDataset(JRCrosstab crosstab)
2552: throws IOException {
2553: JRCrosstabDataset dataset = crosstab.getDataset();
2554: writer
2555: .startElement(JRCrosstabDatasetFactory.ELEMENT_crosstabDataset);
2556: writer.addAttribute(
2557: JRCrosstabDatasetFactory.ATTRIBUTE_isDataPreSorted,
2558: dataset.isDataPreSorted(), false);
2559: writeElementDataset(dataset);
2560: writer.closeElement(true);
2561: }
2562:
2563: private void writeCrosstabWhenNoDataCell(JRCrosstab crosstab)
2564: throws IOException {
2565: JRCellContents whenNoDataCell = crosstab.getWhenNoDataCell();
2566: if (whenNoDataCell != null) {
2567: writer
2568: .startElement(JRCrosstabFactory.ELEMENT_whenNoDataCell);
2569: writeCellContents(whenNoDataCell);
2570: writer.closeElement();
2571: }
2572: }
2573:
2574: private void writeCrosstabHeaderCell(JRCrosstab crosstab)
2575: throws IOException {
2576: JRCellContents headerCell = crosstab.getHeaderCell();
2577: if (headerCell != null) {
2578: writer
2579: .startElement(JRCrosstabFactory.ELEMENT_crosstabHeaderCell);
2580: writeCellContents(headerCell);
2581: writer.closeElement();
2582: }
2583: }
2584:
2585: protected void writeCrosstabRowGroup(JRCrosstabRowGroup group)
2586: throws IOException {
2587: writer.startElement(JRCrosstabRowGroupFactory.ELEMENT_rowGroup);
2588: writer.addEncodedAttribute(
2589: JRCrosstabGroupFactory.ATTRIBUTE_name, group.getName());
2590: writer.addAttribute(JRCrosstabRowGroupFactory.ATTRIBUTE_width,
2591: group.getWidth());
2592: writer.addAttribute(
2593: JRCrosstabGroupFactory.ATTRIBUTE_totalPosition, group
2594: .getTotalPosition(), JRXmlConstants
2595: .getCrosstabTotalPositionMap(),
2596: BucketDefinition.TOTAL_POSITION_NONE);
2597: writer.addAttribute(
2598: JRCrosstabRowGroupFactory.ATTRIBUTE_headerPosition,
2599: group.getPosition(), JRXmlConstants
2600: .getCrosstabRowPositionMap(),
2601: JRCellContents.POSITION_Y_TOP);
2602:
2603: writeBucket(group.getBucket());
2604:
2605: JRCellContents header = group.getHeader();
2606: writer
2607: .startElement(JRCrosstabRowGroupFactory.ELEMENT_crosstabRowHeader);
2608: writeCellContents(header);
2609: writer.closeElement();
2610:
2611: JRCellContents totalHeader = group.getTotalHeader();
2612: writer
2613: .startElement(JRCrosstabRowGroupFactory.ELEMENT_crosstabTotalRowHeader);
2614: writeCellContents(totalHeader);
2615: writer.closeElement();
2616:
2617: writer.closeElement();
2618: }
2619:
2620: protected void writeCrosstabColumnGroup(JRCrosstabColumnGroup group)
2621: throws IOException {
2622: writer.startElement(JRCrosstabGroupFactory.ELEMENT_columnGroup);
2623: writer.addEncodedAttribute(
2624: JRCrosstabGroupFactory.ATTRIBUTE_name, group.getName());
2625: writer.addAttribute(
2626: JRCrosstabColumnGroupFactory.ATTRIBUTE_height, group
2627: .getHeight());
2628: writer.addAttribute(
2629: JRCrosstabGroupFactory.ATTRIBUTE_totalPosition, group
2630: .getTotalPosition(), JRXmlConstants
2631: .getCrosstabTotalPositionMap(),
2632: BucketDefinition.TOTAL_POSITION_NONE);
2633: writer.addAttribute(
2634: JRCrosstabColumnGroupFactory.ATTRIBUTE_headerPosition,
2635: group.getPosition(), JRXmlConstants
2636: .getCrosstabColumnPositionMap(),
2637: JRCellContents.POSITION_X_LEFT);
2638:
2639: writeBucket(group.getBucket());
2640:
2641: JRCellContents header = group.getHeader();
2642: writer
2643: .startElement(JRCrosstabGroupFactory.ELEMENT_crosstabColumnHeader);
2644: writeCellContents(header);
2645: writer.closeElement();
2646:
2647: JRCellContents totalHeader = group.getTotalHeader();
2648: writer
2649: .startElement(JRCrosstabGroupFactory.ELEMENT_crosstabTotalColumnHeader);
2650: writeCellContents(totalHeader);
2651: writer.closeElement();
2652:
2653: writer.closeElement();
2654: }
2655:
2656: protected void writeBucket(JRCrosstabBucket bucket)
2657: throws IOException {
2658: writer.startElement(JRCrosstabBucketFactory.ELEMENT_bucket);
2659: writer.addAttribute(JRCrosstabBucketFactory.ATTRIBUTE_order,
2660: bucket.getOrder(), JRXmlConstants
2661: .getCrosstabBucketOrderMap(),
2662: BucketDefinition.ORDER_ASCENDING);
2663: writer.writeExpression(
2664: JRCrosstabBucketFactory.ELEMENT_bucketExpression,
2665: bucket.getExpression(), true);
2666: writer.writeExpression(
2667: JRCrosstabBucketFactory.ELEMENT_comparatorExpression,
2668: bucket.getComparatorExpression(), false);
2669: writer.closeElement();
2670: }
2671:
2672: protected void writeCrosstabMeasure(JRCrosstabMeasure measure)
2673: throws IOException {
2674: writer.startElement(JRCrosstabMeasureFactory.ELEMENT_measure);
2675: writer.addEncodedAttribute(
2676: JRCrosstabMeasureFactory.ATTRIBUTE_name, measure
2677: .getName());
2678: writer.addAttribute(JRCrosstabMeasureFactory.ATTRIBUTE_class,
2679: measure.getValueClassName());
2680: writer.addAttribute(
2681: JRCrosstabMeasureFactory.ATTRIBUTE_calculation, measure
2682: .getCalculation(), JRXmlConstants
2683: .getCalculationMap(),
2684: JRVariable.CALCULATION_NOTHING);
2685: writer.addAttribute(
2686: JRCrosstabMeasureFactory.ATTRIBUTE_percentageOf,
2687: measure.getPercentageOfType(), JRXmlConstants
2688: .getCrosstabPercentageMap(),
2689: JRCrosstabMeasure.PERCENTAGE_TYPE_NONE);
2690: writer
2691: .addAttribute(
2692: JRCrosstabMeasureFactory.ATTRIBUTE_percentageCalculatorClass,
2693: measure.getPercentageCalculatorClassName());
2694: writer.writeExpression(
2695: JRCrosstabMeasureFactory.ELEMENT_measureExpression,
2696: measure.getValueExpression(), false);
2697: writer.closeElement();
2698: }
2699:
2700: protected void writeCrosstabCell(JRCrosstabCell cell)
2701: throws IOException {
2702: writer.startElement(JRCrosstabCellFactory.ELEMENT_crosstabCell);
2703: writer.addAttribute(JRCrosstabCellFactory.ATTRIBUTE_width, cell
2704: .getWidth());
2705: writer.addAttribute(JRCrosstabCellFactory.ATTRIBUTE_height,
2706: cell.getHeight());
2707: writer.addEncodedAttribute(
2708: JRCrosstabCellFactory.ATTRIBUTE_rowTotalGroup, cell
2709: .getRowTotalGroup());
2710: writer.addEncodedAttribute(
2711: JRCrosstabCellFactory.ATTRIBUTE_columnTotalGroup, cell
2712: .getColumnTotalGroup());
2713:
2714: writeCellContents(cell.getContents());
2715:
2716: writer.closeElement();
2717: }
2718:
2719: protected void writeCellContents(JRCellContents contents)
2720: throws IOException {
2721: if (contents != null) {
2722: writer
2723: .startElement(JRCellContentsFactory.ELEMENT_cellContents);
2724: writer.addAttribute(
2725: JRCellContentsFactory.ATTRIBUTE_backcolor, contents
2726: .getBackcolor());
2727: writer.addAttribute(JRCellContentsFactory.ATTRIBUTE_mode,
2728: contents.getMode(), JRXmlConstants.getModeMap());
2729: JRStyle style = contents.getStyle();
2730: if (style != null) {
2731: writer.addEncodedAttribute(
2732: JRCellContentsFactory.ATTRIBUTE_style, style
2733: .getName());
2734: }
2735:
2736: writeBox(contents.getBox());
2737:
2738: List children = contents.getChildren();
2739: if (children != null) {
2740: for (Iterator it = children.iterator(); it.hasNext();) {
2741: JRChild element = (JRChild) it.next();
2742: element.writeXml(this );
2743: }
2744: }
2745:
2746: writer.closeElement();
2747: }
2748: }
2749:
2750: protected void writeCrosstabParameter(JRCrosstabParameter parameter)
2751: throws IOException {
2752: writer
2753: .startElement(JRCrosstabParameterFactory.ELEMENT_crosstabParameter);
2754: writer.addEncodedAttribute(
2755: JRCrosstabParameterFactory.ATTRIBUTE_name, parameter
2756: .getName());
2757: writer.addAttribute(JRCrosstabParameterFactory.ATTRIBUTE_class,
2758: parameter.getValueClassName(), "java.lang.String");
2759: writer
2760: .writeExpression(
2761: JRCrosstabParameterFactory.ELEMENT_parameterValueExpression,
2762: parameter.getExpression(), false);
2763: writer.closeElement();
2764: }
2765:
2766: public void writeDataset(JRDataset dataset) throws IOException {
2767: writer.startElement(JRXmlConstants.ELEMENT_subDataset);
2768: writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_name,
2769: dataset.getName());
2770: writer.addAttribute(JRXmlConstants.ATTRIBUTE_scriptletClass,
2771: dataset.getScriptletClass());
2772: writer.addEncodedAttribute(
2773: JRXmlConstants.ATTRIBUTE_resourceBundle, dataset
2774: .getResourceBundle());
2775: writer.addAttribute(
2776: JRXmlConstants.ATTRIBUTE_whenResourceMissingType,
2777: dataset.getWhenResourceMissingType(), JRXmlConstants
2778: .getWhenResourceMissingTypeMap(),
2779: JRReport.WHEN_RESOURCE_MISSING_TYPE_NULL);
2780:
2781: writeProperties(dataset);
2782:
2783: writeDatasetContents(dataset);
2784:
2785: writer.closeElement();
2786: }
2787:
2788: protected void writeDatasetContents(JRDataset dataset)
2789: throws IOException {
2790: /* */
2791: JRParameter[] parameters = dataset.getParameters();
2792: if (parameters != null && parameters.length > 0) {
2793: for (int i = 0; i < parameters.length; i++) {
2794: if (!parameters[i].isSystemDefined()) {
2795: writeParameter(parameters[i]);
2796: }
2797: }
2798: }
2799:
2800: /* */
2801: if (dataset.getQuery() != null) {
2802: writeQuery(dataset.getQuery());
2803: }
2804:
2805: /* */
2806: JRField[] fields = dataset.getFields();
2807: if (fields != null && fields.length > 0) {
2808: for (int i = 0; i < fields.length; i++) {
2809: writeField(fields[i]);
2810: }
2811: }
2812:
2813: /* */
2814: JRSortField[] sortFields = dataset.getSortFields();
2815: if (sortFields != null && sortFields.length > 0) {
2816: for (int i = 0; i < sortFields.length; i++) {
2817: writeSortField(sortFields[i]);
2818: }
2819: }
2820:
2821: /* */
2822: JRVariable[] variables = dataset.getVariables();
2823: if (variables != null && variables.length > 0) {
2824: for (int i = 0; i < variables.length; i++) {
2825: if (!variables[i].isSystemDefined()) {
2826: writeVariable(variables[i]);
2827: }
2828: }
2829: }
2830:
2831: writer.writeExpression(JRXmlConstants.ELEMENT_filterExpression,
2832: dataset.getFilterExpression(), false);
2833:
2834: /* */
2835: JRGroup[] groups = dataset.getGroups();
2836: if (groups != null && groups.length > 0) {
2837: for (int i = 0; i < groups.length; i++) {
2838: writeGroup(groups[i]);
2839: }
2840: }
2841: }
2842:
2843: protected void writeDatasetRun(JRDatasetRun datasetRun)
2844: throws IOException {
2845: writer.startElement(JRXmlConstants.ELEMENT_datasetRun);
2846: writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_subDataset,
2847: datasetRun.getDatasetName());
2848:
2849: writer.writeExpression(
2850: JRXmlConstants.ELEMENT_parametersMapExpression,
2851: datasetRun.getParametersMapExpression(), false);
2852:
2853: /* */
2854: JRDatasetParameter[] parameters = datasetRun.getParameters();
2855: if (parameters != null && parameters.length > 0) {
2856: for (int i = 0; i < parameters.length; i++) {
2857: writeDatasetParameter(parameters[i]);
2858: }
2859: }
2860:
2861: writer.writeExpression(
2862: JRXmlConstants.ELEMENT_connectionExpression, datasetRun
2863: .getConnectionExpression(), false);
2864: writer.writeExpression(
2865: JRXmlConstants.ELEMENT_dataSourceExpression, datasetRun
2866: .getDataSourceExpression(), false);
2867:
2868: writer.closeElement();
2869: }
2870:
2871: public void writeFrame(JRFrame frame) throws IOException {
2872: writer.startElement(JRXmlConstants.ELEMENT_frame);
2873:
2874: writeReportElement(frame);
2875: writeBox(frame);
2876:
2877: List children = frame.getChildren();
2878: if (children != null) {
2879: for (Iterator it = children.iterator(); it.hasNext();) {
2880: JRChild element = (JRChild) it.next();
2881: element.writeXml(this );
2882: }
2883: }
2884:
2885: writer.closeElement();
2886: }
2887:
2888: protected void writeHyperlinkParameters(
2889: JRHyperlinkParameter[] parameters) throws IOException {
2890: if (parameters != null) {
2891: for (int i = 0; i < parameters.length; i++) {
2892: JRHyperlinkParameter parameter = parameters[i];
2893: writeHyperlinkParameter(parameter);
2894: }
2895: }
2896: }
2897:
2898: protected void writeHyperlinkParameter(
2899: JRHyperlinkParameter parameter) throws IOException {
2900: if (parameter != null) {
2901: writer
2902: .startElement(JRXmlConstants.ELEMENT_hyperlinkParameter);
2903: writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_name,
2904: parameter.getName());
2905:
2906: writer
2907: .writeExpression(
2908: JRXmlConstants.ELEMENT_hyperlinkParameterExpression,
2909: parameter.getValueExpression(), true,
2910: String.class.getName());
2911:
2912: writer.closeElement();
2913: }
2914: }
2915:
2916: protected void writeHyperlink(String tagName, JRHyperlink hyperlink)
2917: throws IOException {
2918: if (hyperlink != null) {
2919: writer.startElement(tagName);
2920:
2921: writer.addEncodedAttribute(
2922: JRXmlConstants.ATTRIBUTE_hyperlinkType, hyperlink
2923: .getLinkType());
2924: writer.addAttribute(
2925: JRXmlConstants.ATTRIBUTE_hyperlinkTarget, hyperlink
2926: .getHyperlinkTarget(), JRXmlConstants
2927: .getHyperlinkTargetMap(),
2928: JRHyperlink.HYPERLINK_TARGET_SELF);
2929:
2930: writer
2931: .writeExpression(
2932: JRXmlConstants.ELEMENT_hyperlinkReferenceExpression,
2933: hyperlink.getHyperlinkReferenceExpression(),
2934: false);
2935: writer.writeExpression(
2936: JRXmlConstants.ELEMENT_hyperlinkAnchorExpression,
2937: hyperlink.getHyperlinkAnchorExpression(), false);
2938: writer.writeExpression(
2939: JRXmlConstants.ELEMENT_hyperlinkPageExpression,
2940: hyperlink.getHyperlinkPageExpression(), false);
2941: writer.writeExpression(
2942: JRXmlConstants.ELEMENT_hyperlinkTooltipExpression,
2943: hyperlink.getHyperlinkTooltipExpression(), false);
2944: writeHyperlinkParameters(hyperlink.getHyperlinkParameters());
2945:
2946: writer.closeElement();
2947: }
2948: }
2949:
2950: protected boolean toWriteConditionalStyles() {
2951: return true;
2952: }
2953:
2954: }
|