List ret = new ArrayList();
Rectangle2D rect = new Rectangle2D.Float(svgRect.getX(),
svgRect.getY(),
svgRect.getWidth(),
svgRect.getHeight());
GraphicsNode svgGN = ctx.getGraphicsNode(e);
if (svgGN == null) return ret;
Rectangle2D svgBounds = svgGN.getSensitiveBounds();
if (svgBounds == null)
return ret;
// If the svg elem doesn't at least intersect none of the
// children will be enclosed.
if (!rect.intersects(svgBounds))
return ret;
Element base = e;
AffineTransform ati = svgGN.getGlobalTransform();
try {
ati = ati.createInverse();
} catch (NoninvertibleTransformException e) {
}
Element curr;
Node next = base.getFirstChild();
while (next != null) {
if (next instanceof Element)
break;
next = next.getNextSibling();
}
if (next == null) return ret;
curr = (Element)next;
Set ancestors = null;
if (end != null) {
ancestors = getAncestors(end, base);
if (ancestors == null)
end = null;
}
while (curr != null) {
String nsURI = curr.getNamespaceURI();
String tag = curr.getLocalName();
boolean isGroup;
isGroup = SVG_NAMESPACE_URI.equals(nsURI)
&& (SVG_G_TAG.equals(tag)
|| SVG_SVG_TAG.equals(tag)
|| SVG_A_TAG.equals(tag));
GraphicsNode gn = ctx.getGraphicsNode(curr);
if (gn == null) {
// No graphics node but check if curr is an
// ancestor of end.
if ((ancestors != null) && (ancestors.contains(curr)))
break;
curr = getNext(curr, base, end);
continue;
}
AffineTransform at = gn.getGlobalTransform();
Rectangle2D gnBounds = gn.getSensitiveBounds();
at.preConcatenate(ati);
if (gnBounds != null)
gnBounds = at.createTransformedShape(gnBounds).getBounds2D();
if ((gnBounds == null) ||