//
// Build the GVT tree that represents the mask
//
GVTBuilder builder = ctx.getGVTBuilder();
CompositeGraphicsNode maskNode = new CompositeGraphicsNode();
CompositeGraphicsNode maskNodeContent = new CompositeGraphicsNode();
maskNode.getChildren().add(maskNodeContent);
boolean hasChildren = false;
for(Node node = maskElement.getFirstChild();
node != null;
node = node.getNextSibling()){
// check if the node is a valid Element
if(node.getNodeType() != Node.ELEMENT_NODE) {
continue;
}
Element child = (Element)node;
GraphicsNode gn = builder.build(ctx, child) ;
if(gn == null) {
continue;
}
hasChildren = true;
maskNodeContent.getChildren().add(gn);
}
if (!hasChildren) {
return null; // empty mask
}
// 'transform' attribute
AffineTransform Tx;
s = maskElement.getAttributeNS(null, SVG_TRANSFORM_ATTRIBUTE);
if (s.length() != 0) {
Tx = SVGUtilities.convertTransform
(maskElement, SVG_TRANSFORM_ATTRIBUTE, s, ctx);
} else {
Tx = new AffineTransform();
}
// 'maskContentUnits' attribute - default is userSpaceOnUse
short coordSystemType;
s = maskElement.getAttributeNS(null, SVG_MASK_CONTENT_UNITS_ATTRIBUTE);
if (s.length() == 0) {
coordSystemType = SVGUtilities.USER_SPACE_ON_USE;
} else {
coordSystemType = SVGUtilities.parseCoordinateSystem
(maskElement, SVG_MASK_CONTENT_UNITS_ATTRIBUTE, s, ctx);
}
// additional transform to move to objectBoundingBox coordinate system
if (coordSystemType == SVGUtilities.OBJECT_BOUNDING_BOX) {
Tx = SVGUtilities.toObjectBBox(Tx, maskedNode);
}
maskNodeContent.setTransform(Tx);
Filter filter = maskedNode.getFilter();
if (filter == null) {
// Make the initial source as a RenderableImage
filter = maskedNode.getGraphicsNodeRable(true);