net.sf.jasperreports.engine.JasperReportsContext Java Examples

The following examples show how to use net.sf.jasperreports.engine.JasperReportsContext. 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: AwtComponentRenderer.java    From jasperreports with GNU Lesser General Public License v3.0 8 votes vote down vote up
@Override
public void render(JasperReportsContext jasperReportsContext, Graphics2D grx, Rectangle2D rectangle) 
{
	AffineTransform origTransform = grx.getTransform();
	try
	{
		Dimension size = component.getSize();

		grx.translate(rectangle.getX(), rectangle.getY());
		if (rectangle.getWidth() != size.getWidth() 
				|| rectangle.getHeight() != size.getHeight())
		{
			grx.scale(rectangle.getWidth() / size.getWidth(), 
					rectangle.getHeight() / size.getHeight());
		}
		component.paint(grx);
	}
	catch (Exception e)
	{
		throw new JRRuntimeException(e);
	}
	finally
	{
		grx.setTransform(origTransform);
	}
}
 
Example #2
Source File: AbstractPartComponentXmlWriter.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 
 */
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;
}
 
Example #3
Source File: HeaderToolbarElementJsonHandler.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
private List<LinkedHashMap<String, String>> getTranslatedOperators(
	JasperReportsContext jasperReportsContext, 
	String bundleName, 
	NamedEnum[] operators, 
	Locale locale
	) //FIXMEJIVE make utility method for translating enums
{
	List<LinkedHashMap<String, String>> result = new ArrayList<LinkedHashMap<String, String>>();
	MessageProvider messageProvider = MessageUtil.getInstance(jasperReportsContext).getMessageProvider(bundleName);
	LinkedHashMap<String, String> keys;
	
	for (NamedEnum operator: operators) 
	{
		keys = new LinkedHashMap<String, String>();
		String key = bundleName + "." + ((Enum<?>)operator).name();
		keys.put("key", ((Enum<?>)operator).name());
		keys.put("val", messageProvider.getMessage(key, null, locale));
		result.add(keys);
	}
	
	return result;
}
 
Example #4
Source File: JRFiller.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static JasperPrint fill(
	JasperReportsContext jasperReportsContext,
	JasperReportSource reportSource,
	Map<String,Object> parameters,
	Connection conn
	) throws JRException
{
	ReportFiller filler = createReportFiller(jasperReportsContext, reportSource);
	
	JasperPrint jasperPrint = null;
	
	try
	{
		jasperPrint = filler.fill(parameters, conn);
	}
	catch(JRFillInterruptedException e)
	{
		throw 
			new JRException(
				EXCEPTION_MESSAGE_KEY_THREAD_INTERRUPTED,
				null,
				e);
	}
	
	return jasperPrint;
}
 
Example #5
Source File: JRMdxQueryExecuterFactory.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public JRQueryExecuter createQueryExecuter(
	JasperReportsContext jasperReportsContext,
	JRDataset dataset, 
	Map<String,? extends JRValueParameter> parameters
	) throws JRException
{
	JRQueryExecuter queryExecuter;
	if (getParameterValue(parameters, JRMondrianQueryExecuterFactory.PARAMETER_MONDRIAN_CONNECTION) != null)
	{
		queryExecuter = new JRMondrianQueryExecuter(jasperReportsContext, dataset, parameters);
	}
	else if (getParameterValue(parameters, JRXmlaQueryExecuterFactory.PARAMETER_XMLA_URL) != null)
	{
		queryExecuter = new JRXmlaQueryExecuter(jasperReportsContext, dataset, parameters);
	}
	else
	{
		log.warn("No Mondrian connection or XMLA URL set for MDX query");
		queryExecuter = new JREmptyQueryExecuter();
	}
	return queryExecuter;
}
 
Example #6
Source File: HeaderToolbarElementUtils.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 
 */
public static ConditionalFormattingData getConditionalFormattingData(
	JRDesignTextElement textElement, 
	JasperReportsContext jasperReportsContext
	) 
{
	ConditionalFormattingData cfd = null;
	if (textElement != null) 
	{
		JRPropertiesMap propertiesMap = textElement.getPropertiesMap();
		if (
			propertiesMap.containsProperty(ConditionalFormattingCommand.COLUMN_CONDITIONAL_FORMATTING_PROPERTY) 
			&& propertiesMap.getProperty(ConditionalFormattingCommand.COLUMN_CONDITIONAL_FORMATTING_PROPERTY) != null
			) 
		{
			cfd = 
				JacksonUtil.getInstance(jasperReportsContext).loadObject(
					propertiesMap.getProperty(ConditionalFormattingCommand.COLUMN_CONDITIONAL_FORMATTING_PROPERTY), 
					ConditionalFormattingData.class
					);
		}
	}
	return cfd;
}
 
Example #7
Source File: JRViewer.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 
 */
public JRViewer(
	JasperReportsContext jasperReportsContext,
	InputStream is, 
	boolean isXML, 
	Locale locale, 
	ResourceBundle resBundle
	) throws JRException
{
	initViewerContext(jasperReportsContext, locale, resBundle);

	initComponents();

	viewerContext.loadReport(is, isXML);
	
	tlbToolBar.init();
}
 
