Hi,
Below is some code that I'm trying to use to get an image into a SVG document.
If I subsequently render the resulting image on a JSVGCanvas, I get an
exception:
org.apache.batik.bridge.BridgeException: null:-1
The attribute "xlink:href" of the element <image> is required
at
org.apache.batik.bridge.SVGImageElementBridge.buildImageGraphicsNode(Unknown
Source)
at org.apache.batik.bridge.SVGImageElementBridge.createGraphicsNode(Unknown
Source)
at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(Unknown Source)
at org.apache.batik.bridge.GVTBuilder.buildComposite(Unknown Source)
at org.apache.batik.bridge.GVTBuilder.build(Unknown Source)
at org.apache.batik.swing.svg.GVTTreeBuilder.run(Unknown Source)
However, if I serialize to document to a file, it will render just fine if I
read in the file and render it.
I must have missed something somewhere, but what?
-+- Jan Willem Lokin -+-
The code:
package svg;
import org.apache.batik.dom.svg.SVGDOMImplementation;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Text;
public class SVGPicture {
private final int height;
private final int width;
private final Element svgRoot;
private final Document document;
private static final String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
public SVGPicture(int width, int height) {
DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
document = impl.createDocument(svgNS, "svg", null);
svgRoot = document.getDocumentElement();
// Set the width and height attributes on the root 'svg' element.
svgRoot.setAttributeNS(null, "width", Integer.toString(width));
svgRoot.setAttributeNS(null, "height", Integer.toString(height));
this.height = height;
this.width = width;
}
public Document getDocument() {
return document;
}
public void image(String fileName) {
Element image = document.createElementNS(svgNS, "image");
image.setAttributeNS(null, "width", Integer.toString(width));
image.setAttributeNS(null, "height", Integer.toString(height));
image.setAttributeNS(null, "xlink:href", fileName);
svgRoot.appendChild(image);
}
}
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]