/** * */ public ChartRenderableFactory getChartRenderableFactory(String renderType) { String factoryClass = JRPropertiesUtil.getInstance(jasperReportsContext).getProperty(ChartRenderableFactory.PROPERTY_CHART_RENDERER_FACTORY_PREFIX + renderType); if (factoryClass == null) { throw new JRRuntimeException( EXCEPTION_MESSAGE_KEY_RENDERER_FACTORY_NOT_SPECIFIED, new Object[]{renderType}); } try { return CHART_RENDERABLE_FACTORY_CACHE.getCachedInstance(factoryClass); } catch (JRException e) { throw new JRRuntimeException(e); } }
@Override public void contribute(WebRequestContext context, ObjectNode config) { boolean enabled = JRPropertiesUtil.getInstance(context.getJasperReportsContext()).getBooleanProperty( propertyName, defaultEnabled); if (log.isDebugEnabled()) { log.debug("switch for " + propertyName + " is " + enabled); } if (enabled) { contributor.contribute(context, config); } }
protected void setPaths(String registryId, JRPropertiesMap properties, RequirejsTemplateConfigContributor templateContributor) { String pathPropPrefix = EXTENSION_PROPERTY_PATH_PREFIX + registryId + "."; List<PropertySuffix> pathProps = JRPropertiesUtil.getProperties(properties, pathPropPrefix); for (PropertySuffix pathProp : pathProps) { String suffix = pathProp.getSuffix(); String path = pathProp.getValue(); if (log.isDebugEnabled()) { log.debug("setting path " + suffix + " to " + path); } templateContributor.addPath(suffix, path); } }
protected void setResources(String registryId, JRPropertiesMap properties, RequirejsTemplateConfigContributor templateContributor) { String pathPropPrefix = EXTENSION_PROPERTY_RESOURCE_PREFIX + registryId + "."; List<PropertySuffix> pathProps = JRPropertiesUtil.getProperties(properties, pathPropPrefix); for (PropertySuffix pathProp : pathProps) { String suffix = pathProp.getSuffix(); String path = pathProp.getValue(); if (log.isDebugEnabled()) { log.debug("setting resource " + suffix + " to " + path); } templateContributor.addResourcePath(suffix, path); } }
@Override public ExtensionsRegistry createRegistry(String registryId, JRPropertiesMap properties) { List<PropertySuffix> requirejsModuleProperties = JRPropertiesUtil.getProperties(properties, REQUIREJS_MAPPING_PROPERTY_PREFIX); List<RequirejsModuleMapping> requirejsModules = new ArrayList<RequirejsModuleMapping>(); for (Iterator<PropertySuffix> it = requirejsModuleProperties.iterator(); it.hasNext();) { PropertySuffix requirejsModuleProp = it.next(); String suffix = requirejsModuleProp.getSuffix(); boolean isClasspathResource = !suffix.endsWith(URL_SUFFIX); requirejsModules.add( new RequirejsModuleMapping( isClasspathResource ? suffix : suffix.substring(0, suffix.indexOf(URL_SUFFIX)), requirejsModuleProp.getValue(), isClasspathResource ) ); } return new ListExtensionRegistry<RequirejsModuleMapping>(RequirejsModuleMapping.class, requirejsModules); }
@Override public List<ParameterContributor> getContributors(ParameterContributorContext context) throws JRException { List<ParameterContributor> contributors = new ArrayList<ParameterContributor>(); String dataAdapterUri = JRPropertiesUtil.getInstance(context.getJasperReportsContext()).getProperty(context.getDataset(), PROPERTY_DATA_ADAPTER_LOCATION); if (dataAdapterUri != null) { DataAdapterResource dataAdapterResource = RepositoryUtil.getInstance(context.getJasperReportsContext()).getResourceFromLocation(dataAdapterUri, DataAdapterResource.class); ParameterContributor dataAdapterService = DataAdapterServiceUtil.getInstance(context).getService(dataAdapterResource.getDataAdapter()); return Collections.singletonList(dataAdapterService); } return contributors; }
@Override public void evaluate(byte evaluation) throws JRException { jasperReport = evaluateReport(evaluation); JRFillDataset parentDataset = expressionEvaluator.getFillDataset(); datasetPosition = new FillDatasetPosition(parentDataset.getFillPosition()); datasetPosition.addAttribute("subreportPartUUID", fillContext.getPart().getUUID()); parentDataset.setCacheRecordIndex(datasetPosition, evaluation); String cacheIncludedProp = JRPropertiesUtil.getOwnProperty(fillContext.getPart(), DataCacheHandler.PROPERTY_INCLUDED); cacheIncluded = JRPropertiesUtil.asBoolean(cacheIncludedProp, true);// default to true //FIXMEBOOK do not evaluate REPORT_DATA_SOURCE parameterValues = JRFillSubreport.getParameterValues(fillContext.getFiller(), expressionEvaluator, subreportPart.getParametersMapExpression(), subreportPart.getParameters(), evaluation, false, jasperReport.getResourceBundle() != null, jasperReport.getFormatFactoryClass() != null); setBookmarksParameter(); }
/** * */ public static String getVersion(JasperReportsContext jasperReportsContext, JRPart part, JRXmlWriter reportWriter) { String version = null; ComponentKey componentKey = part.getComponentKey(); String versionProperty = PROPERTY_PART_COMPONENTS_PREFIX + componentKey.getName() + AbstractComponentXmlWriter.PROPERTY_COMPONENTS_VERSION_SUFFIX; if (part.getPropertiesMap().containsProperty(versionProperty)) { version = part.getPropertiesMap().getProperty(versionProperty); } else { JRReport report = reportWriter.getReport(); version = JRPropertiesUtil.getInstance(jasperReportsContext).getProperty(report, versionProperty); if (version == null) { version = JRPropertiesUtil.getInstance(jasperReportsContext).getProperty(report, JRXmlBaseWriter.PROPERTY_REPORT_VERSION); } } return version; }
@Override public ExtensionsRegistry createRegistry(String registryId, JRPropertiesMap properties) { List<PropertySuffix> fontFamiliesProperties = JRPropertiesUtil.getProperties(properties, SIMPLE_FONT_FAMILIES_PROPERTY_PREFIX); List<String> fontFamiliesLocations = new ArrayList<String>(); for (Iterator<PropertySuffix> it = fontFamiliesProperties.iterator(); it.hasNext();) { PropertySuffix fontFamiliesProp = it.next(); //String fontFamiliesName = fontFamiliesProp.getSuffix(); String fontFamiliesLocation = fontFamiliesProp.getValue(); //fontFamiliesLocations.addAll(SimpleFontExtensionHelper.getInstance().loadFontFamilies(fontFamiliesLocation)); fontFamiliesLocations.add(fontFamiliesLocation); } return new FontExtensionsRegistry(fontFamiliesLocations); }
@Override @SuppressWarnings("deprecation") public QueryExecuterFactory getQueryExecuterFactory(String language) throws JRException { String factoryClassName = JRPropertiesUtil.getInstance(jasperReportsContext).getProperty(QueryExecuterFactory.QUERY_EXECUTER_FACTORY_PREFIX + language); if (factoryClassName == null) { return null; } JRQueryExecuterFactory factory = cache.getCachedInstance(factoryClassName); if (factory instanceof QueryExecuterFactory) { return (QueryExecuterFactory)factory; } return new JRQueryExecuterUtils.WrappingQueryExecuterFactory(factory); }
private Map<String, String> extractXmlNamespacesFromProperties() throws JRException { Map<String, String> namespaces = new HashMap<String, String>(); String xmlnsPrefix = JaxenXPathQueryExecuterFactory.XML_NAMESPACE_PREFIX; List<PropertySuffix> nsProperties = JRPropertiesUtil.getProperties(dataset, xmlnsPrefix); for (int i=0; i < nsProperties.size(); ++i) { PropertySuffix prop = nsProperties.get(i); String nsPrefix = prop.getKey().substring(xmlnsPrefix.length()); if (nsPrefix.length() > 0) { namespaces.put(nsPrefix, prop.getValue()); } } return namespaces.size()>0 ? namespaces : null; }
private Map<String, String> extractXmlNamespacesFromProperties() throws JRException { Map<String, String> namespaces = new HashMap<String, String>(); String xmlnsPrefix = XalanXPathQueryExecuterFactory.XML_NAMESPACE_PREFIX; List<PropertySuffix> nsProperties = JRPropertiesUtil.getProperties(dataset, xmlnsPrefix); for (int i=0; i < nsProperties.size(); ++i) { PropertySuffix prop = nsProperties.get(i); String nsPrefix = prop.getKey().substring(xmlnsPrefix.length()); if (nsPrefix.length() > 0) { namespaces.put(nsPrefix, prop.getValue()); } } return namespaces.size()>0 ? namespaces : null; }
@Override public String[] getStringArrayParameter(net.sf.jasperreports.engine.JRExporterParameter parameter, String propertyPrefix) { String[] values = null; JRPropertiesMap hintsMap = jasperPrint.getPropertiesMap(); if (hintsMap != null) { List<PropertySuffix> properties = JRPropertiesUtil.getProperties(hintsMap, propertyPrefix); if (properties != null && !properties.isEmpty()) { values = new String[properties.size()]; for(int i = 0; i < values.length; i++) { values[i] = properties.get(i).getValue(); } } } else { values = (String[])parameters.get(parameter); } return values; }
protected void configureParser(SAXParser parser) throws SAXException { List<String> schemaLocations = getSchemaLocations(); parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema"); parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource", schemaLocations.toArray(new String[schemaLocations.size()])); boolean cache = JRPropertiesUtil.getInstance(jasperReportsContext).getBooleanProperty(PROPERTY_CACHE_SCHEMAS); if (cache) { enableSchemaCaching(parser); } }
/** * */ public QRCodeImageProducer getQRCodeProducer(JRPropertiesHolder propertiesHolder) { String producerProperty = JRPropertiesUtil.getInstance(jasperReportsContext).getProperty(propertiesHolder, BarcodeImageProducer.PROPERTY_IMAGE_PRODUCER); String producerClass = JRPropertiesUtil.getInstance(jasperReportsContext).getProperty(propertiesHolder, QRCodeImageProducer.PROPERTY_PREFIX_QRCODE_PRODUCER + producerProperty); if (producerClass == null) { producerClass = producerProperty; } try { return qrCodeProducerCache.getCachedInstance(producerClass); } catch (JRException e) { throw new JRRuntimeException(e); } }
/** * */ public BarcodeImageProducer getProducer(JRPropertiesHolder propertiesHolder) { String producerProperty = JRPropertiesUtil.getInstance(jasperReportsContext).getProperty(propertiesHolder, BarcodeImageProducer.PROPERTY_IMAGE_PRODUCER); String producerClass = JRPropertiesUtil.getInstance(jasperReportsContext).getProperty(propertiesHolder, BarcodeImageProducer.PROPERTY_PREFIX_IMAGE_PRODUCER + producerProperty); if (producerClass == null) { producerClass = producerProperty; } try { return imageProducerCache.getCachedInstance(producerClass); } catch (JRException e) { throw new JRRuntimeException(e); } }
/** * */ public static String getVersion(JasperReportsContext jasperReportsContext, JRComponentElement componentElement, JRXmlWriter reportWriter) { String version = null; ComponentKey componentKey = componentElement.getComponentKey(); String versionProperty = PROPERTY_COMPONENTS_PREFIX + componentKey.getName() + PROPERTY_COMPONENTS_VERSION_SUFFIX; if (componentElement.getPropertiesMap().containsProperty(versionProperty)) { version = componentElement.getPropertiesMap().getProperty(versionProperty); } else { JRReport report = reportWriter.getReport(); version = JRPropertiesUtil.getInstance(jasperReportsContext).getProperty(report, versionProperty); if (version == null) { version = JRPropertiesUtil.getInstance(jasperReportsContext).getProperty(report, JRXmlBaseWriter.PROPERTY_REPORT_VERSION); } } return version; }
protected boolean allowElementNegativeY(JRElement element) { // default to report/global property boolean allow = allowElementNegativeY; if (element.hasProperties()) { JRPropertiesMap properties = element.getPropertiesMap(); if (properties.containsProperty(PROPERTY_ALLOW_ELEMENT_NEGATIVE_Y)) { // use element level property allow = JRPropertiesUtil.asBoolean(properties.getProperty( PROPERTY_ALLOW_ELEMENT_NEGATIVE_Y)); } } return allow; }
/** * */ protected boolean startHyperlink(JRPrintHyperlink link, boolean isText, boolean isOnePagePerSheet) { String href = null; String ignLnkPropName = getIgnoreHyperlinkProperty(); Boolean ignoreHyperlink = HyperlinkUtil.getIgnoreHyperlink(ignLnkPropName, link); if (ignoreHyperlink == null) { ignoreHyperlink = JRPropertiesUtil.getInstance(getJasperReportsContext()).getBooleanProperty(jasperPrint, ignLnkPropName, false); } if (!ignoreHyperlink) { href = documentBuilder.getHyperlinkURL(link, isOnePagePerSheet); } if (href != null) { writeHyperlink(link, href, isText); } return href != null; }
/** * */ public DrawVisitor(ReportConverter reportConverter, Graphics2D grx) { this.convertVisitor = new ConvertVisitor(reportConverter); JasperReportsContext jasperReportsContext = reportConverter.getJasperReportsContext(); JRReport report = reportConverter.getReport(); JRPropertiesUtil propUtil = JRPropertiesUtil.getInstance(jasperReportsContext); this.drawVisitor = new PrintDrawVisitor( jasperReportsContext, new RenderersCache(jasperReportsContext), propUtil.getBooleanProperty(report, Graphics2DReportConfiguration.MINIMIZE_PRINTER_JOB_SIZE, true), propUtil.getBooleanProperty(report, JRStyledText.PROPERTY_AWT_IGNORE_MISSING_FONT, false) ); setGraphics2D(grx); this.drawVisitor.setClip(true); }
@Override public String[] getStringArrayParameter(net.sf.jasperreports.engine.JRExporterParameter parameter, String propertyPrefix) { String[] values = null; if (parameters.containsKey(parameter)) { values = (String[])parameters.get(parameter); } else { List<PropertySuffix> properties = JRPropertiesUtil.getProperties(jasperPrint.getPropertiesMap(), propertyPrefix); if (properties != null && !properties.isEmpty()) { values = new String[properties.size()]; for(int i = 0; i < values.length; i++) { values[i] = properties.get(i).getValue(); } } } return values; }
@SuppressWarnings("unchecked") private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { setThreadJasperReportsContext(); GetField fields = in.readFields(); cachedRenderers = (Map<String, Renderable>) fields.get("cachedRenderers", null); cachedTemplates = (Map<String, JRTemplateElement>) fields.get("cachedTemplates", null); readOnly = fields.get("readOnly", false); // use configured default if serialized by old version pageElementSize = fields.get("pageElementSize", JRPropertiesUtil.getInstance(jasperReportsContext).getIntegerProperty( JRVirtualPrintPage.PROPERTY_VIRTUAL_PAGE_ELEMENT_SIZE, 0)); setThreadVirtualizer(); initLock(); }
private int determineColumnSortMeasure(JRFillCellContents contents) { int sortMeasureIdx = -1; JRElement[] cellElements = contents.getElements(); for (JRElement element : cellElements) { String sortMeasureIdxProp = element.hasProperties() ? element.getPropertiesMap().getProperty(PROPERTY_COLUMN_HEADER_SORT_MEASURE_INDEX) : null; if (sortMeasureIdxProp != null) { sortMeasureIdx = JRPropertiesUtil.asInteger(sortMeasureIdxProp); break; } } return sortMeasureIdx; }
protected HashMap<Pair<UUID, FontKey>, ElementFontInfo> createElementFontInfosFillCache() { final int cacheSize = JRPropertiesUtil.getInstance(context.getJasperReportsContext()).getIntegerProperty( PROPERTY_ELEMENT_CACHE_SIZE, 2000);//hardcoded default if (log.isDebugEnabled()) { log.debug("creating element font infos cache of size " + cacheSize); } // creating a LRU map return new LinkedHashMap<Pair<UUID,FontKey>, SimpleTextLineWrapper.ElementFontInfo>(64, 0.75f, true) { @Override protected boolean removeEldestEntry(Entry<Pair<UUID, FontKey>, ElementFontInfo> eldest) { return size() > cacheSize; } }; }
@Override public ExtensionsRegistry createRegistry(String registryId, JRPropertiesMap properties) { List<PropertySuffix> castorMappingProperties = JRPropertiesUtil.getProperties(properties, CASTOR_MAPPING_PROPERTY_PREFIX); List<CastorMapping> castorMappings = new ArrayList<CastorMapping>(); for (Iterator<PropertySuffix> it = castorMappingProperties.iterator(); it.hasNext();) { PropertySuffix castorMappingProp = it.next(); String key; String version; String suffix = castorMappingProp.getSuffix(); int versionSeparatorIndex = suffix.lastIndexOf(CASTOR_MAPPING_VERSION_SEPARATOR); if (versionSeparatorIndex < 0) { key = suffix; version = null; } else { key = suffix.substring(0, versionSeparatorIndex); version = suffix.substring(versionSeparatorIndex + 1, suffix.length()); } String castorMappingPath = castorMappingProp.getValue(); CastorMapping mapping = new CastorMapping(key, version, castorMappingPath); castorMappings.add(mapping); } return new ListExtensionRegistry<CastorMapping>(CastorMapping.class, castorMappings); }
/** * Return an {@link HtmlPrintElementFactory factory} instance. * * @return a HtmlPrintElementFactory instance * @throws JRException if the {@link #PROPERTY_HTML_PRINTELEMENT_FACTORY factory property} is not defined * or the factory cannot be instantiated. */ public static HtmlPrintElementFactory getHtmlPrintElementFactory() throws JRException { String factoryClassName = JRPropertiesUtil.getInstance(DefaultJasperReportsContext.getInstance()).getProperty(PROPERTY_HTML_PRINTELEMENT_FACTORY); if (factoryClassName == null) { factoryClassName = DefaultHtmlPrintElementFactory.class.getName(); } return cache.getCachedInstance(factoryClassName); }
/** * */ public String getHeaderTemplate() { if (headerTemplate == null) { return JRPropertiesUtil.getInstance(getJasperReportsContext()).getProperty(PROPERTY_TEMPLATE_HEADER); } return headerTemplate; }
/** * */ public String getFooterTemplate() { if (footerTemplate == null) { return JRPropertiesUtil.getInstance(getJasperReportsContext()).getProperty(PROPERTY_TEMPLATE_FOOTER); } return footerTemplate; }
/** * */ protected boolean checkResourceName(JasperReportsContext jasperReportsContext, String resourceName) { boolean matched = false; List<PropertySuffix> patternProps = JRPropertiesUtil.getInstance(jasperReportsContext).getProperties(PROPERTIES_WEB_RESOURCE_PATTERN_PREFIX);//FIXMESORT cache this for (Iterator<PropertySuffix> patternIt = patternProps.iterator(); patternIt.hasNext();) { JRPropertiesUtil.PropertySuffix patternProp = patternIt.next(); String patternStr = patternProp.getValue(); if (patternStr != null && patternStr.length() > 0) { Pattern resourcePattern = Pattern.compile(patternStr); if (resourcePattern.matcher(resourceName).matches()) { if (log.isDebugEnabled()) { log.debug("resource " + resourceName + " matched pattern " + resourcePattern); } matched = true; break; } } } if (!matched) { if (log.isDebugEnabled()) { log.debug("Resource " + resourceName + " does not matched any allowed pattern"); } // throw new JRRuntimeException("Resource " + resourceName // + " does not matched any allowed pattern"); } return matched; }
@Override public ExtensionsRegistry createRegistry(String registryId, JRPropertiesMap properties) { List<PropertySuffix> contentTypeMappingProperties = JRPropertiesUtil.getProperties(properties, CONTENT_TYPE_MAPPING_PROPERTY_PREFIX); List<ContentTypeMapping> contentTypeMappings = new ArrayList<ContentTypeMapping>(); for (Iterator<PropertySuffix> it = contentTypeMappingProperties.iterator(); it.hasNext();) { PropertySuffix contentTypeMappingProp = it.next(); contentTypeMappings.add(new ContentTypeMapping(contentTypeMappingProp.getSuffix(),contentTypeMappingProp.getValue())); } return new ListExtensionRegistry<ContentTypeMapping>(ContentTypeMapping.class, contentTypeMappings); }
@Override public ExtensionsRegistry createRegistry(String registryId, JRPropertiesMap properties) { String root = JRPropertiesUtil.getInstance(DefaultJasperReportsContext.getInstance()).getProperty(properties, PROPERTY_FILE_REPOSITORY_ROOT); boolean resolveAbsolutePath = JRPropertiesUtil.getInstance(DefaultJasperReportsContext.getInstance()).getBooleanProperty(properties, PROPERTY_FILE_REPOSITORY_RESOLVE_ABSOLUTE_PATH, false); return new SingletonExtensionRegistry<RepositoryService>(RepositoryService.class, new FileRepositoryService(DefaultJasperReportsContext.getInstance(), root, resolveAbsolutePath)); }
protected List<ExtensionsRegistry> loadRegistries(JRPropertiesMap properties, Map<String, Exception> registryExceptions) { List<ExtensionsRegistry> registries = new ArrayList<ExtensionsRegistry>(); List<PropertySuffix> factoryProps = JRPropertiesUtil.getProperties(properties, PROPERTY_REGISTRY_FACTORY_PREFIX); for (Iterator<PropertySuffix> it = factoryProps.iterator(); it.hasNext();) { PropertySuffix factoryProp = it.next(); String registryId = factoryProp.getSuffix(); String factoryClass = factoryProp.getValue(); if (log.isDebugEnabled()) { log.debug("Instantiating registry of type " + factoryClass + " for property " + factoryProp.getKey()); } try { ExtensionsRegistry registry = instantiateRegistry( properties, registryId, factoryClass); registries.add(registry); } catch (Exception e) { //skip this registry //error logging is deferred after the registries are cached to avoid a loop from JRRuntimeException.resolveMessage registryExceptions.put(registryId, e); } } return registries; }
public JavaScriptEvaluatorScope(JasperReportsContext jrContext, JREvaluator evaluator, FunctionsUtil functionsUtil) { context = enter(null); int optimizationLevel = JRPropertiesUtil.getInstance(jrContext).getIntegerProperty(JavaScriptEvaluator.PROPERTY_OPTIMIZATION_LEVEL); if (log.isDebugEnabled()) { log.debug("optimization level " + optimizationLevel); } context.setOptimizationLevel(optimizationLevel); context.getWrapFactory().setJavaPrimitiveWrap(false); //using a protection domain in getCompiledExpression context.setSecurityController(new JavaPolicySecurity()); JavaScriptFunctionsObject functionsObject = new JavaScriptFunctionsObject(context, functionsUtil, evaluator); this.scope = context.initStandardObjects(); // is this OK? the original prototype set by initStandardObjects is lost, and functionsObject has no prototype. // seems to be fine for now, if not we could try setting the Object prototype to functionsObject. this.scope.setPrototype(functionsObject); this.scope.put(EVALUATOR_VAR, this.scope, evaluator); // exiting for now because we will enter later in ensureContext(), possibly on other thread Context.exit(); }
/** * */ public static String getNumberPattern(JasperReportsContext jrContext, Locale locale) { String numberPatternBundleName = JRPropertiesUtil.getInstance(jrContext).getProperty(NUMBER_PATTERN_BUNDLE); if (numberPatternBundleName == null) { numberPatternBundleName = DEFAULT_PATTERNS_BUNDLE; } String numberPatternKey = JRPropertiesUtil.getInstance(jrContext).getProperty(NUMBER_PATTERN_KEY); if (numberPatternKey == null) { numberPatternKey = DEFAULT_NUMBER_PATTERN_KEY; } return getBundleMessage(numberPatternKey, jrContext, numberPatternBundleName, locale); }
/** * */ public ParameterOverrideResolver( JasperReportsContext jasperReportsContext, JasperPrint jasperPrint, Map<net.sf.jasperreports.engine.JRExporterParameter, Object> parameters ) { this.propertiesUtil = JRPropertiesUtil.getInstance(jasperReportsContext); this.jasperPrint = jasperPrint; this.parameters = parameters; }
/** * */ private Renderable getRenderer(ReportConverter reportConverter, JRChart chart) { String renderType = chart.getRenderType();//FIXMETHEME try reuse this sequence if(renderType == null) { renderType = JRPropertiesUtil.getInstance(reportConverter.getJasperReportsContext()).getProperty(reportConverter.getReport(), JRChart.PROPERTY_CHART_RENDER_TYPE); } String themeName = chart.getTheme(); if(themeName == null) { themeName = JRPropertiesUtil.getInstance(reportConverter.getJasperReportsContext()).getProperty(reportConverter.getReport(), JRChart.PROPERTY_CHART_THEME); } ChartTheme theme = ChartUtil.getInstance(reportConverter.getJasperReportsContext()).getTheme(themeName); ChartContext chartContext = new ConvertChartContext(reportConverter, chart); JFreeChart jfreeChart = null; try { jfreeChart = theme.createChart(chartContext); } catch (JRException e) { throw new JRRuntimeException(e); } Rectangle2D rectangle = new Rectangle2D.Double(0, 0, chart.getWidth(), chart.getHeight()); return ChartUtil.getInstance(reportConverter.getJasperReportsContext()).getChartRenderableFactory(renderType).getRenderable( reportConverter.getJasperReportsContext(), jfreeChart, null, rectangle ); }
private TimeZone readTimeZone() { //duplicates code from JRFillDataset.defaultTimeZone String timezoneId = JRPropertiesUtil.getInstance(jasperReportsContext).getProperty(report, JRFiller.PROPERTY_DEFAULT_TIMEZONE); TimeZone timezone = (timezoneId == null || timezoneId.isEmpty()) ? TimeZone.getDefault() : JRDataUtils.getTimeZone(timezoneId); return timezone; }
@Override public StyleProvider getStyleProvider(StyleProviderContext context, JasperReportsContext jasperreportsContext) { Map<String, JRPropertyExpression> stylePropertyExpressions = null; JRPropertyExpression[] propertyExpressions = context.getElement().getPropertyExpressions(); if (propertyExpressions != null) { for(JRPropertyExpression propertyExpression : propertyExpressions) { if (propertyExpression.getName().startsWith(PropertyStyleProvider.STYLE_PROPERTY_PREFIX)) { if (stylePropertyExpressions == null) { stylePropertyExpressions = new HashMap<String, JRPropertyExpression>(); } stylePropertyExpressions.put(propertyExpression.getName(), propertyExpression); } } } List<PropertySuffix> styleProperties = JRPropertiesUtil.getProperties(context.getElement(), PropertyStyleProvider.STYLE_PROPERTY_PREFIX); if ( stylePropertyExpressions != null || (styleProperties != null && styleProperties.size() > 0) ) { return new PropertyStyleProvider(context, stylePropertyExpressions); } return null; }
/** * Creates an XML template writer. * * @param jasperReportsContext * @param template the template to write * @param out the output writer * @param encoding the XML encoding to use */ public JRXmlTemplateWriter(JasperReportsContext jasperReportsContext, JRTemplate template, Writer out, String encoding) { this.template = template; this.encoding = encoding; String version = JRPropertiesUtil.getInstance(jasperReportsContext).getProperty(JRXmlBaseWriter.PROPERTY_REPORT_VERSION); useWriter(new JRXmlWriteHelper(out), version); }
private void initInternalResources() { internalEntityResources = new HashMap<String, URL>(); entityURLs = new HashSet<String>(); //FIXME only add entities relevant to the current document type (report, print, template) addEntityResource(JRXmlConstants.JASPERREPORT_SYSTEM_ID, JRXmlConstants.JASPERREPORT_DTD); addEntityResource(JRXmlConstants.JASPERPRINT_SYSTEM_ID, JRXmlConstants.JASPERPRINT_DTD); addEntityResource(JRXmlConstants.JASPERTEMPLATE_SYSTEM_ID, JRXmlConstants.JASPERTEMPLATE_DTD); addEntityResource(JRXmlConstants.JASPERREPORT_XSD_SYSTEM_ID, JRXmlConstants.JASPERREPORT_XSD_RESOURCE); addEntityResource(null, JRXmlConstants.JASPERREPORT_XSD_DTD_COMPAT_RESOURCE); addEntityResource(JRXmlConstants.JASPERPRINT_XSD_SYSTEM_ID, JRXmlConstants.JASPERPRINT_XSD_RESOURCE); addEntityResource(null, JRXmlConstants.JASPERPRINT_XSD_DTD_COMPAT_RESOURCE); addEntityResource(JRXmlConstants.JASPERTEMPLATE_XSD_SYSTEM_ID, JRXmlConstants.JASPERTEMPLATE_XSD_RESOURCE); addEntityResource(null, JRXmlConstants.JASPERTEMPLATE_XSD_DTD_COMPAT_RESOURCE); loadUnknownEntities = JRPropertiesUtil.getInstance(DefaultJasperReportsContext.getInstance()).getBooleanProperty( PROPERTY_LOAD_UNKNOWN_ENTITIES, false); }