Example #8
Source File: JRViewer.java    From nordpos with GNU General Public License v3.0 6 votes vote down vote up
/**
 *
 */
public JRViewer(
	JasperReportsContext jasperReportsContext, 
	JasperPrint jrPrint, 
	Locale locale, 
	ResourceBundle resBundle
	)
{
	this.jasperReportsContext = jasperReportsContext;
	
	initResources(locale, resBundle);

	setScreenDetails();

	setZooms();

	initComponents();

	loadReport(jrPrint);

	cmbZoom.setSelectedIndex(defaultZoomIndex);

	initSaveContributors();

	addHyperlinkListener(this);
}
 
Example #9
Source File: BatikRenderer.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public byte[] getData(JasperReportsContext jasperReportsContext) throws JRException
{
	ensureData(jasperReportsContext);
	
	if (svgText != null)
	{
		try
		{
			return svgText.getBytes("UTF-8");
		}
		catch (UnsupportedEncodingException e)
		{
			throw new JRRuntimeException(e);
		}
	}
	else
	{
		return svgData;
	}
}
 
Example #10
Source File: JasperViewer.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 *
 */
public static void viewReport(
	JasperReportsContext jasperReportsContext,
	String sourceFile,
	boolean isXMLFile,
	boolean isExitOnClose,
	Locale locale,
	ResourceBundle resBundle
	) throws JRException
{
	JasperViewer jasperViewer =
		new JasperViewer(
			jasperReportsContext,
			sourceFile,
			isXMLFile,
			isExitOnClose,
			locale,
			resBundle
			);
	jasperViewer.setVisible(true);
}
 
Example #11
Source File: FontWebResourceHandler.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 
 */
protected byte[] processFont(JasperReportsContext jasperReportsContext, String basePath, HtmlFontFamily htmlFontFamily)
{
	FontFamilyHtmlResourceHandler resourceHandler = new FontFamilyHtmlResourceHandler(basePath, htmlFontFamily);
	
	String fontCss = HtmlFontUtil.getInstance(jasperReportsContext).getHtmlFont(resourceHandler, null, htmlFontFamily, true, true);
	
	try
	{
		return fontCss.getBytes("UTF-8");
	}
	catch (UnsupportedEncodingException e)
	{
		throw new JRRuntimeException(e);
	}
}
 
Example #12
Source File: JasperViewer.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 *
 */
public static void viewReport(
	JasperReportsContext jasperReportsContext,
	InputStream is,
	boolean isXMLFile,
	boolean isExitOnClose
	) throws JRException
{
	viewReport(
		jasperReportsContext,
		is,
		isXMLFile,
		isExitOnClose,
		null,
		null
		);
}
 
Example #13
Source File: FileImageProvider.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Image getImage(JasperReportsContext jasperReportsContext)
{
	try
	{
		return
			JRImageLoader.getInstance(jasperReportsContext).loadAwtImageFromBytes(
				RepositoryUtil.getInstance(jasperReportsContext).getBytesFromLocation(file)
				);
	}
	catch (JRException e)
	{
		throw new JRRuntimeException(e);
	}
}
 
Example #14
Source File: ResourceManager.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
public String getDataResourceLocation(String resourceName, JasperReportsContext jasperReportsContext)
{
	ContextMappings mappings = contextMappings(jasperReportsContext);
	File resourceFile = mappings.dataResourceMapping(resourceName, jasperReportsContext);
	if (resourceFile == null)
	{
		throw new JRRuntimeException(RepositoryUtil.EXCEPTION_MESSAGE_KEY_INPUT_STREAM_NOT_FOUND,
				new Object[]{resourceName});
	}
	return resourceFile.toURI().toString();
}
 
Example #15
Source File: JRRtfSaveContributor.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 
 */
public JRRtfSaveContributor(
	JasperReportsContext jasperReportsContext, 
	Locale locale, 
	ResourceBundle resBundle
	)
{
	super(jasperReportsContext, locale, resBundle);
}
 
Example #16
Source File: JRXlsExporter.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 *
 */
public JRXlsExporter(JasperReportsContext jasperReportsContext)
{
	super(jasperReportsContext);
	
	exporterContext = new ExporterContext();
	
	maxColumnIndex = 255;
}
 
Example #17
Source File: JRViewer.java    From nordpos with GNU General Public License v3.0 5 votes vote down vote up
/**
 *
 */
public JRViewer(
	JasperReportsContext jasperReportsContext, 
	InputStream is, 
	boolean isXML, 
	Locale locale, 
	ResourceBundle resBundle
	) throws JRException
{
	this.jasperReportsContext = jasperReportsContext;
	
	initResources(locale, resBundle);

	setScreenDetails();

	setZooms();

	initComponents();

	loadReport(is, isXML);

	cmbZoom.setSelectedIndex(defaultZoomIndex);

	initSaveContributors();

	addHyperlinkListener(this);
}
 
