예제 #1
0
 /** Removes DOM listeners from the document. */
 protected void removeDocumentListeners() {
   AbstractDocument doc = (AbstractDocument) document;
   XBLEventSupport es = (XBLEventSupport) doc.initializeEventSupport();
   es.removeImplementationEventListenerNS(
       XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMNodeInserted", domNodeInsertedListener, false);
   es.removeImplementationEventListenerNS(
       XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMNodeRemoved", domNodeRemovedListener, false);
   es.removeImplementationEventListenerNS(
       XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMAttrModified", domAttrModifiedListener, false);
 }
  /**
   * Builds using the specified BridgeContext and element, the specified graphics node.
   *
   * @param ctx the bridge context to use
   * @param e the element that describes the graphics node to build
   * @param node the graphics node to build
   */
  public void buildGraphicsNode(BridgeContext ctx, Element e, GraphicsNode node) {
    CompositeGraphicsNode cgn = (CompositeGraphicsNode) node;

    // build flowRegion shapes
    boolean isStatic = !ctx.isDynamic();
    if (isStatic) {
      flowRegionNodes = new HashMap();
    } else {
      regionChangeListener = new RegionChangeListener();
    }
    CompositeGraphicsNode cgn2 = (CompositeGraphicsNode) cgn.get(0);
    GVTBuilder builder = ctx.getGVTBuilder();
    for (Node n = getFirstChild(e); n != null; n = getNextSibling(n)) {
      if (n instanceof SVGOMFlowRegionElement) {
        for (Node m = getFirstChild(n); m != null; m = getNextSibling(m)) {
          if (m.getNodeType() != Node.ELEMENT_NODE) {
            continue;
          }
          GraphicsNode gn = builder.build(ctx, (Element) m);
          if (gn != null) {
            cgn2.add(gn);
            if (isStatic) {
              flowRegionNodes.put(m, gn);
            }
          }
        }

        if (!isStatic) {
          AbstractNode an = (AbstractNode) n;
          XBLEventSupport es = (XBLEventSupport) an.initializeEventSupport();
          es.addImplementationEventListenerNS(
              SVG_NAMESPACE_URI, "shapechange", regionChangeListener, false);
        }
      }
    }

    // build text node
    GraphicsNode tn = (GraphicsNode) cgn.get(1);
    super.buildGraphicsNode(ctx, e, tn);

    // Drop references once static build is completed.
    flowRegionNodes = null;
  }