BlockBox box,
UserAgentCallback uac,
int cssWidth,
int cssHeight) {
SVGPanel panel = new SVGPanel();
String content = null;
JComponent cc = null;
try {
Element elem = box.getElement();
if (elem == null || ! isSVGEmbedded(elem)) {
return null;
}
// HACK: the easiest way to integrate with Salamander is to have it read
// our SVG from a file--so, push the content to a temporary file, yuck!
content = getSVGElementContent(elem);
String path = elem.getAttribute("data");
XRLog.general(Level.FINE, "Rendering embedded SVG via object tag from: " + path);
XRLog.general(Level.FINE, "Content is: " + content);
panel.setAntiAlias(true);
panel.setSvgResourcePath(path);
int width = panel.getSVGWidth();
int height = panel.getSVGHeight();
if ( cssWidth > 0 ) width = cssWidth;
if ( cssHeight > 0 ) height = cssHeight;
String val = elem.getAttribute("width");
if ( val != null && val.length() > 0 ) {
width = Integer.valueOf(val).intValue();
}
val = elem.getAttribute("height");
if ( val != null && val.length() > 0 ) {
height = Integer.valueOf(val).intValue();
}
panel.setScaleToFit(true);
panel.setPreferredSize(new Dimension(width, height));
panel.setSize(panel.getPreferredSize());
cc = panel;
} catch (SVGException e) {
XRLog.general(Level.WARNING, "Could not replace SVG element; rendering failed" +
" in SVG renderer. Skipping and using blank JPanel.", e);