int width = ((Integer) context
.getProperty(RendererContextConstants.WIDTH)).intValue();
int height = ((Integer) context
.getProperty(RendererContextConstants.HEIGHT)).intValue();
Java2DGraphicsState state = (Java2DGraphicsState) context
.getProperty(Java2DRendererContextConstants.JAVA2D_STATE);
ImageManager manager = ua.getFactory().getImageManager();
ImageInfo info = null;
try {
ImageSessionContext sessionContext = ua.getImageSessionContext();
info = manager.getImageInfo(uri, sessionContext);
final ImageFlavor[] flavors = new ImageFlavor[] {
ImageFlavor.GRAPHICS2D, ImageFlavor.BUFFERED_IMAGE,
ImageFlavor.RENDERED_IMAGE, ImageFlavor.XML_DOM };
Map hints = ImageUtil.getDefaultHints(sessionContext);
org.apache.xmlgraphics.image.loader.Image img = manager.getImage(
info, flavors, hints, sessionContext);
if (img instanceof ImageGraphics2D) {
ImageGraphics2D imageG2D = (ImageGraphics2D) img;
renderer.getGraphics2DAdapter().paintImage(
imageG2D.getGraphics2DImagePainter(), context, x, y, width,
height);
} else if (img instanceof ImageRendered) {
ImageRendered imgRend = (ImageRendered) img;
AffineTransform at = new AffineTransform();
at.translate(x / 1000f, y / 1000f);
double sx = (double) width
/ (double) info.getSize().getWidthMpt();
double sy = (double) height
/ (double) info.getSize().getHeightMpt();
sx *= ua.getSourceResolution()
/ info.getSize().getDpiHorizontal();
sy *= ua.getSourceResolution()
/ info.getSize().getDpiVertical();
at.scale(sx, sy);
state.getGraph().drawRenderedImage(imgRend.getRenderedImage(),
at);
} else if (img instanceof ImageXMLDOM) {
ImageXMLDOM imgXML = (ImageXMLDOM) img;
renderer.renderXML(context, imgXML.getDocument(), imgXML
.getRootNamespace());