// 'requiredFeatures', 'requiredExtensions' and 'systemLanguage'
if (!SVGUtilities.matchUserAgent(e, ctx.getUserAgent())) {
return null;
}
ImageNode imgNode = (ImageNode)instantiateGraphicsNode();
if (imgNode == null) {
return null;
}
Rectangle2D b = getImageBounds(ctx, e);
// 'transform'
AffineTransform at = null;
String s = e.getAttribute(SVG_TRANSFORM_ATTRIBUTE);
if (s.length() != 0)
at = SVGUtilities.convertTransform(e, SVG_TRANSFORM_ATTRIBUTE, s);
else
at = new AffineTransform();
at.translate(b.getX(), b.getY());
imgNode.setTransform(at);
// 'visibility'
imgNode.setVisible(CSSUtilities.convertVisibility(e));
Rectangle2D clip;
clip = new Rectangle2D.Double(0,0,b.getWidth(), b.getHeight());
Filter filter = imgNode.getGraphicsNodeRable(true);
imgNode.setClip(new ClipRable8Bit(filter, clip));
// 'enable-background'
Rectangle2D r = CSSUtilities.convertEnableBackground(e);
if (r != null) {
imgNode.setBackgroundEnable(r);
}
ctx.openViewport(e, new MultiImageElementViewport
((float)b.getWidth(), (float)b.getHeight()));
List elems = new LinkedList();
List minDim = new LinkedList();
List maxDim = new LinkedList();
for (Node n = e.getFirstChild(); n != null; n = n.getNextSibling()) {
if (n.getNodeType() != Node.ELEMENT_NODE)
continue;
Element se = (Element)n;
if (!getNamespaceURI().equals(se.getNamespaceURI()))
continue;
if (se.getLocalName().equals(SVG12Constants.SVG_SUB_IMAGE_TAG)) {
addInfo(se, elems, minDim, maxDim, b);
}
if (se.getLocalName().equals(SVG12Constants.SVG_SUB_IMAGE_REF_TAG)) {
addRefInfo(se, elems, minDim, maxDim, b);
}
}
Dimension [] mindary = new Dimension[elems.size()];
Dimension [] maxdary = new Dimension[elems.size()];
Element [] elemary = new Element [elems.size()];
Iterator mindi = minDim.iterator();
Iterator maxdi = maxDim.iterator();
Iterator ei = elems.iterator();
int n=0;
while (mindi.hasNext()) {
Dimension minD = (Dimension)mindi.next();
Dimension maxD = (Dimension)maxdi.next();
int i =0;
if (minD != null) {
for (; i<n; i++) {
if ((mindary[i] != null) &&
(minD.width < mindary[i].width)) {
break;
}
}
}
for (int j=n; j>i; j--) {
elemary[j] = elemary[j-1];
mindary[j] = mindary[j-1];
maxdary[j] = maxdary[j-1];
}
elemary[i] = (Element)ei.next();
mindary[i] = minD;
maxdary[i] = maxD;
n++;
}
GraphicsNode node = new MultiResGraphicsNode(e, clip, elemary,
mindary, maxdary,
ctx);
imgNode.setImage(node);
return imgNode;
}