/**
   * Adds an FXG child node to this node.
   *
   * <p>Graphic content nodes support child property nodes &lt;filter&gt;, &lt;mask&gt;,
   * &lt;matrix&gt;, or &lt;colorTransform&gt;.
   *
   * @param child - a child FXG node to be added to this node.
   * @throws FXGException if the child is not supported by this node.
   */
  @Override
  public void addChild(FXGNode child) {
    if (child instanceof FilterNode) {
      if (filters == null) filters = new ArrayList<FilterNode>();

      filters.add((FilterNode) child);
    } else if (child instanceof MaskPropertyNode) {
      mask = ((MaskPropertyNode) child).mask;
      if (mask instanceof GraphicContentNode) {
        ((GraphicContentNode) mask).setParentGraphicContext(createGraphicContext());
      }
    } else if (child instanceof MatrixNode) {
      if (translateSet || scaleSet || rotationSet)
        // Exception:Cannot supply a matrix child if transformation attributes were provided
        throw new FXGException(
            child.getStartLine(), child.getStartColumn(), "InvalidChildMatrixNode");

      matrix = (MatrixNode) child;
    } else if (child instanceof ColorTransformNode) {
      if (alphaSet)
        // Exception:Cannot supply a colorTransform child if alpha attribute was provided.
        throw new FXGException(
            child.getStartLine(), child.getStartColumn(), "InvalidChildColorTransformNode");

      colorTransform = (ColorTransformNode) child;
    } else {
      super.addChild(child);
    }
  }