Java Code Examples for net.sf.jasperreports.engine.JasperReport#getName()

The following examples show how to use net.sf.jasperreports.engine.JasperReport#getName() . 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 File: AlterDesignApp.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 *
 */
public void fill() throws JRException
{
	long start = System.currentTimeMillis();
	File sourceFile = new File("build/reports/AlterDesignReport.jasper");
	System.err.println(" : " + sourceFile.getAbsolutePath());
	JasperReport jasperReport = (JasperReport)JRLoader.loadObject(sourceFile);
	
	JRRectangle rectangle = (JRRectangle)jasperReport.getTitle().getElementByKey("first.rectangle");
	rectangle.setForecolor(new Color((int)(16000000 * Math.random())));
	rectangle.setBackcolor(new Color((int)(16000000 * Math.random())));

	rectangle = (JRRectangle)jasperReport.getTitle().getElementByKey("second.rectangle");
	rectangle.setForecolor(new Color((int)(16000000 * Math.random())));
	rectangle.setBackcolor(new Color((int)(16000000 * Math.random())));

	rectangle = (JRRectangle)jasperReport.getTitle().getElementByKey("third.rectangle");
	rectangle.setForecolor(new Color((int)(16000000 * Math.random())));
	rectangle.setBackcolor(new Color((int)(16000000 * Math.random())));

	JRStyle style = jasperReport.getStyles()[0];
	style.setFontSize(16f);
	style.setItalic(Boolean.TRUE);

	JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, null, (JRDataSource)null);
	
	File destFile = new File(sourceFile.getParent(), jasperReport.getName() + ".jrprint");
	JRSaver.saveObject(jasperPrint, destFile);
	
	System.err.println("Filling time : " + (System.currentTimeMillis() - start));
}
 
Example 2
Source File: JRReportUtils.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static JRDataset findSubdataset(JRDatasetRun datasetRun, 
		JasperReport report)
{
	JRDataset[] datasets = report.getDatasets();
	JRDataset reportDataset = null;
	if (datasets != null)
	{
		for (int i = 0; i < datasets.length; i++)
		{
			if (datasetRun.getDatasetName().equals(
					datasets[i].getName()))
			{
				reportDataset = datasets[i];
				break;
			}
		}
	}
	
	if (reportDataset == null)
	{
		throw 
			new JRRuntimeException(
				EXCEPTION_MESSAGE_KEY_REPORT_SUBDATASET_NOT_FOUND,
				new Object[]{datasetRun.getDatasetName(), report.getName()});
	}
	return reportDataset;
}
 
Example 3
Source File: JRFillSubreport.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected void verifyBandHeights() throws JRException
{
	if (!filler.isIgnorePagination())
	{
		JasperReport jasperReport = getReport();
		
		int pageHeight;
		int topMargin = jasperReport.getTopMargin();
		int bottomMargin = jasperReport.getBottomMargin();
		
		JRBaseFiller parentFiller = filler;
		do
		{
			// set every time, so at the end it will be the master page height
			pageHeight = parentFiller.jasperReport.getPageHeight();
			
			// sum parent page margins
			topMargin += parentFiller.jasperReport.getTopMargin();
			bottomMargin += parentFiller.jasperReport.getBottomMargin();
			
			parentFiller = 
				parentFiller.parent != null && parentFiller.parent.getFiller() instanceof JRBaseFiller 
					? (JRBaseFiller) parentFiller.parent.getFiller() 
					: null;//FIXMEBOOK
		}
		while (parentFiller != null);
		
		List<JRValidationFault> brokenRules = new ArrayList<JRValidationFault>();
		JRVerifier.verifyBandHeights(brokenRules, 
				jasperReport, pageHeight, topMargin, bottomMargin);
		
		if (!brokenRules.isEmpty())
		{
			throw new JRValidationException("Band height validation for subreport \""
					+ jasperReport.getName() + "\" failed in the current page context "
					+ "(height = " + pageHeight + ", top margin = " + topMargin
					+ ", bottom margin = " + bottomMargin + ") : ",
					brokenRules);
		}
		else if (log.isDebugEnabled())
		{
			log.debug("Band height validation for subreport \""
					+ jasperReport.getName() + "\" succeeded in the current page context "
					+ "(height = " + pageHeight + ", top margin = " + topMargin
					+ ", bottom margin = " + bottomMargin + ")");
		}
	}
}