Java Code Examples for net.sf.jasperreports.engine.JRException
The following examples show how to use
net.sf.jasperreports.engine.JRException.
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: jasperreports Author: TIBCOSoftware File: SpiderChartApp.java License: GNU Lesser General Public License v3.0 | 7 votes |
/** * */ public void ods() throws JRException { long start = System.currentTimeMillis(); File sourceFile = new File("build/reports/SpiderChart.jrprint"); JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile); File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".ods"); JROdsExporter exporter = new JROdsExporter(); exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile)); SimpleOdsReportConfiguration configuration = new SimpleOdsReportConfiguration(); configuration.setOnePagePerSheet(true); exporter.setConfiguration(configuration); exporter.exportReport(); System.err.println("ODT creation time : " + (System.currentTimeMillis() - start)); }
Example #2
Source Project: jasperreports Author: TIBCOSoftware File: AegeanChartTheme.java License: GNU Lesser General Public License v3.0 | 6 votes |
@Override protected JFreeChart createStackedBar3DChart() throws JRException { JFreeChart jfreeChart = super.createStackedBar3DChart(); CategoryPlot categoryPlot = (CategoryPlot)jfreeChart.getPlot(); BarRenderer3D barRenderer3D = (BarRenderer3D)categoryPlot.getRenderer(); barRenderer3D.setWallPaint(ChartThemesConstants.TRANSPARENT_PAINT); barRenderer3D.setItemMargin(0); CategoryDataset categoryDataset = categoryPlot.getDataset(); if(categoryDataset != null) { for(int i = 0; i < categoryDataset.getRowCount(); i++) { barRenderer3D.setSeriesOutlinePaint(i, ChartThemesConstants.TRANSPARENT_PAINT); } } return jfreeChart; }
Example #3
Source Project: nordpos Author: nordpos File: JRViewer.java License: GNU General Public License v3.0 | 6 votes |
void btnReloadActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnReloadActionPerformed {//GEN-HEADEREND:event_btnReloadActionPerformed // Add your handling code here: if (type == TYPE_FILE_NAME) { try { loadReport(reportFileName, isXML); } catch (JRException e) { if (log.isErrorEnabled()) { log.error("Reload error.", e); } jasperPrint = null; setPageIndex(0); refreshPage(); JOptionPane.showMessageDialog(this, getBundleString("error.loading")); } forceRefresh(); } }
Example #4
Source Project: jasperreports Author: TIBCOSoftware File: JRDesignViewerPanel.java License: GNU Lesser General Public License v3.0 | 6 votes |
@Override protected JRGraphics2DExporter getGraphics2DExporter() throws JRException { return new JRGraphics2DExporter(viewerContext.getJasperReportsContext()) { @Override protected void initReport() { super.initReport(); drawVisitor.setClip(true);//FIXMENOW thick border of margin elements is clipped } @Override protected RenderersCache getRenderersCache() { return viewerContext.getRenderersCache(); } }; }
Example #5
Source Project: jasperreports Author: TIBCOSoftware File: JRFillSubreport.java License: GNU Lesser General Public License v3.0 | 6 votes |
protected void cancelSubreportFill() throws JRException { if (log.isDebugEnabled()) { log.debug("Fill " + filler.fillerId + ": cancelling " + subreportFiller.fillerId); } // marking the subreport filler for interruption subreportFiller.setInterrupted(true); synchronized (subreportFiller) { // forcing the creation of a new thread and a new subreport filler runner.cancel(); runner.reset(); } filler.unregisterSubfiller(subreportFiller); }
Example #6
Source Project: jasperreports Author: TIBCOSoftware File: ChartCustomizersApp.java License: GNU Lesser General Public License v3.0 | 6 votes |
/** * */ public void fill() throws JRException { Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("legendWidth", "10"); parameters.put("legendHeight", "10"); File[] files = getFiles(new File("build/reports"), "jasper"); for(int i = 0; i < files.length; i++) { File reportFile = files[i]; long start = System.currentTimeMillis(); JasperFillManager.fillReportToFile( reportFile.getAbsolutePath(), new HashMap<String, Object>(parameters) ); System.err.println("Report : " + reportFile + ". Filling time : " + (System.currentTimeMillis() - start)); } }
Example #7
Source Project: jasperreports Author: TIBCOSoftware File: SaveAction.java License: GNU Lesser General Public License v3.0 | 6 votes |
@Override public void performAction() { // JasperDesign jasperDesign = getJasperDesign(); JasperDesignCache cache = JasperDesignCache.getInstance(getJasperReportsContext(), getReportContext()); Map<String, JasperDesignReportResource> cachedResources = cache.getCachedResources(); for (String uri : cachedResources.keySet()) { JasperDesignReportResource resource = cachedResources.get(uri); JasperDesign jasperDesign = resource.getJasperDesign(); if (jasperDesign != null) { JasperReport jasperReport = resource.getReport(); String appRealPath = null;//FIXMECONTEXT WebFileRepositoryService.getApplicationRealPath(); try { JRSaver.saveObject(jasperReport, new File(new File(new File(appRealPath), "WEB-INF/repository"), uri));//FIXMEJIVE harcoded } catch (JRException e) { throw new JRRuntimeException(e); } } } }
Example #8
Source Project: jasperreports Author: TIBCOSoftware File: CustomVisualizationApp.java License: GNU Lesser General Public License v3.0 | 6 votes |
/** * */ public void ods() throws JRException { File[] files = getFiles(new File("build/reports"), "jrprint"); for(int i = 0; i < files.length; i++) { long start = System.currentTimeMillis(); File sourceFile = files[i]; JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile); File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".ods"); JROdsExporter exporter = new JROdsExporter(); exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile)); SimpleOdsReportConfiguration configuration = new SimpleOdsReportConfiguration(); configuration.setOnePagePerSheet(true); exporter.setConfiguration(configuration); exporter.exportReport(); System.err.println("Report : " + sourceFile + ". ODS export time : " + (System.currentTimeMillis() - start)); } }
Example #9
Source Project: jasperreports Author: TIBCOSoftware File: WrappingSvgDataToGraphics2DRenderer.java License: GNU Lesser General Public License v3.0 | 6 votes |
@Override protected SVGDocument getSvgDocument( JasperReportsContext jasperReportsContext, SVGDocumentFactory documentFactory ) throws JRException { try { return documentFactory.createSVGDocument( null, new ByteArrayInputStream( dataRenderer.getData(jasperReportsContext) ) ); } catch (IOException e) { throw new JRRuntimeException(e); } }
Example #10
Source Project: jasperreports Author: TIBCOSoftware File: JRDesignDataset.java License: GNU Lesser General Public License v3.0 | 6 votes |
/** * Inserts a scriptlet at the specified position into the dataset. * @param index the scriptlet position * @param scriptlet the scriptlet to insert * @throws JRException * @see net.sf.jasperreports.engine.JRDataset#getScriptlets() */ public void addScriptlet(int index, JRScriptlet scriptlet) throws JRException { if (scriptletsMap.containsKey(scriptlet.getName())) { throw new JRException( EXCEPTION_MESSAGE_KEY_DUPLICATE_SCRIPTLET, new Object[]{scriptlet.getName()}); } JRDesignParameter scriptletParameter = new JRDesignParameter(); scriptletParameter.setName(scriptlet.getName() + JRScriptlet.SCRIPTLET_PARAMETER_NAME_SUFFIX); scriptletParameter.setValueClassName(scriptlet.getValueClassName()); scriptletParameter.setSystemDefined(true); scriptletParameter.setForPrompting(false); addParameter(scriptletParameter); scriptletsList.add(index, scriptlet); scriptletsMap.put(scriptlet.getName(), scriptlet); getEventSupport().fireCollectionElementAddedEvent(PROPERTY_SCRIPTLETS, scriptlet, index); }
Example #11
Source Project: jasperreports Author: TIBCOSoftware File: BatchExportApp.java License: GNU Lesser General Public License v3.0 | 6 votes |
/** * */ public void html() throws JRException { long start = System.currentTimeMillis(); List<JasperPrint> jasperPrintList = new ArrayList<JasperPrint>(); jasperPrintList.add((JasperPrint)JRLoader.loadObjectFromFile("build/reports/Report1.jrprint")); jasperPrintList.add((JasperPrint)JRLoader.loadObjectFromFile("build/reports/Report2.jrprint")); jasperPrintList.add((JasperPrint)JRLoader.loadObjectFromFile("build/reports/Report3.jrprint")); HtmlExporter exporter = new HtmlExporter(); exporter.setExporterInput(SimpleExporterInput.getInstance(jasperPrintList)); exporter.setExporterOutput(new SimpleHtmlExporterOutput("build/reports/BatchExportReport.html")); exporter.exportReport(); System.err.println("HTML creation time : " + (System.currentTimeMillis() - start)); }
Example #12
Source Project: jasperreports Author: TIBCOSoftware File: JRXmlUtils.java License: GNU Lesser General Public License v3.0 | 6 votes |
/** * Creates a document having a node as root. * * @param sourceNode the node * @return a document having the specified node as root * @throws JRException */ public static Document createDocument(Node sourceNode, boolean isNamespaceAware) throws JRException { Document doc = JRXmlUtils.createDocumentBuilder(isNamespaceAware).newDocument(); Node source; if (sourceNode.getNodeType() == Node.DOCUMENT_NODE) { source = ((Document) sourceNode).getDocumentElement(); } else { source = sourceNode; } Node node = doc.importNode(source, true); doc.appendChild(node); return doc; }
Example #13
Source Project: jasperreports Author: TIBCOSoftware File: JRXmlUtils.java License: GNU Lesser General Public License v3.0 | 6 votes |
/** * Creates a XML document builder. * * @return a XML document builder * @throws JRException */ public static DocumentBuilder createDocumentBuilder(boolean isNamespaceAware) throws JRException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(false); dbf.setIgnoringComments(true); dbf.setNamespaceAware(isNamespaceAware); try { if (!allowDoctype()) { dbf.setFeature(FEATURE_DISALLOW_DOCTYPE, true); } return dbf.newDocumentBuilder(); } catch (ParserConfigurationException e) { throw new JRException( EXCEPTION_MESSAGE_KEY_DOCUMENT_BUILDER_FACTORY_CREATION_FAILURE, null, e); } }
Example #14
Source Project: jasperreports Author: TIBCOSoftware File: JRCsvDataSource.java License: GNU Lesser General Public License v3.0 | 6 votes |
/** * Reads a character from the stream. * @throws IOException if any I/O error occurs * @throws JRException if end of stream has been reached */ private char getChar() throws IOException, JRException { // end of buffer, fill a new buffer if (position + 1 > bufSize) { bufSize = reader.read(buffer); position = 0; if (bufSize == -1) { throw new JRException( EXCEPTION_MESSAGE_KEY_NO_MORE_CHARS, (Object[])null); } } return buffer[position++]; }
Example #15
Source Project: jasperreports Author: TIBCOSoftware File: JRFillDataset.java License: GNU Lesser General Public License v3.0 | 6 votes |
/** * */ private void setFillParameterValuesFromMap(Map<String,Object> parameterValues, boolean reset) throws JRException { if (parameters != null && parameters.length > 0) { for (int i = 0; i < parameters.length; i++) { JRFillParameter parameter = parameters[i]; String paramName = parameter.getName(); Object value = null; if (parameterValues.containsKey(paramName)) { value = parameterValues.get(paramName); setParameter(parameter, value); } else if (reset) { setParameter(parameter, null); } } } }
Example #16
Source Project: jasperreports Author: TIBCOSoftware File: TableApp.java License: GNU Lesser General Public License v3.0 | 5 votes |
/** * */ public void print() throws JRException { long start = System.currentTimeMillis(); JasperPrintManager.printReport("build/reports/TableReport.jrprint", true); System.err.println("Printing time : " + (System.currentTimeMillis() - start)); }
Example #17
Source Project: jasperreports Author: TIBCOSoftware File: JFreeChartApp.java License: GNU Lesser General Public License v3.0 | 5 votes |
/** * */ public void pdf() throws JRException { long start = System.currentTimeMillis(); JasperExportManager.exportReportToPdfFile("build/reports/JFreeChartReport.jrprint"); System.err.println("PDF creation time : " + (System.currentTimeMillis() - start)); }
Example #18
Source Project: jasperreports Author: TIBCOSoftware File: Barcode4JApp.java License: GNU Lesser General Public License v3.0 | 5 votes |
/** * */ public void xml() throws JRException { long start = System.currentTimeMillis(); JasperExportManager.exportReportToXmlFile("build/reports/Barcode4JReport.jrprint", false); System.err.println("XML creation time : " + (System.currentTimeMillis() - start)); }
Example #19
Source Project: jasperreports Author: TIBCOSoftware File: TabularApp.java License: GNU Lesser General Public License v3.0 | 5 votes |
/** * */ public void xml() throws JRException { long start = System.currentTimeMillis(); JasperExportManager.exportReportToXmlFile("build/reports/TabularReport.jrprint", false); System.err.println("XML creation time : " + (System.currentTimeMillis() - start)); }
Example #20
Source Project: jasperreports Author: TIBCOSoftware File: DataSourceCollection.java License: GNU Lesser General Public License v3.0 | 5 votes |
@Override public Object getFieldValue(JRField field) throws JRException { if (currentDataSource == null) { // should not happen throw new JRRuntimeException( EXCEPTION_MESSAGE_KEY_METHOD_CALL_ERROR, (Object[])null); } return currentDataSource.getFieldValue(field); }
Example #21
Source Project: jasperreports Author: TIBCOSoftware File: JRFillCrosstab.java License: GNU Lesser General Public License v3.0 | 5 votes |
private List<JRPrintElement> fillTitleCell(int availableHeight) throws JRException { setCountVars(-1, -1); JRFillCellContents cell = titleCellContents; int width = rowHeadersXOffsets[rowGroups.length] + columnXOffsets[lastColumnIndex] - columnXOffsets[startColumnIndex]; cell = cell.getTransformedContents(width, cell.getHeight(), getTitleCell().getContentsPosition(), CrosstabRowPositionEnum.TOP); JRFillCellContents contents = cell.getWorkingClone(); contents.evaluate(JRExpression.EVALUATION_DEFAULT); contents.prepare(availableHeight); willOverflow = contents.willOverflow(); if (willOverflow) { return null; } contents.setX(0); contents.setY(yOffset); contents.setHorizontalSpan(rowGroups.length + lastColumnIndex - startColumnIndex); contents.setVerticalSpan(1); JRPrintFrame printCell = contents.fill(); List<JRPrintElement> titleRow = new ArrayList<JRPrintElement>(1); titleRow.add(printCell); yOffset += contents.getPrintHeight(); return titleRow; }
Example #22
Source Project: jasperreports Author: TIBCOSoftware File: SimpleChartTheme.java License: GNU Lesser General Public License v3.0 | 5 votes |
/** * Converts a JasperReport data range into one understood by JFreeChart. * * @param dataRange the JasperReport version of the range * @return the JFreeChart version of the range * @throws JRException thrown when the low value of the range is greater than the * high value */ protected Range convertRange(JRDataRange dataRange) throws JRException { if (dataRange == null) return null; Number low = (Number)evaluateExpression(dataRange.getLowExpression()); Number high = (Number)evaluateExpression(dataRange.getHighExpression()); return new Range( low != null ? low.doubleValue() : 0.0, high != null ? high.doubleValue() : 100.0); }
Example #23
Source Project: jasperreports Author: TIBCOSoftware File: CastorUtil.java License: GNU Lesser General Public License v3.0 | 5 votes |
/** * */ private void loadMapping(Mapping mapping, String mappingFile) { try { byte[] mappingFileData = JRLoader.loadBytesFromResource(mappingFile); InputSource mappingSource = new InputSource(new ByteArrayInputStream(mappingFileData)); mapping.loadMapping(mappingSource); } catch (JRException e) { throw new JRRuntimeException(e); } }
Example #24
Source Project: jasperreports Author: TIBCOSoftware File: JRHorizontalFiller.java License: GNU Lesser General Public License v3.0 | 5 votes |
/** * */ private void fillBackground() throws JRException { if (log.isDebugEnabled() && !background.isEmpty()) { log.debug("Fill " + fillerId + ": background at " + offsetY); } //offsetX = leftMargin; //if (!isSubreport) //{ // offsetY = pageHeight - pageFooter.getHeight() - bottomMargin; //} if (background.getHeight() <= pageHeight - bottomMargin - offsetY) { background.evaluatePrintWhenExpression(JRExpression.EVALUATION_DEFAULT); if (background.isToPrint()) { background.evaluate(JRExpression.EVALUATION_DEFAULT); JRPrintBand printBand = background.fill(pageHeight - bottomMargin - offsetY); fillBand(printBand); //offsetY += printBand.getHeight(); isCrtRecordOnPage = true; isCrtRecordOnColumn = true; } } }
Example #25
Source Project: jasperreports Author: TIBCOSoftware File: LandscapeApp.java License: GNU Lesser General Public License v3.0 | 5 votes |
/** * */ public void xml() throws JRException { long start = System.currentTimeMillis(); JasperExportManager.exportReportToXmlFile("build/reports/LandscapeReport.jrprint", false); System.err.println("XML creation time : " + (System.currentTimeMillis() - start)); }
Example #26
Source Project: jasperreports Author: TIBCOSoftware File: JROdsExporter.java License: GNU Lesser General Public License v3.0 | 5 votes |
@Override protected void exportGenericElement( JRGenericPrintElement element, JRExporterGridCell gridCell, int colIndex, int rowIndex, int emptyCols, int yCutsRow, JRGridLayout layout ) throws JRException { GenericElementOdsHandler handler = (GenericElementOdsHandler) GenericElementHandlerEnviroment.getInstance(getJasperReportsContext()).getElementHandler( element.getGenericType(), ODS_EXPORTER_KEY); if (handler != null) { JROdsExporterContext exporterContext = new ExporterContext(tableBuilder); handler.exportElement(exporterContext, element, gridCell, colIndex, rowIndex, emptyCols, yCutsRow, layout); } else { if (log.isDebugEnabled()) { log.debug("No ODS generic element handler for " + element.getGenericType()); } } }
Example #27
Source Project: jasperreports Author: TIBCOSoftware File: DateRangeApp.java License: GNU Lesser General Public License v3.0 | 5 votes |
/** * */ public void fill() throws JRException { long start = System.currentTimeMillis(); Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("MaxOrderID", 10500); JasperFillManager.fillReportToFile("build/reports/DateRangeReport.jasper", null, getDemoHsqldbConnection()); System.err.println("Filling time : " + (System.currentTimeMillis() - start)); }
Example #28
Source Project: jasperreports Author: TIBCOSoftware File: JRHorizontalFiller.java License: GNU Lesser General Public License v3.0 | 5 votes |
/** * */ @continuable private void fillGroupHeaderReprint(JRFillGroup group, byte evaluation) throws JRException { JRFillSection groupHeaderSection = (JRFillSection)group.getGroupHeaderSection(); JRFillBand[] groupHeaderBands = groupHeaderSection.getFillBands(); for (int i = 0; i < groupHeaderBands.length; i++) { JRFillBand groupHeaderBand = groupHeaderBands[i]; groupHeaderBand.evaluatePrintWhenExpression(evaluation); if (groupHeaderBand.isToPrint()) { setFirstColumn(); while (groupHeaderBand.getBreakHeight() > columnFooterOffsetY - offsetY) { fillPageBreak(false, evaluation, evaluation, true); // using same evaluation for both side of the break is ok here } fillColumnBand(groupHeaderBand, evaluation); //isFirstPageBand = false; isFirstColumnBand = true; } } }
Example #29
Source Project: jasperreports Author: TIBCOSoftware File: ChartConverter.java License: GNU Lesser General Public License v3.0 | 5 votes |
/** * */ 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 ); }
Example #30
Source Project: jasperreports Author: TIBCOSoftware File: JRDesignCrosstab.java License: GNU Lesser General Public License v3.0 | 5 votes |
/** * Adds a measure to the crosstab. * * @param measure the measure * @throws JRException * @see JRCrosstab#getMeasures() */ public void addMeasure(int index, JRDesignCrosstabMeasure measure) throws JRException { String measureName = measure.getName(); if (rowGroupsMap.containsKey(measureName) || columnGroupsMap.containsKey(measureName) || measuresMap.containsKey(measureName)) { throw new JRException( EXCEPTION_MESSAGE_KEY_DUPLICATE_GROUP_OR_MEASURE, (Object[])null); } measure.addPropertyChangeListener(JRDesignCrosstabMeasure.PROPERTY_VALUE_CLASS, measureClassChangeListener); measures.add(index, measure); for (ListIterator<JRCrosstabMeasure> it = measures.listIterator(index); it.hasNext();) { JRCrosstabMeasure itMeasure = it.next(); measuresMap.put(itMeasure.getName(), it.previousIndex()); } addMeasureVars(measure); getEventSupport().fireCollectionElementAddedEvent(PROPERTY_MEASURES, measure, index); }