The issue is resolved. There is a parameter in the JRViewer:
//Maximum size (in pixels) of a buffered image that would be used by {@link JRViewer JRViewer} to render a report page.
//If rendering a report page would require an image larger than this threshold
//(i.e. image width x image height > maximum size), the report page will be rendered directly on the viewer component.
//If this property is zero or negative, buffered images will never be user to render a report page.
//By default, this property is set to 0.
public static final String VIEWER_RENDER_BUFFER_MAX_SIZE
So, if this parameter is set, the reports is drawn as an ImageIcon
on a JLabel
. Otherwise, it's drawn using JRGraphics2DExporter
that is much more slower when working with big images.
So the solution is to set the specified property in the property file or using way like this:
/**
* This number represents maximum size of an image ( x*y )
* So this value cover up to 300% zoom for an image 1000x1000 pixels
*/
public static final String MAX_PIXELS_NUMBER = "10000000";
static {
try {
JRProperties.setProperty(JRViewer.VIEWER_RENDER_BUFFER_MAX_SIZE, MAX_PIXELS_NUMBER);
} catch (Exception e) {
System.err.println("Cannot set the VIEWER_RENDER_BUFFER_MAX_SIZE property. Reports will be rendered slowly.");
}
}