throw new MissingAttributeException(
Messages.formatMessage("image.xlinkHref.required", null));
}
// bad URL type
if (uriStr.indexOf('#') != -1) {
throw new IllegalAttributeValueException(
Messages.formatMessage("image.xlinkHref.invalid", null));
}
GraphicsNode node = null;
try {
if (uriStr.startsWith(PROTOCOL_DATA)) {
// load the image as a base 64 encoded image
node = createBase64ImageNode(ctx, svgElement, uriStr);
} else {
SVGDocument svgDoc = (SVGDocument)element.getOwnerDocument();
URL baseURL = ((SVGOMDocument)svgDoc).getURLObject();
URL url = new URL(baseURL, uriStr);
// try to load an SVG document
DocumentLoader loader = ctx.getDocumentLoader();
URIResolver resolver = new URIResolver(svgDoc, loader);
try {
Node n = resolver.getNode(url.toString());
if (n.getNodeType() == n.DOCUMENT_NODE) {
SVGDocument imgDocument = (SVGDocument)n;
node=createSVGImageNode(ctx, svgElement, imgDocument);
}
} catch (Exception ex) { /* Nothing to do */ }
if (node == null) {
// try to load the image as a raster image (JPG or PNG)
node = createRasterImageNode(ctx, svgElement, url);
}
}
} catch(MalformedURLException ex) {
throw new IllegalAttributeValueException(
Messages.formatMessage("image.xlinkHref.badURL", null));
}
if (node == null) {
throw new IllegalAttributeValueException(
Messages.formatMessage("image.xlinkHref.badImageType", null));
}
ImageNode imgNode = ctx.getGVTFactory().createImageNode();
imgNode.setImage(node);
// initialize the transform