public interface Renderable extends Serializable
Renderable
to offer a common
way to render images.
The Graphics2DRenderable
interface has a method called
Graphics2DRenderable.render(JasperReportsContext, Graphics2D, Rectangle2D)
,
which gets called by the engine each time it needs to draw the image
on a given device or graphic context. This approach provides the best quality for the
SVG images when they must be drawn on unknown devices or zoomed into without
losing sharpness.
The DataRenderable
interface has a method called
DataRenderable.getData(JasperReportsContext)
,
which gets called by the engine each time it needs the actual image data either to embed it
directly into the exported documents, or to use it to draw the image or the graphic onto a device
or graphic context.
When a renderable object provides only binary data, the engine uses wrapping renderable implementations
to add rendering functionality to the source renderable object. On the other hand, when the renderable object
provides only direct rendering functionality, the engine wraps it into special renderable implementations that
would allow producing image data out of the source rendering routines.
The library comes with a default implementation for the
DataRenderable
interface that
wraps images that come from files or binary image data in JPG, GIF, or PNG format.
This is the SimpleDataRenderer
class.
For wrapping SVG data, the SimpleRenderToImageAwareDataRenderer
is better
suited because it allows providing additional information about required resolution of the graphic, when converted to
and image, as the engine needs to do that for certain document formats at export time.
Image renderers are serializable because inside the generated document for each image is
a renderer object kept as reference, which is serialized along with the whole
JasperPrint object.
When a SimpleDataRenderer
instance is serialized,
so is the binary image data it contains.
However, if the image element must be lazy loaded (see the isLazy
image attribute), then the
engine will not load the binary image data at report-filling time. Rather, it stores inside
the renderer only the java.lang.String
location of the image. The actual image data
is loaded only when needed for rendering at report-export or view time.
Lazy image renderers are represented by the the ResourceRenderer
implementation and require
the image data to be loaded at export time for certain export formats.Modifier and Type | Field and Description |
---|---|
static String |
PROPERTY_IMAGE_DPI
Specifies the image resolution in dots-per-inch, for the images created by the engine when rasterizing SVGs or when clipping other renderers.
|
Modifier and Type | Method and Description |
---|---|
String |
getId() |
static final String PROPERTY_IMAGE_DPI
String getId()
Copyright © 2016. All rights reserved.