コード例 #1
0
  /**
   * From the <code>SVGContext</code> from the element children of the node.
   *
   * @param ctx the <code>BridgeContext</code> for the document
   * @param e the <code>Element</code> whose subtree's elements will have threir <code>SVGContext
   *     </code>s removed
   * @see org.apache.batik.dom.svg.SVGContext
   * @see org.apache.batik.bridge.BridgeUpdateHandler
   */
  protected void removeContextFromChild(BridgeContext ctx, Element e) {
    if (SVG_NAMESPACE_URI.equals(e.getNamespaceURI())) {
      String ln = e.getLocalName();
      if (ln.equals(SVG12Constants.SVG_FLOW_DIV_TAG)
          || ln.equals(SVG12Constants.SVG_FLOW_LINE_TAG)
          || ln.equals(SVG12Constants.SVG_FLOW_PARA_TAG)
          || ln.equals(SVG12Constants.SVG_FLOW_SPAN_TAG)) {
        ((AbstractTextChildBridgeUpdateHandler) ((SVGOMElement) e).getSVGContext()).dispose();
      }
    }

    Node child = getFirstChild(e);
    while (child != null) {
      if (child.getNodeType() == Node.ELEMENT_NODE) {
        removeContextFromChild(ctx, (Element) child);
      }
      child = getNextSibling(child);
    }
  }
コード例 #2
0
  /**
   * Add to the element children of the node, a <code>SVGContext</code> to support dynamic update.
   * This is recursive, the children of the nodes are also traversed to add to the support elements
   * their context
   *
   * @param ctx a <code>BridgeContext</code> value
   * @param e an <code>Element</code> value
   * @see org.apache.batik.dom.svg.SVGContext
   * @see org.apache.batik.bridge.BridgeUpdateHandler
   */
  protected void addContextToChild(BridgeContext ctx, Element e) {
    if (SVG_NAMESPACE_URI.equals(e.getNamespaceURI())) {
      String ln = e.getLocalName();
      if (ln.equals(SVG12Constants.SVG_FLOW_DIV_TAG)
          || ln.equals(SVG12Constants.SVG_FLOW_LINE_TAG)
          || ln.equals(SVG12Constants.SVG_FLOW_PARA_TAG)
          || ln.equals(SVG12Constants.SVG_FLOW_SPAN_TAG)) {
        ((SVGOMElement) e).setSVGContext(new FlowContentBridge(ctx, this, e));
      }
    }

    // traverse the children to add SVGContext
    Node child = getFirstChild(e);
    while (child != null) {
      if (child.getNodeType() == Node.ELEMENT_NODE) {
        addContextToChild(ctx, (Element) child);
      }
      child = getNextSibling(child);
    }
  }