@Override public Object createObject(Attributes attrs) throws Exception { XYChartComponent chart = new XYChartComponent(); EvaluationTimeEnum evaluationTime = EvaluationTimeEnum.getByName(attrs.getValue(JRXmlConstants.ATTRIBUTE_evaluationTime)); if (evaluationTime != null) { chart.setEvaluationTime(evaluationTime); } if (chart.getEvaluationTime() == EvaluationTimeEnum.GROUP) { String groupName = attrs.getValue(JRXmlConstants.ATTRIBUTE_evaluationGroup); chart.setEvaluationGroup(groupName); } return chart; }
protected void verifyEvaluation(JRVerifier verifier, XYChartComponent chart) { EvaluationTimeEnum evaluationTime = chart.getEvaluationTime(); if (evaluationTime == EvaluationTimeEnum.AUTO) { verifier.addBrokenRule("Axis chart evaluation time cannot be Auto", chart); } else if (evaluationTime == EvaluationTimeEnum.GROUP) { String groupName = chart.getEvaluationGroup(); if (groupName == null) { verifier.addBrokenRule("Evaluation group not set for axis chart", chart); } else { JasperDesign report = verifier.getReportDesign(); if (!report.getGroupsMap().containsKey(groupName)) { verifier.addBrokenRule("Axis chart evaluation group " + groupName + " not found in report", chart); } } } }
protected void verifyEvaluation(JRVerifier verifier, PieChartComponent chart) { EvaluationTimeEnum evaluationTime = chart.getEvaluationTime(); if (evaluationTime == EvaluationTimeEnum.AUTO) { verifier.addBrokenRule("Pie chart evaluation time cannot be Auto", chart); } else if (evaluationTime == EvaluationTimeEnum.GROUP) { String groupName = chart.getEvaluationGroup(); if (groupName == null) { verifier.addBrokenRule("Evaluation group not set for pie chart", chart); } else { JasperDesign report = verifier.getReportDesign(); if (!report.getGroupsMap().containsKey(groupName)) { verifier.addBrokenRule("Pie chart evaluation group " + groupName + " not found in report", chart); } } } }
public Object createObject(Attributes attrs) throws Exception { PieChartComponent chart = new PieChartComponent(); EvaluationTimeEnum evaluationTime = EvaluationTimeEnum.getByName(attrs.getValue(JRXmlConstants.ATTRIBUTE_evaluationTime)); if (evaluationTime != null) { chart.setEvaluationTime(evaluationTime); } if (chart.getEvaluationTime() == EvaluationTimeEnum.GROUP) { String groupName = attrs.getValue(JRXmlConstants.ATTRIBUTE_evaluationGroup); chart.setEvaluationGroup(groupName); } return chart; }
public Object createObject(Attributes attrs) throws Exception { BarChartComponent chart = new BarChartComponent(); EvaluationTimeEnum evaluationTime = EvaluationTimeEnum.getByName(attrs.getValue(JRXmlConstants.ATTRIBUTE_evaluationTime)); if (evaluationTime != null) { chart.setEvaluationTime(evaluationTime); } if (chart.getEvaluationTime() == EvaluationTimeEnum.GROUP) { String groupName = attrs.getValue(JRXmlConstants.ATTRIBUTE_evaluationGroup); chart.setEvaluationGroup(groupName); } return chart; }
@Override public Object createObject(Attributes attrs) throws Exception { SpiderChartComponent chartComponent = new SpiderChartComponent(); EvaluationTimeEnum evaluationTime = EvaluationTimeEnum.getByName(attrs.getValue(JRXmlConstants.ATTRIBUTE_evaluationTime)); if (evaluationTime != null) { chartComponent.setEvaluationTime(evaluationTime); } else { chartComponent.setEvaluationTime(EvaluationTimeEnum.NOW); } if (chartComponent.getEvaluationTime() == EvaluationTimeEnum.GROUP) { String groupName = attrs.getValue(JRXmlConstants.ATTRIBUTE_evaluationGroup); chartComponent.setEvaluationGroup(groupName); } return chartComponent; }
@SuppressWarnings("deprecation") private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); if (linkType == null) { linkType = JRHyperlinkHelper.getLinkType(HyperlinkTypeEnum.getByValue(hyperlinkType)); } if (linkTarget == null) { linkTarget = JRHyperlinkHelper.getLinkTarget(HyperlinkTargetEnum.getByValue(hyperlinkTarget)); } if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_3_7_2) { evaluationTimeValue = EvaluationTimeEnum.getByValue(evaluationTime); } }
protected void verifyEvaluation(JRVerifier verifier, SpiderChartComponent chart) { EvaluationTimeEnum evaluationTime = chart.getEvaluationTime(); if (evaluationTime == EvaluationTimeEnum.AUTO) { verifier.addBrokenRule("Spider chart evaluation time cannot be Auto", chart); } else if (evaluationTime == EvaluationTimeEnum.GROUP) { String groupName = chart.getEvaluationGroup(); if (groupName == null) { verifier.addBrokenRule("Evaluation group not set for spider chart", chart); } else { JasperDesign report = verifier.getReportDesign(); if (!report.getGroupsMap().containsKey(groupName)) { verifier.addBrokenRule("Spider chart evaluation group " + groupName + " not found in report", chart); } } } }
@Override public Object createObject(Attributes attrs) throws Exception { JasperDesign jasperDesign = (JasperDesign)digester.peek(digester.getCount() - 2); JRDesignGenericElement element = new JRDesignGenericElement(jasperDesign); EvaluationTimeEnum evaluationTime = EvaluationTimeEnum.getByName(attrs.getValue(JRXmlConstants.ATTRIBUTE_evaluationTime)); if (evaluationTime != null) { element.setEvaluationTime(evaluationTime); } if (element.getEvaluationTimeValue() == EvaluationTimeEnum.GROUP) { String groupName = attrs.getValue(JRXmlConstants.ATTRIBUTE_evaluationGroup); if (groupName != null) { element.setEvaluationGroupName(groupName); } } return element; }
private void verifyChart(JRChart chart) { verifyReportElement(chart); if (chart.getEvaluationTimeValue() == EvaluationTimeEnum.AUTO) { addBrokenRule("Charts do not support Auto evaluation time.", chart); } JRChartDataset dataset = chart.getDataset(); if (dataset == null) { addBrokenRule("Chart dataset missing.", chart); } else { dataset.validate(this); } }
@Override public void write(JREvaluationTime value, VirtualizationOutput out) throws IOException { //FIXME we should have keep these in memory and only write an ID/index EvaluationTimeEnum type = value.getType(); @SuppressWarnings("deprecation") byte byteType = type.getValue(); out.writeByte(byteType); if (type == EvaluationTimeEnum.BAND) { out.writeInt(value.getBandId()); } else if (type == EvaluationTimeEnum.GROUP) { out.writeJRObject(value.getGroupName()); } }
@SuppressWarnings("deprecation") protected <T> void addBarcodeRules(Digester digester, String barcodePattern, Class<T> barcodeComponentClass, String[] ignoredProperties) { digester.addObjectCreate(barcodePattern, barcodeComponentClass); digester.addSetProperties(barcodePattern, //properties to be ignored by this rule ignoredProperties, new String[0]); //rule to set evaluation time digester.addRule(barcodePattern, new XmlConstantPropertyRule( JRXmlConstants.ATTRIBUTE_evaluationTime, "evaluationTimeValue", EvaluationTimeEnum.values())); String codeExpressionPattern = barcodePattern + "/codeExpression"; digester.addFactoryCreate(codeExpressionPattern, JRExpressionFactory.StringExpressionFactory.class.getName()); digester.addCallMethod(codeExpressionPattern, "setText", 0); digester.addSetNext(codeExpressionPattern, "setCodeExpression", JRExpression.class.getName()); }
@Override protected JRPrintElement fill() { JRTemplatePrintImage printImage = new JRTemplatePrintImage(getJRTemplateImage(), printElementOriginator); printImage.setUUID(getUUID()); printImage.setX(getX()); printImage.setY(getRelativeY()); printImage.setWidth(getWidth()); printImage.setHeight(getStretchHeight()); printImage.setBookmarkLevel(getBookmarkLevel()); printImage.getPropertiesMap().setProperty(HtmlReportConfiguration.PROPERTY_EMBED_IMAGE, Boolean.TRUE.toString()); printImage.getPropertiesMap().setProperty(HtmlReportConfiguration.PROPERTY_EMBEDDED_SVG_USE_FONTS, Boolean.TRUE.toString()); EvaluationTimeEnum evaluationTime = getEvaluationTimeValue(); if (evaluationTime == EvaluationTimeEnum.NOW) { copy(printImage); } else { filler.addBoundElement(this, printImage, evaluationTime, getEvaluationGroup(), band); } return printImage; }
/** * Resolves an element. * * @param element the element * @param evaluation the evaluation type * @param evaluationTime the current evaluation time */ protected void resolveElement (JRPrintElement element, byte evaluation, JREvaluationTime evaluationTime) throws JRException { EvaluationTimeEnum evaluationTimeType = getEvaluationTimeValue(); switch (evaluationTimeType) { case NOW: break; case AUTO: delayedEvaluate((JRRecordedValuesPrintElement) element, evaluationTime, evaluation); break; default: performDelayedEvaluation(element, evaluation); break; } }
@SuppressWarnings("deprecation") private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { GetField fields = in.readFields(); this.PSEUDO_SERIAL_VERSION_UID = fields.get("PSEUDO_SERIAL_VERSION_UID", 0); if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_3_7_2) { byte evaluationTime = fields.get("evaluationTime", (byte) 0); this.evaluationTimeValue = EvaluationTimeEnum.getByValue(evaluationTime); } else { this.evaluationTimeValue = (EvaluationTimeEnum) fields.get("evaluationTimeValue", null); } this.evaluationGroup = (String) fields.get("evaluationGroup", null); this.codeExpression = (JRExpression) fields.get("codeExpression", null); if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_6_0_2 && this instanceof Barcode4jComponent) { //up to 6.0.0 this class had several fields that were moved to Barcode4jComponent in 6.0.2. //copying the values to the Barcode4jComponent fields. Barcode4jComponent barcode4jComponent = (Barcode4jComponent) this; barcode4jComponent.copyBarcodeComponentFields(fields); } }
public static void addSortComponentRules(Digester digester) { String componentNamespace = digester.getRuleNamespaceURI(); String sortComponentPattern = "*/componentElement/sort"; digester.addObjectCreate(sortComponentPattern, SortComponent.class.getName()); digester.addSetProperties(sortComponentPattern, new String[] { SortComponent.PROPERTY_EVALUATION_TIME, }, new String[0]); digester.addRule(sortComponentPattern, new XmlConstantPropertyRule( SortComponent.PROPERTY_EVALUATION_TIME, EvaluationTimeEnum.values())); digester.addFactoryCreate(sortComponentPattern + "/symbol", SortComponentSymbolFactory.class.getName()); digester.setRuleNamespaceURI(JRXmlConstants.JASPERREPORTS_NAMESPACE); digester.addFactoryCreate(sortComponentPattern + "/symbol/font", SortComponentSymbolFontFactory.class.getName()); digester.addSetNext(sortComponentPattern + "/symbol/font", "setSymbolFont", JRFont.class.getName()); digester.setRuleNamespaceURI(componentNamespace); }
@SuppressWarnings("deprecation") private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_3_7_2) { evaluationTimeValue = EvaluationTimeEnum.getByValue(evaluationTime); } }
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 }
@SuppressWarnings("deprecation") protected void setHtmlComponentRules(Digester digester) { String htmlComponentPattern = "*/componentElement/html"; digester.addObjectCreate(htmlComponentPattern, HtmlComponent.class.getName()); digester.addSetProperties(htmlComponentPattern, new String[] { HtmlComponent.PROPERTY_SCALE_TYPE, HtmlComponent.PROPERTY_HORIZONTAL_ALIGN, HtmlComponent.PROPERTY_VERTICAL_ALIGN, HtmlComponent.PROPERTY_EVALUATION_TIME }, new String[0]); digester.addRule(htmlComponentPattern, new XmlConstantPropertyRule( HtmlComponent.PROPERTY_SCALE_TYPE, ScaleImageEnum.values())); digester.addRule(htmlComponentPattern, new XmlConstantPropertyRule( HtmlComponent.PROPERTY_HORIZONTAL_ALIGN, "horizontalImageAlign", HorizontalImageAlignEnum.values())); digester.addRule(htmlComponentPattern, new XmlConstantPropertyRule( HtmlComponent.PROPERTY_VERTICAL_ALIGN, "verticalImageAlign", VerticalImageAlignEnum.values())); digester.addRule(htmlComponentPattern, new XmlConstantPropertyRule( HtmlComponent.PROPERTY_EVALUATION_TIME, EvaluationTimeEnum.values())); String htmlContentPattern = htmlComponentPattern + "/htmlContentExpression"; digester.addFactoryCreate(htmlContentPattern, JRExpressionFactory.StringExpressionFactory.class.getName()); digester.addCallMethod(htmlContentPattern, "setText", 0); digester.addSetNext(htmlContentPattern, "setHtmlContentExpression", JRExpression.class.getName()); }
/** * @param evaluationTime the evaluationTime to set */ public void setEvaluationTime(EvaluationTimeEnum evaluationTime) { Object old = this.evaluationTime; this.evaluationTime = evaluationTime; getEventSupport().firePropertyChange(PROPERTY_EVALUATION_TIME, old, this.evaluationTime); }
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(); }
@SuppressWarnings("deprecation") private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); if (linkType == null) { linkType = JRHyperlinkHelper.getLinkType(HyperlinkTypeEnum.getByValue(hyperlinkType)); } if (linkTarget == null) { linkTarget = JRHyperlinkHelper.getLinkTarget(HyperlinkTargetEnum.getByValue(hyperlinkTarget)); } if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_3_7_2) { evaluationTimeValue = EvaluationTimeEnum.getByValue(evaluationTime); if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_3_1_3) { legendPositionValue = EdgeEnum.getByValue(legendPosition); titlePositionValue = EdgeEnum.getByValue(titlePosition); showLegend = Boolean.valueOf(isShowLegend); } else { legendPositionValue = EdgeEnum.getByValue(legendPositionByte); titlePositionValue = EdgeEnum.getByValue(titlePositionByte); legendPositionByte = null; titlePositionByte = null; } } }
/** * */ public void writeImage(JRImage image) throws IOException { writer.startElement(JRXmlConstants.ELEMENT_image, getNamespace()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_scaleImage, image.getOwnScaleImageValue()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_hAlign, image.getOwnHorizontalImageAlign()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_vAlign, image.getOwnVerticalImageAlign()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_isUsingCache, image.getUsingCache()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_isLazy, image.isLazy(), false); writer.addAttribute(JRXmlConstants.ATTRIBUTE_onErrorType, image.getOnErrorTypeValue(), OnErrorTypeEnum.ERROR); writer.addAttribute(JRXmlConstants.ATTRIBUTE_evaluationTime, image.getEvaluationTimeValue(), EvaluationTimeEnum.NOW); if (image.getEvaluationGroup() != null) { writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_evaluationGroup, image.getEvaluationGroup().getName()); } writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_hyperlinkType, image.getLinkType(), HyperlinkTypeEnum.NONE.getName()); writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_hyperlinkTarget, image.getLinkTarget(), HyperlinkTargetEnum.SELF.getName()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_bookmarkLevel, image.getBookmarkLevel(), JRAnchor.NO_BOOKMARK); writeReportElement(image); writeBox(image.getLineBox()); writeGraphicElement(image); //FIXME class is mandatory in verifier writeExpression(JRXmlConstants.ELEMENT_imageExpression, image.getExpression(), true); writeExpression(JRXmlConstants.ELEMENT_anchorNameExpression, image.getAnchorNameExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkReferenceExpression, image.getHyperlinkReferenceExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkWhenExpression, image.getHyperlinkWhenExpression(), false);//FIXMENOW can we reuse method for writing hyperlink? writeExpression(JRXmlConstants.ELEMENT_hyperlinkAnchorExpression, image.getHyperlinkAnchorExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkPageExpression, image.getHyperlinkPageExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkTooltipExpression, image.getHyperlinkTooltipExpression(), false); writeHyperlinkParameters(image.getHyperlinkParameters()); writer.closeElement(); }
/** * */ public void writeTextField(JRTextField textField) throws IOException { writer.startElement(JRXmlConstants.ELEMENT_textField, getNamespace()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_isStretchWithOverflow, textField.isStretchWithOverflow(), false); writer.addAttribute(JRXmlConstants.ATTRIBUTE_evaluationTime, textField.getEvaluationTimeValue(), EvaluationTimeEnum.NOW); if (textField.getEvaluationGroup() != null) { writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_evaluationGroup, textField.getEvaluationGroup().getName()); } writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_pattern, textField.getOwnPattern()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_isBlankWhenNull, textField.isOwnBlankWhenNull()); writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_hyperlinkType, textField.getLinkType(), HyperlinkTypeEnum.NONE.getName()); writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_hyperlinkTarget, textField.getLinkTarget(), HyperlinkTargetEnum.SELF.getName()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_bookmarkLevel, textField.getBookmarkLevel(), JRAnchor.NO_BOOKMARK); writeReportElement(textField); writeBox(textField.getLineBox()); writeTextElement(textField); writeExpression(JRXmlConstants.ELEMENT_textFieldExpression, textField.getExpression(), true); if(isNewerVersionOrEqual(JRConstants.VERSION_4_1_1)) { writer.writeExpression(JRXmlConstants.ELEMENT_patternExpression, textField.getPatternExpression()); } writeExpression(JRXmlConstants.ELEMENT_anchorNameExpression, textField.getAnchorNameExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkReferenceExpression, textField.getHyperlinkReferenceExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkWhenExpression, textField.getHyperlinkWhenExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkAnchorExpression, textField.getHyperlinkAnchorExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkPageExpression, textField.getHyperlinkPageExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkTooltipExpression, textField.getHyperlinkTooltipExpression(), false); writeHyperlinkParameters(textField.getHyperlinkParameters()); writer.closeElement(); }
public void setEvaluationTimeValue(EvaluationTimeEnum evaluationTimeValue) { Object old = this.evaluationTimeValue; this.evaluationTimeValue = evaluationTimeValue; getEventSupport().firePropertyChange(PROPERTY_EVALUATION_TIME, old, this.evaluationTimeValue); }
/** * * protected XmlNamespace getNamespace() { return JASPERREPORTS_NAMESPACE; } /** * */ public void writeGenericElement( JRGenericElement element, String elementName) { write( "JRDesignGenericElement " + elementName + " = new JRDesignGenericElement(jasperDesign);\n"); write( elementName + ".setEvaluationTime({0});\n", element.getEvaluationTimeValue(), EvaluationTimeEnum.NOW); write( elementName + ".setEvaluationGroup(\"{0}\");\n", JRStringUtil.escapeJavaStringLiteral(element.getEvaluationGroupName())); writeReportElement( element, elementName); JRGenericElementType printKey = element.getGenericType(); // JRGenericElementType t = new JRGenericElementType(printKey.getNamespace(), printKey.getName()); write( "JRGenericElementType " + elementName + "Type = new JRGenericElementType(\"" + JRStringUtil.escapeJavaStringLiteral(printKey.getNamespace()) + "\", \"" + JRStringUtil.escapeJavaStringLiteral(printKey.getName()) + "\");\n"); write( elementName + ".setGenericType(" + elementName + "Type);\n"); flush();//genericElementType JRGenericElementParameter[] params = element.getParameters(); for (int i = 0; i < params.length; i++) { JRGenericElementParameter param = params[i]; String paramName = elementName + "Parameter" + i; write( "JRDesignGenericElementParameter " + paramName + " = new JRDesignGenericElementParameter();\n"); write( paramName + ".setName(\"{0}\");\n", JRStringUtil.escapeJavaStringLiteral(param.getName())); write( paramName + ".setSkipWhenEmpty({0});\n", param.isSkipWhenEmpty(), false); writeExpression(param.getValueExpression(), paramName, "ValueExpression"); write( elementName + ".addParameter({0});\n", paramName); flush();//genericElementParameter } flush();//genericElement }
/** * */ public void setEvaluationTime(EvaluationTimeEnum evaluationTimeValue) { Object old = this.evaluationTimeValue; this.evaluationTimeValue = evaluationTimeValue; getEventSupport().firePropertyChange(PROPERTY_EVALUATION_TIME, old, this.evaluationTimeValue); }
/** * Sets the evaluation time for this image. * */ public void setEvaluationTime(EvaluationTimeEnum evaluationTimeValue) { Object old = this.evaluationTimeValue; this.evaluationTimeValue = evaluationTimeValue; getEventSupport().firePropertyChange(PROPERTY_EVALUATION_TIME, old, this.evaluationTimeValue); }
@SuppressWarnings("deprecation") private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_3_7_2) { horizontalAlignmentValue = net.sf.jasperreports.engine.type.HorizontalAlignEnum.getByValue(horizontalAlignment); verticalAlignmentValue = net.sf.jasperreports.engine.type.VerticalAlignEnum.getByValue(verticalAlignment); scaleImageValue = ScaleImageEnum.getByValue(scaleImage); onErrorTypeValue = OnErrorTypeEnum.getByValue(onErrorType); evaluationTimeValue = EvaluationTimeEnum.getByValue(evaluationTime); horizontalAlignment = null; verticalAlignment = null; scaleImage = null; } if (linkType == null) { linkType = JRHyperlinkHelper.getLinkType(HyperlinkTypeEnum.getByValue(hyperlinkType)); } if (linkTarget == null) { linkTarget = JRHyperlinkHelper.getLinkTarget(HyperlinkTargetEnum.getByValue(hyperlinkTarget)); } if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_6_0_2) { horizontalImageAlign = net.sf.jasperreports.engine.type.HorizontalAlignEnum.getHorizontalImageAlignEnum(horizontalAlignmentValue); verticalImageAlign = net.sf.jasperreports.engine.type.VerticalAlignEnum.getVerticalImageAlignEnum(verticalAlignmentValue); horizontalAlignmentValue = null; verticalAlignmentValue = null; } }
@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 addBarbecueRules(Digester digester) { String barcodePattern = "*/componentElement/barbecue"; digester.addObjectCreate(barcodePattern, StandardBarbecueComponent.class); digester.addSetProperties(barcodePattern, //properties to be ignored by this rule new String[]{JRXmlConstants.ATTRIBUTE_evaluationTime, StandardBarbecueComponent.PROPERTY_ROTATION}, new String[0]); digester.addRule(barcodePattern, new XmlConstantPropertyRule( JRXmlConstants.ATTRIBUTE_evaluationTime, "evaluationTimeValue", EvaluationTimeEnum.values())); digester.addRule(barcodePattern, new XmlConstantPropertyRule( StandardBarbecueComponent.PROPERTY_ROTATION, RotationEnum.values())); String barcodeExpressionPattern = barcodePattern + "/codeExpression"; digester.addFactoryCreate(barcodeExpressionPattern, JRExpressionFactory.StringExpressionFactory.class.getName()); digester.addCallMethod(barcodeExpressionPattern, "setText", 0); digester.addSetNext(barcodeExpressionPattern, "setCodeExpression", JRExpression.class.getName()); String applicationIdentifierExpressionPattern = barcodePattern + "/applicationIdentifierExpression"; digester.addFactoryCreate(applicationIdentifierExpressionPattern, JRExpressionFactory.StringExpressionFactory.class.getName()); digester.addCallMethod(applicationIdentifierExpressionPattern, "setText", 0); digester.addSetNext(applicationIdentifierExpressionPattern, "setApplicationIdentifierExpression", JRExpression.class.getName()); }
@Override public void registerDelayedEvaluation(JRPrintElement printElement, EvaluationTimeEnum evaluationTime, String evaluationGroup) { filler.addBoundElement(this, printElement, evaluationTime, evaluationGroup, band); }
@Override protected JRPrintElement fill() throws JRException { EvaluationTimeEnum evaluationTime = this.getEvaluationTimeValue(); JRTemplatePrintImage printImage; JRRecordedValuesPrintImage recordedValuesImage; if (isEvaluateAuto()) { printImage = recordedValuesImage = new JRRecordedValuesPrintImage(getJRTemplateImage(), printElementOriginator); } else { printImage = new JRTemplatePrintImage(getJRTemplateImage(), printElementOriginator); recordedValuesImage = null; } printImage.setUUID(this.getUUID()); printImage.setX(this.getX()); printImage.setY(this.getRelativeY()); printImage.setWidth(getWidth()); printImage.setHeight(this.getStretchHeight()); printImage.setBookmarkLevel(getBookmarkLevel()); if (isEvaluateNow()) { this.copy(printImage); } else if (isEvaluateAuto()) { initDelayedEvaluationPrint(recordedValuesImage); } else { filler.addBoundElement(this, printImage, evaluationTime, getEvaluationGroup(), band); } return printImage; }
/** * Returns the evaluation time corresponding to an evaluation time type. * * @param type the evaluation time type * @param group the group used for {@link EvaluationTimeEnum#GROUP EvaluationTimeEnum.GROUP} * evaluation time type * @param band the band used for {@link EvaluationTimeEnum#BAND EvaluationTimeEnum.BAND} * evaluation time type * @return the evaluation time corresponding to an evaluation time type */ public static JREvaluationTime getEvaluationTime(EvaluationTimeEnum type, JRGroup group, JRFillBand band) { JREvaluationTime evaluationTime; switch (type) { case REPORT: evaluationTime = EVALUATION_TIME_REPORT; break; case MASTER: evaluationTime = EVALUATION_TIME_MASTER; break; case PAGE: evaluationTime = EVALUATION_TIME_PAGE; break; case COLUMN: evaluationTime = EVALUATION_TIME_COLUMN; break; case GROUP: evaluationTime = getGroupEvaluationTime(group.getName()); break; case BAND: evaluationTime = getBandEvaluationTime(band); break; default: evaluationTime = null; break; } return evaluationTime; }
private JREvaluationTime(EvaluationTimeEnum type, String groupName, int bandId) { this.type = type; this.groupName = groupName; this.bandId = bandId; this.hash = computeHash(); }
@Override protected void evaluate(byte evaluation) throws JRException { reset(); evaluatePrintWhenExpression(evaluation); if (isPrintWhenExpressionNull() || isPrintWhenTrue()) { if (getEvaluationTimeValue() == EvaluationTimeEnum.NOW) { evaluateRenderer(evaluation); } } }