writer.write("<a name=\"");
writer.write(image.getAnchorName());
writer.write("\"/>");
}
JRRenderable renderer = image.getRenderer();
JRRenderable originalRenderer = renderer;
boolean imageMapRenderer = renderer != null
&& renderer instanceof JRImageMapRenderer
&& ((JRImageMapRenderer) renderer).hasImageAreaHyperlinks();
boolean hasHyperlinks = false;
if(renderer != null || isUsingImagesToAlign)
{
if (imageMapRenderer)
{
hasHyperlinks = true;
hyperlinkStarted = false;
}
else
{
hasHyperlinks = startHyperlink(image);
}
writer.write("<img");
String imagePath = null;
String imageMapName = null;
List imageMapAreas = null;
ScaleImageEnum scaleImage = image.getScaleImageValue();
if (renderer != null)
{
if (renderer.getType() == JRRenderable.TYPE_IMAGE && rendererToImagePathMap.containsKey(renderer.getId()))
{
imagePath = (String)rendererToImagePathMap.get(renderer.getId());
}
else
{
if (image.isLazy())
{
imagePath = ((JRImageRenderer)renderer).getImageLocation();
}
else
{
JRPrintElementIndex imageIndex = getElementIndex(gridCell);
imagesToProcess.add(imageIndex);
String imageName = getImageName(imageIndex);
imagePath = imagesURI + imageName;
//backward compatibility with the IMAGE_MAP parameter
if (imageNameToImageDataMap != null)
{
if (renderer.getType() == JRRenderable.TYPE_SVG)
{
renderer =
new JRWrappingSvgRenderer(
renderer,
new Dimension(image.getWidth(), image.getHeight()),
ModeEnum.OPAQUE == image.getModeValue() ? image.getBackcolor() : null
);
}
imageNameToImageDataMap.put(imageName, renderer.getImageData());
}
//END - backward compatibility with the IMAGE_MAP parameter
}
rendererToImagePathMap.put(renderer.getId(), imagePath);
}
if (imageMapRenderer)
{
Rectangle renderingArea = new Rectangle(image.getWidth(), image.getHeight());
if (renderer.getType() == JRRenderable.TYPE_IMAGE)
{
imageMapName = (String) imageMaps.get(new Pair(renderer.getId(), renderingArea));
}
if (imageMapName == null)
{
imageMapName = "map_" + getElementIndex(gridCell).toString();
imageMapAreas = ((JRImageMapRenderer) originalRenderer).getImageAreaHyperlinks(renderingArea);//FIXMECHART
if (renderer.getType() == JRRenderable.TYPE_IMAGE)
{
imageMaps.put(new Pair(renderer.getId(), renderingArea), imageMapName);
}
}
}
}
else // ie: if(isUsingImagesToAlign)
{
loadPxImage();
imagePath = imagesURI + "px";
scaleImage = ScaleImageEnum.FILL_FRAME;
}
writer.write(" src=\"");
if (imagePath != null)
{
writer.write(imagePath);
}
writer.write("\"");
int imageWidth = image.getWidth() - image.getLineBox().getLeftPadding().intValue() - image.getLineBox().getRightPadding().intValue();
if (imageWidth < 0)
{
imageWidth = 0;
}
int imageHeight = image.getHeight() - image.getLineBox().getTopPadding().intValue() - image.getLineBox().getBottomPadding().intValue();
if (imageHeight < 0)
{
imageHeight = 0;
}
switch (scaleImage)
{
case FILL_FRAME :
{
writer.write(" style=\"width: ");
writer.write(toSizeUnit(imageWidth));
writer.write("; height: ");
writer.write(toSizeUnit(imageHeight));
writer.write("\"");
break;
}
case CLIP : //FIXMEIMAGE image clip could be achieved by cutting the image and preserving the image type
case RETAIN_SHAPE :
default :
{
double normalWidth = imageWidth;
double normalHeight = imageHeight;
if (!image.isLazy())
{
// Image load might fail.
JRRenderable tmpRenderer =
JRImageRenderer.getOnErrorRendererForDimension(renderer, image.getOnErrorTypeValue());
Dimension2D dimension = tmpRenderer == null ? null : tmpRenderer.getDimension();
// If renderer was replaced, ignore image dimension.
if (tmpRenderer == renderer && dimension != null)
{
normalWidth = dimension.getWidth();
normalHeight = dimension.getHeight();