}
}
}
// Fallback: (At the moment, we only support drawables and images.)
final ReportAttributeMap attributes = node.getAttributes();
if (rawObject instanceof ImageContainer)
{
final String type = RenderUtility.getEncoderType(attributes);
final float quality = RenderUtility.getEncoderQuality(attributes);
// Make it a PNG file ..
//xmlWriter.writeComment("Image content source:" + source);
final String name = contentGenerator.writeImage((ImageContainer) rawObject, type, quality, true);
if (name != null)
{
// Write image reference ..
final AttributeList attrList = new AttributeList();
attrList.setAttribute(HtmlPrinter.XHTML_NAMESPACE, SRC_ATTR, name);
attrList.setAttribute(HtmlPrinter.XHTML_NAMESPACE, "border", "0");
final Object titleText = attributes.getAttribute(AttributeNames.Html.NAMESPACE, AttributeNames.Html.TITLE);
if (titleText != null)
{
attrList.setAttribute(HtmlPrinter.XHTML_NAMESPACE, TITLE_ATTR, String.valueOf(titleText));
}
final Object altText = attributes.getAttribute(AttributeNames.Html.NAMESPACE, AttributeNames.Html.ALT);
if (altText != null)
{
attrList.setAttribute(HtmlPrinter.XHTML_NAMESPACE, ALT_ATTR, String.valueOf(altText));
}
// width and height and scaling and so on ..
final StyleBuilder imgStyle = produceImageStyle(node);
if (imgStyle == null)
{
final AttributeList clipAttrList = new AttributeList();
final StyleBuilder divStyle = produceClipStyle(node);
styleManager.updateStyle(divStyle, clipAttrList);
xmlWriter.writeTag(HtmlPrinter.XHTML_NAMESPACE, DIV_TAG, clipAttrList, XmlWriterSupport.OPEN);
xmlWriter.writeTag(HtmlPrinter.XHTML_NAMESPACE, IMG_TAG, attrList, XmlWriterSupport.CLOSE);
xmlWriter.writeCloseTag();
}
else
{
styleManager.updateStyle(imgStyle, attrList);
xmlWriter.writeTag(HtmlPrinter.XHTML_NAMESPACE, IMG_TAG, attrList, XmlWriterSupport.CLOSE);
}
result = true;
}
return;
}
if (rawObject instanceof DrawableWrapper)
{
// render it into an Buffered image and make it a PNG file.
final DrawableWrapper drawable = (DrawableWrapper) rawObject;
final StrictBounds cb = new StrictBounds(node.getX(), node.getY(), node.getWidth(), node.getHeight());
final ImageContainer image = RenderUtility.createImageFromDrawable(drawable, cb, node,
metaData);
if (image == null)
{
//xmlWriter.writeComment("Drawable content [No image generated]:" + source);
return;
}
final String type = RenderUtility.getEncoderType(attributes);
final float quality = RenderUtility.getEncoderQuality(attributes);
final String name = contentGenerator.writeImage(image, type, quality, true);
if (name == null)
{
//xmlWriter.writeComment("Drawable content [No image written]:" + source);
return;
}
//xmlWriter.writeComment("Drawable content:" + source);
// Write image reference ..
final ImageMap imageMap;
final AttributeList attrList = new AttributeList();
attrList.setAttribute(HtmlPrinter.XHTML_NAMESPACE, SRC_ATTR, name);
attrList.setAttribute(HtmlPrinter.XHTML_NAMESPACE, "border", "0");
final Object imageMapNameOverride = attributes.getAttribute
(AttributeNames.Html.NAMESPACE, AttributeNames.Html.IMAGE_MAP_OVERRIDE);
if (imageMapNameOverride != null)
{
attrList.setAttribute(HtmlPrinter.XHTML_NAMESPACE, USEMAP_ATTR, String.valueOf(imageMapNameOverride));
imageMap = null;
}
else
{
// only generate a image map, if the user does not specify their own onw via the override.
// Of course, they would have to provide the map by other means as well.
imageMap = RenderUtility.extractImageMap(node);
if (imageMap != null)
{
final String mapName = imageMap.getAttribute(HtmlPrinter.XHTML_NAMESPACE, "name");
if (mapName != null)
{
attrList.setAttribute(HtmlPrinter.XHTML_NAMESPACE, USEMAP_ATTR, "#" + mapName);
}
else
{
final String generatedName = "generated_" + name + "_map"; //NON-NLS
imageMap.setAttribute(HtmlPrinter.XHTML_NAMESPACE, "name", generatedName);
//noinspection MagicCharacter
attrList.setAttribute(HtmlPrinter.XHTML_NAMESPACE, USEMAP_ATTR, '#' + generatedName);//NON-NLS
}
}
}
final Object titleText = attributes.getAttribute(AttributeNames.Html.NAMESPACE, AttributeNames.Html.TITLE);
if (titleText != null)
{
attrList.setAttribute(HtmlPrinter.XHTML_NAMESPACE, TITLE_ATTR, String.valueOf(titleText));
}
final Object altText = attributes.getAttribute(AttributeNames.Html.NAMESPACE, AttributeNames.Html.ALT);
if (altText != null)
{
attrList.setAttribute(HtmlPrinter.XHTML_NAMESPACE, ALT_ATTR, String.valueOf(altText));
}
// width and height and scaling and so on ..