protected void writeTextInputComponent(TextInputComponent textInputComponent, ComponentKey componentKey, JRXmlWriter reportWriter) throws IOException { JRXmlWriteHelper writer = reportWriter.getXmlWriteHelper(); String namespaceURI = componentKey.getNamespace(); String schemaLocation = ComponentsEnvironment.getInstance(jasperReportsContext) .getBundle(namespaceURI).getXmlParser().getPublicSchemaLocation(); XmlNamespace componentNamespace = new XmlNamespace(namespaceURI, componentKey.getNamespacePrefix(), schemaLocation); writer.startElement("textInput", componentNamespace); writer.addAttribute("multiLine", textInputComponent.isMultiLine()); reportWriter.writeTextField(textInputComponent.getTextField()); writer.closeElement(); }
/** * Writes the template to the output writer. * * @throws IOException */ public void write() throws IOException { writer.writeProlog(encoding); XmlNamespace namespace; if (isNewerVersionOrEqual(JRConstants.VERSION_6_3_0)) { namespace = JASPERTEMPLATE_NAMESPACE; } else { writer.writePublicDoctype(JRXmlConstants.TEMPLATE_ELEMENT_ROOT, JRXmlConstants.JASPERTEMPLATE_PUBLIC_ID, JRXmlConstants.JASPERTEMPLATE_SYSTEM_ID); namespace = null; } writer.startElement(JRXmlConstants.TEMPLATE_ELEMENT_ROOT, namespace); writeIncludedTemplates(); writeStyles(); writer.closeElement(); }
/** * */ public void writeBox(JRLineBox box, XmlNamespace namespace) throws IOException { if (box != null) { writer.startElement(JRXmlConstants.ELEMENT_box, namespace); writer.addAttribute(JRXmlConstants.ATTRIBUTE_padding, box.getOwnPadding()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_topPadding, box.getOwnTopPadding()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_leftPadding, box.getOwnLeftPadding()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_bottomPadding, box.getOwnBottomPadding()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_rightPadding, box.getOwnRightPadding()); writePen(JRXmlConstants.ELEMENT_pen, box.getPen()); writePen(JRXmlConstants.ELEMENT_topPen, box.getTopPen()); writePen(JRXmlConstants.ELEMENT_leftPen, box.getLeftPen()); writePen(JRXmlConstants.ELEMENT_bottomPen, box.getBottomPen()); writePen(JRXmlConstants.ELEMENT_rightPen, box.getRightPen()); writer.closeElement(true); } }
private void writeItemDataContent(String name, ItemData itemData, JRXmlWriteHelper writer, JRXmlWriter reportWriter, XmlNamespace namespace, JRComponentElement componentElement) throws IOException { writer.startElement(name, namespace); JRElementDataset dataset = itemData.getDataset(); if (dataset != null) { reportWriter.writeElementDataset(dataset, false); } /* */ List<Item> itemList = itemData.getItems(); if (itemList != null && !itemList.isEmpty()) { for(Item item : itemList) { if(item.getProperties() != null && !item.getProperties().isEmpty()) { writeItem(item, writer, reportWriter, namespace, componentElement); } } } }
/** * @deprecated To be removed. */ private void writeMarker( net.sf.jasperreports.components.map.Marker marker, JRXmlWriteHelper writer, JRXmlWriter reportWriter, XmlNamespace namespace, JRComponentElement componentElement ) throws IOException { writer.startElement(MapXmlFactory.ELEMENT_marker, namespace); List<net.sf.jasperreports.components.map.MarkerProperty> markerProperties = marker.getProperties(); for(net.sf.jasperreports.components.map.MarkerProperty property : markerProperties) { writeMarkerProperty(property, writer, reportWriter, namespace, componentElement); } writer.closeElement(); }
/** * @deprecated To be removed. */ private void writeMarkerProperty( net.sf.jasperreports.components.map.MarkerProperty markerProperty, JRXmlWriteHelper writer, JRXmlWriter reportWriter, XmlNamespace namespace, JRComponentElement componentElement ) throws IOException { writer.startElement(MapXmlFactory.ELEMENT_markerProperty, namespace); writer.addAttribute(JRXmlConstants.ATTRIBUTE_name, markerProperty.getName()); if(markerProperty.getValue() != null) { writer.addAttribute(JRXmlConstants.ATTRIBUTE_value, markerProperty.getValue()); } writeExpression(JRXmlConstants.ELEMENT_valueExpression, JRXmlWriter.JASPERREPORTS_NAMESPACE, markerProperty.getValueExpression(), false, componentElement, reportWriter); writer.closeElement(); }
private void writeSpiderDataSet(SpiderDataset dataset, JRXmlWriteHelper writer, JRXmlWriter reportWriter, XmlNamespace namespace) throws IOException { writer.startElement(ELEMENT_spiderDataset, namespace); reportWriter.writeElementDataset(dataset); /* */ JRCategorySeries[] categorySeries = dataset.getSeries(); if (categorySeries != null && categorySeries.length > 0) { for(int i = 0; i < categorySeries.length; i++) { writeCategorySeries(categorySeries[i], writer, reportWriter); } } writer.closeElement(); }
private void writeSpiderPlot(SpiderPlot spiderPlot, ChartSettings chartSettings, JRXmlWriteHelper writer, XmlNamespace namespace) throws IOException { writer.startElement(ELEMENT_spiderPlot, namespace); writer.addAttribute(ATTRIBUTE_rotation, spiderPlot.getRotation()); writer.addAttribute(ATTRIBUTE_tableOrder, spiderPlot.getTableOrder()); writer.addAttribute(ATTRIBUTE_webFilled, spiderPlot.getWebFilled()); writer.addAttribute(ATTRIBUTE_startAngle, spiderPlot.getStartAngle()); writer.addAttribute(ATTRIBUTE_headPercent, spiderPlot.getHeadPercent()); writer.addAttribute(ATTRIBUTE_interiorGap, spiderPlot.getInteriorGap()); writer.addAttribute(ATTRIBUTE_axisLineColor, spiderPlot.getAxisLineColor()); writer.addAttribute(ATTRIBUTE_axisLineWidth, spiderPlot.getAxisLineWidth()); writer.addAttribute(ATTRIBUTE_labelGap, spiderPlot.getLabelGap()); writer.addAttribute(ATTRIBUTE_labelColor, spiderPlot.getLabelColor()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_backcolor, spiderPlot.getBackcolor()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_backgroundAlpha, spiderPlot.getBackgroundAlpha()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_foregroundAlpha, spiderPlot.getForegroundAlpha()); //FIXME: series colors // writeSeriesColors(spiderPlot.getSeriesColors(), writer); writeLabelFont(spiderPlot.getLabelFont(), writer); writeExpression(ELEMENT_maxValueExpression, namespace, spiderPlot.getMaxValueExpression(), false, writer); writer.closeElement(true); }
public void writeToXml(JRComponentElement componentElement, JRXmlWriter reportWriter) throws IOException { Component component = componentElement.getComponent(); PieChartComponent chart = (PieChartComponent) component; JRXmlWriteHelper writer = reportWriter.getXmlWriteHelper(); ComponentKey componentKey = componentElement.getComponentKey(); String namespaceURI = componentKey.getNamespace(); String schemaLocation = ComponentsEnvironment.getInstance(jasperReportsContext) .getBundle(namespaceURI).getXmlParser().getPublicSchemaLocation(); XmlNamespace namespace = new XmlNamespace(namespaceURI, componentKey.getNamespacePrefix(), schemaLocation); writer.startElement("pieChart", namespace); writer.addAttribute("evaluationTime", chart.getEvaluationTime(), EvaluationTimeEnum.NOW); if (chart.getEvaluationTime() == EvaluationTimeEnum.GROUP) { writer.addEncodedAttribute("evaluationGroup", chart.getEvaluationGroup()); } PieDataset dataset = chart.getDataset(); writer.startElement("pieDataset"); reportWriter.writeElementDataset(dataset); writer.writeExpression("keyExpression", dataset.getKeyExpression()); writer.writeExpression("valueExpression", dataset.getValueExpression()); writer.closeElement();//pieDataset writer.writeExpression("titleExpression", chart.getTitleExpression()); writer.closeElement();//pieChart }
protected void writeHtmlComponent(JRComponentElement componentElement, JRXmlWriter reportWriter) throws IOException { Component component = componentElement.getComponent(); HtmlComponent htmlComponent = (HtmlComponent) component; ComponentKey componentKey = componentElement.getComponentKey(); XmlNamespace namespace = new XmlNamespace( HtmlComponentExtensionsRegistryFactory.NAMESPACE, componentKey.getNamespacePrefix(), HtmlComponentExtensionsRegistryFactory.XSD_LOCATION); JRXmlWriteHelper writer = reportWriter.getXmlWriteHelper(); writer.startElement("html", namespace); writer.addAttribute(HtmlComponent.PROPERTY_SCALE_TYPE, htmlComponent.getScaleType()); writer.addAttribute(HtmlComponent.PROPERTY_HORIZONTAL_ALIGN, htmlComponent.getHorizontalImageAlign()); writer.addAttribute(HtmlComponent.PROPERTY_VERTICAL_ALIGN, htmlComponent.getVerticalImageAlign()); writeExpression(HtmlComponent.PROPERTY_HTMLCONTENT_EXPRESSION, htmlComponent.getHtmlContentExpression(), false, componentElement, reportWriter); if (htmlComponent.getEvaluationTime() != EvaluationTimeEnum.NOW) { writer.addAttribute(HtmlComponent.PROPERTY_EVALUATION_TIME, htmlComponent.getEvaluationTime()); } writer.addAttribute(HtmlComponent.PROPERTY_EVALUATION_GROUP, htmlComponent.getEvaluationGroup()); writer.addAttribute(HtmlComponent.PROPERTY_CLIP_ON_OVERFLOW, htmlComponent.getClipOnOverflow()); writer.closeElement(); }
protected void writeSubreport(JRPart part, JRXmlWriter reportWriter) throws IOException { SubreportPartComponent subreport = (SubreportPartComponent) part.getComponent(); ComponentKey componentKey = part.getComponentKey(); JRXmlWriteHelper writer = reportWriter.getXmlWriteHelper(); XmlNamespace namespace = new XmlNamespace( PartComponentsExtensionsRegistryFactory.NAMESPACE, componentKey.getNamespacePrefix(), PartComponentsExtensionsRegistryFactory.XSD_LOCATION); writer.startElement(PartComponentsExtensionsRegistryFactory.SUBREPORT_PART_COMPONENT_NAME, namespace); writer.addAttribute("usingCache", subreport.getUsingCache()); writer.writeExpression(JRXmlConstants.ELEMENT_parametersMapExpression, JRXmlWriter.JASPERREPORTS_NAMESPACE, subreport.getParametersMapExpression()); JRSubreportParameter[] parameters = subreport.getParameters(); if (parameters != null && parameters.length > 0) { for(int i = 0; i < parameters.length; i++) { reportWriter.writeSubreportParameter(parameters[i], JRXmlWriter.JASPERREPORTS_NAMESPACE); } } JRSubreportReturnValue[] returnValues = subreport.getReturnValues(); if (returnValues != null && returnValues.length > 0) { for(int i = 0; i < returnValues.length; i++) { reportWriter.writeSubreportReturnValue(returnValues[i], JRXmlWriter.JASPERREPORTS_NAMESPACE); } } writer.writeExpression(JRXmlConstants.ELEMENT_subreportExpression, JRXmlWriter.JASPERREPORTS_NAMESPACE, subreport.getExpression()); writer.closeElement(); }
/** * */ public void writeParagraph(JRParagraph paragraph, XmlNamespace namespace) throws IOException { if (paragraph != null && isNewerVersionOrEqual(JRConstants.VERSION_4_0_2)) { writer.startElement(JRXmlConstants.ELEMENT_paragraph, namespace); writer.addAttribute(JRXmlConstants.ATTRIBUTE_lineSpacing, paragraph.getOwnLineSpacing()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_lineSpacingSize, paragraph.getOwnLineSpacingSize()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_firstLineIndent, paragraph.getOwnFirstLineIndent()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_leftIndent, paragraph.getOwnLeftIndent()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_rightIndent, paragraph.getOwnRightIndent()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_spacingBefore, paragraph.getOwnSpacingBefore()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_spacingAfter, paragraph.getOwnSpacingAfter()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_tabStopWidth, paragraph.getOwnTabStopWidth()); /* */ TabStop[] tabStops = paragraph.getTabStops(); if (tabStops != null && tabStops.length > 0) { for(int i = 0; i < tabStops.length; i++) { writeTabStop(tabStops[i]); } } writer.closeElement(true); } }
/** * */ public void writeSubreportParameter(JRSubreportParameter subreportParameter, XmlNamespace namespace) throws IOException { writer.startElement(JRXmlConstants.ELEMENT_subreportParameter, namespace); writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_name, subreportParameter.getName()); writeExpression(JRXmlConstants.ELEMENT_subreportParameterExpression, subreportParameter.getExpression(), false); writer.closeElement(); }
public void writeSubreportReturnValue(JRSubreportReturnValue returnValue, XmlNamespace namespace) throws IOException { writer.startElement(JRXmlConstants.ELEMENT_returnValue, namespace); writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_subreportVariable, returnValue.getFromVariable()); writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_toVariable, returnValue.getToVariable()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_calculation, returnValue.getCalculation(), CalculationEnum.NOTHING); writer.addAttribute(JRXmlConstants.ATTRIBUTE_incrementerFactoryClass, returnValue.getIncrementerFactoryClassName()); writer.closeElement(); }
public void writeHyperlink(String tagName, XmlNamespace namespace, JRHyperlink hyperlink) throws IOException { if (hyperlink != null) { writer.startElement(tagName, namespace); writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_hyperlinkType, hyperlink.getLinkType(), HyperlinkTypeEnum.NONE.getName()); writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_hyperlinkTarget, hyperlink.getLinkTarget(), HyperlinkTargetEnum.SELF.getName()); writeExpression(JRXmlConstants.ELEMENT_hyperlinkReferenceExpression, JASPERREPORTS_NAMESPACE, hyperlink.getHyperlinkReferenceExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkWhenExpression, JASPERREPORTS_NAMESPACE, hyperlink.getHyperlinkWhenExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkAnchorExpression, JASPERREPORTS_NAMESPACE, hyperlink.getHyperlinkAnchorExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkPageExpression, JASPERREPORTS_NAMESPACE, hyperlink.getHyperlinkPageExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkTooltipExpression, JASPERREPORTS_NAMESPACE, hyperlink.getHyperlinkTooltipExpression(), false); writeHyperlinkParameters(hyperlink.getHyperlinkParameters()); if(isNewerVersionOrEqual(JRConstants.VERSION_3_5_1)) { writer.closeElement(true); } else { writer.closeElement(); } } }
@SuppressWarnings("deprecation") protected void writeExpression(String name, XmlNamespace namespace, JRExpression expression, boolean writeClass) throws IOException { if(isNewerVersionOrEqual(JRConstants.VERSION_4_1_1)) { writer.writeExpression(name, namespace, expression); } else { writer.writeExpression(name, namespace, expression, writeClass); } }
protected void startBarcode(BarcodeComponent barcode) { XmlNamespace namespace = new XmlNamespace( ComponentsExtensionsRegistryFactory.NAMESPACE, componentKey.getNamespacePrefix(), ComponentsExtensionsRegistryFactory.XSD_LOCATION); xmlWriteHelper.startElement(componentKey.getName(), namespace); }
protected void writeList(JRComponentElement componentElement, JRXmlWriter reportWriter) throws IOException { ListComponent list = (ListComponent) componentElement.getComponent(); ComponentKey componentKey = componentElement.getComponentKey(); JRXmlWriteHelper writer = reportWriter.getXmlWriteHelper(); XmlNamespace namespace = new XmlNamespace( ComponentsExtensionsRegistryFactory.NAMESPACE, componentKey.getNamespacePrefix(), ComponentsExtensionsRegistryFactory.XSD_LOCATION); writer.startElement("list", namespace); if(isNewerVersionOrEqual(componentElement, reportWriter, JRConstants.VERSION_3_6_1)) { writer.addAttribute("printOrder", list.getPrintOrderValue()); } writer.addAttribute("ignoreWidth", list.getIgnoreWidth()); reportWriter.writeDatasetRun(list.getDatasetRun()); ListContents contents = list.getContents(); writer.startElement("listContents"); writer.addAttribute("height", contents.getHeight()); writer.addAttribute("width", contents.getWidth()); reportWriter.writeChildElements(contents); writer.closeElement(); writer.closeElement(); }
protected void writeBarbecue(JRComponentElement componentElement, JRXmlWriter reportWriter) throws IOException { Component component = componentElement.getComponent(); BarbecueComponent barcode = (BarbecueComponent) component; JRXmlWriteHelper writer = reportWriter.getXmlWriteHelper(); ComponentKey componentKey = componentElement.getComponentKey(); XmlNamespace namespace = new XmlNamespace( ComponentsExtensionsRegistryFactory.NAMESPACE, componentKey.getNamespacePrefix(), ComponentsExtensionsRegistryFactory.XSD_LOCATION); writer.startElement("barbecue", namespace); writer.addAttribute("type", barcode.getType()); writer.addAttribute("drawText", barcode.isDrawText()); writer.addAttribute("checksumRequired", barcode.isChecksumRequired()); writer.addAttribute("barWidth", barcode.getBarWidth()); writer.addAttribute("barHeight", barcode.getBarHeight()); if (isNewerVersionOrEqual(componentElement, reportWriter, JRConstants.VERSION_4_0_0)) { writer.addAttribute("rotation", barcode.getOwnRotation()); } if (barcode.getEvaluationTimeValue() != EvaluationTimeEnum.NOW) { writer.addAttribute(JRXmlConstants.ATTRIBUTE_evaluationTime, barcode.getEvaluationTimeValue()); } writer.addAttribute(JRXmlConstants.ATTRIBUTE_evaluationGroup, barcode.getEvaluationGroup()); writeExpression("codeExpression", barcode.getCodeExpression(), false, componentElement, reportWriter); writeExpression("applicationIdentifierExpression", barcode.getApplicationIdentifierExpression(), false, componentElement, reportWriter); writer.closeElement(); }
private void writeItemData(String name, ItemData itemData, JRXmlWriteHelper writer, JRXmlWriter reportWriter, XmlNamespace namespace, JRComponentElement componentElement) throws IOException { if (itemData != null) { writeItemDataContent(name, itemData, writer, reportWriter, namespace, componentElement); writer.closeElement(); } }
private void writeItem(Item item, JRXmlWriteHelper writer, JRXmlWriter reportWriter, XmlNamespace namespace, JRComponentElement componentElement) throws IOException { writer.startElement(MapXmlFactory.ELEMENT_item, namespace); List<ItemProperty> itemProperties = item.getProperties(); for(ItemProperty property : itemProperties) { writeItemProperty(property, writer, reportWriter, namespace, componentElement); } writer.closeElement(); }
private void writeItemProperty(ItemProperty itemProperty, JRXmlWriteHelper writer, JRXmlWriter reportWriter, XmlNamespace namespace, JRComponentElement componentElement) throws IOException { writer.startElement(MapXmlFactory.ELEMENT_itemProperty, namespace); writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_name, itemProperty.getName()); if(itemProperty.getValue() != null) { writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_value, itemProperty.getValue()); } writeExpression(JRXmlConstants.ELEMENT_valueExpression, JRXmlWriter.JASPERREPORTS_NAMESPACE, itemProperty.getValueExpression(), false, componentElement, reportWriter); writer.closeElement(); }
/** * @deprecated To be removed. */ private void writeMarkerDataset(net.sf.jasperreports.components.map.MarkerDataset dataset, JRXmlWriteHelper writer, JRXmlWriter reportWriter, XmlNamespace namespace, JRComponentElement componentElement) throws IOException { if (dataset != null) { writer.startElement(MapXmlFactory.ELEMENT_markerDataset, namespace); JRDatasetRun datasetRun = dataset.getDatasetRun(); if (datasetRun != null) { reportWriter.writeDatasetRun(datasetRun); } /* */ List<net.sf.jasperreports.components.map.Marker> markerList = dataset.getMarkers(); if (markerList != null && !markerList.isEmpty()) { for(net.sf.jasperreports.components.map.Marker marker : markerList) { if(marker.getProperties() != null && !marker.getProperties().isEmpty()) { writeMarker(marker, writer, reportWriter, namespace, componentElement); } } } writer.closeElement(); } }
@Override public void writeToXml(JRComponentElement componentElement, JRXmlWriter reportWriter) throws IOException { Component component = componentElement.getComponent(); SpiderChartComponent spiderChartComponent = (SpiderChartComponent) component; JRXmlWriteHelper writer = reportWriter.getXmlWriteHelper(); ComponentKey componentKey = componentElement.getComponentKey(); String namespaceURI = componentKey.getNamespace(); String schemaLocation = ComponentsEnvironment.getInstance(jasperReportsContext) .getBundle(namespaceURI).getXmlParser().getPublicSchemaLocation(); XmlNamespace componentNamespace = new XmlNamespace(namespaceURI, componentKey.getNamespacePrefix(), schemaLocation); writer.startElement(ELEMENT_spiderChart, componentNamespace); writer.addAttribute(JRXmlConstants.ATTRIBUTE_evaluationTime, spiderChartComponent.getEvaluationTime(), EvaluationTimeEnum.NOW); if (spiderChartComponent.getEvaluationTime() == EvaluationTimeEnum.GROUP) { writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_evaluationGroup, spiderChartComponent.getEvaluationGroup()); } ChartSettings chartSettings = spiderChartComponent.getChartSettings(); writeChart(chartSettings, writer, reportWriter, componentNamespace); SpiderDataset dataset = (SpiderDataset)spiderChartComponent.getDataset(); writeSpiderDataSet(dataset, writer, reportWriter, componentNamespace); SpiderPlot spiderPlot = (SpiderPlot)spiderChartComponent.getPlot(); writeSpiderPlot(spiderPlot, chartSettings, writer, componentNamespace); writer.closeElement();//spiderChart }
@SuppressWarnings("deprecation") protected void writeExpression(String name, XmlNamespace namespace, JRExpression expression, boolean writeClass, JRXmlWriteHelper writer) throws IOException { if(isNewerVersionOrEqual(version, JRConstants.VERSION_4_1_1)) { writer.writeExpression(name, namespace, expression); } else { writer.writeExpression(name, namespace, expression, writeClass); } }
@SuppressWarnings("deprecation") protected void writeExpression(String name, XmlNamespace namespace, JRExpression expression, boolean writeClass, JRComponentElement componentElement, JRXmlWriter reportWriter) throws IOException { JRXmlWriteHelper writer = reportWriter.getXmlWriteHelper(); if(isNewerVersionOrEqual(componentElement, reportWriter, JRConstants.VERSION_4_1_1)) { writer.writeExpression(name, namespace, expression); } else { writer.writeExpression(name, namespace, expression, writeClass); } }
protected void writeIconLabelComponent(IconLabelComponent iconLabelComponent, ComponentKey componentKey, JRXmlWriter reportWriter) throws IOException { JRXmlWriteHelper writer = reportWriter.getXmlWriteHelper(); String namespaceURI = componentKey.getNamespace(); String schemaLocation = ComponentsEnvironment.getInstance(jasperReportsContext) .getBundle(namespaceURI).getXmlParser().getPublicSchemaLocation(); XmlNamespace componentNamespace = new XmlNamespace(namespaceURI, componentKey.getNamespacePrefix(), schemaLocation); writer.startElement("iconLabel", componentNamespace); writer.addAttribute(IconLabelComponent.PROPERTY_ICON_POSITION, iconLabelComponent.getIconPosition()); writer.addAttribute(IconLabelComponent.PROPERTY_LABEL_FILL, iconLabelComponent.getLabelFill()); writer.addAttribute(IconLabelComponent.PROPERTY_HORIZONTAL_ALIGNMENT, iconLabelComponent.getOwnHorizontalImageAlign()); writer.addAttribute(IconLabelComponent.PROPERTY_VERTICAL_ALIGNMENT, iconLabelComponent.getOwnVerticalImageAlign()); reportWriter.writeBox(iconLabelComponent.getLineBox(), JRXmlWriter.JASPERREPORTS_NAMESPACE); writer.startElement("label", componentNamespace); reportWriter.writeTextField(iconLabelComponent.getLabelTextField()); writer.closeElement(); writer.startElement("icon", componentNamespace); reportWriter.writeTextField(iconLabelComponent.getIconTextField()); writer.closeElement(); writer.closeElement(); }
@Override public void writeToXml(JRComponentElement componentElement, JRXmlWriter reportWriter) throws IOException { if (components.containsKey(componentElement.getComponentKey().getName())) { JRXmlWriteHelper writer = reportWriter.getXmlWriteHelper(); String namespaceURI = componentElement.getComponentKey().getNamespace(); String schemaLocation = ComponentsEnvironment.getInstance(DefaultJasperReportsContext.getInstance()).getBundle(namespaceURI).getXmlParser().getPublicSchemaLocation(); XmlNamespace namespace = new XmlNamespace(namespaceURI, componentElement.getComponentKey().getNamespacePrefix(), schemaLocation); writer.startElement(componentElement.getComponentKey().getName(), namespace); writer.closeElement(); } }
protected void writeWmsMap(JRComponentElement componentElement, JRXmlWriter reportWriter) throws IOException { Component component = componentElement.getComponent(); WmsMapComponent map = (WmsMapComponent) component; JRXmlWriteHelper writer = reportWriter.getXmlWriteHelper(); ComponentKey componentKey = componentElement.getComponentKey(); XmlNamespace namespace = new XmlNamespace( ComponentsExtensionsRegistryFactory.NAMESPACE, componentKey.getNamespacePrefix(), ComponentsExtensionsRegistryFactory.XSD_LOCATION); writer.startElement("wmsmap", namespace); if (map.getEvaluationTime() != EvaluationTimeEnum.NOW) { writer.addAttribute(JRXmlConstants.ATTRIBUTE_evaluationTime, map.getEvaluationTime()); } writer.addAttribute(JRXmlConstants.ATTRIBUTE_evaluationGroup, map.getEvaluationGroup()); writer.addAttribute(ATTRIBUTE_WMS_SERVICE_URL, map.getWmsServiceUrl()); writer.addAttribute(ATTRIBUTE_WMS_VERSION, map.getWmsVersion()); writer.addAttribute(ATTRIBUTE_SRS, map.getSrs()); writer.addAttribute(ATTRIBUTE_TRANSPARENT, map.getTransparent()); writer.addAttribute(ATTRIBUTE_IMAGE_TYPE, map.getImageType()); writer.writeExpression("bboxExpression", map.getBBoxExpression()); writer.writeExpression("layersExpression", map.getLayersExpression()); writer.writeExpression("stylesExpression", map.getStylesExpression()); writer.writeExpression("urlParametersExpression", map.getUrlParametersExpression()); writer.closeElement(); }
@SuppressWarnings("deprecation") protected void writeExpression(String name, XmlNamespace namespace, JRExpression expression, boolean writeClass, JRComponentElement componentElement, JRXmlWriter reportWriter) throws IOException { JRXmlWriteHelper writer = reportWriter.getXmlWriteHelper(); if (isNewerVersionOrEqual(componentElement, reportWriter, JRConstants.VERSION_4_1_1)) { writer.writeExpression(name, namespace, expression); } else { writer.writeExpression(name, namespace, expression, writeClass); } }
@Override public void writeToXml(JRComponentElement componentElement, JRXmlWriter reportWriter) throws IOException { Component component = componentElement.getComponent(); XYChartComponent chart = (XYChartComponent) component; JRXmlWriteHelper writer = reportWriter.getXmlWriteHelper(); ComponentKey componentKey = componentElement.getComponentKey(); String namespaceURI = componentKey.getNamespace(); String schemaLocation = ComponentsEnvironment.getInstance(jasperReportsContext) .getBundle(namespaceURI).getXmlParser().getPublicSchemaLocation(); XmlNamespace namespace = new XmlNamespace(namespaceURI, componentKey.getNamespacePrefix(), schemaLocation); writer.startElement(ELEMENT_XYChart, namespace); writer.addAttribute("evaluationTime", chart.getEvaluationTime(), EvaluationTimeEnum.NOW); if (chart.getEvaluationTime() == EvaluationTimeEnum.GROUP) { writer.addEncodedAttribute("evaluationGroup", chart.getEvaluationGroup()); } XYDataset dataset = chart.getDataset(); writer.startElement(ELEMENT_XYDataset); reportWriter.writeElementDataset(dataset); XYSeries[] xySeriesArray = dataset.getSeries(); if (xySeriesArray != null && xySeriesArray.length > 0) { for(XYSeries xySeries : xySeriesArray) { writer.startElement(ELEMENT_XYSeries); writeExpression(JRXmlConstants.ELEMENT_seriesExpression, JRXmlWriter.JASPERREPORTS_NAMESPACE, xySeries.getSeriesExpression(), false, writer); writeExpression(JRXmlConstants.ELEMENT_xValueExpression, JRXmlWriter.JASPERREPORTS_NAMESPACE, xySeries.getXValueExpression(), false, writer); writeExpression(JRXmlConstants.ELEMENT_yValueExpression, JRXmlWriter.JASPERREPORTS_NAMESPACE, xySeries.getYValueExpression(), false, writer); writeExpression(ELEMENT_colorExpression, xySeries.getColorExpression(), false, componentElement, reportWriter); writer.closeElement(); } } writer.closeElement();//XYDataset writeExpression(ELEMENT_chartTitleExpression, chart.getChartTitleExpression(), false, componentElement, reportWriter); writeExpression(ELEMENT_xAxisTitleExpression, chart.getXAxisTitleExpression(), false, componentElement, reportWriter); writeExpression(ELEMENT_yAxisTitleExpression, chart.getYAxisTitleExpression(), false, componentElement, reportWriter); writer.closeElement();//XYChart }
protected void writeExpression(String name, XmlNamespace namespace, JRExpression expression, boolean writeClass, JRXmlWriteHelper writer) throws IOException { writer.writeExpression(name, namespace, expression); }
public void writeToXml(JRComponentElement componentElement, JRXmlWriter reportWriter) throws IOException { Component component = componentElement.getComponent(); BarChartComponent chart = (BarChartComponent) component; JRXmlWriteHelper writer = reportWriter.getXmlWriteHelper(); ComponentKey componentKey = componentElement.getComponentKey(); String namespaceURI = componentKey.getNamespace(); String schemaLocation = ComponentsEnvironment.getInstance(jasperReportsContext) .getBundle(namespaceURI).getXmlParser().getPublicSchemaLocation(); XmlNamespace namespace = new XmlNamespace(namespaceURI, componentKey.getNamespacePrefix(), schemaLocation); writer.startElement("barChart", namespace); writer.addAttribute("evaluationTime", chart.getEvaluationTime(), EvaluationTimeEnum.NOW); if (chart.getEvaluationTime() == EvaluationTimeEnum.GROUP) { writer.addEncodedAttribute("evaluationGroup", chart.getEvaluationGroup()); } BarDataset dataset = chart.getDataset(); writer.startElement("barDataset"); reportWriter.writeElementDataset(dataset); List<BarSeries> seriesList = dataset.getSeries(); for(BarSeries series : seriesList) { writer.startElement("barSeries"); writer.writeExpression("seriesExpression", series.getSeriesExpression()); writer.writeExpression("categoryExpression", series.getCategoryExpression()); writer.writeExpression("valueExpression", series.getValueExpression()); writer.closeElement();//barSeries } writer.closeElement();//barDataset writer.writeExpression("titleExpression", chart.getTitleExpression()); writer.closeElement();//barChart }
protected XmlNamespace getNamespace() { return JASPERREPORTS_NAMESPACE; }
/** * */ protected XmlNamespace getNamespace() { return JASPERPRINT_NAMESPACE; }
/** * */ private void writeChart(ChartSettings chartSettings, JRXmlWriteHelper writer, JRXmlWriter reportWriter, XmlNamespace namespace) throws IOException { writer.startElement(ELEMENT_chartSettings, namespace); writer.addAttribute(JRXmlConstants.ATTRIBUTE_isShowLegend, chartSettings.getShowLegend()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_backcolor, chartSettings.getBackcolor()); writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_hyperlinkType, chartSettings.getLinkType(), HyperlinkTypeEnum.NONE.getName()); writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_hyperlinkTarget, chartSettings.getLinkTarget(), HyperlinkTargetEnum.SELF.getName()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_bookmarkLevel, chartSettings.getBookmarkLevel(), JRAnchor.NO_BOOKMARK); if(isNewerVersionOrEqual(version, JRConstants.VERSION_3_7_5)) { writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_customizerClass, chartSettings.getCustomizerClass()); } writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_renderType, chartSettings.getRenderType()); // write title writer.startElement(JRXmlConstants.ELEMENT_chartTitle, JRXmlWriter.JASPERREPORTS_NAMESPACE); writer.addAttribute(JRXmlConstants.ATTRIBUTE_position, chartSettings.getTitlePosition()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_color, chartSettings.getTitleColor()); writeFont(chartSettings.getTitleFont(), writer); if (chartSettings.getTitleExpression() != null) { writeExpression(JRXmlConstants.ELEMENT_titleExpression, JRXmlWriter.JASPERREPORTS_NAMESPACE, chartSettings.getTitleExpression(), false, writer); } writer.closeElement(); // write subtitle writer.startElement(JRXmlConstants.ELEMENT_chartSubtitle, JRXmlWriter.JASPERREPORTS_NAMESPACE); writer.addAttribute(JRXmlConstants.ATTRIBUTE_color, chartSettings.getSubtitleColor()); writeFont(chartSettings.getSubtitleFont(), writer); if (chartSettings.getSubtitleExpression() != null) { writeExpression(JRXmlConstants.ELEMENT_subtitleExpression, JRXmlWriter.JASPERREPORTS_NAMESPACE, chartSettings.getSubtitleExpression(), false, writer); } writer.closeElement(); // write chartLegend writer.startElement(JRXmlConstants.ELEMENT_chartLegend, JRXmlWriter.JASPERREPORTS_NAMESPACE); if (chartSettings.getLegendColor() != null) { writer.addAttribute(JRXmlConstants.ATTRIBUTE_textColor, chartSettings.getLegendColor()); } if (chartSettings.getLegendBackgroundColor() != null) { writer.addAttribute(JRXmlConstants.ATTRIBUTE_backgroundColor, chartSettings.getLegendBackgroundColor()); } writer.addAttribute(JRXmlConstants.ATTRIBUTE_position, chartSettings.getLegendPosition()); writeFont(chartSettings.getLegendFont(), writer); writer.closeElement(); writeExpression(JRXmlConstants.ELEMENT_anchorNameExpression, JRXmlWriter.JASPERREPORTS_NAMESPACE, chartSettings.getAnchorNameExpression(), false, writer); writeExpression(JRXmlConstants.ELEMENT_hyperlinkReferenceExpression, JRXmlWriter.JASPERREPORTS_NAMESPACE, chartSettings.getHyperlinkReferenceExpression(), false, writer); writeExpression(JRXmlConstants.ELEMENT_hyperlinkWhenExpression, JRXmlWriter.JASPERREPORTS_NAMESPACE, chartSettings.getHyperlinkWhenExpression(), false, writer); writeExpression(JRXmlConstants.ELEMENT_hyperlinkAnchorExpression, JRXmlWriter.JASPERREPORTS_NAMESPACE, chartSettings.getHyperlinkAnchorExpression(), false, writer); writeExpression(JRXmlConstants.ELEMENT_hyperlinkPageExpression, JRXmlWriter.JASPERREPORTS_NAMESPACE, chartSettings.getHyperlinkPageExpression(), false, writer); writeExpression(JRXmlConstants.ELEMENT_hyperlinkTooltipExpression, JRXmlWriter.JASPERREPORTS_NAMESPACE, chartSettings.getHyperlinkTooltipExpression(), false, writer); writeHyperlinkParameters(chartSettings.getHyperlinkParameters(), writer); writer.closeElement(); }
protected void writeSortComponent(JRComponentElement componentElement, JRXmlWriter reportWriter) throws IOException { Component component = componentElement.getComponent(); SortComponent sortComponent = (SortComponent) component; ComponentKey componentKey = componentElement.getComponentKey(); String namespaceURI = componentKey.getNamespace(); String schemaLocation = ComponentsEnvironment.getInstance(jasperReportsContext) .getBundle(namespaceURI).getXmlParser().getPublicSchemaLocation(); XmlNamespace componentNamespace = new XmlNamespace(namespaceURI, componentKey.getNamespacePrefix(), schemaLocation); JRXmlWriteHelper writer = reportWriter.getXmlWriteHelper(); writer.startElement("sort", componentNamespace); if(isOlderVersionThan(componentElement, reportWriter, JRConstants.VERSION_4_1_3)) { writer.addAttribute(SortComponent.PROPERTY_COLUMN_NAME, sortComponent.getSortFieldName()); writer.addAttribute(SortComponent.PROPERTY_COLUMN_TYPE, sortComponent.getSortFieldType()); writer.addAttribute(SortComponent.PROPERTY_HANDLER_COLOR, sortComponent.getHandlerColor()); writer.addAttribute(PROPERTY_HANDLER_FONT_SIZE, sortComponent.getSymbolFont().getFontsize()); writer.addAttribute(SortComponent.PROPERTY_HANDLER_HORIZONTAL_ALIGN, sortComponent.getHandlerHorizontalImageAlign()); writer.addAttribute(SortComponent.PROPERTY_HANDLER_VERTICAL_ALIGN, sortComponent.getHandlerVerticalImageAlign()); } if (sortComponent.getEvaluationTime() != EvaluationTimeEnum.NOW) { writer.addAttribute(SortComponent.PROPERTY_EVALUATION_TIME, sortComponent.getEvaluationTime()); } writer.addAttribute(SortComponent.PROPERTY_EVALUATION_GROUP, sortComponent.getEvaluationGroup()); if(isNewerVersionOrEqual(componentElement, reportWriter, JRConstants.VERSION_4_1_3)) { // write symbol settings writer.startElement("symbol"); if (sortComponent.getHandlerColor() != null) { writer.addAttribute(SortComponent.PROPERTY_HANDLER_COLOR, sortComponent.getHandlerColor()); } writer.addAttribute(SortComponent.PROPERTY_COLUMN_TYPE, sortComponent.getSortFieldType()); writer.addAttribute(SortComponent.PROPERTY_COLUMN_NAME, sortComponent.getSortFieldName()); writer.addAttribute(SortComponent.PROPERTY_HANDLER_HORIZONTAL_ALIGN, sortComponent.getHandlerHorizontalImageAlign()); writer.addAttribute(SortComponent.PROPERTY_HANDLER_VERTICAL_ALIGN, sortComponent.getHandlerVerticalImageAlign()); reportWriter.writeFont(sortComponent.getSymbolFont()); writer.closeElement(); } writer.closeElement(); }