Example #18
Source File: AwtTextRenderer.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * @deprecated Replaced by {@link #AwtTextRenderer(JasperReportsContext, boolean, boolean, boolean, boolean)}.
 */
public AwtTextRenderer(
	JasperReportsContext jasperReportsContext,
	boolean isMinimizePrinterJobSize,
	boolean ignoreMissingFont
	)
{
	this(
		jasperReportsContext, 
		isMinimizePrinterJobSize, 
		ignoreMissingFont,
		true,
		false
		);
}
 
Example #19
Source File: JRAbstractQueryExecuter.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 
 */
protected JRAbstractQueryExecuter(
	JasperReportsContext jasperReportsContext, 
	JRDataset dataset, 
	Map<String, ? extends JRValueParameter> parametersMap
	)
{
	this(SimpleQueryExecutionContext.of(jasperReportsContext), dataset, parametersMap);
}
 
Example #20
Source File: JaxenXPathQueryExecuterFactory.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public JRQueryExecuter createQueryExecuter(
	JasperReportsContext jasperReportsContext, 
	JRDataset dataset, 
	Map<String,? extends JRValueParameter> parameters
	) throws JRException
{
	return createQueryExecuter(SimpleQueryExecutionContext.of(jasperReportsContext), dataset, parameters);
}
 
Example #21
Source File: XlsQueryExecuter.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 
 */
protected XlsQueryExecuter(
	JasperReportsContext jasperReportsContext, 
	JRDataset dataset, 
	Map<String,? extends JRValueParameter> parametersMap
	)
{
	this(SimpleQueryExecutionContext.of(jasperReportsContext), 
			dataset, parametersMap);
}
 
Example #22
Source File: JRPrintXmlLoader.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 *
 */
public static JasperPrint load(JasperReportsContext jasperReportsContext, InputStream is) throws JRException
{
	JasperPrint jasperPrint = null;

	JRPrintXmlLoader printXmlLoader = new JRPrintXmlLoader(jasperReportsContext);
	jasperPrint = printXmlLoader.loadXML(is);

	return jasperPrint;
}
 
Example #23
Source File: JRFiller.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 *
 */
public static JasperPrint fill(
	JasperReportsContext jasperReportsContext,
	JasperReport jasperReport,
	Map<String,Object> parameters,
	JRDataSource dataSource
	) throws JRException
{
	return fill(jasperReportsContext, SimpleJasperReportSource.from(jasperReport),
			parameters, dataSource);
}
 
Example #24
Source File: JRVerticalFiller.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 *
 */
protected JRVerticalFiller(
	JasperReportsContext jasperReportsContext, 
	JasperReport jasperReport
	) throws JRException
{
	this(jasperReportsContext, jasperReport, null);
}
 
Example #25
Source File: DefaultRepositoryService.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 *
 */
public DefaultRepositoryService(JasperReportsContext jasperReportsContext) 
{
	this.jasperReportsContext = jasperReportsContext;
	this.filesEnabled = JRPropertiesUtil.getInstance(jasperReportsContext).getBooleanProperty(
			PROPERTY_FILES_ENABLED, true);
}
 
Example #26
Source File: SimpleRenderToImageAwareDataRenderer.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public int getImageDataDPI(JasperReportsContext jasperReportsContext)
{
	int dpi = super.getImageDataDPI(jasperReportsContext);
	
	int lcMinDPI = getMinDPI();
	if (lcMinDPI > 0 && dpi < lcMinDPI)
	{
		dpi = lcMinDPI;
	}
	return dpi;
}
 
Example #27
Source File: BatikRenderer.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Dimension2D getDimension(JasperReportsContext jasperReportsContext)
{
	try
	{
		ensureSvg(jasperReportsContext);
		return documentSize;
	}
	catch (JRException e)
	{
		throw new JRRuntimeException(e);
	}
}
 
Example #28
Source File: ScriptletFactoryContext.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 *
 */
public ScriptletFactoryContext(
	JasperReportsContext jasperReportsContext,
	JRDataset dataset,
	Map<String,Object> parameterValues 
	)
{
	this.jasperReportsContext = jasperReportsContext;
	this.jasperReport = (JasperReport)parameterValues.get(JRParameter.JASPER_REPORT);
	this.dataset = dataset;
	this.parameterValues = parameterValues;
}
 
Example #29
Source File: JRXlsxExporter.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 *
 */
public JRXlsxExporter(JasperReportsContext jasperReportsContext)
{
	super(jasperReportsContext);
	
	exporterContext = new ExporterContext();
	
	maxColumnIndex = 16383;
}
 
Example #30
Source File: PdfTextRenderer.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * @deprecated Replaced by {@link #PdfTextRenderer(JasperReportsContext, boolean, boolean, boolean)}.
 */
public PdfTextRenderer(
	JasperReportsContext jasperReportsContext, 
	boolean ignoreMissingFont
	)
{
	this(jasperReportsContext, ignoreMissingFont, true, false);
}