// 'requiredFeatures', 'requiredExtensions' and 'systemLanguage'
if (!SVGUtilities.matchUserAgent(e, ctx.getUserAgent())) {
return null;
}
ImageNode imageNode = (ImageNode)super.createGraphicsNode(ctx, e);
// 'xlink:href' attribute - required
String uriStr = XLinkSupport.getXLinkHref(e);
if (uriStr.length() == 0) {
throw new BridgeException(e, ERR_ATTRIBUTE_MISSING,
new Object[] {"xlink:href"});
}
if (uriStr.indexOf('#') != -1) {
throw new BridgeException(e, ERR_ATTRIBUTE_VALUE_MALFORMED,
new Object[] {"xlink:href", uriStr});
}
GraphicsNode node = null;
// try to load the image as an svg document
SVGDocument svgDoc = (SVGDocument)e.getOwnerDocument();
// try to load an SVG document
DocumentLoader loader = ctx.getDocumentLoader();
URIResolver resolver = new URIResolver(svgDoc, loader);
try {
Node n = resolver.getNode(uriStr, e);
if (n.getNodeType() == n.DOCUMENT_NODE) {
SVGDocument imgDocument = (SVGDocument)n;
node = createSVGImageNode(ctx, e, imgDocument);
}
} catch (BridgeException ex) {
throw ex;
} catch (Exception ex) {
/* Nothing to do */
}
if (node == null) {
String baseURI = XMLBaseSupport.getCascadedXMLBase(e);
ParsedURL purl;
if (baseURI == null)
purl = new ParsedURL(uriStr);
else
purl = new ParsedURL(baseURI, uriStr);
// try to load the image as a raster image (JPG or PNG)
node = createRasterImageNode(ctx, e, purl);
}
if (node == null) {
throw new BridgeException(e, ERR_URI_IMAGE_INVALID,
new Object[] {uriStr});
}
// 'image-rendering' and 'color-rendering'
Map imageHints = CSSUtilities.convertImageRendering(e);
Map colorHints = CSSUtilities.convertColorRendering(e);
if (imageHints != null || colorHints != null) {
RenderingHints hints;
if (imageHints == null) {
hints = new RenderingHints(colorHints);
} else if (colorHints == null) {
hints = new RenderingHints(imageHints);
} else {
hints = new RenderingHints(imageHints);
hints.putAll(colorHints);
}
node.setRenderingHints(hints);
}
imageNode.setImage(node);
return imageNode;
}